//CLASSIFICA
var serie= 3287;
var camp = "Seleziona il Campionato";
loadContentCl=function(aserie,acamp) {	
		serie =	aserie;
		camp = acamp;
		switch(serie) {
			case 3287:
				if (camp.indexOf('Seleziona il Campionato')>-1 ){ 
					camp = "<b style=\"color:#01AD3D\">Seleziona il Campionato</b>";					
				}else{
					camp = "<img height='20px' src='/img/scudetti/flag/italia.png' border='0' /><span><b style=\"color:#01AD3D\">" +acamp+"</b></span>";
				}
				
			break; 
			case 3288:
				camp = "<img height='20px' src='/img/scudetti/flag/italia.png' border='0' /><span><b style=\"color:#01AD3D\">" +acamp+"</b></span>";
			break; 
			case 3385:
				camp = "<img height='20px' src='/img/scudetti/flag/italia.png' border='0' /><span><b style=\"color:#01AD3D\">" +acamp+"</b></span>";
			break;
			case 3384:
				camp = "<img height='20px' src='/img/scudetti/flag/italia.png' border='0' /><span><b style=\"color:#01AD3D\">" +acamp+"</b></span>";
			break;						
			case 3171:
				camp = "<img height='20px' src='/img/scudetti/flag/francia.png' border='0' /><span><b style=\"color:#01AD3D\">" +acamp+"</b></span>";
			break; 
			case 3265:
				camp = "<img height='20px' src='/img/scudetti/flag/spagna.png' border='0' /><span><b style=\"color:#01AD3D\">" +acamp+"</b></span>";
			break; 									
			case 3263:
				camp = "<img height='20px' src='/img/scudetti/flag/portogallo.png' border='0' /><span><b style=\"color:#01AD3D\">" +acamp+"</b></span>";
			break; 	
		}
		//$("#campsel").innerHTML = camp;
		try
		{
			document.getElementById('campsel').innerHTML = camp;
		}
		catch(e)
		{}	

		url = "/classifica/classificaWsLight.asp?serie=" + serie +"&a="+Math.floor(10000000*Math.random());
	    $.ajax({
	        type: "GET",
	        url: url,
	        dataType: 'html',		
	        success: function(html){
	                 $("#contcll").html(html);
	        },
	        error: function(){
	        },		
	        complete: function(){
	       	 $(".versligth li[title]").tooltip('#cltip'); 	
	        }
	    });
	}
$(function() { 		
// NEWS ULTIMA ORA	
	$(".newsultimaora").jCarouselLite({  
	         vertical: true,  
	         visible: 2,  
	         auto:8000,  
	         speed:800,
	         easing: 'easeOutBounce'
	     }); 	
});

