c = false;

window.onload = function(){
	//ricavo tutti i banner della pagina
	listaBanner = $(".imgBanners");
	for(i=0;i<listaBanner.length;i++){
		urlPhp = "dir=banner&file=upBanner&id=" + listaBanner[i].id;
		$.ajax({
			type: "GET",
			url: "../../blocchi.php?",
			data: urlPhp,
			success: function(msg){
				//alert(msg);
			}
		});
	}
	
	//Get our elements for faster access and set overlay width
	var div = $('div.sc_menu'),
		ul = $('ul.sc_menu'),
		ulPadding = 0;
	if(div)
	{
	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars	
	div.css({overflow: 'hidden'});
	
	//Find last image container
	var lastLi = ul.find('li:last-child');
	
	//When user move mouse over menu
	div.mousemove(function(e){
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
	}
	$(".ghome").click(function() { // bind click event to link
		clickHome(this.href);
		$(this).prev("li").addClass("selected");
		return false;
	});
	
};

$(document).ready(function(){
	$(".cbox").colorbox();
});
						   
//funzione che incrementa il click di un
function clickHome(urlLink) {
	arrUrl = urlLink.split("?");
	$.ajax({
		type: "GET",
		url: arrUrl[0]+"?",
		data: arrUrl[1],
		success: function(msg){
			$("#gallery").html(msg);
		}
	});	
}
function clickBanner(idBanner){
	urlPhp = "dir=banner&file=upBanner&cp=click&id=" + idBanner;
	$.ajax({
		type: "GET",
		url: "../../blocchi.php?",
		data: urlPhp,
		success: function(msg){
			//alert(msg);
		}
	});
}
function redir(url){
	window.location=url;
}
function updatecaptcha() {
   img = document.getElementById('imgCaptcha'); 
   //Change the image
   img.src = '../../lib/captcha/immagine.php?' + Math.random();
}
