// funzione per la toolbar in hp
	function viewMenu(type){
		try {
			if (location.href=="http://www.yalp.alice.it/" || location.href=="http://www.yalp.alice.it/hp/index.html" || location.href=="http://www.yalp.alice.it/?refresh") {
				if (type=='video'){
					menuDisplay='video';
					statoBox('path_video_2L','block');
				 	changeClass('btVideo','select');
				 	statoBox('path_hp_2L','none');
				 	statoBox('path_community_2L','none');
				 	changeClass('btCommunity','');
				} else if (type=='community'){
						menuDisplay='community';
						statoBox('path_community_2L','block');
				 		changeClass('btCommunity','select');
				 		statoBox('path_hp_2L','none');
				 		statoBox('path_video_2L','none');
				 		changeClass('btVideo','');
				} else {
					menuDisplay='';
					statoBox('path_hp_2L','block');
			 		statoBox('path_video_2L','none');
			 		statoBox('path_community_2L','none');
			 		changeClass('btCommunity','');
			 		changeClass('btVideo','');
			 	}
			}
		} catch(ex){}
	}

// funzione per visualizzare flash senza bordo su ie
function includeSwf(movie,qs,width,height,wmode,imgSost,idFlash)
{ 
	var elementDiv=null;
	var strSost="";
	
	if (imgSost!=undefined)
		strSost = '<img src="' + imgSost + '" width="'+ width +'" height="' + height + '" />';
		
	var objStr=	'<object type="application/x-shockwave-flash" data="'+movie+'" width="'+width+'" height="'+height+'" id="'+idFlash+'">\n'+
	'<param name="allowScriptAccess" value="always" />\n'+
	'<param name="allowFullScreen" value="true" />\n'+
	'<param name="movie" value="'+movie+'" />\n'+
	'<param name="quality" value="high" />\n'+
	'<param name="scale" value="exactfit" />\n'+
	'<param name="FlashVars" value="'+qs+'" />\n'+
	'<param name="wmode" value="'+wmode+'" />\n'+
	strSost + '\n'+
	'</object>';

	if (elementDiv==null)
		document.write(objStr);
	else
		elementDiv.innerHTML = objStr;
}

// funzione per scrivere windows media senza bordo in ie
function includeWmv(width,height,src)
{
//getcoockie("lostls") se vuoto creare timestamp_URL_random da 0 -900000
	
	//tempo 300
	//var newsrc=src.replace("ck=&u=","");
	//alert("newscr"+newscr);
	try {
	var lostls=getCookie("lostls");
	    if (lostls!=""){
			//alert("coockie trovato ");
		}else{
			//alert("coockie non trovato ");
		    var d=new Date();
			var rand=Math.random()*9000000;
			var val=d.getTime()+"_"+escape(location.href)+"_"+rand;
			setCookie( "lostls", val, 300, "");
		}
		src=src.replace("ck=&u=","ck="+lostls+"&u="+lostls);
	} catch(ex){}
	
	var srcDef='';
	if(src!=undefined) {
		srcDef=src;
	document.write(
		'<OBJECT ID="MediaPlayer" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" '+
		'CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" '+
		'STANDBY="Loading Microsoft Windows Media Player components..." '+
		'TYPE="application/x-oleobject" NAME="MediaPlayer" width="'+width+'" height="'+height+'"> '+
		//'<PARAM NAME="AnimationatStart" VALUE="true" /> '+
		'<PARAM NAME="TransparentatStart" VALUE="false" /> '+
		'<PARAM NAME="ShowControls" VALUE="1" /> '+
		'<PARAM NAME="ShowStatusBar" VALUE="true" /> '+
		'<PARAM NAME="AutoStart" VALUE="true" /> '+      
		'<PARAM NAME="Url" VALUE="'+srcDef+'" /> '+
		'<PARAM NAME="stretchToFit" VALUE="true" /> '+
		'<PARAM NAME="fullScreen" VALUE="false" /> '+
		//'<embed src="'+srcDef+'" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/mediaplayer/" width="'+width+'" height="'+height+'" id="fPlayer" '+
		//' autostart="true" animationatstart="true" transparentatstart="false" showcontrols="1" showstatusbar="1" fullscreen="false"stretchtofit="true"\n'+
		//' displaysize="0"\n'+
		//' name="fPlayer"></embed>\n'+
		'</OBJECT>');
	}
	setTimeout("statusPlayer()",5000);
}

function statusPlayer(){
	if (MediaPlayer.playState==10 ){
		MediaPlayer.URL=_video;
		setTimeout("statusPlayer()",7000);
	}
	
}

// funzione per gestione tab
function selTab(sez,boxId01) {
	document.getElementById(boxId01).className=sez;
}

// funzione per cambiare la classe ad un specifico id
function changeClass(boxId01,nomeClass) {
	document.getElementById(boxId01).className=nomeClass;
}

