function getElementsIdByClass(tag, classe){
	ElementsId = new Array();
	var c = 0;
	var tutti = document.getElementsByTagName(tag);
	
	for(var i=0; i<tutti.length; i++){
		if(tutti.item(i).className==classe){
			ElementsId[c]=tutti.item(i).id;
			c++;
		}
	}
	return ElementsId;
}

function Ridimensiona(max_height, min_height, navigation_height, tag, classe){
	var total_height = document.documentElement.clientHeight - navigation_height;
	var height = 0;
	var width = 0;
	
	if(min_height<=total_height && total_height<=max_height){
		height = total_height;
		if(classe=="ridimensiona3"){
			/*
			width = ($("img-li-1").offsetWidth * 2) + 30;
			
			if(width>957){
				width = 957;
			}
			*/
			$("menu").style.marginTop = "-92px"
		}
	}
	else if(total_height >= max_height){
		height = max_height;
		if(classe=="ridimensiona3"){
			width = 957;
			$("menu").style.marginTop = "-89px"
		}
	}
	else{
		height = min_height;
		if(classe=="ridimensiona3"){
			width = 783;
			$("menu").style.marginTop = "-92px"
		}
	}
	
	getElementsIdByClass(tag, classe);
	for(var i=0; i<ElementsId.length; i++){
		$(ElementsId[i]).style.height = height + "px";
		
		if(tag=="li"){
			$(ElementsId[i]).style.width = $("img-" + ElementsId[i]).offsetWidth*2 + "px";
		}
		else if(classe=="ridimensiona2"){
			//$(ElementsId[i]).style.width = ($("immagine").offsetWidth + 125) + "px";
		}
		else if(classe=="ridimensiona3"){
			// $(ElementsId[i]).style.width = width + "px";
		}
	}
}

function Ridimensiona2(id, max_height, min_height, navigation_height){
	var immagine = document.getElementById(id);
	var height = document.documentElement.clientHeight - navigation_height;
	
	if(min_height<=height && height<=max_height){
		immagine.height = height;
	}
	else if(height >= max_height){
		immagine.height = max_height;
	}
	else{
		immagine.height = min_height;
	}
}

function Ridimensiona3(div_id, max_height, min_height, navigation_height, origHeight, origWidth){
	
	var div = document.getElementById(div_id);
	var total_height = document.documentElement.clientHeight - navigation_height;
	
	if(min_height<=total_height && total_height<=max_height){
		height = total_height;
	}
	else if(total_height >= max_height){
		height = max_height;
	}
	else{
		height = min_height;
	}
	
	div.style.height = height + "px";
	div.style.width = Math.round((origHeight/origWidth).toFixed(2) * height) + "px";
}

function Ridimensiona4(div_id, max_height, min_height, navigation_height, origHeight, origWidth){
	
	var div = document.getElementById(div_id);
	var total_height = document.documentElement.clientHeight - navigation_height;
	
	if(min_height<=total_height && total_height<=max_height){
		height = total_height;
	}
	else if(total_height >= max_height){
		height = max_height;
	}
	else{
		height = min_height;
	}
	
	div.style.height = height + "px";
	div.style.width = Math.round((origWidth/origHeight).toFixed(2) * height) + "px";
}

var immagini=new Array()
function Preload(){   
	var total=Preload.arguments.length;
	var cc=0;
	
	for (cont=0;cont<total;cont++){
		immagini[cont]=new Image();
		immagini[cont].src=Preload.arguments[cont];
		immagini[cont].onload=function(){cc++;}
	}
}

function Cambia(img){
	$("immagine").tween("opacity", 0);
	( function(){ $("immagine").src=img; $("immagine").tween("opacity", 1); } ).delay(480);
}

function Provincia(nazione,prov){
	if(document.getElementById(nazione).value!="195") {
		document.getElementById(prov).value = "0"; 
		document.getElementById(prov).disabled = "disabled";
	} 
	else {
		document.getElementById(prov).value="AG";
		document.getElementById(prov).disabled = "";
	}
}
