//window.onload = aggiorna; 

function aggiorna()
{ window.setInterval("aggSession()", 30000);}

aggSession = function(){
	XMLHTTP = chkBrowser(Aggiornato);
	XMLHTTP.open("GET", "/risposta.asp", true);
	XMLHTTP.send(null);		
}

function Aggiornato()
{	//alert("Aggiornato");
	if (XMLHTTP.readyState == 4)
	{ var ok = XMLHTTP.responseText;}
}

function chkBrowser(QualeBrowser)
{
	if (navigator.userAgent.indexOf("MSIE") != (-1))
	{
		var Classe = "Msxml2.XMLHTTP";
		if (navigator.appVersion.indexOf("MSIE 5.5") != (-1));
		{
			Classe = "Microsoft.XMLHTTP";
		} 
		try
		{
			OggettoXMLHTTP = new ActiveXObject(Classe);
			OggettoXMLHTTP.onreadystatechange = QualeBrowser;
			return OggettoXMLHTTP;
		}
		catch(e)
		{
			alert("Errore: l'ActiveX non verrà eseguito!");
		}
	}
	else if (navigator.userAgent.indexOf("Mozilla") != (-1))
	{
		OggettoXMLHTTP = new XMLHttpRequest();
		OggettoXMLHTTP.onload = QualeBrowser;
		OggettoXMLHTTP.onerror = QualeBrowser;
		return OggettoXMLHTTP;
	}
	else
	{
		alert("L'esempio non funziona con altri browser!");
	}
}


var req = null;
var divId = 0;

function fadeIt(strEle,url){
	
	var ele = document.getElementById(strEle);
	
	cover(ele);
	
	//ele.innerHTML = "<div style='width:100%;height:"+ele.offsetHeight+"px;background-color:#e0e0e0;overflow:hidden;'>Aggiornamento in corso</div>"	
	
	//Spry.Effect.DoFade(ele,{ duration: 20, from: 100, to: 30, finish: function() {
		Spry.Utils.updateContent(ele, url, function() {
		//	Spry.Effect.DoFade(ele,{ duration: 50, from: 30, to: 100 });
			//waitStop();
		});
  //}
 //});
}
/*
function fadeIt(strEle,url){
	//alert("test");
	var ele = document.getElementById(strEle);
	Spry.Effect.DoFade(ele,{ duration: 20, from: 100, to: 30, finish: function() {
		Spry.Utils.updateContent(ele, url, function() {
			
			Spry.Effect.DoFade(ele,{ duration: 50, from: 30, to: 100 });
			//waitStop();
		});
  }
 });
}
*/

function fadeItAndDo(strEle, url, f){
	var ele = document.getElementById(strEle);
	Spry.Effect.DoFade(ele,{ duration: 20, from: 100, to: 30, finish: function() {
		Spry.Utils.updateContent(
									ele,
									url,
									function() {
										Spry.Effect.DoFade(ele,{ duration: 50, from: 30, to: 100 });
										//waitStop();
										f();
									}
								);
  }
 });
}

function cover(e){
	var scanObj = e;
	var lleft = 0;
	var ttop = 0;
	while (scanObj){
		lleft += scanObj.offsetLeft;
		ttop += scanObj.offsetTop;
		scanObj = scanObj.offsetParent;
	}
	
	var d0 = createObject('div');
	d0.style.width = e.offsetWidth+'px';
	d0.style.height = e.offsetHeight+'px';
	d0.style.position = 'absolute';
	d0.style.top = ttop+'px';
	d0.style.left = lleft+'px';
	d0.style.backgroundColor = '#FFFFFF';
	d0.style.opacity = .5;
	d0.style.filter = 'alpha(opacity=' + 50 + ')';
	d0.innerHTML = "";
	e.appendChild(d0);
}


function updateInterval(strEle,url,interval){
	//alert("test");
	var ele = document.getElementById(strEle);
	Spry.Utils.updateContent(ele, url);
	
	var strSet = "Spry.Utils.updateContent( document.getElementById('"+strEle+"'), '"+url+"');"
	//eval(strSet);
	setInterval(strSet, interval);
	
}

function addDiv(gruppo,txtGruppo,manifestazione){
	if(document.getElementById('div_'+manifestazione)){
		spAlert("Manifestazione gi&agrave; presente");
	}else{
		if(!document.getElementById('divG_'+gruppo)){
			var d0 = createObject('div','class', 'box99');
			d0.style.marginRight = '20px';
			d0.style.width = '100%';
			var d1 = createObject('div', 'class', 'topLeft2');
			d0.appendChild(d1);
			var d2 = createObject('div', 'class', 'topRight bg01');
			d1.appendChild(d2);
			var d3 = createObject('div', 'class', 'heading');
			d2.appendChild(d3);
			var d4 = createObject('h1');
			d4.innerHTML = txtGruppo;
			d3.appendChild(d4);
			var d5 = createObject('div', 'class', 'clearBox');
			d2.appendChild(d5);
			
			var d = createObject('div', 'id','divG_'+gruppo, 'class', 'contenuto');
			d0.appendChild(d);
			
			var d6 = createObject('div', 'class', 'bottomLeft');
			d0.appendChild(d6);
			var d7 = createObject('div', 'class', 'bottomRight');
			d6.appendChild(d7);	
			document.getElementById('containerGruppi').appendChild(d0);
		}else{
			var d = document.getElementById('divG_'+gruppo);
		}
		
		var m = createObject('div','id','div_'+manifestazione);
		d.appendChild(m);
		tmp = 'apriChiudi_div_'+manifestazione
		fadeIt(
				'div_'+manifestazione, '/boxeventi.asp?a='+Math.floor(10000000*Math.random())+'&desgruppo='+txtGruppo+'&divid=div_'+manifestazione+'&manifestazione='+manifestazione
				);
		divId++;
		//spAlert("Manifestazione inserita");//
		
	}
}


