/* stato mousedown dei pulsanti */
function buttons(){
	$("input.button, #confirm a, input.button_right, input.button3").mousedown(function(){
		$(this).css("background","url(../img/bg_butt_down.gif) repeat-x #e3df7b");
	}).mouseup(function(){
		$(this).css("background","url(../img/bg_butt.gif) repeat-x #f7f386");
	});
}

/* country container */
var myWidth = 0, myHeight = 0,  myWidth_1 = 0, myHeight_1 = 0,  myWidth_2 = 0, myHeight_2 = 0;
function country(){
	$("a.framebox").click(function(){
		var url = $(this).attr("href");

		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth_1 = window.innerWidth;
			myHeight_1 = window.innerHeight;		
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth_1 = document.documentElement.clientWidth;
			myHeight_1 = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth_1 = document.body.clientWidth;
			myHeight_1 = document.body.clientHeight;
		}
		
		myWidth_2 = document.body.clientWidth;
		myHeight_2 = document.body.clientHeight;
		
		if (myWidth_1 > myWidth_2) {
			myWidth = myWidth_1-17;
		} else {
			myWidth = myWidth_2;
		}
		
		if (myHeight_1 > myHeight_2) {
			myHeight = myHeight_1-20;
		} else {
			myHeight = myHeight_2; 
		}

		
//		alert (myWidth + " x " + myHeight);		
//		alert ("myHeight:" + myHeight + "px\n" + "myHeight_1:" + myHeight_1 + "px\n" + "myHeight_2:" + myHeight_2 + "px\n");
//		return false;
		
		$('#back').remove();
		$('#choose').remove();
		$('body').append('<div id="back"></div>');
		$('#back').css({width:myWidth, height:myHeight+20, background:'#000', opacity:0, position:'absolute', top:'0px', left:'0px', zIndex:1000});
		$('#back').animate({opacity:0.8},500,function(){
			$('body').append('<div id="choose"></div>');
			$('#choose').css({width:myWidth, background:'url(/img/bg_choose_language.gif) repeat-x #fff top left!important', height:'480px', opacity:0, position:'absolute', top:'0px', left:'0px', top:'50%', marginTop:'0', zIndex:1200});
			$('#choose').animate({opacity:1, marginTop:'-240px'},500,function(){
				$('#choose').append('<iframe align="middle" id="iCountry" frameborder="0" height="480" scrolling="auto" src="'+url+'" width="100%"></iframe>');
		});		
		//$.scrollTo("#header",800);
	});
		
		function closeIt() {
			$('#choose').animate({opacity:0},500,function(){
				$('#back').animate({opacity:0},500,function(){
					$('#choose').remove();
					$('#back').remove();
				});
			});
		}	
		$('#back').click(closeIt);
		$('a.closeFrame').click(function(){
			alert ($(this).html());
		});
		
		return false;
		
	});
}

window.onresize = function() {
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth_1 = window.innerWidth;
			myHeight_1 = window.innerHeight;		
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth_1 = document.documentElement.clientWidth;
			myHeight_1 = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth_1 = document.body.clientWidth;
			myHeight_1 = document.body.clientHeight;
		}
		// Nel caso di pagina con iFrame viene segnalato sempre un errore
		// andando a recuperare clientWidth e clientHeight. Il try evita l'errore
		try
		{
			myWidth_2 = document.body.clientWidth;
			myHeight_2 = document.body.clientHeight;
			
			if (myWidth_1 > myWidth_2) {
				myWidth = myWidth_1-17;
			} else {
				myWidth = myWidth_2;
			}
			
			if (myHeight_1 > myHeight_2) {
				myHeight = myHeight_1-20;
			} else {
				myHeight = myHeight_2;
			}
			
			$('#back').css({width:myWidth, height:myHeight+20});
			$('#choose').css({width:myWidth});
		}
		catch (e)
		{
		}
}



