	//per listing video
	function init1() {
		//scrollablediv 1
		var scroller = new Bs_ScrollableDiv();
		scroller.init('divContainer_1', 'divContent_1');

	  	var sliderObj = new Bs_Slider();
		sliderObj.width          = 11;
		sliderObj.height         = 'auto';
		sliderObj.arrowMouseOver = true;
		sliderObj.direction      = 1;
		sliderObj.imgDir         = 'img-scrollbar/';
		sliderObj.setBackgroundImage('scroll_ln.png', 'repeat');
		sliderObj.setSliderIcon('scroll_knob.png', 11, 80);
		sliderObj.setArrowIconLeft('scroll_up.png', 11, 10);
		sliderObj.setArrowIconRight('scroll_dn.png', 11, 10);

		scroller.setSliderObject(sliderObj, 'sliderDiv1');
		scroller.setSlideSpeed(100, 'pixel'); //50 pixel per second
		scroller.setWheelSpeed(80, 'pixel'); //10 pixel per tick
	}

		function getFlash()
		{
            var div_video = document.getElementById('SWF_video');
            var att = div_video.getAttribute('widget').split(",");
            setFlash(div_video.id, att[0], att[1], att[2], att[3], att[4]);
		}
		function setFlash(elm, id_video, swf, w, h, version)
		{
			var fo = new SWFObject('flvplayer.swf', 'playlist', w, h, version, "#000000");
	 			fo.addParam("allowfullscreen","true");
				fo.addParam("wmode","transparent");
				fo.addParam("allowscriptaccess","always");
				fo.addVariable("file","playlist-xml.php?v="+palin_sesto+"," + id_video+","+Math.random()*100);//+"&n="+Math.random()*100
				fo.addVariable("autostart","true");
				fo.addVariable("repeat","false");
				fo.addVariable("shuffle","false");
				//AGGIUNTI DA ME
				fo.addVariable("enablejs","true");
				fo.addVariable("javascriptid","mpl");
				fo.addVariable("overstretch","fit");
				fo.addVariable("width", w);
				fo.addVariable("height", h);
				//Controllo banda
//				fo.addVariable("bwfile","http://www1.videotank.tv/38278/100k.jpg?"+Math.random()*100);//http://www.shiftzero.tv/
				fo.addVariable("bwfile","../100k.jpg?"+Math.random()*100);//http://www.shiftzero.tv/
				fo.addVariable("bwstreams", bwstreams_php);
				//fine controllo banda
				//FINE AGGIUNTA
	      		fo.addVariable('bufferlength','4');
			    fo.addVariable("image","images/back-video.jpg");
			    fo.addVariable("backcolor","0x303030");
			    fo.addVariable("frontcolor","0xDDDDDD");
			    fo.addVariable("lightcolor","0x888888");
		    fo.write(elm);
		}

		function getUpdate(typ,pr1,pr2,pid) {
		    if((pr1>0)&&(pr2==0))
				window.parent.focus();
			if((palin_sesto=='si')&&((pr1>0)&&(pr2==0)))
			{
			    //alert("typ"+typ+"\npr1->"+pr1+"\npr2->"+pr2);
				palinsesto_avanti('0p');
				sendEvent('playlist','stop');
			}
		};
		function sendEvent(swf,typ,prm) {
			thisMovie(swf).sendEvent(typ,prm);
		};
		function thisMovie(movieName) {
			if(navigator.appName.indexOf("Microsoft") != -1) {
				return window[movieName];
			} else {
				return document[movieName];
			}
		};


	    var numero_div_canali;

		function ajax_video_stream(id) {
			palin_sesto='no';
			id_video_old=id_video;
			id_video=id;
			sendEvent('playlist','stop');
			document.body.scrollTop=0;
			//alert(document.getElementById('deactive_pal').src);
			document.getElementById('deactive_pal').style.visibility='visible';
			$.post("jquery_php/agg_video_stream.php",
			   { num: Math.random(), id: id },
			   function(data){
//				 var i = array_id_video_old.length;
			     $('div#div_content_video').html(data);
			     setTimeout('getFlash()',1);
			     load_titolo_video(id);
			     document.getElementById('input_idvideo-share').value=id_video;
/*				    if(id_video_old!=null)
				    {
						array_id_video_old.push(id_video_old);
						var a_listing = document.getElementById('a_listing_video_'+id_video_old);
						a_listing.onmouseover=function() { over_listing_video(array_id_video_old[i]); }
						a_listing.onmouseout=function() { out_listing_video(array_id_video_old[i]); }
						var div_tool_video = document.getElementById('tool_video_'+id_video_old);
						div_tool_video.onmouseover=function() { over_listing_video(array_id_video_old[i]); }
						div_tool_video.onmouseout=function() { out_listing_video(array_id_video_old[i]); }
						var image_pul = document.getElementById('image_pulsante_play_'+id_video_old);
						image_pul.src=config_imagepath_php+'/play-off.png';
						image_pul.onmouseover=function() { over_listing_video(array_id_video_old[i]); }
						image_pul.onmouseout=function() { out_listing_video(array_id_video_old[i]); }
						var image_thumb = document.getElementById('image_thumb_'+id_video_old);
						image_thumb.style.border='1px solid #041534';
						image_thumb.onmouseover=function() { over_listing_video(array_id_video_old[i]); }
						image_thumb.onmouseout=function() { out_listing_video(array_id_video_old[i]); }
					}
					var a_listing = document.getElementById('a_listing_video_'+id_video);
					a_listing.onmouseover='';
					a_listing.onmouseout='';
					var div_tool_video = document.getElementById('tool_video_'+id_video);
					div_tool_video.onmouseover='';
					div_tool_video.onmouseout='';
					var image_pul = document.getElementById('image_pulsante_play_'+id_video);
					image_pul.src=config_imagepath_php+'/play-air.png';
					image_pul.onmouseover='';
					image_pul.onmouseout='';
					var image_thumb = document.getElementById('image_thumb_'+id_video);
					image_thumb.style.border='1px solid #930301';
					image_thumb.onmouseover='';
					image_thumb.onmouseout='';
					*/
				}
			 );
		}
        function load_titolo_video(id) {
			$.post("jquery_php/agg_titolo_video.php",
			   { num: Math.random(), id: id },
			   function(data){
				 document.getElementById('div_titolo_video').innerHTML = data;
			   }
			 );
			 return;
        }

		function ajax_video_stream_pal(id) {
			$.post("jquery_php/agg_video_stream_pal.php",
			   { num: Math.random(), id: id },
			   function(data){
			     $('div#div_content_video').html(data);
			     setTimeout('getFlash()',1);
				    id_primo_video_pal=document.getElementById('id_primo_video').innerHTML;
				}
			 );
		}

        function load_titolo_video_pal() {
			$.post("jquery_php/agg_titolo_video_pal.php",
			   { num: Math.random() },
			   function(data){
					if(data!='video--adv--') {
						 document.getElementById('div_titolo_video').innerHTML = data;
					}
					else
					{
						 document.getElementById('div_titolo_video').innerHTML = "";
					}
			   }
			 );
			 return;
        }

        function load_video_correlati(id) {
			$.post("jquery_php/agg_video_correlati.php",
			   { id_video: id },
			   function(data){
			     document.getElementById('div_video_correlati').innerHTML = data;
			     load_versione_testuale(id)
			   }
			 );
        }

        function load_versione_testuale(id) {
			$.post("jquery_php/agg_versione_testuale.php",
			   { id_video: id },
			   function(data){
			     document.getElementById('div_versione_testuale').innerHTML = data;
				 load_keywords(id)
			   }
			 );
        }

        function load_keywords(id) {
			$.post("jquery_php/agg_keywords.php",
			   { id_video: id },
			   function(data){
			     document.getElementById('div_keywords').innerHTML = data;
			   }
			 );
        }

		function load_send_mail() {
			mionome=document.getElementById('nome_mitt').value;
			miaemail=document.getElementById('email_mitt').value;
			if(miaemail=='')
			{
				document.getElementById('div_send_mail').innerHTML = 'Inserisci la tua email';
				return;
			}
			tuonome=document.getElementById('nome_dest').value;
			tuaemail=document.getElementById('email_dest').value;
			if(tuaemail=='')
			{
				document.getElementById('div_send_mail').innerHTML = 'Inserisci l\'email del destinatario';
				return;
			}
			var id_email_video;
			if(id_video==null)
				id_email_video=document.getElementById('id_primo_video').innerHTML;
			else
				id_email_video = id_video;
			$.post("jquery_php/agg_send_mail.php",
			   { id_video: id_email_video, nome_mitt: mionome, email_mitt: miaemail, nome_dest: tuonome, email_dest: tuaemail },
			   function(data){
			     //alert("Data Loaded: " + data);
			     if(data=='ok')
			     	document.getElementById('div_send_mail').innerHTML = 'Email inviata con successo';
			    else
			     	document.getElementById('div_send_mail').innerHTML = 'Impossibile inviare l\'email. Riprova più tardi.';

			   }
			 );
		}

		var naviga_tra_canali;
		function load_new_sfondo_canali(id, pag) {
   			naviga_tra_canali=true;
			idcanale_idprog=id;
			load_new_video(idcanale_idprog, pag);
/*			$.post("jquery_php/agg_sfondo_canale.php",
			   { idcanale_idprog: id },
			   function(data){
			     document.getElementById('cx_dx_sup').style.background = '#fff url(' + data + ') no-repeat';
				 load_new_video(idcanale_idprog);
			   }
			 );*/
		}

		function load_new_sfondo_programmi(id) {
			palin_sesto='no';
		    idcanale_idprog=id;
/*			$.post("jquery_php/agg_sfondo_prog.php",
			   { idcanale_idprog: id },
			   function(data){
			     document.getElementById('cx_dx_sup').style.background = '#fff url(' + data + ') no-repeat';
				 load_new_video(idcanale_idprog);
			   }
			 );*/
			load_new_video(idcanale_idprog, '1');
		}

		function load_new_video(id, pagina) {
			$.post("jquery_php/agg_div_video.php",
			   { idcanale_idprog: id, pag: pagina },
			   function(data){
			     $('div#contenuto_video_bottom').html(data);
				 //init1();
			    //document.getElementById('loading').style.display='none';
			   }
			 );
		}

		function load_new_video_sp(id, pagina) {
			$.post("jquery_php/agg_div_video_ev_es.php",
			   { type: id, pag: pagina },
			   function(data){
			     $('div#contenuto_video_bottom').html(data);
				 //init1();
			    //document.getElementById('loading').style.display='none';
			   }
			 );
		}

		function cerca_video(testo) {
			if(testo!="")
			{
				//document.getElementById('loading').style.display='block';
				palin_sesto='no';
				$.post("jquery_php/cerca_video.php",
				   { testo: testo },
				   function(data){
						cambia_width('no_pal');
						document.getElementById('cx_dx_sup').style.background = '#fff url(images/sfondo-ricerca.jpg) no-repeat';
					    document.getElementById('div_video').innerHTML = data;
					    init1();
					    //document.getElementById('loading').style.display='none';
				   }
				 );
			}
		    else
		    {
		    	alert('Devi inserire almeno una parola da cercare');
		    }
		}

		function filtra(numazione) {
		    naviga_tra_canali=true;
		    if(numazione==1)
                document.getElementById('cx_dx_sup').style.background = '#fff url(images/sfondo-esclusiva.jpg) no-repeat';
		    else if(numazione==2)
                document.getElementById('cx_dx_sup').style.background = '#fff url(images/sfondo-evidenza.jpg) no-repeat';
		    else if(numazione==3)
                document.getElementById('cx_dx_sup').style.background = '#fff url(images/sfondo-ultimi.jpg) no-repeat';
		    else if(numazione==4)
                document.getElementById('cx_dx_sup').style.background = '#fff url(images/sfondo-visti.jpg) no-repeat';

			$.post("jquery_php/filtra_azione.php",
			   { num: numazione },
			   function(data){
				    document.getElementById('div_video').innerHTML = data;
				    init1();
				    //document.getElementById('loading').style.display='none';
			   }
			 );
		}

		var num_pal;
		function palinsesto_avanti(numero) {
			if(naviga_tra_canali!=true) {
			    num_pal=numero;
				$.post("jquery_php/palinsesto_avanti.php",
				   { num: Math.random(), inizio: numero },
				   function(data){
		             naviga_tra_canali=null;
				     $('div#div_video').html(data);
				     if(num_pal=='0p') {
	 				 	 load_titolo_video_pal();
						 setTimeout('getFlash()',1);
				     }
				   }
				 );
			}
			else if(naviga_tra_canali==true) {
				$.post("jquery_php/palinsesto_avanti_novideo.php",
				   { num: Math.random(), inizio: numero },
				   function(data){
 				 	 load_titolo_video_pal();
					 setTimeout('getFlash()',1);
				   }
				 );
			}
			return;
		}

		function attiva_visualizza_palinsesto() {
			if(palin_sesto=='no') {
				//document.getElementById('loading').style.display='block';

	            document.getElementById('image-channel_over-tastolive').style.visibility='visible';
				document.getElementById('image-channel_out-tastolive').style.visibility='hidden';

	            document.getElementById('image-channel_over-tastoondemand').style.visibility='visible';
				document.getElementById('image-channel_out-tastoondemand').style.visibility='hidden';

	            if(old_idch!=null) {
					var i = arr_active_idch.length;
					i--;
		            document.getElementById('image-channel_active-'+arr_active_idch[i]).style.visibility='hidden';
		            document.getElementById('image-channel_over-'+arr_active_idch[i]).style.visibility='hidden';
					document.getElementById('image-channel_out-'+arr_active_idch[i]).style.visibility='visible';
	                old_idch.onmouseover=function() { channel_over(arr_active_idch[i]); }
	                old_idch.onmouseout=function() { channel_out(arr_active_idch[i]); }
	                old_idch=null;
	                //arr_active_idch=[];
	            }

	            //document.getElementById('cx_dx_sup').style.background = '#fff url(images/sfondo-palinsesto.jpg) no-repeat';
				azzera_variabili();
		     	$('div#div_video').html('');
				if(naviga_tra_canali!=true){
					palinsesto_avanti('0p');
				}
				else if(naviga_tra_canali==true) {
					$.post("jquery_php/palinsesto_avanti_nosession.php",
					   { num: Math.random(), inizio: 0 },
					   function(data){
			             naviga_tra_canali=null;
					     $('div#div_video').html(data);
					   }
					 );
				}

			    //document.getElementById('loading').style.display='none';
	            if(palin_sesto=='no')
					ajax_video_stream_pal(sessionid_php);
				palin_sesto='si';
			}
		}

		var idcanale_idprog=null;
		var id_video=null;
		var id_video_old=null;
		var array_id_video_old = [];

		function azzera_variabili() {
			idcanale_idprog=null;
			id_video=null;
			id_video_old=null;
			array_id_video_old = [];
		}

		function over_listing_video(id) {
			document.getElementById('image_pulsante_play_' + id).src=config_imagepath_php+'/play-on.png';
			document.getElementById('image_thumb_' + id).style.border='1px solid #930301';
		}
		function out_listing_video(id) {
			document.getElementById('image_pulsante_play_' + id).src=config_imagepath_php+'/play-off.png';
			document.getElementById('image_thumb_' + id).style.border='1px solid #192239';
		}

		function close_divvideo() {
		    alert('Se leggi questo messaggio avvisa l\'amministratore');
		}

		var dhtmlgoodies_slideSpeed = 20;	// Higher value = faster
		var dhtmlgoodies_timer = 1;	// Lower value = faster

		var objectIdToSlideDown = false;
		var dhtmlgoodies_activeId = false;
		var dhtmlgoodies_slideInProgress = false;
		function showHideContent(e,inputId)
		{
			if(dhtmlgoodies_slideInProgress)return;
			dhtmlgoodies_slideInProgress = true;
			if(!inputId)inputId = this.id;
			inputId = inputId + '';
			var numericId = inputId.replace(/[^0-9]/g,'');
			var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

			objectIdToSlideDown = false;

			if(!answerDiv.style.display || answerDiv.style.display=='none'){
				if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){
					objectIdToSlideDown = numericId;
					slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
				}else{

					answerDiv.style.display='block';
					answerDiv.style.visibility = 'visible';

					slideContent(numericId,dhtmlgoodies_slideSpeed);
				}
			}else{
				slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
				dhtmlgoodies_activeId = false;
			}
		}

		function slideContent(inputId,direction)
		{

			var obj =document.getElementById('dhtmlgoodies_a' + inputId);
			var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
			height = obj.clientHeight;
			if(height==0)height = obj.offsetHeight;
			height = height + direction;
			rerunFunction = true;
			if(height>contentObj.offsetHeight){
				height = contentObj.offsetHeight;
				rerunFunction = false;
			}
			if(height<=1){
				height = 1;
				rerunFunction = false;
			}

			obj.style.height = height + 'px';
			var topPos = height - contentObj.offsetHeight;
			if(topPos>0)topPos=0;
			contentObj.style.top = topPos + 'px';
			if(rerunFunction){
				setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
			}else{
				if(height<=1){
					obj.style.display='none';
					if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
						document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
						document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
						slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);
					}else{
						dhtmlgoodies_slideInProgress = false;
					}
				}else{
					dhtmlgoodies_activeId = inputId;
					dhtmlgoodies_slideInProgress = false;
				}
			}
		}



		function initShowHideDivs()
		{
			var divs = document.getElementsByTagName('DIV');
			var divCounter = 1;
			for(var no=0;no<divs.length;no++){
				if(divs[no].className=='dhtmlgoodies_question'){
					divs[no].onclick = showHideContent;
					divs[no].id = 'dhtmlgoodies_q'+divCounter;
					var answer = divs[no].nextSibling;
					while(answer && answer.tagName!='DIV'){
						answer = answer.nextSibling;
					}
					answer.id = 'dhtmlgoodies_a'+divCounter;
					contentDiv = answer.getElementsByTagName('DIV')[0];
					contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px';
					contentDiv.className='dhtmlgoodies_answer_content';
					contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
					answer.style.display='none';
					answer.style.height='1px';
					divCounter++;
				}
			}
			numero_div_canali = divCounter - 1;
		}
		var old_idch;
		var arr_active_idch=[];
        function active_button(obj, ch) {
			var i = arr_active_idch.length;
			i--;
			if(palin_sesto=='si') {
	            document.getElementById('image-channel_over-tastolive').style.visibility='hidden';
				document.getElementById('image-channel_out-tastolive').style.visibility='visible';
	            document.getElementById('image-channel_over-tastoondemand').style.visibility='hidden';
				document.getElementById('image-channel_out-tastoondemand').style.visibility='visible';
				palin_sesto='no';
			}
			arr_active_idch.push(ch);
            if(old_idch!=null) {
	            document.getElementById('image-channel_active-'+arr_active_idch[i]).style.visibility='hidden';
	            document.getElementById('image-channel_over-'+arr_active_idch[i]).style.visibility='hidden';
				document.getElementById('image-channel_out-'+arr_active_idch[i]).style.visibility='visible';
                old_idch.onmouseover=function() { channel_over(arr_active_idch[i]); }
                old_idch.onmouseout=function() { channel_out(arr_active_idch[i]); }
            }

            document.getElementById('image-channel_active-'+ch).style.visibility='visible';
            document.getElementById('image-channel_over-'+ch).style.visibility='hidden';
			document.getElementById('image-channel_out-'+ch).style.visibility='visible';
			obj.onmouseover='';
			obj.onmouseout='';
			old_idch=obj;
        }


		function channel_over(ch) {
			document.getElementById('image-channel_over-'+ch).style.visibility='visible';
			document.getElementById('image-channel_out-'+ch).style.visibility='hidden';
		}
		function channel_out(ch) {
			document.getElementById('image-channel_over-'+ch).style.visibility='hidden';
			document.getElementById('image-channel_out-'+ch).style.visibility='visible';
		}

	function apri(form,car,width,height,nome) {
	    if(!nome)
	        nome = 'aa' + (new Date().getTime());
	    //----------
	    var win_w = width;
	    var win_h = height + 0;
	    var left = Math.floor((screen.width - win_w) / 2);
	    var top = Math.floor((screen.height - win_h) / 2);
	    car = car + ',width=' + width + ',height=' + height + ',top=' + top + ',left=' + left;
	    //----------

	    form.target = nome;
	    open ('', nome, car);
	    form.submit();
	}
	function controllo_e_popup(nomeform)
	{
		if(palin_sesto=='si')
			document.getElementById('input_idvideo-share').value=document.getElementById('id_primo_video').innerHTML;
//  		else
//			document.getElementById('input_idvideo-share').value="nessuno_id";

	    apri(nomeform,'resizable=0,scrollbars=1,toolbar=0,status=0,menubar=0,location=0',535,276);
	    return true;
	}
	function view_video_piuvisti(id_video, idch) {
	    active_button('piu_visti', idch);
	    load_new_sfondo_canali(idch+',all');
	    ajax_video_stream(id_video);
	}