function addDiv2(gruppo,txtGruppo,manifestazione,datasel){
	if(document.getElementById('div_'+manifestazione)){
		spAlert("Manifestazione gi&agrave; presente");
	}else{
		if(!document.getElementById('divG_'+gruppo)){
			var d0 = createObject('div','class', 'box99');
			d0.style.marginRight = '20px';
			d0.style.width = '100%';
			var d1 = createObject('div', 'class', 'topLeft2');
			d0.appendChild(d1);
			var d2 = createObject('div', 'class', 'topRight bg01');
			d1.appendChild(d2);
			var d3 = createObject('div', 'class', 'heading');
			d2.appendChild(d3);
			var d4 = createObject('h1');
			d4.innerHTML = txtGruppo;
			d3.appendChild(d4);
			var d5 = createObject('div', 'class', 'clearBox');
			d2.appendChild(d5);
			
			var d = createObject('div', 'id','divG_'+gruppo, 'class', 'contenuto');
			d0.appendChild(d);
			
			var d6 = createObject('div', 'class', 'bottomLeft');
			d0.appendChild(d6);
			var d7 = createObject('div', 'class', 'bottomRight');
			d6.appendChild(d7);	
			document.getElementById('containerGruppi').appendChild(d0);
		}else{
			var d = document.getElementById('divG_'+gruppo);
		}
		
		var m = createObject('div','id','div_'+manifestazione);
		d.appendChild(m);
		tmp = 'apriChiudi_div_'+manifestazione
		fadeIt(
				'div_'+manifestazione, '/boxeventi.asp?a='+Math.floor(10000000*Math.random())+'&desgruppo='+txtGruppo+'&divid=div_'+manifestazione+'&manifestazione='+manifestazione+'&data='+datasel
				);
		divId++;
		//spAlert("Manifestazione inserita");//
		
	}
}

function addDiv2gruppo(gruppo,txtGruppo,datasel){
	if(document.getElementById('divgr_'+gruppo)){
		spAlert("Gruppo gi&agrave; presente");
	}else{
		if(!document.getElementById('divG_'+gruppo)){
			var d0 = createObject('div','class', 'box99');
			d0.style.marginRight = '20px';
			d0.style.width = '100%';
			var d1 = createObject('div', 'class', 'topLeft2');
			d0.appendChild(d1);
			var d2 = createObject('div', 'class', 'topRight bg01');
			d1.appendChild(d2);
			var d3 = createObject('div', 'class', 'heading');
			d2.appendChild(d3);
			var d4 = createObject('h1');
			d4.innerHTML = txtGruppo;
			d3.appendChild(d4);
			var d5 = createObject('div', 'class', 'clearBox');
			d2.appendChild(d5);
			
			var d = createObject('div', 'id','divG_'+gruppo, 'class', 'contenuto');
			d0.appendChild(d);
			
			var d6 = createObject('div', 'class', 'bottomLeft');
			d0.appendChild(d6);
			var d7 = createObject('div', 'class', 'bottomRight');
			d6.appendChild(d7);	
			document.getElementById('containerGruppi').appendChild(d0);
		}else{
			var d = document.getElementById('divG_'+gruppo);
		}
		
		var m = createObject('div','id','divgr_'+gruppo);
		m.innerHTML = '<div style=\'width:100%;text-align:center;\'>...attendere...</div>';
		d.appendChild(m);
		tmp = 'apriChiudi_div_'+gruppo
		fadeIt(
				'divgr_'+gruppo, '/boxeventi_gruppo.asp?a='+Math.floor(10000000*Math.random())+'&desgruppo='+txtGruppo+'&divid=divgr_'+gruppo+'&gruppo='+gruppo+'&data='+datasel
				);
		divId++;
		//spAlert("Gruppo inserito");//
		
	}
}