// funzione per gestione layer temporizzati e stato operazione
function addRd(boxId01,nomeClass,org) {
	document.getElementById(boxId01).className=nomeClass;
	var ogg = document.getElementById(org).getElementsByTagName("a") ;
	setTimeout(function(){document.getElementById(boxId01).className='off';document.getElementById(org).className='ok';},2000)
}

// funzione per gestione layer temporizzati in tre stati
function changeClassTemp(boxId01,sec,stato1Class,stato2Class,stato3Class) {
	document.getElementById(boxId01).className=stato1Class;
	setTimeout(function(){document.getElementById(boxId01).className=stato2Class},sec);
	if (stato3Class != '') {
		oggetto=stato3Class;
		}
}

// funzione per indicare lo stato display di un id
function statoDisplay(boxId01) {
	var statoD="";
	try {
		statoD=document.getElementById(boxId01).style.display;
	} catch(ex){
	}
	return statoD;
}

// funzione per indicare il class di un id
function classDisplay(boxId) {
	var className="";
	try {
		className=document.getElementById(boxId).className;
	} catch(ex){
	}
	return className;
}

// funzione per regolare l'altezza di div adiacenti in funzione dell'immagine (orizzontale/verticale)
function setHeight(dis) {
	var azz = document.getElementById(dis);
	var olcio = azz.getElementsByTagName('img');
	var trv = false;
	for (t = 0; t < olcio.length ;t++) {
	if (olcio[t].height > 62) {
		trv = true;
		break;
		} 
	
	}
	if(trv == true) {
		for (k = 0; k < olcio.length ;k++) {
		document.getElementById("v" + k).className = "box01b";
		}
	}
}

// funzione per regolare l'altezza di elementi adiacenti
function setHeigth2(boxId05,tag) {
	var azz = document.getElementById(boxId05);
	var cascio = azz.getElementsByTagName(tag);
	var MaxAltezza = 0;
	for (t = 0; t < cascio.length ; t++) {
		if (cascio[t].offsetHeight > MaxAltezza) {
			MaxAltezza = cascio[t].offsetHeight;
			}
	}
	for (t = 0; t < cascio.length ; t++) {
			cascio[t].style.height = MaxAltezza+'px';
	}
}

// funzione per regolare larghezza
function setWidth2(boxId06,tag,larg) {
	var azz = document.getElementById(boxId06);
	var cascio = azz.getElementsByTagName(tag);
	azz.style.width = cascio.length*larg+'px';
}

// funzione per cambiare la classe ad un specifico id e cambio dell'immagine di apertura e chiusura
function changeClassImg(boxId,imm) {
	document.getElementById(boxId).className="on";
	var g = document.getElementById(imm).className;
	document.getElementById(imm).className=g+'on';
	}


// funzione per scroll contenuti

var y=0;    // spostamento verticale
var x=0;    // spostamento orizzontale
var inizio=0;   // posizione iniziale del testo in pixel
var attesa=10;  // millisecondi di attesa 
var fine;   // posizione finale del testo
var pos=inizio; // variabile corrente che memorizza la posizione
var globalContId; //id del box che si vuole muovere
var globalMaschId; //id del box maschera
var vel=2 // velocità scorrimento in px

function muovi(contId, maschId) {
	if (x==0 && y!=0){
		if(contId){
			globalContId = contId;
			globalMaschId = maschId;
		}
		var hCont = document.getElementById(globalContId).offsetHeight;
		var hMasch = document.getElementById(globalMaschId).offsetHeight;
		var fine = (hMasch - hCont);
		var pos = Number(document.getElementById(globalContId).style.top.replace('px',''));
		if ( ( (pos<=fine)&&(y==-vel) )||( (pos>=inizio)&&(y==vel) ) ) y=0;
		pos=pos+y;
		document.getElementById(globalContId).style.top=pos+'px';
		if (y!=0) setTimeout('muovi();',attesa);
	} else if (y==0 && x!=0) {
		if(contId){
			globalContId = contId;
			globalMaschId = maschId;
		}
		var wCont = document.getElementById(globalContId).offsetWidth;
		var wMasch = document.getElementById(globalMaschId).offsetWidth;
		var fine = (wMasch - wCont);
		var pos = Number(document.getElementById(globalContId).style.left.replace('px',''));
		if ( ( (pos<=fine)&&(x==-vel) )||( (pos>=inizio)&&(x==vel) ) ) x=0;
		pos=pos+x;
		document.getElementById(globalContId).style.left=pos+'px';
		if (x!=0) setTimeout('muovi();',attesa);
	}
}

// funzione per gestione grafica votazione
function votaGraf(boxId02,star) {
	document.getElementById(boxId02).style.backgroundImage='url(http://images1.yalp.alice.it/images/star/'+star+'.gif)';
}