/* funzione tabs menu prodotti */
var querystring=location.href;
var tab;
function tabbIt() {
	if (querystring.search("tabs_")!=-1) {
		tab = querystring.substr(querystring.search("tabs_"),querystring.search("tabs_")+6);
	} else if (querystring.search("product")!=-1) {
		tab = "tabs_6";
	} else {
		// ciclo i tab per vedere se il trim della lunghezza dell'html è maggiore di 0
		$("#tabs div[id^='tabs_']").each(function(){
			if($.trim($(this).html()).length > 1) {
				tab = $(this).attr("id");
				return false;
			}
		});
	}
	$("#tabs_ul li a").removeClass("on");
	$("#tabs_ul li a[href='#"+tab+"']").addClass("on");
	$("#tabs div[id^='tabs_']").hide();
	$("#tabs div#"+tab).show();

	$("#tabs_ul li a").click(function(){
		tab = $(this).attr("href");
		$("#tabs_ul li a").removeClass("on");
		$("#tabs_ul li a[href='"+tab+"']").addClass("on");
		$("#tabs div[id^='tabs_']").hide();
		$("#tabs div"+tab).show();
		if (tab.indexOf("#tabs_6")!=-1 || tab.indexOf("#tabs_7")!=-1) {
			location.href = location.href.substr(0,location.href.indexOf("#")) + "#product";
		}
		return false;
	});
}

// funzione per nascondere un tab nei prodotti se il suo contenuto è nullo
function hideEmptyTab() {
	$("#tabs div[id^='tabs_']").each(function(){
		thisId = $(this).attr("id");
		if($.trim($(this).html()) == "") {
			$(this).remove();
			$("#tabs_ul li a[href='#" + thisId + "']").parent().remove();
		}
	});
	
	$("#tabs div#tabs_4").each(function(){
		if($(this).find("tr").size() == 0) {
			$(this).remove();
			$("#tabs_ul li a[href='#tabs_4']").parent().remove();
		}
	});
}


/* funzione innermenu */
function innerMenu() {
	$("#inner_menu ul li a.on").not($("#inner_menu ul li ul li a.on")).next().show();
	$("#inner_menu ul li a").not($("#inner_menu ul li ul li a")).click(function(){
		if ($(this).attr("class")=="on") {
			$(this).removeClass("on").next().slideUp("normal");
		} else {
			$("#inner_menu ul li a.on").not($("#inner_menu ul li ul li a.on")).removeClass("on").next().slideUp("normal");
			$(this).addClass("on").next().slideDown("normal");
		}
	});
}


/* funzione innergallery */
function innerGallery() {
	nFigliVideo = $("#inner_video h3").next().find("li").size();
	var videoHeight = "";
	switch (nFigliVideo) {
		case 1:
			videoHeight = "85px";
		break;
		case 2:
			videoHeight = "167px";
		break;
		case 3:
			videoHeight = "250px";
		break;
	}
	
	
	nFigliPhoto = $("#inner_photo h3").next().find("li").size();
	var photoHeight = "";
	switch (nFigliPhoto) {
		case 1:
			photoHeight = "85px";
		break;
		case 2:
			photoHeight = "167px";
		break;
		case 3:
			photoHeight = "250px";
		break;
	}
	
	
	if ($("#inner_video ul").size()) {
		$("#inner_photo ul").css({padding:"0px 6px", height:0});
	} else {
		$("#inner_photo ul").css("height",photoHeight);
	}
	
	$("#inner_video ul").css("height",videoHeight);
	
	$("#inner_photo h3").mouseover(function(){
		$("#inner_photo ul").stop().animate({height:photoHeight},400,function(){$("#inner_photo h3").addClass("on");}).css({padding:"6px 6px 2px 6px"});
		$("#inner_video ul").stop().animate({height:"0px"},400,function(){$("#inner_video h3").removeClass("on");}).css({padding:"0px 6px"});
		//$("#inner_photo ul").stop().animate({padding:"6px 6px 2px 6px", height:photoHeight, display:"block"},400,function(){$("#inner_photo h3").addClass("on");});
		//$("#inner_video ul").stop().animate({padding:"0px 6px", height:"0px", display:"none"},400,function(){$("#inner_video h3").removeClass("on");});
	});
	
	$("#inner_video h3").mouseover(function(){
		$("#inner_video ul").stop().animate({height:videoHeight},400,function(){$("#inner_video h3").addClass("on");}).css({padding:"6px 6px 2px 6px"});
		$("#inner_photo ul").stop().animate({height:"0px"},400,function(){$("#inner_photo h3").removeClass("on");}).css({padding:"0px 6px"});

		//$("#inner_video ul").stop().animate({padding:"6px 6px 2px 6px", height:videoHeight, display:"block"},400,function(){$("#inner_video h3").addClass("on");});
		//$("#inner_photo ul").stop().animate({padding:"0px 6px", height:"0px", display:"none"},400,function(){$("#inner_photo h3").removeClass("on");});
	});
	
	$("#highlights h3").click(function(){
		if($(this).attr("class")=="on"){
				$("#highlights").find("h3").parent().find("ul").stop().animate({padding:"0px 6px", height:"0px", display:"none"},400,function(){
	$("#highlights").find("h3").removeClass("on");																													});
			} else {
			$("#highlights").find("h3").addClass("on").parent().find("ul").stop().animate({padding:"6px 6px 2px 6px", height:"250px", display:"block"},400);
		}
	});

}