function addDiv2bigliettone(gruppo,txtGruppo,datasel){
	var dCG = document.getElementById('containerGruppi');
	while(dCG.hasChildNodes()){
		dCG.removeChild(dCG.lastChild);
	}
	if(document.getElementById('divgr_'+gruppo)){
		spAlert("Gruppo gi&agrave; presente");
	}else{
		if(!document.getElementById('divG_'+gruppo)){
			var d0 = createObject('div','class', 'box99');
			d0.style.marginRight = '20px';
			d0.style.width = '100%';
			var d1 = createObject('div', 'class', 'topLeft2');
			d0.appendChild(d1);
			var d2 = createObject('div', 'class', 'topRight bg01');
			d1.appendChild(d2);
			var d3 = createObject('div', 'class', 'heading');
			d2.appendChild(d3);
			var d4 = createObject('h1');
			d4.innerHTML = txtGruppo;
			d3.appendChild(d4);
			var d5 = createObject('div', 'class', 'clearBox');
			d2.appendChild(d5);
			
			var d = createObject('div', 'id','divG_'+gruppo, 'class', 'contenuto');
			d0.appendChild(d);
			
			var d6 = createObject('div', 'class', 'bottomLeft');
			d0.appendChild(d6);
			var d7 = createObject('div', 'class', 'bottomRight');
			d6.appendChild(d7);	
			document.getElementById('containerGruppi').appendChild(d0);
		}else{
			var d = document.getElementById('divG_'+gruppo);
		}
		
		var m = createObject('div','id','divgr_'+gruppo);
		m.innerHTML = '<div style=\'width:100%;text-align:center;\'>...attendere...</div>';
		d.appendChild(m);
		tmp = 'apriChiudi_div_'+gruppo
		fadeIt(
				'divgr_'+gruppo, '/boxeventi_bigliettone.asp?a='+Math.floor(10000000*Math.random())+'&desgruppo='+txtGruppo+'&divid=divgr_'+gruppo+'&gruppo='+gruppo+'&data='+datasel
				);
		divId++;
		
		fadeIt('container_carrello','/boxcarrello_bigliettone.asp?a='+Math.floor(10000000*Math.random())+'&act=delAll&id_bigliettone=' + gruppo);
		//spAlert("Gruppo inserito");//
		
	}
}

function createObject ()
{
	args=arguments;
	var newObj=document.createElement(args[0]);
	for (var i=1; i < args.length; i=i+2){
		if(args[i]=='class'){
			newObj.className = args[i+1];
		}else{
			newObj.setAttribute(args[i],args[i+1]);
		}
	}
	return newObj;
}

function visTotaleEsiti(obj,idEvento,desgruppo)
{

	var scanObj = obj;
	var lleft = 0;
	var ttop = 0;
	while (scanObj){
		lleft += scanObj.offsetLeft;
		ttop += scanObj.offsetTop;
		scanObj = scanObj.offsetParent;
	}
	
	
	var d0 = createObject('div', 'id', 'tuttiEsiti', 'class', 'tuttiEsiti');
	d0 = document.getElementById('tuttiEsiti');
	d0.innerHTML = '<div style="text-align:center;background-color:#ffffff;">...caricamento in corso...</div>';
	d0.style.display = 'block';
	d0.style.left = (lleft + 15) + 'px';
	d0.style.top = (ttop + 15) + 'px';
	
	fadeIt('tuttiEsiti','/include/tuttiRisultati.asp?evid='+idEvento+'&desgruppo='+desgruppo);
}


function addBet(rid,desgruppo){
	//var r_carrello = [];
	var strChk = getCarrelloChkQueryString();
	var req = Spry.Utils.loadURL('GET', '/boxcarrello.asp?a='+Math.floor(10000000*Math.random())+'&act=test&rid='+rid+'&desgruppo='+desgruppo+strChk, false);
	var r = req.xhRequest.responseText;
	
	eval(r);
		
	switch(r_carrello.codice){
		case '0':
			//spAlert(r_carrello.messaggio);
			fadeIt('container_carrello','/boxcarrello.asp?a='+Math.floor(10000000*Math.random())+'&act=add&rid='+rid+'&desgruppo='+desgruppo+strChk);
			break;
		case '1':
			//spAlert(r_carrello.messaggio);//
			break;
		case '2':
			//spAlert(r_carrello.messaggio);
			fadeIt('container_carrello','/boxcarrello.asp?a='+Math.floor(10000000*Math.random())+'&act=add&rid='+rid+'&desgruppo='+desgruppo+strChk);
			break;
		case '100':
			//spAlert(r_carrello.messaggio);//
			break;
		case '1000':
			//spAlert(r_carrello.messaggio);//
			fadeIt('container_carrello','/boxcarrello.asp?a='+Math.floor(10000000*Math.random()));
			break;
		default:
	}
	
}



function addBet_Big(rid){
	//var r_carrello = [];
	var strChk = getCarrelloChkQueryString();
	var req = Spry.Utils.loadURL('GET', '/boxcarrello_bigliettone.asp?a='+Math.floor(10000000*Math.random())+'&act=test&rid='+rid, false);
	var r = req.xhRequest.responseText;
	
	eval(r);
		
	switch(r_carrello.codice){
		case '0':
			//spAlert(r_carrello.messaggio);
			fadeIt('container_carrello','/boxcarrello_bigliettone.asp?a='+Math.floor(10000000*Math.random())+'&act=add&rid='+rid);
			break;
		case '1':
			//spAlert(r_carrello.messaggio);//
			break;
		case '2':
			//spAlert(r_carrello.messaggio);
			fadeIt('container_carrello','/boxcarrello_bigliettone.asp?a='+Math.floor(10000000*Math.random())+'&act=add&rid='+rid);
			break;
		case '100':
			//spAlert(r_carrello.messaggio);//
			break;
		case '1000':
			//spAlert(r_carrello.messaggio);//
			fadeIt('container_carrello','/boxcarrello_bigliettone.asp?a='+Math.floor(10000000*Math.random()));
			break;
		default:
	}
	
}

