// JavaScript Document

//RESIZE CHAR
function ResizeChar(fontSize, o){
	if(ok){
		var size = $("#text,#scheda").css("font-size").substring(0, 2);
		var dimFont = parseInt(size, 10)
		if(isNaN(dimFont)){dimFont = 12;}
		if(o == "m"){
			dimFont -= 1;
			if (dimFont < fontSize){dimFont = fontSize;}
		}else{
			dimFont += 1;
			if (dimFont > fontSize){dimFont = fontSize;}
		}
		$("#text,#scheda").css("font-size", dimFont + "px");
	}
} 

//DOCUMENT READY
$(document).ready(function(){
	/* IMMAGINE CENTRALE SOSTITUITA DA QUELLE NELLA GALLERY
	$("#box_related_pictures a").click(function(){
		$("img#ImageCentral").attr({ 
          src: "/img/loadingAnimation.gif",
          title: "loading..",
          alt: "loading.."
        });
		
		var titolo = $(this).attr("title");
		var immagine = $(this).attr("rel");
		
		if((titolo!='')&&(immagine!='')){
			$("img#ImageCentral").attr({ 
			  src: "/media/immagini/" + immagine,
			  title: titolo,
			  alt: titolo
			});
		}
	});*/
	
	/* Funzione per aumentare-diminuire font articolo */
	ok = (document.styleSheets) ? 1 : 0;
	$("#Ameno").click(function(){
		ResizeChar(11, "m");
	});
	$("#Apiu").click(function(){
		ResizeChar(20, "p");
	});
	
	//AREE GEO
	$("#DDL_AreeGeo").change(function(){
		$("#FormCercaProdotto").submit();
	});

	toggleProvincia();

});


function countryOnChange() {
	// al change della select country
	toggleProvincia()
}

// toggle lista provincia / provincia campo libero
function toggleProvincia() {
	if (document.getElementById('signup_country') && document.getElementById('signup_province')) {
		var Country,i;
		Country = new Array('72','95','114','202','204')
		i = 0;		
		//$("#lState").show(); $("#signup_state").show();
		$("#lProvince").hide();	 $("#signup_province").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=signup_province&t=" + t ,{},function(data){ 																																								
					$("#signup_province").after(data).remove(); 		
					//$("#signup_state").val('');
				}); 
				$("#lProvince").show(); $("#signup_province").show();	
				//$("#lState").hide(); $("#signup_state").hide();
				i = Country.length + 1;
			} 
 		 	i++; 			
		}		
	}	
}

