/*betting*/
function selectOdds(gameId,tipoScomm){				
	nome="sbmt_"+gameId+"_"+tipoScomm;
	document.getElementById(nome).click();
}

/*SERVE PER CAMBIARE IL CSS*/
function defCss()
{
	if(document.getElementById("nomeCss")!=null && document.getElementById("nomeCss")!=undefined){
		css=document.getElementById("nomeCss").value;
		
		if(navigator.appName=="Microsoft Internet Explorer")
	    	css=css+".css";
	    else
	    	 css=css+"_frx.css";
		document.getElementById("linkcss").href=css;
	}
}    	 
function riconosciBrowser()
{
	if(navigator.appName!="Microsoft Internet Explorer"){
		var w = 520;
		   var h = 200;
		   var l = Math.floor((screen.width-w)/2);
		   var t = Math.floor((screen.height-h)/2);
		   window.open("/betPlus/pop-up/avviso.jsp","avviso","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
	 	}
} 

function openPopup(URL,name)
{
	window.open(URL,name,"width=1000,height=500,top=50,left=100,scrollbars=1");
}

/*contratto*/
function openContratto(idGioco,token,idRivenditore,idConto)
{
	var width  = 400;//dimensioni[idGioco]["buy"][0]; // larghezza e altezza vengono impostate
	var height = 377;//dimensioni[idGioco]["buy"][1]; // nel contenitore 'dimensioni'
	var title  = '';//dimensioni[idGioco]["title"];  // titolo del gioco
	
	// calcolo per l'apertura della popup al centro dello schermo
	var pLeft  = (screen.width - width) / 2;
  	var pRight = (screen.height - height) / 2;

	window.open('/betPlus3/private/actions/ViewAccettazioneContrattoAction.action?idGioco='+idGioco+'&token='+token+'&idRivenditore='+idRivenditore+'&idConto='+idConto, 'info', 'left=' + pLeft + ',top=' + pRight + ',width=' + width + ',height=' + height + ',scrollbars=yes,resizable=no,status=yes');
}

function accettaContratto()
{
	var idConto = document.getElementById('idConto').value;
	var idGioco = document.getElementById('idGioco').value;
	var idRivenditore = document.getElementById('idRivenditore').value;
	var token = document.getElementById('token').value;
	var radioLength = document.form1.contratto.length;
	
	var width  = 400;//dimensioni[idGioco]["buy"][0]; // larghezza e altezza vengono impostate
	var height = 377;//dimensioni[idGioco]["buy"][1]; // nel contenitore 'dimensioni'
	var title  = '';//dimensioni[idGioco]["title"];  // titolo del gioco
	
	// calcolo per l'apertura della popup al centro dello schermo
	var pLeft  = (screen.width - width) / 2;
  	var pRight = (screen.height - height) / 2;
	
	for(var i=0; i<radioLength; i++)
	{
		if(document.form1.contratto[i].checked && document.form1.contratto[i].value=='SI')
		{	location.replace('/betPlus3/private/actions/ConfirmAccettazioneContrattoAction.action?idGioco='+idGioco+'&token='+token+'&idRivenditore='+idRivenditore+'&idConto='+idConto);
			break;
		}
		else if(document.form1.contratto[i].checked && document.form1.contratto[i].value=='NO')
		{	window.close();
			break;
		}
			
	}
}

function gioca()
{
	var idConto = document.getElementById('idConto').value;
	var idGioco = document.getElementById('idGioco').value;
	var idRivenditore = document.getElementById('idRivenditore').value;
	var token = document.getElementById('token').value;
	/*
	var width  = dimensioni[idGioco]["buy"][0]; // larghezza e altezza vengono impostate
	var height = dimensioni[idGioco]["buy"][1]; // nel contenitore 'dimensioni'
	var title  = dimensioni[idGioco]["title"];  // titolo del gioco
	
	// calcolo per l'apertura della popup al centro dello schermo
	var pLeft  = (screen.width - width) / 2;
  	var pRight = (screen.height - height) / 2;*/
	window.close();
	buyLauncher(idGioco, token, idConto, idRivenditore);
}

/*coupon*/
function ricalcolaImporto(importo,saldoUtente,maxGiocabile,minGiocabile,client,messageImporto,messageImportoMin,messageminConsentito,messageminConsentito2,messagesuperaSaldo,messagemaxConsentito,messagemaxConsentito2)
{	
	var expr = /^[0-9]*$/;
	var exprLettere=/^[a-zA-Z]*$/;
	
	importo=document.getElementById("fieldImport").value;
	var eliminaMessaggio="<a href=\"javascript:void(0);\" style=\"float:right;margin-right:3px;margin-top:1px;text-align:center;border:1px solid white;background-color:#3DA8DE;\" onclick=\"javascript:document.getElementById('couponAlerts').style.display='none';\">X</a>";
	var eliminaMessaggio2="";
	var cont=0;
	if(exprLettere.test(importo)){
		//alert(messageImporto);
		cont++;
		if(cont==1)
			eliminaMessaggio2=eliminaMessaggio;
		$("#couponAlerts").html(eliminaMessaggio2+" "+messageImporto);
		importo=minGiocabile;
//		document.getElementById("sbmSched").disabled=true;
	}
	else if(isNaN( parseInt(importo))||!expr.test(importo)){
	
			//alert(messageImportoMin+" "+minGiocabile+" Euro." )
			cont++;
			if(cont==1)
				eliminaMessaggio2=eliminaMessaggio;
			$("#couponAlerts").html(eliminaMessaggio2+" "+messageImportoMin+" "+minGiocabile+" Euro." );
			importo=parseInt(importo);
		
		/*if(importo>minGiocabile)
			document.getElementById("nuovoImporto").value=importo;*/				
		
		document.getElementById("sbmSched").disabled=true;
	}
	else if(saldoUtente>-1 && importo>saldoUtente)
	{
//		alert(messagesuperaSaldo)
		cont++;
		if(cont==1)
			eliminaMessaggio2=eliminaMessaggio;
		$("#couponAlerts").html(eliminaMessaggio2+" "+messagesuperaSaldo);
		document.getElementById("sbmSched").disabled=true;
	}
	else if(importo>maxGiocabile)
	{
//		alert(messagemaxConsentito+" "+maxGiocabile+" "+messagemaxConsentito2)
		cont++;
		if(cont==1)
			eliminaMessaggio2=eliminaMessaggio;
		$("#couponAlerts").html(eliminaMessaggio2+" "+messagemaxConsentito+" "+maxGiocabile+" "+messagemaxConsentito2);
		document.getElementById("sbmSched").disabled=true;
	}
	else if(importo<minGiocabile)
	{
//		alert(messageminConsentito+" "+minGiocabile+" "+messageminConsentito2)
		cont++;
		if(cont==1)
			eliminaMessaggio2=eliminaMessaggio;
		$("#couponAlerts").html(eliminaMessaggio2+" "+messageminConsentito+" "+minGiocabile+" "+messageminConsentito2);
		document.getElementById("sbmSched").disabled=true;
	}
	else
	{	
		document.getElementById("sbmSched").disabled=false;
		/*document.getElementById("nuovoImporto").value=importo;*/
//		$("#sRight").load("CreaSchedinaAction_aggiornaImporto.action",{'nuovoImporto':importo });
		$("#sezVincita").load("CreaSchedinaAction_aggiornaImporto.action",{'nuovoImporto':importo });
	}
}
/*sostituite con jquery*/

//function eliminaScommessa(gameId,nrEvento)
//{
//	alert("elimina scommessa");
//	document.getElementById("scomEliminata").value=gameId;
//	document.getElementById("nrEventoEliminata").value=nrEvento;
//	document.getElementById("frmElimina").submit();
//}   
/*sostituite con jquery*/
//
//function selezionaDeselezionaScommessa(gameId,nrEvento)
//{
//	document.getElementById("gameIdSelDeselBet").value=gameId;
//	document.getElementById("nrEventoSelDeselBet").value=nrEvento;
//	document.getElementById("submitSelDeselBet").click();
//}   


function dettaglioScommessa(matchId)
{
	document.getElementById("matchId").value=matchId;
	$("#loadScommesse").html("<div style='margin-top:20px;margin-left:250px;'><img alt='' src='/betPlus3/style/images/ajax-loader.gif'></div>");
	$("#loadScommesse").load("VisualizzaScommesseAction_dettaglioScommessa.action",{'matchId':matchId });
}   

/*menu*/
function aggiornaMenu(sportId,altriSportIdMenu){
	document.getElementById("sportIdMenu").value=sportId;	
	document.getElementById("altriSportIdMenu").value=altriSportIdMenu;
	document.getElementById("competitionId").value=0;
	document.getElementById("sbmtMenuAjaxForm").click();
	
}
function aggiornaMenuComp(sportId,altriSportIdMenu){
	document.getElementById("sportIdMenu").value=sportId;	
	document.getElementById("altriSportIdMenu").value=altriSportIdMenu;
	document.getElementById("competitionId").value=999999;
	document.getElementById("sbmtMenuAjaxForm").click();
	
}
// Script for GoalsLive PopUp
function goalslivepopup(){
	var tmp;
	if (aPopupWin){tmp=aPopupWin;aPopupWin=null;}
	aPopupWin=window.open('http://www.GoalsLive.com/new/live/index4.aspx?myid=3620','GoalsLive','height=400,location=0,menubar=0,personalbar=0,scrollbars=1,status=0,toolbar=0,width=580,resizable=1,screenx=0,screeny=0,left=0,top=0');
} var aPopupWin;

/*submit*/
function swaperOver(id){
	if(document.getElementById(id).style.color=="#EB7C23"){
		document.getElementById(id).style.color="#008BC9";
		document.getElementById(id).style.borderBottomColor="#008BC9";
		}
	else{
		document.getElementById(id).style.color="#EB7C23";
		document.getElementById(id).style.borderBottomColor="#EB7C23";
		}
}
function swaperOut(id){
	if(document.getElementById(id).style.color=="#008BC9"){
		document.getElementById(id).style.color="#EB7C23";
		document.getElementById(id).style.borderBottomColor="#EB7C23";
		}
	else{
		document.getElementById(id).style.color="#008BC9";
		document.getElementById(id).style.borderBottomColor="#008BC9";
		}
}
function swaper2(){
	if(document.formName.Logout.style.color=="orange")
		document.formName.Logout.style.color="white";
	else
		document.formName.Logout.style.color="orange";
}	

/*vetrina*/ 
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
function HideAll(){
	var tab0 =  document.getElementById("tab0")
	var tab1 =  document.getElementById("tab1")
	var tab2 =  document.getElementById("tab2")
	//var tab3 =  document.getElementById("tab3")
	//var tab4 =  document.getElementById("tab4")
	
	tab0.style.display="none";
	tab1.style.display="none";
	tab2.style.display="none";
	//tab3.style.display="none";
	//tab4.style.display="none";
}

function View(obj){
	HideAll();
	var objtab =  document.getElementById(obj);
	objtab.style.display="block";
}	

/*registrazione*/
function setAbilityDichiaro(){
	//da rivedere bene i controlli
	         
     if (document.getElementById("accetto").checked)
    	 document.getElementById("dichiaro").style.display="none";
     else
    	 document.getElementById("dichiaro").style.display="inline";
}
function setAbilityNuovoID(){
	
	if (document.getElementById("accetto").checked){
		document.getElementById("confermaDisattivo").style.display="none";
		document.getElementById("confermaAttivo").style.display="inline";
	}
	else{
		document.getElementById("confermaDisattivo").style.display="inline";
		document.getElementById("confermaAttivo").style.display="none";
	}
}
function setAbilityAccetto2(){
	  if(document.getElementById("accetto2").checked){
      	document.getElementById("consenso").style.display="none";	
      	if(document.getElementById("accetto3").checked){
      		document.getElementById("consenso").style.display="inline";	
      		document.getElementById("accetto3").checked=false;
      		document.getElementById("consenso").style.display="none";	
      		 }
	  }
       else if(document.getElementById("accetto3").checked){
      	 document.getElementById("consenso").style.display="inline";
      	 if(document.getElementById("accetto2").checked)
      	 {
      		document.getElementById("consenso").style.display="none";	
      		document.getElementById("accetto3").checked=false;
      	 }
       }
     
}

function setAbility4(id){
	  if(document.getElementById(id).checked){
		  if(id=="accetto4"){
	      	document.getElementById("accetto5").checked=false;
	      	 document.getElementById("consenso2").style.display="none";
		  }  
	      else{
	      	document.getElementById("accetto4").checked=false;
	      	 document.getElementById("consenso2").style.display="none";
	      }
     }
}




function setAbility(){
        	 if (document.getElementById("accetto").checked && document.getElementById("accetto2").checked && !document.getElementById("accetto3").checked && (document.getElementById("accetto4").checked || document.getElementById("accetto5").checked)){
        		 document.getElementById("dichiaro").style.display="none";
        		 document.getElementById("consenso").style.display="none";
        		 document.getElementById("consenso2").style.display="none";
        		 return 1;
        	 }
        	 else if(!document.getElementById("accetto").checked && !document.getElementById("accetto2").checked && !document.getElementById("accetto4").checked && !document.getElementById("accetto5").checked){
        		 document.getElementById("dichiaro").style.display="inline";
        		 document.getElementById("consenso").style.display="inline";
        		 document.getElementById("consenso2").style.display="inline";
        		 return 0;
        	 }
        	 else if(!document.getElementById("accetto").checked && !document.getElementById("accetto2").checked && document.getElementById("accetto3").checked){
        		 document.getElementById("dichiaro").style.display="inline";
        		 document.getElementById("consenso").style.display="inline";
        		 return 0;
        	 }
        	 else if(!document.getElementById("accetto").checked && !document.getElementById("accetto2").checked && document.getElementById("accetto3").checked && !document.getElementById("accetto4").checked && !document.getElementById("accetto5").checked){
        		 document.getElementById("dichiaro").style.display="inline";
        		 document.getElementById("consenso").style.display="inline";
        		 document.getElementById("consenso2").style.display="inline";
        		 return 0;
        	 }
        	 if(!document.getElementById("accetto").checked){
        		 document.getElementById("dichiaro").style.display="inline";
        		 return 0;
        		 }
        	 if(!document.getElementById("accetto2").checked){
        		 document.getElementById("consenso").style.display="inline";
        		 return 0;
        	     }
        	 if(document.getElementById("accetto3").checked){
        		 document.getElementById("consenso").style.display="inline";
        		 return 0;
        		}
        	 if(!document.getElementById("accetto4").checked && !document.getElementById("accetto5").checked){
        		 document.getElementById("consenso2").style.display="inline";
        		 return 0;
        	 }
}

function annulla(){
	if(confirm('Sei sicuro di voler annullare la registrazione?')){
		window.location.replace("/betPlus3"); 
	}	
}
function annullaModificaDatiAnagrafici(){
	if(confirm('Sei sicuro di voler annullare la modifica?')){
		$("#datiAnagrafici").html("<div style='margin-top:20px;margin-left:250px;color:white;height:100%;'>Loading...</div>");
		$("#datiAnagrafici").load("ViewDatiPersonaliAction_annullaModifica.action"); 
	}	
}
		
function dettaglioScommesseBR(matchId) {
//	var href='http://www.stats.betradar.com/statistics/betplus/main.php?page=guth_statistics_headtohead&language=it&matchid='+matchId;
	var href='/betPlus3/private/actions/BetradarMatchStatAction.action?matchId='+matchId;
	var load = window.open(href,'','scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}

function tornaTop()
{	return document.getElementById('infoCavallo').style.top;
}

function inline(idPalinsesto,idEvento,idEsito)
{	
	dataString="";
	dataString="idPalinsesto="+idPalinsesto+"&idEvento="+idEvento+"&idEsito="+idEsito;
	$("#cont-infoCavallo").load("/betPlus3/private/actions/ippica/InfoCavalloAction.action?"+dataString);
	//document.getElementById('sbmtInfoCavallo').click();
	
} 
function infoCavallo(idPalinsesto,idEvento,idEsito)
{
	document.getElementById('idPalinsestoInfoCavallo').value=idPalinsesto;
	document.getElementById('idEventoInfoCavallo').value=idEvento;
	document.getElementById('idEsitoInfoCavallo').value=idEsito;
	document.getElementById('sbmtInfoCavallo').click();
	document.getElementById('cont-infoCavallo').style.display="inline";
}
function dispNone()
{
	if(document.getElementById('infoCavallo')!=null)
	document.getElementById('infoCavallo').style.display="none";
}
/**  SCRIPT IPPICA  **/

function scegliCorsaSingolaAbilitazioniScommesse(idConcorso,idPalinsesto,idEvento)
{
	scegliCorsaSingola(idConcorso);
	abilitazioniScommesse(idPalinsesto,idEvento);
	visualizzaTabellaCavalli(idPalinsesto,idEvento,idConcorso);

	azzera();
	calcolaImporto('3');
}
function scegliCorsaSingola(idConcorso)
{	
	dataString="";
	dataString+="idConcorso="+idConcorso;
	$(".iContieniCavallo").load("/betPlus3/private/actions/ippica/ScegliCorsaSingolaAction.action?"+dataString);
	
	//document.getElementById('sbmtCorsaSingola').click();
}
function abilitazioniScommesse(idPalinsesto,idEvento)
{
	dataString="";
	dataString+="idPalinsesto="+idPalinsesto+"&idEvento="+idEvento;
	$("#cont-scommetti").load("/betPlus3/private/actions/ippica/AbilitaScommesseAction.action?"+dataString);
	
	//document.getElementById('sbmtScommetti').click();
}
function visualizzaTabellaCavalli(idPalinsesto,idEvento,idConcorso)
{
	dataString="";
	dataString+="idPalinsesto="+idPalinsesto+"&idEvento="+idEvento+"&idConcorso="+idConcorso;
	$("#cont-cavalli").load("/betPlus3/private/actions/ippica/VisualizzaTabellaCavalliAction.action?"+dataString);
	
	//document.getElementById('sbmtCavalli').click();
}
function scegliTipo(id)
{	
	for(var i=1; i<=5; i++)
	{	
		if(document.getElementById('tipo'+i)!=undefined)
		{	document.getElementById('tipo'+i).className="iQuadratinoNoSelezione";
			document.getElementById('iCinquetipo'+i).style.display='none';
			document.getElementById('iCinqueNotipo'+i).style.display='inline';	
			for(var j=1; j<=6; j++)
			{	document.getElementById('volte'+j+'tipo'+i).className='iQuadratinoNoSelezioneVolte';
				document.getElementById('volteFont'+j+'tipo'+i).className='iFont279CEC-piccolo';
			}
		}
	}
	document.getElementById('volte').value='volte1';
	document.getElementById('volte1'+id).className='iQuadratinoSelezioneVolte';
	document.getElementById('volteFont1'+id).className='iFontWhite-piccolo';
	
	document.getElementById(id).className="iQuadratinoSelezione";
	document.getElementById('tipo').value=id;
	document.getElementById('iCinque'+id).style.display='inline';
	document.getElementById('iCinqueNo'+id).style.display='none';
	document.getElementById('erroreGiocataMinima').style.display='none';
	document.getElementById('erroreImportoMinimo').style.display='none';
	
	checkAbilitazione();
	moltiplicaColonne();
	visualizzaConferma();
	
}
function scegliGioco(id)
{
	for(var i=1; i<=2; i++)
		document.getElementById('gioco'+i).className="iQuadratinoNoSelezione";
	document.getElementById(id).className="iQuadratinoSelezione";
	document.getElementById('gioco').value=id;
	document.getElementById('erroreGiocataMinima').style.display='none';
	document.getElementById('erroreImportoMinimo').style.display='none';
	
	checkAbilitazione();
	moltiplicaColonne();
	visualizzaConferma();
}

function selezionaTuttiCavalli(riga)
{
	if(document.getElementById('selCavalloTutti'+riga).className=="iQuadratinoNoSelezione")
	{
		document.getElementById('selCavalloTutti'+riga).className="iQuadratinoSelezione";
		document.getElementById('selCavalloFont'+riga).className="iFontWhite-piccolo";
		for(i=1; i<=20; i++)
		{
			if(document.getElementById('selCavallo'+riga+i)!=undefined && document.getElementById('selCavallo'+riga+i).className=="iQuadratinoNoSelezione")
			{	document.getElementById('selCavallo'+riga+i).className="iQuadratinoSelezione";
				document.getElementById('selCavalloFont'+riga+i).className="iFontWhite-piccolo";
				document.getElementById('numCavallo_'+riga+'_'+i).value="true";
				document.getElementById('num').value=Number(document.getElementById('num').value)+1;
			}
		}
	}
	else
	{
		document.getElementById('selCavalloTutti'+riga).className="iQuadratinoNoSelezione";
		document.getElementById('selCavalloFont'+riga).className="iFont279CEC-piccolo";
		for(i=1; i<=20; i++)
		{
			if(document.getElementById('selCavallo'+riga+i)!=undefined && document.getElementById('selCavallo'+riga+i).className=="iQuadratinoSelezione")
			{	document.getElementById('selCavallo'+riga+i).className="iQuadratinoNoSelezione";
				document.getElementById('selCavalloFont'+riga+i).className="iFont279CEC-piccolo";
				document.getElementById('numCavallo_'+riga+'_'+i).value="false";
				document.getElementById('num').value=Number(document.getElementById('num').value)-1;
			}
		}
	}
	document.getElementById('erroreGiocataMinima').style.display='none';
	document.getElementById('erroreImportoMinimo').style.display='none';
	
	calcolaColonneImporto();
	moltiplicaColonne();
	visualizzaConferma();       
}
function selezionaCavallo(riga,idCavallo)
{	
	if(document.getElementById('selCavallo'+riga+idCavallo).className=="iQuadratinoNoSelezione")
	{	
		document.getElementById('selCavallo'+riga+idCavallo).className="iQuadratinoSelezione";
		document.getElementById('selCavalloFont'+riga+idCavallo).className="iFontWhite-piccolo";
		document.getElementById('numCavallo_'+riga+'_'+idCavallo).value="true";
		document.getElementById('num').value=Number(document.getElementById('num').value)+1;
	}
	else
	{	document.getElementById('selCavallo'+riga+idCavallo).className="iQuadratinoNoSelezione";
		document.getElementById('selCavalloFont'+riga+idCavallo).className="iFont279CEC-piccolo";
		document.getElementById('numCavallo_'+riga+'_'+idCavallo).value="false";
		document.getElementById('num').value=Number(document.getElementById('num').value)-1;
	}
	document.getElementById('erroreGiocataMinima').style.display='none';
	document.getElementById('erroreImportoMinimo').style.display='none';
	
	
	calcolaColonneImporto();
	moltiplicaColonne();
	visualizzaConferma();
}
function calcolaColonneImporto()
{
	var num = Number(document.getElementById('num').value);
	var gruppi = Number(document.getElementById('gruppi').value);
	var minimo = Number(document.getElementById('minimoSelezionabileAGirare').value);
	var gioco = document.getElementById('gioco').value;
	if(num!=0)
	{	if(gioco=='gioco2' && num>=minimo) // gioco 'A girare'
			document.getElementById('colonne').value=binomiale(num,gruppi);
		else if(gioco=='gioco1') // gioco 'Ordine esatto'
			document.getElementById('colonne').value=calcolaColonneOrdineEsatto();
		else
			document.getElementById('colonne').value='0';
	}
	else
		document.getElementById('colonne').value='0';
	calcolaImporto(gruppi);
}
function moltiplicaColonne(tipo)
{
	var volte = document.getElementById('volte').value;
	var colonne = document.getElementById('colonne').value;
	
	if(volte=='volte1')
		document.getElementById('colonne').value=Number(document.getElementById('colonne').value)*1;
	else if(volte=='volte2')
		document.getElementById('colonne').value=Number(document.getElementById('colonne').value)*2;
	else if(volte=='volte3')
		document.getElementById('colonne').value=Number(document.getElementById('colonne').value)*4;
	else if(volte=='volte4')
		document.getElementById('colonne').value=Number(document.getElementById('colonne').value)*5;
	else if(volte=='volte5')
		document.getElementById('colonne').value=Number(document.getElementById('colonne').value)*10;
	else if(volte=='volte6')
		document.getElementById('colonne').value=Number(document.getElementById('colonne').value)*20;
	calcolaImporto();
}
var varGruppi=0;
function calcolaImporto(gruppi)
{
	if(gruppi!=undefined){
		varGruppi=gruppi;
		var i=0;
		for(i=1;i<=5;i++){
			document.getElementById('iTextTab'+i).innerHTML="";
			document.getElementById('iTextTabValue'+i).innerHTML="";
		}
	}
	
	if(document.getElementById('colonne').value!='0')
		document.getElementById('importo').value=Number(document.getElementById('colonne').value)*calcolaPuntata();
	else
		document.getElementById('importo').value='0';
	
	
	var imValue=Number(document.getElementById('importo').value);
	var j=imValue.toFixed(2);
	var colValue=document.getElementById('colonne').value;
	var imCol="Col "+colValue+" ";
	var imColValue="&euro; "+j+" ";
	if(imValue!=undefined){
	document.getElementById('iTextTab'+varGruppi).innerHTML=imCol;
	document.getElementById('iTextTabValue'+varGruppi).innerHTML=imColValue;
	document.getElementById('iTextTabTotale').innerHTML=imCol;
	document.getElementById('iTextTabValueTotale').innerHTML=imColValue;
	}
	
}
function checkAbilitazione()
{
	var tipo = document.getElementById('tipo').value;
	var volte = document.getElementById('volte').value;
	var gioco = document.getElementById('gioco').value;
	if(tipo!="" && gioco!="" && volte!="") // Ho selezionato tutte e tre le tipologie
	{
		disabilitaTutti();
		if(gioco=="gioco1") // gioco 'Ordine esatto'
		{
			if(tipo=="tipo1") // tipo 'Vincente'
			{
				abilitaTabella(1);
				document.getElementById('gruppi').value=1;
			
			}
			else if(tipo=="tipo2") // tipo 'Accoppiata'
			{
				abilitaTabella(1);
				abilitaTabella(2);
				document.getElementById('gruppi').value=2;
			}
			else if(tipo=="tipo3") // tipo 'Tris'
			{
				abilitaTabella(1);
				abilitaTabella(2);
				abilitaTabella(3);
				document.getElementById('gruppi').value=3;
			}
			else if(tipo=="tipo4") // tipo 'Quartè'
			{
				abilitaTabella(1);
				abilitaTabella(2);
				abilitaTabella(3);
				abilitaTabella(4);
				document.getElementById('gruppi').value=4;
			}
			else if(tipo=="tipo5") // tipo 'Quintè'
			{
				abilitaTabella(1);
				abilitaTabella(2);
				abilitaTabella(3);
				abilitaTabella(4);
				abilitaTabella(5);
				document.getElementById('gruppi').value=5;
			}
		}
		else if(gioco=="gioco2") // gioco 'A girare'
		{
			abilitaTabella(1);
			disabilitaOrdineEsatto();
			if(tipo=="tipo1") // tipo 'Vincente'
			{	document.getElementById('minimoSelezionabileAGirare').value=1;
				document.getElementById('gruppi').value=1;
			}
			else if(tipo=="tipo2") // tipo 'Accoppiata'
			{	document.getElementById('minimoSelezionabileAGirare').value=2;
				document.getElementById('gruppi').value=2;
			}
			else if(tipo=="tipo3") // tipo 'Tris'		
			{	document.getElementById('minimoSelezionabileAGirare').value=3;
				document.getElementById('gruppi').value=3;
			}
			else if(tipo=="tipo4") // tipo 'Quartè'	
			{	document.getElementById('minimoSelezionabileAGirare').value=4;
				document.getElementById('gruppi').value=4;
			}
			else if(tipo=="tipo5") // tipo 'Quintè'
			{	document.getElementById('minimoSelezionabileAGirare').value=5;
				document.getElementById('gruppi').value=5;
			}	
		}	
	}
	calcolaColonneImporto();
}

function abilitaTabella(i)
{
	for(j=1; j<=20; j++){
		if(document.getElementById('selCavalloFont'+i+j)!=undefined && document.getElementById('selCavalloFont'+i+j).className=="iFontWhite-piccolo")
			document.getElementById('selCavalloFont'+i+j).className="iFontWhite-piccolo";
	}
	document.getElementById('tabellaCavalliDisabilitata'+i).style.display='none';
	document.getElementById('tabellaCavalliAbilitata'+i).style.display='inline';
}


function calcolaPuntata()
{
	var tipo = document.getElementById('tipo').value;
	if(tipo=='tipo1')
		return 1;
	else if(tipo=='tipo2')
		return 1;
	else if(tipo=='tipo3')
		return 0.50;
	else if(tipo=='tipo4')
		return 0.25;
	else if(tipo=='tipo5')
		return 0.25;
}
function binomiale(num1,num2)
{
    var val;
    var i;
    var ret_val;
    var continua;
    val = 1;
    i = 0;
    continua = true;
    while (continua)
    {	if (i == num2)
     		continua = false;
       	else
       	{	val = val * num1;
         	num1--;
       	}
       	i++;
    }
    ret_val = (val / fattoriale(num2));
    return(ret_val);
}

function fattoriale(val_1,val_2)
{
	var i,k;
	var p,p1;
	var retu;
	
	retu=0;
	if((val_1<1) || (val_2<1) || (val_1<val_2) ) return 0;
	p=1;
	k=val_1-val_2+1;
	
	for(i=val_1;i>=k;i--) p=p*i;
	p1=1;
	for(i=val_2;i>=1;i--) p1=p1*i;
	
	retu =( p / p1);
	return retu;
}

function calcolaColonneOrdineEsatto()
{	
	var colonne = 0;
	var tipo = getColonneAbilitate();
	var cavallo1 = new Array();
	var cavallo2 = new Array();
	var cavallo3 = new Array();
	var cavallo4 = new Array();
	var cavallo5 = new Array();
	
	switch(tipo)
	{
		case 1:
			cavallo1 = riempiCavalliSelezionati(1,cavallo1);
			for(var i=0; i<cavallo1.length; i++)
				colonne++;
		break;
		case 2:
			cavallo1 = riempiCavalliSelezionati(1,cavallo1);
			cavallo2 = riempiCavalliSelezionati(2,cavallo2);
			for(var i=0; i<cavallo1.length; i++)
				for(var j=0; j<cavallo2.length; j++)
					if(cavallo1[i]!=cavallo2[j])
						colonne++;	
		break;
		case 3:
			cavallo1 = riempiCavalliSelezionati(1,cavallo1);
			cavallo2 = riempiCavalliSelezionati(2,cavallo2);
			cavallo3 = riempiCavalliSelezionati(3,cavallo3);
			for(var i=0; i<cavallo1.length; i++)
				for(var j=0; j<cavallo2.length; j++)
					if(cavallo1[i]!=cavallo2[j])
						for(var k=0; k<cavallo3.length; k++)
							if(cavallo2[j]!=cavallo3[k] && cavallo1[i]!=cavallo3[k])
								colonne++;
		break;
		case 4:
			cavallo1 = riempiCavalliSelezionati(1,cavallo1);
			cavallo2 = riempiCavalliSelezionati(2,cavallo2);
			cavallo3 = riempiCavalliSelezionati(3,cavallo3);
			cavallo4 = riempiCavalliSelezionati(4,cavallo4);
			for(var i=0; i<cavallo1.length; i++)
				for(var j=0; j<cavallo2.length; j++)
					if(cavallo1[i]!=cavallo2[j])
						for(var k=0; k<cavallo3.length; k++)
							if(cavallo2[j]!=cavallo3[k] && cavallo1[i]!=cavallo3[k])
								for(l=0; l<cavallo4.length; l++)
									if(cavallo4[l]!=cavallo1[i] && cavallo4[l]!=cavallo2[j] && cavallo4[l]!=cavallo3[k])
										colonne++;
		break;								
		case 5:
			cavallo1 = riempiCavalliSelezionati(1,cavallo1);
			cavallo2 = riempiCavalliSelezionati(2,cavallo2);
			cavallo3 = riempiCavalliSelezionati(3,cavallo3);
			cavallo4 = riempiCavalliSelezionati(4,cavallo4);
			cavallo5 = riempiCavalliSelezionati(5,cavallo5);
			for(var i=0; i<cavallo1.length; i++)
				for(var j=0; j<cavallo2.length; j++)
					if(cavallo1[i]!=cavallo2[j])
						for(var k=0; k<cavallo3.length; k++)
							if(cavallo2[j]!=cavallo3[k] && cavallo1[i]!=cavallo3[k])
								for(l=0; l<cavallo4.length; l++)
									if(cavallo4[l]!=cavallo1[i] && cavallo4[l]!=cavallo2[j] && cavallo4[l]!=cavallo3[k])
										for(p=0; p<cavallo5.length; p++)
											if(cavallo5[p]!=cavallo1[i] && cavallo5[p]!=cavallo2[j] && cavallo5[p]!=cavallo3[k] && cavallo5[p]!=cavallo4[l])
												colonne++;
		break;											
	}
	return colonne;
}
function getColonneAbilitate()
{	
	var tipo = document.getElementById('tipo').value;
	if(tipo=='tipo1')
		return 1;
	else if(tipo=='tipo2')
		return 2;
	else if(tipo=='tipo3')
		return 3;
	else if(tipo=='tipo4')
		return 4;
	else if(tipo=='tipo5')
		return 5;
}
function riempiCavalliSelezionati(i,cavallo)
{
	var k = 0;
	for(var j=1; j<=20; j++)
	{	if(document.getElementById('selCavallo'+i+j)!=undefined && document.getElementById('selCavallo'+i+j).className=="iQuadratinoSelezione")
		{	cavallo[k]=j;
			k++;
		} 
	}
	return cavallo;
}



function disabilitaTabella(i)
{
	document.getElementById('tabellaCavalliDisabilitata'+i).style.display='inline';
	document.getElementById('tabellaCavalliAbilitata'+i).style.display='none';
}

function disabilitaTutti()
{
	for(var i=1; i<=5; i++)
		disabilitaTabella(i);
}

function disabilitaOrdineEsatto()
{
	for(var i=2; i<=5; i++)
	{	
		for(var j=1; j<=20; j++)
		{	if(document.getElementById('selCavallo'+i+j)!=undefined && document.getElementById('selCavallo'+i+j).className=="iQuadratinoSelezione")
			{
				document.getElementById('selCavallo'+i+j).className="iQuadratinoNoSelezione";
				document.getElementById('selCavalloFont'+i+j).className="iFont279CEC-piccolo";
				document.getElementById('num').value=Number(document.getElementById('num').value)-1;
				document.getElementById('selCavalloTutti'+i).className="iQuadratinoNoSelezione";
			}
		}
	}
}
function scegliVolte(id,scoM,tipo)
{
	for(var i=1; i<=6; i++)
	{	
		document.getElementById('volte'+i+tipo).className="iQuadratinoNoSelezioneVolte";
		document.getElementById('volteFont'+i+tipo).className="iFont279CEC-piccolo";
	}
	document.getElementById(id+tipo).className="iQuadratinoSelezioneVolte";
	document.getElementById(scoM+tipo).className="iFontWhite-piccolo";
	document.getElementById('volte').value=id;
	checkAbilitazione();
	moltiplicaColonne(tipo);
	visualizzaConferma();
}

function visualizzaConferma()
{
	if(document.getElementById('colonne').value!='0')
	{	document.getElementById('contieniBottoneGrigio').style.display='none';
		document.getElementById('contieniBottoneArancio').style.display='inline';
	}
	else	
	{	document.getElementById('contieniBottoneArancio').style.display='none';
		document.getElementById('contieniBottoneGrigio').style.display='inline';
	}
}

function controlliConferma(oneclick, saldo,loggato)
{
	if(oneclick<1)
	{	
		if(controllaLoggato(loggato) && controllaGiocataMinima() &&  controllaImportoMinimo(saldo)){
			
			var dataString=$("#formConfermaGiocataIppica").serialize();
			$("#loadScommesse").html("<div style='margin-top:20px;margin-left:250px;'><img alt='' src='/betPlus3/style/images/ajax-loader.gif'></div>");
			$("#loadScommesse").load("ConfermaGiocataIppicaAction.action?"+dataString);
			//document.getElementById('formConfermaGiocataIppica').submit();
		}
	}
	oneclick++;
	return oneclick;
}

function controllaLoggato(loggato)
{
	if(loggato==0)
	{	document.getElementById('erroreLoggato').style.display='inline';
		return false;
	}
	else
	{	document.getElementById('erroreLoggato').style.display='none';
		return true;
	}
}
function controllaGiocataMinima()
{
	var colonne = Number(document.getElementById('colonne').value);
	if(colonne>=2)
	{	document.getElementById('erroreGiocataMinima').style.display='none';
	return true;
	}
	else
	{	document.getElementById('erroreGiocataMinima').style.display='inline';
	return false;
	}
}

function controllaImportoMinimo(saldo)
{
	var importo = Number(document.getElementById('importo').value);
	if(Number(saldo)>=importo)
	{	document.getElementById('erroreImportoMinimo').style.display='none';
		return true;
	}
	else
	{	document.getElementById('erroreImportoMinimo').style.display='inline';
		return false;
	}
}

function azzera(){
	document.getElementById('importo').value='0';
	document.getElementById('colonne').value='0';
	document.getElementById('num').value='0';
	document.getElementById('gruppi').value='3';
	document.getElementById('gioco').value='gioco2';
}

function scegliUltimaCorsa(idPalinsesto,idConcorso)
{
	document.getElementById('idPalinsestoConfirm').value=idPalinsesto;
	document.getElementById('idConcorsoConfirm').value=idConcorso;
	document.getElementById('sbmtUltimaCorsa').click();
}
function infoScommessaIppica(idTicket)
{
	document.getElementById('idTicket').value=idTicket;
	document.getElementById('sbmtInfoScommessaIppica').click();
}

function conferma()
{	
	document.getElementById('sbmtConferma').click();
}

function abilitaModificaPPA(){ 	
	if(!document.getElementById('abilita').checked){
	
		document.getElementById('provinciaInvio').disabled=false;
		document.getElementById('provinciaInvio').value="";
		
		document.getElementById('provinciaInvioHidden').value="";
		document.getElementById('sbmtComuneInvio').click();
		
		document.getElementById('capInvio').readOnly=false;
		document.getElementById('capInvio').value="";
	
		document.getElementById('indirizzoInvio').readOnly=false;
		document.getElementById('indirizzoInvio').value="";
	}
	else{
		document.getElementById('abilita').checked="checked";
		
		document.getElementById('provinciaInvio').value=document.getElementById('provinciaResidenza').value;
		
		document.getElementById('capInvio').value=document.getElementById('capResidenza').value;
		
		document.getElementById('indirizzoInvio').value=document.getElementById('indirizzoResidenza').value;
		
		if(document.getElementById('comuneResidenza').value!=null && document.getElementById('provinciaResidenza').value!=undefined 
				&& document.getElementById('comuneResidenza').value!=""){
			document.getElementById('provinciaInvioHidden').value=document.getElementById('provinciaResidenza').value;
			document.getElementById('sbmtComuneInvio').click();
		}
	}
}

function disableEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	} 

function comuneNascitaPPAY(provNascita){
	document.getElementById('provinciaNascitaHidden').value=provNascita;
	document.getElementById('sbmtComuneNascita').click();
}
function comuneResidenzaPPAY(provResidenza){
	document.getElementById('provinciaResidenzaHidden').value=provResidenza;
	document.getElementById('sbmtComuneResidenza').click();
}
function comuneInvioPPAY(provInvio){
	document.getElementById('provinciaInvioHidden').value=provInvio;
	document.getElementById('sbmtComuneInvio').click();
}
/******scala reale******/
function classificaScalaReale(tourId)
{
	document.getElementById('tourIdClassifica').value=tourId;
	document.getElementById('sbmtClassifica').click();
	document.getElementById('infoClassifica').style.display='inline';
}
function classificaGradimento(i)
{
	for(var j=1; j<=i; j++)
		document.getElementById('s'+j).className='stellaGialla';
	
	for(var j=i+1; j<=5; j++)
		document.getElementById('s'+j).className='stellaBianca';
	
	document.getElementById('voto').value=i;
}

/*****PAGINAZIONE******/
var pagEnabled = true;
function paginazione(page,numList)
{
	if(!pagEnabled)
		return;
	pagEnabled = false;
	var idPaginazione=$("#noStampaPaginazione").parent('div').attr("id");
	var azione=tornaAzionePaginazione(idPaginazione);
	var data=new Date();
	
	$("#"+idPaginazione).load(""+azione+".action?page="+page+"&"+data.getMilliseconds()+"aa",
			function(){
				pagEnabled = true;
			
	});
	
}	
function tornaAzionePaginazione(idPaginazione)
{
	if(idPaginazione=="movimentoContoPaginazione")
		return "ViewMovimentiContoAction_paginazione";
	else if(idPaginazione=="scommesseAttesaEsitoPaginazione")
	 return "ViewBetsAction_paginazioneScAttesaEsito";
	else if(idPaginazione=="storicoScommessePaginazione")
	 return "ViewStoricoScommesseAction_paginazioneStScommesse";
	else if(idPaginazione=="storicoPokerPaginazione")
		return "ViewStoricoPokerAction_paginazione";
	else if(idPaginazione=="storicoIppicaPaginazione")
		return "ViewStoricoIppicaAction_paginazione";
	else if(idPaginazione=="storicoScalaRealePaginazione")
		return "ViewStoricoScalaRealeAction_paginazione";
	else if(idPaginazione=="leMieGiocatePaginazione")
		return "LeMieGiocateAction_paginazione";
	
	//adolfo
	else if(idPaginazione=="networkAdolfoPaginazione")
		return "NetworkAction_paginazione";
	else if(idPaginazione=="listaScommesseAdolfoPaginazione")
		return "ListaScommesseAction_paginazione";
	else if(idPaginazione=="listaMovimentoAdolfoPaginazione")
		return "ListaMovimentoAction_paginazione";
	else if(idPaginazione=="bilancioAgentiPaginazione")
		return "BilancioAgenteAction_paginazione";
	else if(idPaginazione=="bilancioAdolfoPaginazione")
		return "BilancioAction_paginazione";
			
}
function validaData(){
	data=document.getElementById('dataDal').value;
	var espressione=/^([0][1-9]||[1-2][0-9]||[3][0-1])[/]([0][1-9]||[1][0-2])[/](19||20)[0-9][0-9]/;
	if (!espressione.test(data))
	{
		document.getElementById('msgDataErrata').innerHTML="&bull; La stringa non è valida!";
	}
	else{
		document.getElementById('msgDataErrata').innerHTML="";
		document.getElementById('sbmConfermaData').click();
	}
}
/*script per menu utente*/
function mmenu(ac,mid) {
	if(ac == "chiuso"){
		document.getElementById('chiuso'+mid).style.display='none';
		document.getElementById('aperto'+mid).style.display='inline';
	}
	else if(ac== "aperto"){
		document.getElementById('aperto'+mid).style.display='none';
		document.getElementById('chiuso'+mid).style.display='inline';}
	
}

function dettaglioCouponFun(couponId,codTicket,dataTicket){
	document.getElementById("couponId").value=couponId;
	document.getElementById("codTicket").value=codTicket;	
	document.getElementById("dataTicket").value=dataTicket;	
	var dataString="";
	var i=0;
	$("#idFrmdettaglio").find('input').each
	(function() {
		i++;
		var name=$(this).attr("name");
		var val= escape($(this).val());
		if(i>1)
			dataString+="&";
		dataString+=name+"="+val;
	});
	$("#dettaglioCoupon").html("<div style='margin-top:20px;margin-left:250px;color:white;height:300px;'>Loading...</div>");
	$("#dettaglioCoupon").load("ViewDettaglioCouponAction.action?"+dataString);

	//document.getElementById("sbmFrmdettaglio").click();	
}
function dettaglioIppicaTicket(idTicket){
	$("#dettaglioIppica").html("<div style='margin-top:20px;margin-left:250px;color:white;height:300px;'>Loading...</div>");
	$("#dettaglioIppica").load("ViewStoricoIppicaAction_dettagliIdTicket.action?idTicket="+idTicket);
}
/* calcola la commissione per il merchant cim in singlebet*/
function calcolaCommissione(){
	importo=document.getElementById("importoFloat").value;
	importoCommissione=importo*0.02;
	document.getElementById("importoCommissione").value=importoCommissione;
	importoTotale=importo*1.02;
//	document.getElementById("totale").innerHTML=importoTotale;
	document.getElementById("totale").value=importoTotale;
}
function Trim(stringa){ //Levo eventuali spazi indesiderati
	   reTrim=/\s+$|^\s+/g;
	   return stringa.replace(reTrim,"");
}

function controllaCF(codiceFiscale){  // Controllo correttezza codice fiscale
    var re = /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/;
    Codice=Trim(codiceFiscale.value.toUpperCase());
    return re.test(Codice);
}

function isEmail(email) {
	if (email.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/))
		return true;
	else 
		return false;
}
    
function controllaDatiAccount(nome,cognome,codiceFiscale,email)
{
	if(!controllaCF(codiceFiscale))
		alert('Codice fiscale errato');
	else if(!isEmail(email.value))
		alert('Email non valida');
	else if(nome.value=='')
		alert('Inserisci il nome');
	else if(cognome.value=='')
		alert('Inserisci il cognome');
	else
		document.getElementById('formId').submit();
}
function chiediLogin(messageLogin){
	alert(messageLogin);
	
}

function popupie6(){
	
	var ievs = (/MSIE (\d+\.\d+);/.test(navigator.userAgent));

	// IF BROWSER IS IE 6 LOAD IE6 popup
	if (ievs){

	var iev=new Number(RegExp.$1);

	if (iev==6) {
		alert("Attenzione!\nQuesto sito é ottimizzato per INTERNET EXPLORER 7.0  e versioni superiori.\n" +
				"Continuando la navigazione con questo browser potrebbero verificarsi alcuni errori.");

	}

	}

}
function selectCheck(val){
	if(document.getElementById('uvw'+val)==null || document.getElementById('uvw'+val).value=='')
	{	document.getElementById('uvw'+val).value=document.getElementById('xyz'+val).value;
	}
	else 
	{	document.getElementById('uvw'+val).value='';
	}
}
function submitManifestazione(){
	
	flag=false
	man=document.getElementsByName('manifestazione');
	for (var i=0;i<man.length;i++){
		if (man[i].checked){
			flag = true;
		}
	}
	if(flag){
		document.getElementById('submitManifestazione').click();
	}
}

function submitLogin(e){
	if(navigator.appName!="Microsoft Internet Explorer"){
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		if(keycode==13)
			document.getElementById("submitLog").click();
	}
}

//	function getFormInputsString(idDiv) {
//		var dataString="";
//		var i=0;
//		/*leggo in automatico tutti i fratelli del link a che in questo caso sono gli input*/
//		var myDiv=document.getElementById(idDiv);
//		alert(idDiv);
//		alert("div: "+$(myDiv));
//		//alert("class: "+$("'"+myDiv+"'").attr("class"));
//		alert("align: "+$(""+myDiv+"").attr("align"));
//		alert("figli: "+$(myDiv).children());
//		
//		//$("div[id='"+idDiv+"'] > input").nextAll().each(			
//		$(""+myDiv+"").children().nextAll().each(			
//			function(){
//				i++;
//				var name=$(this).attr("name");
//				//alert("name>>"+name);
//				var val= escape($(this).val());
//				//alert(val);
//				if(i>1)
//					dataString+="&";
//				//da fare urlEncoding o qualcosa del genere
//				dataString+=name+"="+val;
//				
//			});
//		return dataString;
//	}



/******ADN - ADOLFO********/
function paginazioneJQ(action,page,numList)
{
	numPagina=new Number(document.getElementById('numeroPagina').value);
	numPaginaTot=new Number(document.getElementById('numeroPagineTotali').value);
	if(numPagina==null || numPagina==undefined || numPagina=="")
		numPagina=1;
	if(page=='last'){
		numPagina=document.getElementById('numeroPagineTotali').value;
	}
	else if(page=='next'){
		if(numPagina<numPaginaTot)
			numPagina++;
	}
	else{
		if(numPagina>1)
			numPagina--;
	}
	document.getElementById('numeroPagina').value=numPagina;
	
	document.getElementById('page').value=page;
	
	dataString="numeroPagina="+numPagina+"&numeroPagineTotali="+numPaginaTot;
	
	$("#listaLoad").load(action+"?"+dataString);
	
}	
function dettaglioCouponFunJQ(couponId,codTicket,dataTicket,useridScelto){
	
	dataString="couponId="+couponId+"&codTicket="+codTicket+"&dataTicket="+dataTicket+"&useridScelto="+useridScelto;
	
	$("#dettCouponLoad").load("/betPlus3/private/actions/ViewDettaglioCouponAction_executeADN.action?"+dataString);
}
function changeClient(action){
	var val=$("#listClient").val();
	
	$("#loadNominativo").load(action+""+val);
}

function changeProvNasc(val){	
	$("#campoProvNasc").load("/betPlus3/private/actions/ConfirmRegistrationAction_cambiaProvNascita.action?nazioneNascita="+val);
}


function selectMenuScomm(id){
	if(document.getElementById("offertaIndex")!=undefined)
		document.getElementById("offertaIndex").style.display="none";
	if(document.getElementById("bannerMob")!=undefined)
		document.getElementById("bannerMob").style.display="none";
	
	if(id!=undefined && id!=""){
		if($("#varID").val())
			$("#"+$("#varID").val()).removeClass("bold");
		
		$("#"+id).addClass("bold");
		$("#varID").val(id);
	}
}
function selectMenuPoker(id,parentId){
	if(id!=undefined && id!=""){
		$("#primaryAccordion").find('a').each
		(function() {
			$(this).removeClass("bold");
		});
		$("#"+id).addClass("bold");
		$("#varID").val(id);
	}
}
function selectMenuPoker(id){
	if(id!=undefined && id!=""){
		$("#primaryAccordion").find('a').each
		(function() {
			$(this).removeClass("bold");
		});
		$("#"+id).addClass("bold");
		$("#varID").val(id);
		
	}
}

function aggiornaPagePoker(page){
	var arrayPage={"betplusPoker":"betplusPoker",
			"superSunday":"SuperSundayTournament.jsp",
            "pptmontenegro":"TourMontenegro.jsp",
            "classificaMensile":"classificaPromo|Classifiche/TorneiMensile.aspx?notemplate=yes&theme=betplus.it|750",
            "montepremiGarantiti":"TorneiMg.jsp",
            "freeroll":"Freeroll.jsp",
            "ranking":"RankingTournament.jsp"};
	
	var pageTrack="";
	
	if(page=="classificaMensile"){
		var param=arrayPage[page];
		var arrayParam=param.split("|");
		$("#loadPageMyPoker").load("/betPlus3/newPages/poker/pokerCenterClassifica.jsp",{'param':arrayParam[1],'height':arrayParam[2]});
		pageTrack="/betPlus3/Classifiche/TorneiMensile.jsp";
	}
	else if(page=="betplusPoker"){
		$("#loadPageMyPoker").load("/betPlus3/newPages/poker/betplusPoker.jsp");
		pageTrack="/betPlus3/Classifiche/betplusPoker.jsp";
	}
	else{
		$("#loadPageMyPoker").load("/betPlus3/newPages/poker/pagePeoplesPoker/"+arrayPage[page]);
		pageTrack="/betPlus3/Classifiche/"+page;
	}
	pageTracker._trackPageview(pageTrack); 
}
function browserCompatible(){
	var stile = "top=400, left=400, width=500, height=200, resizable=no,menubar=no,toolbar=no, scrollbars=no,location=0,status=no'";
    //var apri  ="/betPlus3/private/LinkActionattenzioneDownload.action";
    var apri  ="/betPlus3/private/LinkActionattenzioneDownload.action";
	
	if(navigator.appName =="Microsoft Internet Explorer" &&
			navigator.appVersion.indexOf("MSIE") > -1 && 
			navigator.userAgent.indexOf("Opera") == -1){
		var versione1 = navigator.appVersion.split(";");
		
		if((parseInt(versione1[1].split(" ")[2]))<8){
			document.getElementById("visualizzaPopup").style.display="inline";
			//window.open(apri, "Poker", stile);
		}
		else{ 
			var data=new Date();
			window.open('PokerAction.action?clientType=DotNet','Poker','width=' + 800 + ',height=' + 650 + ',top=' + 200 + ',left=' + 200 +', resizable=no, menubar=no, toolbar=no, scrollbars=no, locations=no, status=no');
		}
	}
	else{
		document.getElementById("visualizzaPopup").style.display="inline";
		//window.open(apri, "Poker", stile);
	}
}
