var xmlHttp,secondoAttuale,secondoPreload,secondiVenduti,nextProg,currentSponsor,NStipo,state,showProg,showProgTmp;function caricaDatiSponsor(){xmlHttp=GetXmlHttpObject();if(xmlHttp==null){alert("Browser does not support HTTP Request");return}var url="getDatiGame.php?sid="+Math.random();xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(null)}function stateChanged(){if(xmlHttp.readyState==4||xmlHttp.readyState=="complete"){xmlDoc=xmlHttp.responseXML;NSimgsrc=xmlDoc.getElementsByTagName("i")[0].childNodes[0].nodeValue;NSimg=new Image();NSimg.src=NSimgsrc;NStipo=xmlDoc.getElementsByTagName("t")[0].childNodes[0].nodeValue;if(NStipo=="random")showProgTmp=xmlDoc.getElementsByTagName("p")[0].childNodes[0].nodeValue;secondoAttuale=xmlDoc.getElementsByTagName("cS")[0].childNodes[0].nodeValue;nextProg=xmlDoc.getElementsByTagName("nS")[0].childNodes[0].nodeValue;NSstartTime=progToLocalFormatTime(nextProg,0);NSendTime=progToLocalFormatTime(nextProg,1)}}function GetXmlHttpObject(){var objXMLHttp=null;if(window.XMLHttpRequest)objXMLHttp=new XMLHttpRequest();else if(window.ActiveXObject)objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");return objXMLHttp}function centraSponsor(){dimW=468;dimH=289;marW=(dimW-document.getElementById('box1_img').width)/2;marH=(dimH-document.getElementById('box1_img').height)/2;margine=' '+marH+' '+marW;document.getElementById('box1_img').style.margin=margine}function startShow(){centraSponsor();randomSiteDisplay();$('#blackPannelBig').fadeOut(1300,function(){$('#blackPannelSmall').fadeOut(700)});timePickerInitialize(timePickerBack,timePickerClose);NSstartTime=progToLocalFormatTime(nextProg,0);NSendTime=progToLocalFormatTime(nextProg,1);iniziaConteggio()}function iniziaConteggio(){state="game";secondoPreload=Math.floor(Math.random()*7)+1;caricaDatiSponsor();t1=window.setInterval("conteggio()",1000);document.getElementById('lblVenduti').innerHTML=secondiVenduti;document.getElementById('lblLiberi').innerHTML=(86400-secondiVenduti);document.getElementById('contOrarioSX').innerHTML=progToLocalFormatTime(currentSponsor,0);document.getElementById('contOrarioDX').innerHTML=progToLocalFormatTime(currentSponsor,1);document.getElementById('lblSponsor').innerHTML="#"+currentSponsor}function timePickerBack(prmProg){window.clearInterval(t1);$('#cornice').fadeOut('slow',function(){location.href='http://www.isell86400seconds.com/showSite.php?prog='+prmProg})}function go2siteProg(prmProg){if(prmProg>0&&prmProg<8641){window.clearInterval(t1);$('#cornice').fadeOut('slow',function(){location.href='http://www.isell86400seconds.com/showSite.php?prog='+prmProg})}}function timePickerClose(){$('#timePicker').fadeOut('fast',function(){$('#box1').fadeIn('fast');randomSiteDisplay()});state="game"}function conteggio(){switch(secondoAttuale){case secondoPreload:caricaDatiSponsor();break;case 9:$('#box1_img').fadeOut(1000);break;case 10:document.getElementById('lblCounter').innerHTML=(10-secondoAttuale);document.getElementById('box1_img').src=NSimgsrc;currentSponsor=nextProg;showProg=showProgTmp;centraSponsor();$('#box1_img').fadeIn(1000);document.getElementById('contOrarioSX').innerHTML=NSstartTime;document.getElementById('contOrarioDX').innerHTML=NSendTime;document.getElementById('lblSponsor').innerHTML="#"+nextProg;randomSiteDisplay();secondoAttuale=0;break}document.getElementById('lblCounter').innerHTML=(10-secondoAttuale);secondoAttuale++}function randomSiteDisplay(){if(NStipo=="random"){if(state=="game")document.getElementById('tipoSponsor').style.visibility="visible"}else document.getElementById('tipoSponsor').style.visibility="hidden"}function clickDivDiscoverTime(){if(state=="discoverTime")timePickerClose();else{document.getElementById('tipoSponsor').style.visibility="hidden";$('#box1').fadeOut('fast',function(){$('#timePicker').fadeIn('fast')});state="discoverTime"}}function showDivPickNumber(){$('#divDiscoverNumberUnder').fadeOut('fast',function(){$('#divDiscoverNumber').fadeIn('fast')})}function showDivDiscoverNumberUnder(){$('#divDiscoverNumber').fadeOut('fast',function(){$('#divDiscoverNumberUnder').fadeIn('fast');document.getElementById('inputDiscoverNumber').value="";$('#inputDiscoverNumber').focus()})}function onlyNumericSelection(){document.getElementById('inputDiscoverNumber').value=document.getElementById('inputDiscoverNumber').value.replace(/[^0-9]/g,"")}function goSponsor(){switch(NStipo){case"buyer":document.location.href="http://www.isell86400seconds.com/showSite.php?prog="+currentSponsor;break;case"random":document.location.href="http://www.isell86400seconds.com/showSite.php?prog="+showProg;break;case"autopromozione":document.location.href="http://www.isell86400seconds.com/addSite.php";break}}function enterInput(prmEvent){var keycode;if(window.event)keycode=window.event.keyCode;else if(prmEvent)keycode=prmEvent.which;if(keycode==13)go2siteProg(document.getElementById('inputDiscoverNumber').value)}