// funzione inner_home_old
function innerHomeOld() {
	if ($("#inner_home").size()) {
		$("#inner_home_chiudi").click(function(){
			if ($(this).attr("class")=="chiuso") {
				$("#inner_home_chiudi").animate({right:"141px"},200);
				$("#inner_home_content").animate({width:"125px"},200);
				$("#inner_home").animate({width:"157px"},200, function(){
					$("#inner_home_chiudi").removeClass("chiuso");
				});
			} else {
				$("#inner_home_chiudi").animate({right:"10px"},200);
				$("#inner_home_content").animate({width:"0px"},200);
				$("#inner_home").animate({width:"25px"},200, function(){
					$("#inner_home_chiudi").addClass("chiuso");
				});
			}
			return false;
		});
	}
}


function innerHome() {
	if ($("#inner_home").size()) {
		$("#inner_home h3").mouseover(function(){
			if ($(this).attr("class") != "on") {
				$("#inner_home").animate({height:"20px"},400);
				$("#inner_home_content").animate({height:"0px", opacity:0},400);
				$("#inner_home h3").addClass("on");
			} else {
				$("#inner_home").animate({height:"355px"},400);
				$("#inner_home_content").animate({height:"349px", opacity:1},400);
				$("#inner_home h3").removeClass("on");
			}
		});
	}
}


// funzione tooltip
function tooltip(){
	$("a.tooltip").mouseover(function(){
		var txt = $(this).attr("title");
		$(this).after("<span class='tool_wrap'><div class='tooltipz'>"+txt+"</div></span>");
		$(".tool_wrap").css("opacity",0.9);
		return false;
	});
	$("a.tooltip").mouseout(function(){
		$(this).css("position","static");
		$(this).next().remove();
		return false;
	});
}


function toolFirstSignUp() {
	//  Yes, I'd like to create a Technogym account.
	if (location.href.indexOf('co_id=906') == -1 && location.href.indexOf('co_id=1673') == -1) {
		$("#pass_account > label > em").html('')
		$("#pass_account2 > label > em").html('')			
		$("#pass_account").hide();
		$("#pass_account2").hide();
		$("#signup_pass_1").val('')
		$("#signup_pass_2").val('')		
		$("#signup_account").click(function(){
			if($(this).attr("checked")){
				$("#pass_account > label > em").html('*')
				$("#pass_account2 > label > em").html('*')	
				$("#pass_account").show();
				$("#pass_account2").show();
			} else {
				$("#signup_pass_1").val('')
				$("#signup_pass_2").val('')			
				$("#pass_account > label > em").html('')
				$("#pass_account2 > label > em").html('')				
				$("#pass_account").hide();
				$("#pass_account2").hide();
			}
		});
	} 
}