function delBet(rid){
	var strChk = getCarrelloChkQueryString();
	fadeIt('container_carrello','/boxcarrello.asp?a='+Math.floor(10000000*Math.random())+strChk+'&act=del&rid='+rid);
}

function delAllBet(){
	var strChk = getCarrelloChkQueryString();
	fadeIt('container_carrello','/boxcarrello.asp?a='+Math.floor(10000000*Math.random())+strChk+'&act=delAll');
}

function getCarrelloChkQueryString(){
	var strChk = '';
	var arrChk = document.getElementsByName('chkQuota');
	for(var j=0;j<arrChk.length;j++){
		if(!arrChk[j].checked){
			strChk += '&' + arrChk[j].value + '=0';	
		}
	}
	return strChk;
}

function spAlert(a){
	var d = document.getElementById('alertDiv');
	var b = document.getElementById('disab');
	//d.style.display='block';
	d.innerHTML = a; 
	ttop = document.documentElement.scrollTop;
	
	lleft = 50;
	/*
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	*/
	var winW = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
   	var winH = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
	
	b.style.top = ttop +'px';
	b.style.left = '0px';
	b.style.width = winW+'px';
	b.style.height = winH+'px';
	b.style.display = 'block';
	//d.style.width = winW+"px";
	
	
	//d.style.height = (winH+ttop)+"px";
	//d.style.display = 'block';
	d.style.display = 'block';
	d.style.top = (ttop + (winH - d.offsetHeight) / 2)+"px";
	d.style.left = ((winW - d.offsetWidth) / 2)+"px";
	
	
	
	Spry.Effect.DoFade(	
						d,
						{	duration: 100, 
							from: 0,
							to: 100,
							finish: function() {
								setTimeout('Spry.Effect.DoFade(document.getElementById(\'alertDiv\'),{ duration: 150, from: 100, to: 0, finish: function(){document.getElementById(\'alertDiv\').style.display=\'none\';document.getElementById(\'disab\').style.display=\'none\';}});',1500);
							}
						}
					);
}

function dropElement(strId){
	o = document.getElementById(strId);
	p = o.parentNode;
	p.removeChild(o);
	if (!p.hasChildNodes()){
		p.parentNode.parentNode.removeChild(p.parentNode);
	}
}

function gratta(idm,width,heigth)
{
	window.open("http://lit.grattaevinci.com/gioco-igp-web/template/demo.jsp?IDConcorso="+idm+"&widthFlash="+width+"&heightFlash="+heigth+"&posx=426&posy=229&title=Miliardario","newwindow","height=470,width=520,alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=1,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,z-lock=0,screenX=0,screeny=0,left=0,top=0");
}
function grattagioca(idm,width,heigth)
{
	window.open("http://lit.grattaevinci.com/gioco-igp-web/template/demo.jsp?IDConcorso="+idm+"&widthFlash="+width+"&heightFlash="+heigth+"&posx=426&posy=229&title=Miliardario","newwindow","height=470,width=520,alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=1,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,z-lock=0,screenX=0,screeny=0,left=0,top=0");
}


function buyLauncher(IDConcorso, Token, IDConto, width,height) {
//var width = dimensioni[IDConcorso]["buy"][0]; // larghezza e altezza vengono impostate
//var height = dimensioni[IDConcorso]["buy"][1]; // nel contenitore 'dimensioni'
//var title = dimensioni[IDConcorso]["title"]; // titolo del gioco
// calcolo per l'apertura della popup al centro dello schermo
var title="Gratta&Vinci"
var pLeft = (screen.width - width) / 2;
var pRight = (screen.height - height) / 2;
// impostazione URL
var URL = "https://lit.grattaevinci.com/gioco-igp-web/template/template_incl_flash.jsp";
URL = URL + "?IDConcorso=" + IDConcorso;
URL = URL + "&Token=" + Token;
URL = URL + "&IDConto=" + IDConto;
URL = URL + "&IDRivenditore=3471";
URL = URL + "&widthFlash=" + width;
URL = URL + "&heightFlash=" + height;
URL = URL + "&posx=" + pLeft;
URL = URL + "&posy=" + pRight;
URL = URL + "&title=" + title;
// apertura popup
window.open(URL,'game','left=' + pLeft + ',top=' + pRight + ',width=' + width + ',height=' + height + ',scrollbars=no,resizable=no,status=yes');
}

