var imageFile;
    
    function prova(e){
		if(e.keyCode==13){
			$("#Result-Login").animate({opacity:"toggle"},500,function(){
				xmlhttpPost("logon.asp","Login-WebForm","Result-PostBack-Login","<img src='images/i_loader.gif' border='0' />","if(document.getElementById('PassedOk')) AfterLogin()");        
			});
		}
    }   

function init_interface(pdefBtn) {
    
    $("#Login-Label-User").html("User");
    $("#Login-Label-PassWord").html("Password");
    $("#Login-Label-Forgot-PassWord").html("&gt; Hai dimenticato la password?");
    $("#Content").animate({opacity:"toggle"},500,function(){
        $("#Header-Band").animate({opacity:"toggle"},500,function(){
              $("#Footer").animate({opacity:"toggle"},500,function(){});
        });
    });
    $("#Logout-Label-Partecipante").html("&#8226 &nbsp; Benvenuto/a");
    $("#Logout-Button").html("x Logout");
    

    if(document.getElementById('WebForm-Name-Player')){
        document.getElementById('Label-FullName-Player').innerHTML = '<b>' + document.getElementById('WebForm-Name-Player').value + '</b>';
    }
    if(document.getElementById('WebForm-Surname-Player')){
        document.getElementById('Label-FullName-Player').innerHTML = '<b>' + document.getElementById('Label-FullName-Player').innerHTML + ' ' + document.getElementById('WebForm-Surname-Player').value + '</b>';
    }
    
    if(document.getElementById('Button-Register')){
        document.getElementById('Button-Register').onclick=function(){
            location.href='registrazione.asp';
        }
    }
    if(document.getElementById('Button-Play')){
        document.getElementById('Button-Play').onclick=function(){
            location.href='partecipa.asp';
        }
    } 

    if(document.getElementById('WebForm-PassWord')){
        /*document.getElementById('WebForm-PassWord').onkeyup=function(){
            if (this.addEventListener){
                this.addEventListener("onkeyup",prova(Event) , false);
            }else{
                this.attachEvent("onkeyup", prova);
            }
        }*/
    }
    
    if(document.getElementById('Login-Button-Submit')){
        document.getElementById('Login-Button-Submit').onclick=function(){
            $("#Result-Login").animate({opacity:"toggle"},300,function(){
                        xmlhttpPost("logon.asp","Login-WebForm","Result-PostBack-Login","<img src='images/i_loader.gif' border='0' />","if(document.getElementById('PassedOk')) AfterLogin()");        
            });
        }
    }
    
    if(document.getElementById('Login-Close-Button')){
        document.getElementById('Login-Close-Button').onclick=function(){
            $("#Result-Login").animate({opacity:"toggle"},300,function(){});
        }
    }
    
    if(document.getElementById('Logout-Button')){
        document.getElementById('Logout-Button').onclick=function(){
            location.href='logout.asp';  
        }
    }
    
    if(document.getElementById('Login-Label-Forgot-PassWord')){
        document.getElementById('Login-Label-Forgot-PassWord').onclick=function(){
            location.href='password_dimenticata.asp';
        }
    }
    
       
    document.getElementById('Header-Button-Partecipare').onclick=function(){
        location.href='come_partecipare.asp';
    }
    
    document.getElementById('Header-Button-Premio').onclick=function(){
        location.href='premio_giornaliero.asp';
    }
    
    document.getElementById('Header-Button-Regolamento').onclick=function(){
        location.href='regolamento.asp';
    }
    
    document.getElementById('Header-Logo').onclick=function(){
        location.href='index.asp';
    }
    
    
    
    // ************************** 
    // Registrazione
    
    if(pdefBtn.toString()=='856a36a478f2808761708172a590e188'){
   
    }
    
    
    // ************************** 
    // Partecipa
    
    if(pdefBtn.toString()=='fe51f5c8d6d6bc299256299282f19838'){
		
		//logging start
		//console.log('Start debug');
		//logging end
		
		//definizione del sesso per il premio
		var sex = 'M';
		if (document.getElementById('Button-Game-M')==null) {
			sex = 'F';
		} else {
			sex = 'M';
		}

		if (sex=='M') {
			document.getElementById('Button-Game-M').onmouseover=function(){
				this.style.backgroundPosition = 'bottom';
			}
			document.getElementById('Button-Game-M').onmouseout=function(){
				this.style.backgroundPosition = 'top';
			}
		}
		
		if (sex=='F') {
			document.getElementById('Button-Game-F').onmouseover=function(){
				this.style.backgroundPosition = 'bottom';
			}
			document.getElementById('Button-Game-F').onmouseout=function(){
				this.style.backgroundPosition = 'top';
			}
		}
				
		//logging start
		//console.log('Pre Game Permitted (value='+document.getElementById('Game-Permitted').value+')');
		//logging end		

          if(document.getElementById('Game-Permitted').value=='0') {
			
			//logging start
			//console.log('Pre Game Winner (value='+document.getElementById('Game-Winner').value.toString()+')');
			//logging end		

             if(document.getElementById('Game-Winner').value.toString()=='1'){
                $("#Content-Desc-Premio").hide();
				if (sex=='F') {
					$('.Game-F').attr('style', 'background: url(images/gioca/bg_gia_vinto_' + sex + '.jpg) #fff !important;');
				} else {
					$('.Game-M').attr('style', 'background: url(images/gioca/bg_gia_vinto_' + sex + '.jpg) #fff !important;');
				}
				//document.getElementById('Game-Permitted-Label').style.marginLeft = "-155px";
				document.getElementById('Game-Permitted-Label').style.marginRight = "0px";
                document.getElementById('Game-Permitted-Label').style.width = "680px";
				document.getElementById('Game-Permitted-Label').style.textAlign = "center";
				document.getElementById('Game-Permitted-Label').style.fontSize = "15px";
                document.getElementById('Game-Permitted-Label').style.color= "#333333";
                //document.getElementById('Game-Permitted-Label').innerHTML = "<br />Ti ricordiamo che puoi vincere solo<br />una volta durante tutta la durata del concorso.<br /><br />Ti invitiamo a collegarti al nostro sito www.collistar.it<br /> per rimanere aggiornato su tutte le novit&agrave;, le promozioni <br />e i prossimi concorsi Collistar.";
				$('Game-Permitted-Label').html('&nbsp;');
			 }else{
                //document.getElementById('Game-Permitted-Label').innerHTML = "Hai gi&agrave; giocato per oggi, torna domani";
                $("#Content-Desc-Premio").hide();
                document.getElementById('Game-Permitted-Label').style.width = "287px";
                document.getElementById('Game-Permitted-Label').style.height = "42px";
                document.getElementById('Game-Permitted-Label').style.marginTop = "30px";
                document.getElementById('Game-Permitted-Label').style.marginLeft = "auto";
                document.getElementById('Game-Permitted-Label').style.marginRight = "auto";
                document.getElementById('Game-Permitted-Label').style.backgroundImage = 'url("images/gioca/btn_gg_' + sex + '.jpg")';
				$("#Label-PostResult").html("<b>Ritenta la fortuna ogni giorno<br />fino al 18 dicembre</b>.");
				document.getElementById('Label-PostResult').style.marginLeft = "0px";
				document.getElementById('Label-PostResult').style.marginTop = "-10px";                $("#Label-PostResult").show();             }
			if (sex=='M') {
				document.getElementById('Button-Game-M').style.display='none';
			}
			if (sex=='F') {
				document.getElementById('Button-Game-F').style.display='none';
			}

          }
		if (sex=='M') {
			document.getElementById('Button-Game-M').onclick=function() {
				if(document.getElementById('Game-Permitted').value=='1') {
					xmlhttpPost("time.aspx","Game-WebForm","Result-PostClick-Time","","AfterGetTimeClick('" + sex + "')");        
				} else {
					alert(document.getElementById('Game-Permitted-Label').innerHTML);
				}
			}
		}
		if (sex=='F') {
			document.getElementById('Button-Game-F').onclick=function() {
				if(document.getElementById('Game-Permitted').value=='1') {
					xmlhttpPost("time.aspx","Game-WebForm","Result-PostClick-Time","","AfterGetTimeClick('" + sex + "')");        
				} else {
					alert(document.getElementById('Game-Permitted-Label').innerHTML);
				}
			}
		}
    } else {
    
    }
    
    // ************************** 
    // Come_Partecipare
    
    if(pdefBtn.toString()=='7cda6896c18062e84b97a01dde4ad680'){
    
        document.getElementById('Header-Button-Partecipare').style.backgroundPosition='bottom';
        
    }else{
        document.getElementById('Header-Button-Partecipare').onmouseover=function(){
            document.getElementById('Header-Button-Partecipare').style.backgroundPosition='bottom';
        }
        document.getElementById('Header-Button-Partecipare').onmouseout=function(){
            document.getElementById('Header-Button-Partecipare').style.backgroundPosition='top';
        }
    }
    // ************************** 
    // Regolamento
    
    if(pdefBtn.toString()=='bcd219546831f8ec2316296cd0e5ac88'){
    
        document.getElementById('Header-Button-Regolamento').style.backgroundPosition='bottom';
        $('.scroll-pane').hide()
        $('.scroll-pane').jScrollPane({showArrows: true});   
        setTimeout(function(){ 
            $('.scroll-pane').animate({opacity:"toggle"},1000,function(){})
        },1000);
        
    }else{
        document.getElementById('Header-Button-Regolamento').onmouseover=function(){
            document.getElementById('Header-Button-Regolamento').style.backgroundPosition='bottom';
        }
        document.getElementById('Header-Button-Regolamento').onmouseout=function(){
            document.getElementById('Header-Button-Regolamento').style.backgroundPosition='top';
        }
    }
    
    // ************************** 
    // Premio_Giornaliero
	if(pdefBtn.toString()=='6d4fede10c8450d03fe07ba71c40a3fb'){
        $("#BackgroundLightbox").animate({opacity:"0.00"},100,"linear",function(){});
        $("#Lightbox").animate({opacity:"0.00"},100,"linear",function(){});
        document.getElementById('Header-Button-Premio').style.backgroundPosition='bottom';   
        
		/*document.getElementById('Premio-Uno').onclick=function(){
            imageFile = "pg_zoom1.jpg";
            VeilFloatLB() 
        }
        document.getElementById('Premio-Due').onclick=function(){
            imageFile = "pg_zoom2.jpg";
            VeilFloatLB() 
        }
        document.getElementById('Premio-Tre').onclick=function(){
            imageFile = "pg_zoom3.jpg";
            VeilFloatLB() 
        }
        document.getElementById('Premio-Quattro').onclick=function(){
            imageFile = "pg_zoom4.jpg";
            VeilFloatLB() 
        }*/  
         
    }else{
	
        document.getElementById('Header-Button-Premio').onmouseover=function(){
            document.getElementById('Header-Button-Premio').style.backgroundPosition='bottom';
        }
        document.getElementById('Header-Button-Premio').onmouseout=function(){
            document.getElementById('Header-Button-Premio').style.backgroundPosition='top';
        }
    }
}

