var loadTimer;
function startLoading(){
	spalma('myFogKgo');
	if(loadTimer){
		clearInterval(loadTimer);
	}
	loadTimer = setInterval("spalma('myFogKgo')", 5);
}
function stopLoading(){
	if(loadTimer){
		clearInterval(loadTimer);
	}
	Nascondi('myFogKgo');
}
function spalma(div){
	var screenLen = document.body.clientWidth;
	var screenHei= document.body.clientHeight;
	document.getElementById(div).style.width = screenLen;
	document.getElementById(div).style.height = screenHei;
	document.getElementById('myFogTableKgo').style.height = screenHei;
	document.getElementById(div).style.left = 0+document.body.scrollLeft;
	document.getElementById(div).style.top=0+document.body.scrollTop;
	document.getElementById(div).style.visibility = 'visible';
	document.getElementById(div).style.display = 'block';
}
function CreateXmlHttpReqKgo(handler) {
	var xmlhttp = null;
	try {
		xmlhttp = new XMLHttpRequest();
	}catch(e){
		try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	xmlhttp.onreadystatechange = handler;
	return xmlhttp;
}
function StandardMyHandlerKgo(div) {
	if (myRequest.readyState == 4 && myRequest.status == 200) {
		e = document.getElementById(div);
		e.innerHTML = myRequest.responseText;
		stopLoading();
	}
}



//ancora in bozza.. da completare quando trovo tempo----------------------------------
function loadObjX(div, who, dominio, b, y){
	startLoading();
	setTimeout("loadObjX2('"+div+"', '"+who+"', '"+dominio+"', '"+b+"', '"+y+"')", 0);
}
function loadObjX2(div, who, dominio, b, y){
	var r = Math.random();
	myRequest = CreateXmlHttpReqKgo(function() {StandardMyHandlerKgo(div)});
	myRequest.open("GET","kgoLoader/kgoLoader.php?r="+escape(r)+"&d="+encodeURIComponent(dominio)+"&who="+encodeURIComponent(who)+"&b="+encodeURIComponent(b)+"&y="+escape(y));
	myRequest.send(null);
}

//con lightBox init...
function loadObjXLB(div, who, dominio, b, y){
	startLoading();
	setTimeout("loadObjXLB2('"+div+"', '"+who+"', '"+dominio+"', '"+b+"', '"+y+"')", 0);
}
function loadObjXLB2(div, who, dominio, b, y){
	var r = Math.random();
	myRequest = CreateXmlHttpReqKgo(function() {StandardMyHandlerKgoLB(div)});
	myRequest.open("GET","kgoLoader/kgoLoader.php?r="+escape(r)+"&d="+encodeURIComponent(dominio)+"&who="+encodeURIComponent(who)+"&b="+encodeURIComponent(b)+"&y="+escape(y));
	myRequest.send(null);
}
function StandardMyHandlerKgoLB(div) {
	if (myRequest.readyState == 4 && myRequest.status == 200) {
		e = document.getElementById(div);
		e.innerHTML = myRequest.responseText;
		stopLoading();
		initLightbox();
	}
}
//ancora in bozza.. da completare quando trovo tempo-----------------------------------


function start(div){
	document.getElementById(div).innerHTML = '<div id="myFogKgo" style="position:absolute; width:100px; filter: alpha(opacity=85); -moz-opacity: 0.85; opacity: 0.85; z-index:150; height: 3px; left: 350px; top: 195px; border-color:#333333; visibility:hidden; display:none; background: #333333; layer-background-color: #333333; border: 1px none #333333;"><div align="center"><table width="100%" id="myFogTableKgo" height="0" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">Caricamento...</td></tr></table></div></div>';
}
function MostraCentra(div){
	var hC=document.body.clientHeight;
	var wC=document.body.clientWidth;
	var sL = document.body.scrollLeft;
	myDiv = document.getElementById(div);
	myDiv.style.visibility = 'visible';
	myDiv.style.display = 'block';
	var myDivW = myDiv.offsetWidth;
	var myDivH = myDiv.offsetHeight;
	var myLeft = (wC/2)-(myDivW/2)+document.body.scrollLeft;
	var myTop = (hC/2)-(myDivH/2)+document.body.scrollTop;
	myDiv.style.top = myTop;
	myDiv.style.left = myLeft;
}
function Nascondi(quale){
	var r = document.getElementById(quale);
	r.style.visibility = 'hidden';
	r.style.display = 'none';
}
function Mostra(quale){
	var r = document.getElementById(quale);
	r.style.visibility = 'visible';
	r.style.display = 'block';
}

function MostraNascondi(quale){
	var r = document.getElementById(quale);
	if(r.style.visibility == 'hidden'){
		r.style.visibility = 'visible';
		r.style.display = 'block';
	}else{
		r.style.visibility = 'hidden';
		r.style.display = 'none';
	}
}

function cambiaCodice(){
	startLoading();
	setTimeout('cambiaCodice2()', 150);
}
function cambiaCodice2(){
	var r = Math.random();
	document.getElementById('captchaDiv').innerHTML = '<img src="http://www.wateronlinestore.com/kgoLoader/captcha/immagine.php?r='+r+'"><br>se il codice è illeggibile, <span class="linkGrigioSottile" onClick="cambiaCodice();">[clicca qui]</span>';
	stopLoading();
}