//easeInOutBack
	$(document).ready(function(){
		try
		{
			$('#photos').galleryView({
				panel_width: 608,
				panel_height: 350,
				frame_width: 100,
				frame_height: 55,
			    border: 'none',
			    filmstrip_position: 'top',			    
		        transition_speed: 1200,
	            overlay_height: 52,
	            background_color: '#4b494a',
			    easing: 'easeOutBounce',
			    overlay_text_color: '#8AB134',
			    pause_on_hover: true
			});
		}
		catch(e)
		{}	


	    $(".button").hover(function(){
	        $(".button img")
	        .animate({top:"-10px"}, 200).animate({top:"-4px"}, 200) // first jump
	        .animate({top:"-7px"}, 100).animate({top:"-4px"}, 100) // second jump
	        .animate({top:"-6px"}, 100).animate({top:"-4px"}, 100); // the last jump
	    });				
	    
	var speed = 8000;
		try
		{	
			
			
			var run = setInterval('newsscoller(0,0)', speed);	
			
					
			$('#btn-pause').click(function () {
				clearInterval(run);
				return false;
			});
		
			$('#btn-play').click(function () {
				run = setInterval('newsscoller(0,0)', speed);	
				return false;
			});
			

			$('#slider').hover(
			
				function() {
					clearInterval(run);
				}, 
				function() {
					run = setInterval('newsscoller(0,0)', speed);	
				}
			); 
		}	
		catch(e){};
		
		try{
		$("div.scrollable").scrollable({easing: 'easeOutBack', speed: 700}).circular().autoscroll({ 
		    steps: 3, 
		    interval: 4000         
		});}
		catch(e){};	
		
//BOTTONI OVERLAY	
		$("#overlayCl").overlay({expose: '#000000'});
		
		$("#overprezzi").overlay({expose: '#FFFFFF'});
		
		$("#overlayProd").overlay({expose: '#000000'});
		$("#overlayReg").overlay({expose: '#000000'});
				
		$("button[rel]").each(function() { 
		  $(this).overlay({expose: '#000000'}); 
		}); 
	    //$("button[rel]").overlay({expose: '#000000'}); 
	    $("button.btnfb").click(function (){
	    	document.getElementById('ifrfacebook').src = "http://www.myphotosoccer.it:85/fbconnect/index.php"
	    });
		$("#regForm :input").tooltip({
		position: ['center', 'right'],
		offset: [-2, 10],
		effect: 'toggle',
		opacity: 0.7
		});
		$("#loginForm :input").tooltip({
		position: ['center', 'right'],
		offset: [-2, 10],
		effect: 'toggle',
		opacity: 0.7
		});
		$("#frmLogProd :input").tooltip({
		position: ['center', 'right'],
		offset: [-2, 10],
		effect: 'toggle',
		opacity: 0.7
		});		
// select the thumbnails and make them trigger our overlay
	
	try{	
	$("#triggers").each(function() { 
	  $(".fotogallery a",this).overlay({   
	    target: '#gallery',   
	    expose: '#f1f1f1'  
	  }).gallery({speed:800}); 
	});	}
	catch(e){};	
	
	try{
		$('a[rel=pgallery]',this).overlay({   
		target: '#gallery',   
		 expose: '#f1f1f1'  
	    }).gallery({speed:800});}
	catch(e){};	
	
	/*
			$("#triggers .fotogallery a").overlay({
				target: '#gallery',
				expose: '#f1f1f1'
			}).gallery({
				speed: 800
			});				
	*/

	try{  			    
		$('#faqregistrazione a').click(function(){	
			$('#ContFaq').scrollTo(this.hash, 800, {easing:'easeOutBounce'} );		
			return false;
		});}
	catch(e){};
	
	$('#galleryHome').galleryHome({
	  interval: 6000,
	  height: '230px',
	  width: '465px',
	  barPosition: 'top',
	  easing : 'easeOutBounce'
	});
		

	try{
		$('#childframe a[rel=prezzoalbum]',this).overlay({   
		target: '#gallery',   
		 expose: '#f1f1f1'
		}).gallery({speed:800});}
	catch(e){};	

	try{
		$(".fotogallery a").append("<span></span>");
		$(".fotogallery a").hover(function(){
		    $(this).children("span").fadeIn(600);
		},function(){
		    $(this).children("span").fadeOut(200);
		});}
	catch(e){};	 
	try{
		$("#scommesse").overlay({
			expose: '#ffffff',
			closeOnClick: false,
			absolute:true,
			left:'0',
			top:'0',			
			onClose: function() { 
				//document.getElementById("scReg").style.display = "none";
    	        document.getElementById("fixover").style.display = "none";
        	}
		});
	}
	catch(e){};
	
	try{
		$("#destinatari").overlay({
			expose: '#ffffff',
			closeOnClick: false,
			absolute:true,
			left:'0',
			top:'0',
	        onClose: function() { 
    	        document.getElementById("fixover").style.display = "none";
        	}/*,
        	onBeforeClose: function(){
        		document.getElementById("childframe").contentWindow.location.reload(true);
        	} */	
		});
	}
	catch(e){};
	try{
		$("#lnkreg").click(function () {
			visRegistrazione();
		});
	}
	catch(e){};
	$("#registrati").click(function () {
		$("#overlayReg").overlay({expose: '#000000' }).load();
	});
});


function visRegistrazione(){
			$("#overlayProd").overlay().close();
			$("#overlayReg").overlay({expose: '#000000' }).load();
} 
switchIfr = function(target,ifr,overL,btn){
	document.getElementById(target).src = ifr;
	$(overL).overlay().close();
	document.getElementById(btn).style.display = "none";
}
iframeOverlay = function(overlayObj,target,ifr,w,h,fixover) { 
	// es. chiamata da iframe top.iframeOverlay('nomeoverlay','targetifr','pagIframe','width','height','fixover')
	// .overlay({ onClose: function() { 
    //	        document.getElementById("fixover").style.display = "none";
    //    	}})
//  alert(ifr + " -> " +"http://quigioco.devbiz.it/skillgames");
    if (ifr == "http://quigioco.devbiz.it/skillgames"){
    	//alert("ok");
    	//document.getElementById("scReg").style.display = "block";
    }
	document.getElementById(fixover).style.width = w+"px"; 
	document.getElementById(fixover).style.height = h+"px"; 
	document.getElementById(fixover).style.marginLeft = "-" + parseInt(w/2)+"px";
	document.getElementById(fixover).style.marginTop = "-" + parseInt(h/2) +"px";
	document.getElementById(fixover).style.display = "block"; 
	$("#"+overlayObj).overlay().load();
	document.getElementById(target).innerHTML = "<iframe src='" + ifr + "' width='"+w+"' height='"+h+"' allowtransparency='true' frameborder='0' id='ifrcont' />";
};

function overlayProd(pag){
	$("#overlayProd").overlay({expose: '#FFFFFF' }).load();
	document.frmLogProd.pagret.value = pag;
}