// funzione per stato block, none, inline
function statoBox(boxId03,val01) {
	document.getElementById(boxId03).style.display=val01;
}

// funzione per stato block, none, inline Temporizzato
function statoBoxTemp(boxId04,sec,stato1Display,stato2Display) {
	alertd("statoBoxTemp : "+boxId04);
	document.getElementById(boxId04).style.display=stato1Display;
	setTimeout(function(){document.getElementById(boxId04).style.display=stato2Display},sec);
}

// funzione di specifica campo vuoto
function assignValue(obj){
	if(obj == ""){
		document.write("-");
	}else{
		document.write(obj);
	}
}

// funzione per aprire popup
function popup(url,nome,width,height) {
	window.open(url,nome,'height='+height+',width='+width+',resizablle=0,scrollbar=0,location=0,status=0');
}

// funzione per ridimensionare o aumentare popup
function resizePopup(valW,valH) {
	if (window.outerWidth) {
		wW = window.outerWidth;
		hW = window.outerHeight;
		wW += valW;
		hW += valH;
	} else {
		wW = document.body.offsetWidth;
		hW = document.body.offsetHeight;
		wW += (valW + 10);
		hW += (valH + 80);
	}
	window.resizeTo(wW,hW);
}

// funzione per invio form da tag <a href></a>
function submitForm(nomeform) {
	document[nomeform].submit();
}

// funzione per apertura singolo box e chiusura adiacenti (moviestore)
function ApriBoxTopDownload(NodoDom){
	BoxDom=NodoDom.parentNode.parentNode;
	ContainerBoxDom=BoxDom.parentNode;
	ArrayDiv=ContainerBoxDom.getElementsByTagName('div')
		for(i=0; i<ArrayDiv.length;i++){
			ArrayDiv[i].className="BoxTopDownload"
		}
	BoxDom.className="BoxTopDownload Aperto"
	return false;
}

// funzione per apertura singole voci (aiuto)
function espandiVoce(acc){
	var stato = acc.parentNode.parentNode.className;
	if (stato == 'off') {
		acc.parentNode.parentNode.className='on';
	} else {
		acc.parentNode.parentNode.className='off';
	}
}


//funzione per invio form di ricerca per i listing di 3° livello
function searchListing(){
	try{
			//var txtSearch=getParameters("qs");
			var qs=getElementById_s("qs").value;
			//alertd("url : "+location.href+"qs : "+qs);
			
			var url_call=location.href;
			if (qs==null || qs==""){
				location.href=url_call;
				return false;
			}
			
			
			if (url_call.indexOf("?")!=-1){
					if (url_call.indexOf("qs=")!=-1){
							url_call=url_call.substring(0,url_call.indexOf("qs="));
								url_call+="qs="+qs;
						}else{
								url_call+="&qs="+qs;
							}
				
			}else{
					url_call+="?qs="+qs;
				}
				alertd("url_call: "+url_call);
				location.href=url_call;
				
   }
	  catch(e) {alertd(e.message);}
	  //return true;
	
	
	}
	
	
function consigliatigetVote(pos){
	try{
		var objConsigliati=document.getElementById("consigliatiVote"+pos);
		var _contentId = objConsigliati.title;
		SearchClient.getData(_contentId , 'consigliati'+pos+'Vote');
	} catch(ex){}
}

	
function consigliati1Vote(data){
	consigliatiVote(data,'1');
}
function consigliati2Vote(data){
	consigliatiVote(data,'2');
}
function consigliati3Vote(data){
	consigliatiVote(data,'3');
}
function consigliati4Vote(data){
	consigliatiVote(data,'4');
}
function consigliati5Vote(data){
	consigliatiVote(data,'5');
}

function consigliatiVote(data,pos){
	try {
		var objConsigliati=document.getElementById("consigliatiVote"+pos);
		var pathImgVote='http://community.yalp.alice.it/images/star/s/';
		var average=data.AVERAGE_VOTE;
		var vote=data.VOTE_TOTAL;
		average=average+"00";
		var imgVote=pathImgVote+average.replace(".","").substring(0,2)+".gif";
		var strVoteConsigliati='<img src="'+imgVote+'" alt="4" /> Voti: <em>'+ vote+'</em>'
		objConsigliati.innerHTML=strVoteConsigliati;
	} catch(ex){}
}


function viewLanciVideoHpCanali(nameBox){
	statoBox('piuvisti','none');		
	statoBox('piuvotati','none');
	statoBox('piurecenti','none');		
	statoBox('consigliati','none');
	statoBox(nameBox,'block');
	if(nameBox=='consigliati'){
		try {
			consigliatigetVote('1');
			consigliatigetVote('2');
			consigliatigetVote('3');
			consigliatigetVote('4');
			consigliatigetVote('5');
		} catch(ex){}
	}
}