getCurrPosition()

function VeilFloatLB(){
  $("#BackgroundLightbox").show();  
  $("#BackgroundLightbox").animate({opacity:"0.80"},500,"linear",function(){
    setTimeout(function(){
    maxWidthImage()
          //$("#Lightbox").show();  
          //$("#Lightbox").animate({opacity:"1.00"},400,"linear",function(){maxWidthImage()});

    },300)
  });
     
}

var pImageWidth = 794;
var pImageHeight = 620;
function maxWidthImage() {
  var pWidth = pImageWidth;
  var pHeight = pImageHeight;
  $("#Lightbox").show();
  $("#Lightbox").animate({opacity:"1.00",top:"-="+40,height:pHeight},200,"swing",function(){
    setTimeout(function(){
        $("#Lightbox").animate({width:pWidth},200,"swing",function(){
            $("#Zoom-Image").html("<img src=images/premio_giornaliero/"+imageFile+" border=0>");
            $("#Zoom-Image").animate({opacity:"toggle"},800,"linear",function(){});
        });
    },100);
  });
}

function getCurrPosition() {
   setTimeout(function(){
        var DocRef;
	    var f = document.getElementById('Lightbox')
	    var s = document.getElementById('BackgroundLightbox')
    	
	    if (f && s){
            if( document.documentElement && document.documentElement.clientWidth) DocRef = document.documentElement; else DocRef = document.body;
		    f.style.left=parseInt(DocRef.clientWidth) / 2 - parseInt(pImageWidth) / 2  + "px"; 
		    f.style.top=parseInt(DocRef.clientHeight) / 2 - parseInt(pImageHeight) / 2 + "px"; 
		    
	    }
   
   },100);
}