function xmlhttpPostProd(strURL,formname,responsediv,responsemsg) {

    var xmlHttpReq = false;
    var self = this;
    var retPag;
    // Xhr per Mozilla/Safari/Ie7
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // per tutte le altre versioni di IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    retPag = document.frmLogProd.pagret.value;
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {	
		if (self.xmlHttpReq.readyState == 4) {
			updatepageProd(self.xmlHttpReq.responseText,responsediv,retPag);
		}
		else{			
			updatepageProd(responsemsg,responsediv,retPag);
		}
    }
    self.xmlHttpReq.send(getquerystring(formname));
}
function updatepageProd(str,responsediv,retpag){
	if(str.substr(0,9)=="Benvenuto"){
		try{
		//window.location.reload();		
		parent.childframe.location.href = retpag;
		document.getElementById("autenticazione").className="loggato";
		testoret="";
		testoret+='<span class="benvenuto">'+str;
		testoret+='</span><span class="carrellobtn"><a href="#" id="carrello"  title="carrello"></a></form></span><span class="personale"><a href="/areapersonale" id="areapersonale" title="area personale"></a>';
		testoret+='</span><span class="logoutbtn"><a href="/logout.asp" id="esci" title="esci"></a></span>';
		document.getElementById("autenticazione").innerHTML=testoret
		}catch(e){}
		$("#overlayProd").overlay().close();
	}
}


function overlayifr(obj) { 
	$("#overprezzi").overlay({expose: '#FFFFFF' }).load();
	document.getElementById("prezzoimg").innerHTML = "<img src='"+obj+"' />";	
};


scommesse = function(ifr){
	$("#scommesse").overlay().load();
	document.getElementById("iframe").innerHTML = "<iframe src='" + ifr + "' width='980' height='632'  />";
}

function newsscoller(prev,cmd) {

	//Get the current selected item (with selected class), if none was found, get the first item
	var current_image = $('#galleryslide li.selected').length ? $('#galleryslide li.selected') : $('#galleryslide li:first');
	var current_excerpt = $('#excerpt li.selected').length ? $('#excerpt li.selected') : $('#excerpt li:first');

	if ( $('#galleryslide li:first').hasClass("selected") ){
			if(cmd==0){
				$('#palloni li#1').html("<img src=\"/images/pallone.png\" />");			
				$('#palloni li#1').animate({marginTop:"0px"}, 100);
				$('#palloni li#2').html("<img src=\"/images/pallone_verde.png\" />");				
	 			$('#palloni li#2').animate({marginTop:"-10px"}, 200).animate({marginTop:"-4px"}, 200)  
		        .animate({marginTop:"-7px"}, 100).animate({marginTop:"-4px"}, 100) 
		        .animate({marginTop:"-6px"}, 100);  
			}
	}
	 if ( $('#galleryslide li:last').hasClass("selected") ){
 			if(cmd==0){
				$('#palloni li#3').html("<img src=\"/images/pallone.png\" />");	 
				$('#palloni li#3').animate({marginTop:"0px"}, 100);
				$('#palloni li#1').html("<img src=\"/images/pallone_verde.png\" />");				
	 			$('#palloni li#1').animate({marginTop:"-10px"}, 200).animate({marginTop:"-4px"}, 200)  
		        .animate({marginTop:"-7px"}, 100).animate({marginTop:"-4px"}, 100) 
		        .animate({marginTop:"-6px"}, 100);  
			}	
	}
	 if ( !$('#galleryslide li:first').hasClass("selected") && !$('#galleryslide li:last').hasClass("selected")  ){
			if(cmd==0){	 
				$('#palloni li#2').html("<img src=\"/images/pallone.png\" />");
				$('#palloni li#2').animate({marginTop:"0px"}, 100);
				$('#palloni li#3').html("<img src=\"/images/pallone_verde.png\" />");				
	 			$('#palloni li#3').animate({marginTop:"-10px"}, 200).animate({marginTop:"-4px"}, 200)  
		        .animate({marginTop:"-7px"}, 100).animate({marginTop:"-4px"}, 100) 
		        .animate({marginTop:"-6px"}, 100);  
		}
	}

	if (prev) {
		var next_image = (current_image.prev().length) ? current_image.prev() : $('#galleryslide li:last');
		var next_excerpt = (current_excerpt.prev().length) ? current_excerpt.prev() : $('#excerpt li:last');
	} else {
		var next_image = (current_image.next().length) ? current_image.next() : $('#galleryslide li:first');
		var next_excerpt = (current_excerpt.next().length) ? current_excerpt.next() : $('#excerpt li:first');
	}

	$('#excerpt li, #galleryslide li').removeClass('selected');
	
	next_image.addClass('selected');
	next_excerpt.addClass('selected');
	$('#mask-gallery').scrollTo(next_image, 800);		
	$('#mask-excerpt').scrollTo(next_excerpt, 800);			
	
}