function countryOnChange() {
	// al change della select country
	toggleProvincia()
	}

// funzione per recuperare l'id di un prodotto e evidenziarlo nell'inner_menu
function getMyOn() {
	if ($("#inner_title").size() && $("#inner_menu").size()) {
		$("#inner_menu ul li a").each(function(){
			if ($(this).html() == $("#inner_title").html()) {
				$(this).addClass("on");
			}
		});
	}
}


// funzione per alternare il colore delle righe nelle tabelle
function tableEvent() {if ($("table.events").size()){$("table.events tr:even").addClass("row_1");}}


// funzione box linea categorie
function pocCatLinea(){
	if ($(".wrap_cat")) {
		var firstTime = true;
		$(".wrap_cat h2").click(function(){
			var myBox = $(this).next();
			if (myBox.is(":visible")){
				myBox.hide();
				$(this).css("background","url(../img/bg_h2_wrap_cat.gif) no-repeat 695px -33px"); 
			} else {
				myBox.show();
				$(this).css("background","url(../img/bg_h2_wrap_cat.gif) no-repeat 695px 0px"); 
			}
			//$(".wrap_cat2:visible").not(myBox).hide().prev().css("background","url(../img/bg_h2_wrap_cat.gif) no-repeat 695px -33px"); //per chiuderli tutti la prima volta che si clicca.
		});
	}
}

// funzione box linea prodotti
function popLinea() {
	if ($(".wrap_linea")) {
		$(".wrap_linea").each(function(){
			$(this).append("<div class='box_linea'><h2>" + $(this).find("h2").html() + "</h2>" + $(this).find("p").html() + "</div>");			
		});
		$(".box_linea").hide();
			
		$(".wrap_linea img").mouseover(function(){
			if ($(this).parent().parent().find(".box_linea").size()) {
				$(this).parent().parent().find(".box_linea").stop().animate({opacity:0.9},200).show();
			}
			//$(this).find(".box_linea").show();
		});
			
	
		$(".wrap_linea img").mouseout(function(){
			if ($(this).parent().parent().find(".box_linea").size()) {
				$(this).parent().parent().find(".box_linea").stop().hide();
			}
			//$(this).find(".box_linea").hide();
		});
	}
}


// toggle lista provincia / provincia campo libero
function toggleProvincia() {
		
	if ((document.getElementById('signup_country') && document.getElementById('signup_province')) ||
		(document.getElementById('signup_country') && document.getElementById('club_province')) )
	{
		var f_prov;
		var f_state;
		if (document.getElementById('signup_province'))
		{
			f_prov = 'signup_province';
			f_state = 'signup_state';
		}
		if (document.getElementById('club_province'))
		{
			f_prov = 'club_province';
			f_state = 'club_state';
		}
		
		var Country,i;
		Country = new Array('72','95','114','202','204')
		i = 0;		
		//$("#CercaCAP").hide();
		$("#CercaCAP").show(); //ora lo mettiamo sempre
		$("#lState").show();
		$("#" + f_state).show();
		$("#lProvince").hide();	
		$("#" + f_prov).hide();	
		while (i<Country.length)	
		{
			if ($("#signup_country").val() == Country[i]) 
			{			
				var t = new Date();
				$.get("/bom/includes/fSignUpAJAX.asp?act=PopulateProvince&p1=" + $("#signup_country").val() + "&p2=" + f_prov + "&t=" + t ,{},function(data){ 																																								
					$("#" + f_prov).after(data).remove(); 		
					$("#" + f_state).val('');
				}); 
				/*if ($("#signup_country").val() == '114'){
						$("#CercaCAP").show();
				}*/
				$("#lProvince").show(); $("#" + f_prov).show();	
				$("#lState").hide(); $("#" + f_state).hide();
				i = Country.length + 1;
			}
 		 	i++; 			
		}		
	}	
}


