function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

/**funzioni scriptaculous**/

var isClosed=Array(1,1,1,1,1,1,1,1);
var isOn=Array(0,0,0,0,0,0,0,0);
var idArr=Array('Gcomedy_cont','Gdrama_cont','Gfantasy_cont','Gsuper_cont','Gscifi_cont','Gaction_cont','Ghorror_cont','Ganimation_cont');

function div_down(div_id,div_key)
{
	if(isOn[div_key]){//solo se c'è ancora il mouse sopra
		hideAllMenu(div_key);
		document.getElementById(idArr[div_key]).style.display="inline";
		new Effect.SlideDown(div_id,  {duration:0.4,queue:'end'});
	}
	else isClosed[div_key]=1;
}

function div_up(div_id,div_content)
{
	document.getElementById(div_content).style.display="inline";
	new Effect.SlideUp(div_id, {duration:0.4,queue:'end'});
//	document.getElementById(div_content).style.display="none";
}

//richiama il div_up solo se il puntatore non è sul sottomenu
function hideMenu(div_id,icl)
{
	if(!isOn[icl] && isClosed[icl]==0 && document.getElementById(div_id).style.display!='none' ){
		div_up('GeneriFather',div_id);
		isClosed[icl]=1;
	}
}

function hideAllMenu(no)
{
//	var queue = Effect.Queues.get('global');
//	queue.each(function(e) { e.cancel() });
	for(i=0;i<=7;i++)
		if(no!=i)
		{
			isClosed[i]=1;
			if(document.getElementById(idArr[i])!=null)
				document.getElementById(idArr[i]).style.display='none';
		}
}

//---------------------------------------------------------------
	function menu_mouseover(id, div, img)
	{
		if(document.getElementById(idArr[id])!=null)
		{
			isOn[id]=1;
			if(isClosed[id]==1)
			{
				setTimeout('div_down(\'GeneriFather\','+id+')',300);
				//div_down('GeneriFather',id);
				isClosed[id]=0;
			}
		}	
		document.getElementById(div).style.background='url('+img+') no-repeat bottom center';
	}

	function menu_mouseout(id, div, img)
	{
		if(document.getElementById(idArr[id])!=null)
		{
			isOn[id]=0;
			setTimeout('hideMenu(\''+idArr[id]+'\','+id+')',1000);
		}	
		document.getElementById(div).style.background='url('+img+') no-repeat top center';
	}
	
	function div_mouseout(id)
	{
		isOn[id]=0;
		setTimeout('hideMenu(\''+idArr[id]+'\','+id+')',1000)
	}
	//cambia l'anno della tabella mesi di blog_post.php
	function setMonth(div_id,newyear,idoa,lang){
	//Effect.Shake(div_id);
	idoa=(idoa?'&idoa='+idoa:'');

	new Ajax.Updater(div_id, 'months_tab.php?y='+newyear+idoa+'&lang='+lang);

	}
	
	function setWeekM7(div_id,monTs,idu){
		new Ajax.Updater(div_id, 'magnifici.php?ts='+monTs+'&aj=0&idu='+idu);
	}
	//svuota il valore del campo id, se il valore è uguale a val
	function resetField(id,val){
		if(document.getElementById(id).value==val) document.getElementById(id).value='';
	}
	
	function newsScrollUp(){

		if(num==current){
			
			//if(current==0) new Ajax.Updater(newsStartId, '../content/aj_newsScroll.php?num=0&gen='+newsGenre);
			
			var newdiv = document.createElement('div');
			var newId=num+1;
			newdiv.setAttribute('id', 'cont'+newId);
			newdiv.style.width='100%';
			newdiv.style.height=284;
			 
			newdiv.style.position = "relative";
			newdiv.style.top = 0;
			newdiv.style.left = 0;
			
			//newdiv.style.zIndex='10';
			new Ajax.Updater('cont'+newId, '../content/aj_newsScroll.php?num='+newId+'&gen='+newsGenre);
			
			document.getElementById("cont").appendChild(newdiv)
		
			if(current) new Effect.SlideUp('cont'+num,{duration:1.6});
			else new Effect.SlideUp(newsStartId,{duration:1.6});
			
			num++;
			current++;
		}
		else{
			if(current) new Effect.SlideUp('cont'+current,{duration:1.6});
			else new Effect.SlideUp(newsStartId,{duration:1.6});
			current++;
		}
	}

	function newsScrollDown(){
		if(current>0){
			current--;
			if(current){
				
				new Effect.SlideDown('cont'+current,{duration:1.6});
			}
			else new Effect.SlideDown(newsStartId,{duration:1.6});
		}
	}