function grattahelp(idm)
{
	window.open("https://lit.grattaevinci.com/infoprodotti/info"+idm+"_popup.html","newwindow","height=290,width=550,alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=1,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,z-lock=0,screenX=0,screeny=0,left=0,top=0");
}

function popup(url){
	document.body.style.overflow="hidden";
	var d = document.getElementById('popUpDiv');
	var o = document.getElementById('popUpDivOmbra');
	var b = document.getElementById('disab');
	//d.style.display='block';
	var winW = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
	var winH = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
	
	ttop = document.documentElement.scrollTop;
	lleft = 50;
	b.style.top = ttop +'px';
	b.style.left = '0px';
	b.style.width = winW+'px';
	b.style.height = winH+'px';
	b.style.display = 'block';
	
	
	Spry.Utils.updateContent(d, url, function(){
		d.style.display = 'block';
		d.style.top = (ttop + (winH - d.offsetHeight) / 2)+"px";
		d.style.left = ((winW - d.offsetWidth) / 2)+"px";
		
		o.style.display = 'block';
		o.style.top = (ttop + 3 +(winH - d.offsetHeight) / 2)+"px";
		o.style.left = ((winW + 3 - d.offsetWidth) / 2)+"px";
	
		o.style.width = (d.offsetWidth-10)+"px";
		o.style.height = (d.offsetHeight-10)+"px";
		
		Spry.Effect.DoFade(	
							d,
							{	duration: 150, 
								from: 0,
								to: 100
							}
						);
	
		}
	);
	
}
function chiudiPopUP(){
	document.getElementById('popUpDiv').style.display='none';
	document.getElementById('disab').style.display='none';
	document.getElementById('popUpDivOmbra').style.display = 'none';
	document.body.style.overflow="auto";
}


function sendMe2(f, strDiv){
	
	$(f).set('send', {onComplete: function(response) {
									//alert(response);
									var d = document.getElementById(strDiv);
									d.innerHTML = response;
									//d.set('html', response);
							}
	});
	$(f).send();
	
}

function sendMe_old(f, strDiv){
	var ele = document.getElementById(strDiv);
	Spry.Effect.DoFade(ele,{ duration: 50, from: 100, to: 30, finish: function() {
	
			$(f).set('send', {onComplete: function(response){
										
										var d = document.getElementById(strDiv);
										d.innerHTML = response;
										Spry.Effect.DoFade(d,{ duration: 50, from: 30, to: 100 });
										
									}
			});
			$(f).send();
			}
	});
}
function sendMe(strIdForm, strDiv){
	var ele = document.getElementById(strDiv);
	cover(ele);
	var form = jQuery('#'+strIdForm)
	var dataSerial = form.serialize();
	//alert(dataSerial);
	jQuery.post(form.attr("action"), dataSerial, complete, 'html');
	function complete(response){
		var d = document.getElementById(strDiv);
		d.innerHTML = response;
		try
		{	
			document.getElementById('btn_reg').style.display = "block";
			document.getElementById('wait').style.display = "none";
			document.getElementById('sWait').style.display = "none";
		}
		catch(e)
		{
		}						
		//Spry.Effect.DoFade(d,{ duration: 50, from: 30, to: 100 });
	}
}


function sendMeDiffAction(strIdForm, strDiv, act){
	var d = document.getElementById(strDiv);
	//d.style.opacity='0.3';
	//d.style.filter = 'alpha(opacity=30)';
	cover(d);
	var form = jQuery('#'+strIdForm)
	var dataSerial = form.serialize();
	jQuery.post(act, dataSerial, complete, 'html');
	function complete(response){
		var arr = response.split('||finearray||');
		var d = document.getElementById(strDiv);
		d.innerHTML = arr[1];
		//Spry.Effect.DoFade(d,{ duration: 150, from: 30, to: 100 });
		if(arr[0]!=''){
			document.getElementById('str_hd_VObj').value = arr[0];
		}
	}
}

function sendMeCarrello_old(f, strDiv){
	var ele = document.getElementById(strDiv);
	Spry.Effect.DoFade(ele,{ duration: 50, from: 100, to: 30, finish: function() {
	
			$(f).set('send', {onComplete: function(response){
										
										var d = document.getElementById(strDiv);
										d.innerHTML = response;
										Spry.Effect.DoFade(d,{ duration: 50, from: 30, to: 100 });
										aggiornaSaldo();
									}
			});
			$(f).send();
			}
	});
}
function sendMeCarrello(strIdForm, strDiv, qryStr){
	var ele = document.getElementById(strDiv);
	cover(ele);
	var form = jQuery('#'+strIdForm)
	var dataSerial = form.serialize();
	jQuery.post('/boxcarrello.asp?a=Math.floor(10000000*Math.random())'+qryStr, dataSerial, complete, 'html');
	function complete(response){
		var d = document.getElementById(strDiv);
		d.innerHTML = response;
		//Spry.Effect.DoFade(d,{ duration: 50, from: 30, to: 100 });
		aggiornaSaldo();
	}
}

function aggiornaSaldo(){
	fadeIt('divLogin','/ASP/include/login2.asp?login=y&ricalcola=y&a='+Math.floor(10000000*Math.random()));
	
}

