var player = null;
var browserType=null;
var cont=0;
var tim=0;
function playerReady(thePlayer) { player = window.document[thePlayer.id]; }
//funzione abbreviativa per la lunghezza della stringa
function Len(StrToLen)
{
return StrToLen.length;
}

// Funzioni ajax per laggiornamento del div nav
function createRequestObject() {
  
  var ro;

 try {
 ro = new XMLHttpRequest();
 } catch(e){
 try {
 ro = new ActiveXObject("Msxm12.XMLHTTP");
 } catch(e) {
 ro = new ActiveXObject("Microsoft.XMLHTTP");
 }
 } 
  return ro;
}
var http = createRequestObject();

//funzione per l'onclick del paginatore
function nav(canale) {
 // http.open('get', 'elencovideo.php?pagina=' + pagina + '&categoria=' + categoria + '&sid=' + Math.random());
 http.open('get', 'browse.php?canale=' + canale + '&sid=' + Math.random());
    http.onreadystatechange = handleResponse;
  http.send(null);
}


function handleResponse() {
  if(http.readyState == 4) {
    var response = http.responseText;
	
	if (document.getElementById('box_nav') ) { document.getElementById('box_nav').innerHTML = response;    }
	
	if (document.getElementById('box_lookaround') ) { document.getElementById('box_lookaround').innerHTML = response;    }
   
  }
}

function CJL_BrowserSniffer()
{
   var ua = navigator.userAgent;

   this.isOpera = function()
   {
      return /Opera/.test(ua);
   }

   this.isSafari = function()
   {
      return /Safari/.test(ua);
   }

   this.isGecko = function()
   {
      return navigator.product == "Gecko" &&
	     ! ( this.isOpera() || this.isSafari() );
   }

   this.isIEWin = function()
   {
      return window.external && /Win/.test(ua);
   }

   this.isIEMac = function()
   {
      return window.external && /Mac/.test(ua);
   }

   this.getVersion = function()
   {
      if( this.isIEWin() || this.isIEMac() )
      {
         return Number(ua.match(/MSIE ([0-9.]+)/)[1]);
      }
      else if( this.isSafari() )
      {
         return Number(ua.match(/[0-9.]+$/));
      }
      else if( this.isGecko() )
      {
         var n = ua.match(/rv:([0-9.]+)/)[1];

         var ar = n.split(".");

         var s = ar[0] + ".";

         for(var i = 1; i < ar.length; ++i)
         {
            s += ("0" + ar[i]).match(/.{2}$/)[0];
         }

         return Number(s);
      }
      else if( this.isOpera() )
      {
         return Number(ua.match(/Opera.([0-9.]+)/)[1]);
      }
      else
      {
         return null;
      }
   }
}
 

function cambiaFrame(param){
/**
 * param = frame di destinazione
 */


 if(document.getElementById("box_nav"))
 {
  document.getElementById("box_nav").style.zIndex= "0";
 }
 else
 {
  document.getElementById("box_lookaround").style.zIndex= "0";
 }

var controllo=0;
document.getElementById("piframe").style.visibility= "visible";
document.getElementById("myFrame").style.zIndex= "10";
var indirizzo=window.location;
if((indirizzo=='http://www.televisionet.tv/live.aspx') ||(indirizzo=='http://televisionet.tv/live.aspx')||(indirizzo=='http://www.televisionet.tv/live.aspx#')||(indirizzo=='http://televisionet.tv/live.aspx#'))
																																								  {
		controllo=1;
																																					  }
																																					sniffer = new CJL_BrowserSniffer();
if( sniffer.isSafari() )
   {
      controllo=0;
   }
 
var myFrame = document.getElementById("myFrame");
switch(param){
	case '1': 
				//if(controllo==1) {player.sendEvent('LOAD','flash/playlist_network.php');}
			  document.getElementById('uno').src="/images/newlayout/newmenu/NETWORK_on.aspx";
			  document.getElementById('due').src="/images/newlayout/newmenu/AROUND_off.aspx";
			  document.getElementById('tre').src="/images/newlayout/newmenu/KNOWLEDGE_off.aspx";
			  document.getElementById('quattro').src="/images/newlayout/newmenu/INNOVA_off.aspx";
			  document.getElementById('cinque').src="/images/newlayout/newmenu/PLANET_off.aspx";
				break;
	case '2': 
			//	if(controllo==1){player.sendEvent('LOAD','flash/playlist_around.php');}
			  document.getElementById('uno').src="/images/NewLayout/NewMenu/NETWORK_off.aspx";
			  document.getElementById('due').src="/images/newlayout/newmenu/AROUND_on.aspx";
			  document.getElementById('tre').src="/images/newlayout/newmenu/KNOWLEDGE_off.aspx";
			  document.getElementById('quattro').src="/images/newlayout/newmenu/INNOVA_off.aspx";
			  document.getElementById('cinque').src="/images/newlayout/newmenu/PLANET_off.aspx";
			break;
		case '3': 
			  //if(controllo==1){player.sendEvent('LOAD','flash/playlist_knowledge.php');}
		      document.getElementById('uno').src="/images/NewLayout/NewMenu/NETWORK_off.aspx";
			  document.getElementById('due').src="/images/newlayout/newmenu/AROUND_off.aspx";
			  document.getElementById('tre').src="/images/newlayout/newmenu/KNOWLEDGE_on.aspx";
			  document.getElementById('quattro').src="/images/newlayout/newmenu/INNOVA_off.aspx";
			  document.getElementById('cinque').src="/images/newlayout/newmenu/PLANET_off.aspx";
			break;
		case '4': 
			  //if(controllo==1){player.sendEvent('LOAD','flash/playlist_innova.php');}
			  document.getElementById('uno').src="/images/NewLayout/NewMenu/NETWORK_off.aspx";
			  document.getElementById('due').src="/images/newlayout/newmenu/AROUND_off.aspx";
			  document.getElementById('tre').src="/images/newlayout/newmenu/KNOWLEDGE_off.aspx";
			  document.getElementById('quattro').src="/images/newlayout/newmenu/INNOVA_on.aspx";
			  document.getElementById('cinque').src="/images/newlayout/newmenu/PLANET_off.aspx";
			break;
		case '5': 
		      //if(controllo==1){player.sendEvent('LOAD','flash/playlist_planet.php');}
			  document.getElementById('uno').src="/images/NewLayout/NewMenu/NETWORK_OFF.aspx";
			  document.getElementById('due').src="/images/newlayout/newmenu/AROUND_off.aspx";
			  document.getElementById('tre').src="/images/newlayout/newmenu/KNOWLEDGE_off.aspx";
			  document.getElementById('quattro').src="/images/newlayout/newmenu/INNOVA_off.aspx";
			 document.getElementById('cinque').src="/images/newlayout/newmenu/PLANET_on.aspx";
			break;}
//Provo a cambiare il frame
if(param.length > 0){
myFrame.src = "canale.php?can="+param;
}
}