// local menu - apertura chiusura sottolivelli
function localMenu() {
	if ($("#local_menu").size()) { // controllo se esiste il #local_menu

		if ($("#local_menu ul li a[href='#']").size()) { // controllo se all'interno esiste un link con ancora
			
			if ($("#local_menu ul li a[href='#']").next().find("span.on").size()){ // controllo se ha figli con .on
				$("#local_menu ul li a[href='#']").next().find("span.on").parent().parent().prev().css("background","transparent url(../img/arrow_bold.gif) no-repeat scroll left center").css("font-weight","bold").css("color","#42525A");
			} else {
				$("#local_menu ul li a[href='#']").next().hide();
			}
			
			$("#local_menu ul li a[href='#']").click(function(){
				if ($(this).next().is(":visible")) {
					$(this).next().slideUp("normal");
				} else {
					$(this).next().slideDown("normal");
				}
				return false;
			});
			
		}
		
	}
}


// shop
function toggleProvinciaShop() {
	if (document.getElementById('signup_countryShop') && document.getElementById('signup_province2')) {
		var Country,i;
		Country = new Array('72','95','114','202','204')		
		i = 0;		
		$("#lState2").show(); $("#signup_state2").show();
		$("#lProvince2").hide();	 $("#signup_province2").hide();	
		while(i<Country.length)	{
			if ($("#signup_countryShop").val() == Country[i]) {
				var t = new Date()
				$.get("/bom/includes/fSignUpAJAX.asp?act=PopulateProvince&p1=" + $("#signup_countryShop").val() + "&p2=signup_province2&t=" + t,{},function(data){ 
					$("#signup_province2").after(data).remove(); 		
					$("#signup_state2").val('');
				}); 
				$("#lProvince2").show(); $("#signup_province2").show();	
				$("#lState2").hide(); $("#signup_state2").hide();
				i = Country.length + 1;
			} 
 		 	i++; 			
		}		
	}
	
	if (document.getElementById('signup_countryShop_Billing') && document.getElementById('signup_province3')) {
		var Country,i;
		Country = new Array('72','95','114','202','204')		
		i = 0;		
		$("#lState3").show(); $("#signup_state3").show();
		$("#lProvince3").hide();	 $("#signup_province3").hide();	
		while(i<Country.length)	{
			if ($("#signup_countryShop").val() == Country[i]) {
				var t = new Date()
				$.get("/bom/includes/fSignUpAJAX.asp?act=PopulateProvince&p1=" + $("#signup_countryShop_Billing").val() + "&p2=signup_province3&t=" + t,{},function(data){ 
					$("#signup_province3").after(data).remove(); 		
					$("#signup_state3").val('');
				}); 
				$("#lProvince3").show(); $("#signup_province3").show();	
				$("#lState3").hide(); $("#signup_state3").hide();
				i = Country.length + 1;
			} 
 		 	i++; 			
		}		
	}
	
}


function showPaymentAlert(c)
{
	$(".signup_alert_show").addClass("signup_alert_hide").removeClass("signup_alert_show");
	$("#signup_payments_alert" + c.value).addClass("signup_alert_show").removeClass("signup_alert_hide");	
}

function toggleMarket()
{
	if (document.getElementById('signup_markets') && document.getElementById('signup_club')) 
	{	
		// Verifico se sono in un centro fitness
		if ($('#signup_markets').val() == 9)
			$('#li_club_name').show();
		else
			$('#li_club_name').hide();
	}
}


/* allineaCheckout */
function allineaCheckout(){
	if ($("#checkout").size()) {
		var h3Width = $("#checkout h3").width()+8; // 8 è il padding dell'h2
		var maxUlWidth = 718 - h3Width - 5; // 5 è il padding dell'ul
	
		var ulWidth = 0;
		var numMarkets = $("#checkout ol li").size();
		
		$("#checkout ol li").each(function(i){
			ulWidth = ulWidth + $("#checkout ol li:eq("+i+")").width();
		});
		
		var padding = Math.floor(((maxUlWidth - ulWidth)/numMarkets)/2);
		$("#checkout ol li").css("padding","3px " + padding + "px");
		
		$("#checkout ol li:last").css("background","none");
	}
}