function popolaCombo(strSelectId,strTabella,strCampoValore,strCampoTxt,strCondizione){
	var s = document.getElementById('div_' + strSelectId);
	var req = Spry.Utils.loadURL('GET', '/include/popolacombo.asp?a='+Math.floor(10000000*Math.random())+'&tabella='+strTabella+'&campoval='+strCampoValore+'&campotxt='+strCampoTxt+'&condizione='+escape(strCondizione), false);
	var r = req.xhRequest.responseText;
	r = "<select id='"+strSelectId+"' name='"+strSelectId+"' class='selectReg' style='width:180px;'>" + r +"</select>"
	s.innerHTML = r;//"<option value='0'>Zero</option><option value='1'>Uno</option>";
}

function pulisci(param_id, default_value){
    if(document.getElementById(param_id).value == default_value){
        document.getElementById(param_id).value="";
           }
    if(document.getElementById(param_id).value != default_value){
       
    }  
}

function inserisci_testoDefault(param_id, default_value){
    if(document.getElementById(param_id).value == ""){
        document.getElementById(param_id).value = default_value;
            }
    if(document.getElementById(param_id).value != default_value){
            }
}

function showCal(t){
	
	var scanObj = t;
	var lleft = 0;
	var ttop = 0;
	while (scanObj){
		//alert(scanObj);
		lleft += scanObj.offsetLeft;
		ttop += scanObj.offsetTop;
		scanObj = scanObj.offsetParent;
	}
	//alert(ttop + "-" + lleft);
	
	var iframecal = document.getElementById("iframecal");
	var divCal = document.getElementById("calendarDiv");
	divCal.style.left = (lleft + 110) + 'px';
	divCal.style.top = (ttop) + 'px';
	iframecal.src = '/include/cal.asp?campo='+t.id;
	divCal.style.display = 'block';
}

function poker() {
	width = 1024;
	height = 700;
	var title="Poker"
	var pLeft = (screen.width - width) / 2;
	var pRight = (screen.height - height) / 2;
	// impostazione URL
	var URL = "/include/popPoker.asp";
	// apertura popup
	window.open(URL,'game','left=' + pLeft + ',top=' + pRight + ',width=' + width + ',height=' + height + ',scrollbars=no,resizable=no,status=yes');
}

function gratta(w,h) {
	width = w;
	height = h;
	var title="Gratta&Vinci"
	var pLeft = (screen.width - width) / 2;
	var pRight = (screen.height - height) / 2;
	// impostazione URL
	var URL = "/include/popGratta.asp";
	// apertura popup
	window.open(URL,'game','left=' + pLeft + ',top=' + pRight + ',width=' + width + ',height=' + height + ',scrollbars=no,resizable=no,status=yes');
}


function totocalcio() {
	width = 1024;
	height = 700;
	var title="Totocalcio"
	var pLeft = (screen.width - width) / 2;
	var pRight = (screen.height - height) / 2;
	// impostazione URL
	var URL = "/include/totocalcio.asp";
	// apertura popup
	window.open(URL,'game','left=' + pLeft + ',top=' + pRight + ',width=' + width + ',height=' + height + ',scrollbars=no,resizable=no,status=yes');
}

function ippica() {
	width = 1024;
	height = 700;
	var title="Ippica"
	var pLeft = (screen.width - width) / 2;
	var pRight = (screen.height - height) / 2;
	// impostazione URL
	var URL = "/include/ippica.asp";
	// apertura popup
	window.open(URL,'game','left=' + pLeft + ',top=' + pRight + ',width=' + width + ',height=' + height + ',scrollbars=no,resizable=no,status=yes');
}

function bigrace() {
	width = 1024;
	height = 700;
	var title="Bigrace"
	var pLeft = (screen.width - width) / 2;
	var pRight = (screen.height - height) / 2;
	// impostazione URL
	var URL = "/include/bigrace.asp";
	// apertura popup
	window.open(URL,'game','left=' + pLeft + ',top=' + pRight + ',width=' + width + ',height=' + height + ',scrollbars=no,resizable=no,status=yes');
}

//============== Ippica ===============

function ip1Click(cbox, cav, nomeGruppo){
	if(cbox.checked){
		var cboxs = document.getElementsByName(cbox.name);
		for(var j=0;j<cboxs.length;j++){
			cboxs[j].checked = false;
		}
		cbox.checked = true;
		fadeIt('container_carrello','/boxcarrelloippica.asp?act=send&strcav='+cav+'&gruppo='+nomeGruppo+'&a='+Math.floor(10000000*Math.random()));
	}else{
		fadeIt('container_carrello','/boxcarrelloippica.asp?act=send&strcav=&gruppo='+nomeGruppo+'&a='+Math.floor(10000000*Math.random()));
	}
}