function minWidthImage(){
    $("#Lightbox").animate({top:"+="+40,height:"200"},200,"swing",function(){
        setTimeout(function(){
            $("#Lightbox").animate({width:"200"},200,"swing",function(){
                $("#Lightbox").animate({opacity:"0.00",top:"-="+200},200,"swing",function(){
                    $("#BackgroundLightbox").animate({opacity:"0.00"},500,"linear",function(){
                            $("#BackgroundLightbox").hide();
                            $("#Lightbox").hide();
                            $("#Lightbox").animate({top:"+="+200},50,"swing",function(){});
                    });
                });
            });
        },100)});
}
function CloseVeilFloatLB(){
    $("#Zoom-Image").animate({opacity:"toggle"},200,"linear",function(){minWidthImage();});
}

function AfterLogin(){ 
   $('#Login-Close-Button').hide();
    $("#Logout-Button").html("<b>Logout</b>");
    if(document.getElementById('Logout-Button')){
            document.getElementById('Logout-Button').onclick=function(){
                location.href='logout.asp';  
            }
        }
        
        $("#Button-Register").animate({opacity:"toggle"},1000,function(){}); 
        setTimeout(function(){
			location.href='partecipa.asp'
        },1000);
}

function AfterGetTimeClick(sex) {
    document.getElementById('Button-Game-' + sex).onclick=function(){
       //alert("Hai gia' giocato per oggi, torna domani.")
    }
    //xmlhttpPost("gioca.asp","Game-WebForm","Result-PostClick-Game","",""); 
    //$("#Button-Game").animate({opacity:"toggle"},1000,function(){});
    
    $("#Button-Game-" + sex).animate({opacity:"toggle"},500,function(){
        xmlhttpPost("gioca-doppio.asp","Game-WebForm","Result-PostClick-Game","","AfterPlayClick('" + sex + "')");
    }); 
}

function AfterPlayClick(sex) {
    if (document.getElementById('NoWin')){
        $("#Content-Desc-Premio").animate({opacity:"toggle"},500,function(){
            document.getElementById('Button-Game-' + sex).style.backgroundImage='url("images/gioca/btn_nowin_' + sex + '.jpg")';
            document.getElementById('Button-Game-' + sex).style.cursor='default';
            document.getElementById('Button-Game-' + sex).onclick=function(){};
            setTimeout(function(){
                $("#Button-Game").animate({opacity:"toggle"},1000,function(){
                    $("#Label-PostResult").html("<b>Ritenta la fortuna ogni giorno<br /> fino al 18 dicembre</b>");
                    $("#Label-PostResult").animate({opacity:"toggle"},1000,function(){});
                });
            },500);
        
        });
    } else if(document.getElementById('Winner')) {
        $("#Content-Desc-Premio").hide();
        $("#Winner").animate({opacity:"toggle"},1000,function(){});
    }
    
}
    