function control_Number(ctrl_name){
    if (($("#" + ctrl_name).val())) {
        $("#" + ctrl_name).keyup(function() { $(this).val($(this).val().replace(/^([+\d]?)\D*([\d]*)\D*([\d]*)\D*([\d]*)\D*/, "$1$2$3$4").substr(0, 15)); });
        $("#" + ctrl_name).blur(function() { $(this).val($(this).val().replace(/^([+\d]?)\D*([\d]*)\D*([\d]*)\D*([\d]*)\D*/, "$1$2$3$4").substr(0, 15)); });
        $("#btn_send").click(function() { $("#" + ctrl_name).val($("#" + ctrl_name).val().replace(/^([+\d]?)\D*([\d]*)\D*([\d]*)\D*([\d]*)\D*/, "$1$2$3$4").substr(0, 15)); });
    }
	/*$("#"+ctrl_name).keyup(function(){
		var ftChar
		var allChar
		ftChar = $(this).val().substr(0,1);
		allChar = $(this).val().substr(1,19);
		ftChar= ftChar.replace(/^[^+\d]/,'');
		allChar= allChar.replace(/\D+/,'');
		$(this).val(ftChar+allChar); ///^[\+0-9]([0-9]{1,19})$/
	});*/
}

function control_Number_NoPiu(ctrl_name){
	$("#"+ctrl_name).keyup(function(){$(this).val($(this).val().replace(/^([\d]?)\D*([\d]*)\D*([\d]*)\D*([\d]*)\D*/,"$1$2$3$4").substr(0,15));});
	$("#"+ctrl_name).blur(function(){$(this).val($(this).val().replace(/^([\d]?)\D*([\d]*)\D*([\d]*)\D*([\d]*)\D*/,"$1$2$3$4").substr(0,15));});
	$("#btn_send").click(function(){$("#"+ctrl_name).val($("#"+ctrl_name).val().replace(/^([\d]?)\D*([\d]*)\D*([\d]*)\D*([\d]*)\D*/,"$1$2$3$4").substr(0,15));});
}


/* legge i parametri dalla querystring */
function objQueryString(qs){ 
	dic = new Array()
	if(!qs)	qs = document.location.search
	qs = qs.replace(/\?/,'')
	aQs = qs.split('&')
	txt = ''
	for(i=0;i<aQs.length;i++){
		aPV = aQs[i].split('=')
		dic[aPV[0]]=aPV[1]
	}
	return dic
}


// get querystring
function queryStr(el) {
	url = window.location.search.substring(1);
	myArr = url.split("&");
	for (i=0;i<myArr.length;i++) {
		myRes = myArr[i].split("=");
		if (myRes[0] == el) {
			return myRes[1];
		}
	}
}


/* append target */
/*
function appendTarget() {
	var myTarget = "";
	switch ($("#menu").attr("class")){
		case "ab":
		myTarget = "about";
		break;
		case "cf":
		myTarget = "commercial";
		break;
		case "hf":
		myTarget = "home";
		break;
		default:
		myTarget = "about";
	}
	
	if (!myTarget) {
		myTarget = queryStr("target");
	}
	$("a[href]").not($("#menu a, #logo a, #top_tools a")).each(function(i){
		var href = $(this).attr("href");
		if (href.indexOf("#") == 0 || href.indexOf("mailto:") == 0) {
			return false;
		} else if (href.indexOf("http://") != 0) {
			if (href.indexOf("target") == -1) {
				if (href.indexOf("?")!= -1) {
					//alert ("target: " + myTarget + "\nlink: " + $(this).text() + "\nhref: " + href);
					$(this).attr("href",href+"&target="+myTarget);
				} else if (href.indexOf("&")== -1) {
					$(this).attr("href", href+"?target="+myTarget);
				}
			}
		}
	});
}
*/