//2 + 3
function ip2Click(cbox,nomeGruppo){ 
	var cav1 = '';
	var cboxs = document.getElementsByName(cbox.name);
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav1 += '' + (j+1) + ';';
		}
	}
	if(cav1.length>0){
		cav1 = cav1.substring(0,cav1.length-1);
	}
	fadeIt('container_carrello','/boxcarrelloippica.asp?act=send&strcav='+cav1+'&gruppo='+nomeGruppo+'&a='+Math.floor(10000000*Math.random()));
}

function ip4Click(){
	var cav1 = '';
	var cav2 = '';
	var cboxs = document.getElementsByName('gruppo1');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav1 += '' + (j+1) + ';';
		}
	}
	if(cav1.length>0){
		cav1 = cav1.substring(0,cav1.length-1);
	}
	var cboxs = document.getElementsByName('gruppo2');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav2 += '' + (j+1) + ';';
		}
	}
	if(cav2.length>0){
		cav2 = cav2.substring(0,cav2.length-1);
	}
	fadeIt('container_carrello','/boxcarrelloippica.asp?act=send&strcav='+cav1+'|'+cav2+'&gruppo=<%=server.urlencode("Piazz.(1)|1°, 2°")%>&a='+Math.floor(10000000*Math.random()));
}

function ip5Click(){
	var cav1 = '';
	var cav2 = '';
	var cav3 = '';
	var cboxs = document.getElementsByName('gruppo1');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav1 += '' + (j+1) + ';';
		}
	}
	if(cav1.length>0){
		cav1 = cav1.substring(0,cav1.length-1);
	}
	var cboxs = document.getElementsByName('gruppo2');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav2 += '' + (j+1) + ';';
		}
	}
	if(cav2.length>0){
		cav2 = cav2.substring(0,cav2.length-1);
	}
	var cboxs = document.getElementsByName('gruppo3');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav3 += '' + (j+1) + ';';
		}
	}
	if(cav3.length>0){
		cav3 = cav3.substring(0,cav3.length-1);
	}
	fadeIt('container_carrello','/boxcarrelloippica.asp?act=send&strcav='+cav1+'|'+cav2+'|'+cav3+'&gruppo=<%=server.urlencode("1°|2°|3°")%>&a='+Math.floor(10000000*Math.random()));
}

function ip6Click(){ 
	var cav1 = '';
	var cboxs = document.getElementsByName('gruppo1');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav1 += '' + (j+1) + ';';
		}
	}
	if(cav1.length>0){
		cav1 = cav1.substring(0,cav1.length-1);
	}
	fadeIt('container_carrello','/boxcarrelloippica.asp?act=send&strcav='+cav1+'&gruppo=<%=server.urlencode("1°, 2°, 3°")%>&a='+Math.floor(10000000*Math.random()));
}


function ip7Click(){
	var cav1 = '';
	var cav2 = '';
	var cboxs = document.getElementsByName('gruppo1');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav1 += '' + (j+1) + ';';
		}
	}
	if(cav1.length>0){
		cav1 = cav1.substring(0,cav1.length-1);
	}
	var cboxs = document.getElementsByName('gruppo2');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav2 += '' + (j+1) + ';';
		}
	}
	if(cav2.length>0){
		cav2 = cav2.substring(0,cav2.length-1);
	}
	fadeIt('container_carrello','/boxcarrelloippica.asp?act=send&strcav='+cav1+'|'+cav2+'&gruppo=<%=server.urlencode("Vin.(1)|2°, 3°")%>&a='+Math.floor(10000000*Math.random()));
}

function ip8Click(){
	var cav1 = '';
	var cav2 = '';
	var cboxs = document.getElementsByName('gruppo1');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav1 += '' + (j+1) + ';';
		}
	}
	if(cav1.length>0){
		cav1 = cav1.substring(0,cav1.length-1);
	}
	var cboxs = document.getElementsByName('gruppo2');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav2 += '' + (j+1) + ';';
		}
	}
	if(cav2.length>0){
		cav2 = cav2.substring(0,cav2.length-1);
	}
	fadeIt('container_carrello','/boxcarrelloippica.asp?act=send&strcav='+cav1+'|'+cav2+'&gruppo=<%=server.urlencode("Piazz.(1)|1°, 2°, 3°")%>&a='+Math.floor(10000000*Math.random()));
}

function ip9Click(){
	var cav1 = '';
	var cav2 = '';
	var cboxs = document.getElementsByName('gruppo1');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav1 += '' + (j+1) + ';';
		}
	}
	if(cav1.length>0){
		cav1 = cav1.substring(0,cav1.length-1);
	}
	var cboxs = document.getElementsByName('gruppo2');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav2 += '' + (j+1) + ';';
		}
	}
	if(cav2.length>0){
		cav2 = cav2.substring(0,cav2.length-1);
	}
	fadeIt('container_carrello','/boxcarrelloippica.asp?act=send&strcav='+cav1+'|'+cav2+'&gruppo=<%=server.urlencode("Piazz.(2)|1°, 2°, 3°")%>&a='+Math.floor(10000000*Math.random()));
}