/* linea click */
function lineaClick(){
	if ($("#linea_desc").size()) {
		$("#linea_click a").click(function(){
			if ($(this).attr("class") == "close") {
				$("#linea_slide").slideUp(400);
				$(this).attr("class","open").removeClass("close");
			} else {
				$("#linea_slide").slideDown(400);
				$(this).attr("class","close").removeClass("open");
			}
			return false;
		});
	}
}




/* slideshow */
$.fn.slideshow = function(settings) {
	settings = jQuery.extend({
  	"type":"a",
		"fade":800,
		"loop":1000
	}, settings);
	
	return this.each(function() {
		var $this = $(this);
		var maxEl = $this.find(settings.type).size();
		var i = maxEl;
		function loop() {
			i--;
			if (i == 0) {
				$this.find(settings.type).eq(maxEl-1).fadeIn(settings.fade,function(){
					$this.find(settings.type).show();
				});
				i = maxEl;
			} else {
				$this.find(settings.type).eq(i).fadeOut(settings.fade);
			}
		}
		
		var myloop = setInterval(function(){
			loop();
		},settings.loop);
	});
}



/* init */
$(document).ready(function(){
	hideEmptyTab();
	//print
	var isPrint=false;
	if (document.location.href.indexOf("print=on") != -1) isPrint=true;
	
	if (!isPrint) {
		tabbIt();
	}		
	country();
	// open country choice by qs
	if (document.location.href.indexOf("choice=on") != -1) {
		$("#id_country").attr("href","country.asp?choice=on");
		$("#id_country").click();
		}	
	// open Tell a friend by qs
	if (document.location.href.indexOf("taf=on") != -1) 
	{
		// memorizzo in array i parametri della querystring
		qs = objQueryString()
		tb_show('Tell a Friend','/tell_friend.asp?co_id='+qs['co_id']+'&KeepThis=true&TB_iframe=true&height=450&width=550','');
	}	
	/*if (document.location.href.indexOf("iaf=on") != -1) 
	{
		// memorizzo in array i parametri della querystring
		qs = objQueryString()
		tb_show('Invite a Friend','/invite_friend.asp?co_id='+qs['co_id']+'&iaf_id='+qs['iaf_id']+'&KeepThis=true&TB_iframe=true&height=450&width=550','');
	}*/
	//Alza l'immagine trasparente se c'è l'inner menu e manca l'immagine di prodotto
	if ($("#product img").size() > 0 )
	{
		if ($("#product img:first").attr("height")=="1" && $("#inner_menu").size() >0)
		{
			$("#product img:first").attr("height","100");
		}
	}
	
	
	innerMenu();
	innerHome();
	innerGallery();
	//tooltip();
	toolFirstSignUp();
	getMyOn();
	tableEvent();
	pocCatLinea();
	popLinea();
	toggleProvincia();
	toggleProvinciaShop();
	toggleMarket();
	localMenu();
	buttons();
	//appendTarget();
	lineaClick();
	if ($("#linea_img").size()) { $("#linea_img").slideshow({"type":"img","fade":800,"loop":4000}); }
	
// visioweb bar 03/08/2010
	try{
		if ( document.cookie.match('VisioWebBar=True') && parent.location.href === document.location.href){
			var _fw = null;
			if(typeof FlashWrite === 'function'){
				_fw = FlashWrite;
				FlashWrite = jQuery.noop;
			}
			var co_id = location.search.split(/co_id=/i)[1].split('&')[0];
			$('#container').parent().children('div').wrapAll('<div style="overflow: auto; height: '+($(window).height() - 44).toString()+'px; display:block"></div>');
			$('body')
				.css('margin-top','44px')
				.append('<div id="frame_visioweb" style="position:absolute; left:0; top:0; width:100%; z-index:9999; position:fixed;"></div>');
			$('#frame_visioweb').load('/bom/includes/fGalleriesAJAX.asp?act=VisioBar',{'co_id' : co_id});
			
			if (_fw != null)
				FlashWrite = _fw;
		}
	}catch(err){}
//
});