function ip10Click(){
	var cav1 = '';
	var cav2 = '';
	var cboxs = document.getElementsByName('gruppo1');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav1 += '' + (j+1) + ';';
		}
	}
	if(cav1.length>0){
		cav1 = cav1.substring(0,cav1.length-1);
	}
	var cboxs = document.getElementsByName('gruppo2');
	for(var j=0;j<cboxs.length;j++){
		if (cboxs[j].checked){
			cav2 += '' + (j+1) + ';';
		}
	}
	if(cav2.length>0){
		cav2 = cav2.substring(0,cav2.length-1);
	}
	fadeIt('container_carrello','/boxcarrelloippica.asp?act=send&strcav='+cav1+'|'+cav2+'&gruppo=<%=server.urlencode("1°,2°|3°")%>&a='+Math.floor(10000000*Math.random()));
}


function sicuroform()
	{
		temp=window.confirm('Confermi?');
		if (temp==(false))
		{
				return(false);
		}
		return(true);
	}

//Multiaccordion
var TINY={};

function T$(i){return document.getElementById(i)}
function T$$(e,p){return p.getElementsByTagName(e)}

TINY.accordion=function(){
	function slider(n){this.n=n; this.h=[]; this.c=[]}
	slider.prototype.init=function(t,e,m,o,k){
		var a=T$(t), i=x=0; this.s=k||'', w=[], n=a.childNodes, l=n.length; this.m=m||false;
		for(i;i<l;i++){if(n[i].nodeType!=3){w[x]=n[i]; x++}} this.l=x;
		for(i=0;i<this.l;i++){
			var v=w[i]; this.h[i]=h=T$$(e,v)[0]; this.c[i]=c=T$$('div',v)[0]; h.onclick=new Function(this.n+'.pr(false,this)');
			if(o==i){h.className=this.s; c.style.height='auto'; c.d=1}else{c.style.height=0; c.d=-1}
		}
	};
	slider.prototype.pr=function(f,d){
		for(var i=0;i<this.l;i++){
			var h=this.h[i], c=this.c[i], k=c.style.height; k=k=='auto'?1:parseInt(k); clearInterval(c.t);
			if((k!=1&&c.d==-1)&&(f==1||h==d)){
				c.style.height=''; c.m=c.offsetHeight; c.style.height=k+'px'; c.d=1; h.className=this.s; su(c,1)
			}else if(k>0&&(f==-1||this.m||h==d)){
				c.d=-1; h.className=''; su(c,-1)
			}
		}
	};
	function su(c){c.t=setInterval(function(){sl(c)},2)};
	function sl(c){
		var h=c.offsetHeight, d=c.d==1?c.m-h:h; c.style.height=h+(Math.ceil(d/5)*c.d)+'px';
		c.style.opacity=h/c.m; c.style.filter='alpha(opacity='+h*100/c.m+')';
		if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'} clearInterval(c.t)}
	};
	return{slider:slider}
}();


//$(function(){$('form').jqTransform({imgPath:'/images/form/'});});
	
//Lightbox
//$(document).ready(function(){$("a.single").colorbox({transition:"fade"});});


function accSwitch(target, source){
	//alert(source.className);
	if (source.className=='chiuso'){
		document.getElementById(target).style.display = 'block';
		source.className='aperto';
	}else{
		document.getElementById(target).style.display = 'none';
		source.className='chiuso';
	}
}

function salvaSbk(id_sbk){
	Form01.action.value='save_' + id_sbk;
	Form01.tmp.value=document.getElementById('titolo_' + id_sbk).value;
	document.getElementById('htestata').value = document.getElementById('bg' + id_sbk).value;
	s_data = document.getElementById('sezione_' + id_sbk);v_data = s_data.options[s_data.selectedIndex].value;document.getElementById('hsezione').value = v_data;
	t_data = document.getElementById('template_' + id_sbk);t_data = t_data.options[t_data.selectedIndex].value;document.getElementById('htemplate').value= t_data;
	document.getElementById('hurl').value = document.getElementById('url_' + id_sbk).value;
	document.getElementById('hnumeroelementi').value = document.getElementById('numeroelementi_' + id_sbk).value;
	document.getElementById('haltezzabox').value = document.getElementById('altezzabox_' + id_sbk).value;
	document.getElementById('hboxlinkurl').value = document.getElementById('boxlinkurl_' + id_sbk).value;
	document.getElementById('hboxlinktext').value = document.getElementById('boxlinktext_' + id_sbk).value;
	mu_select = document.getElementById('modoutente_' + id_sbk);mu_data = mu_select.options[mu_select.selectedIndex].value;document.getElementById('hmodoutente').value = mu_data;
	document.getElementById('id_sbk_sender').value = id_sbk;
	sendMeDiffAction('Form01','editIdSbk_' + id_sbk,'paginew_t99_part.asp')
	Form01.action.value='';
	Form01.tmp.value='';
	document.getElementById('htestata').value = '';
	document.getElementById('hurl').value = '';
	document.getElementById('hnumeroelementi').value = '';
	document.getElementById('haltezzabox').value = '';
	document.getElementById('hboxlinkurl').value = '';
	document.getElementById('hboxlinktext').value = '';
	document.getElementById('id_sbk_sender').value = '0';
}
