window.onload = function() {
	renderSwfs();
	
	if (document.getElementById("menu")) {
		var tags = document.getElementById("menu").getElementsByTagName("div");
		for (var i = 0; i <  tags.length  ; i++) {
			var tag = tags[i];
			var tagClassName = tag.className;
			if (tagClassName.indexOf("menuItem") != -1) {
				tag.onmouseover = function() {
					var thisId = this.id;
					//alert(thisId);
					document.getElementById(thisId).className += " on";
				}
				tag.onmouseout = function() {
					var thisId = this.id;
					//alert(thisId);
					document.getElementById(thisId).className = document.getElementById(thisId).className.replace(" on", "");
				}
			}
		}
	}
	
	if (document.getElementById("i_username")) {
		i_u = document.getElementById("i_username");
		i_p = document.getElementById("i_password");
		i_u.onclick = function() {
			clearLogin();
		}
		i_p.onclick = function() {
			clearLogin();
		}
	}
	if (document.getElementById("mapImgMap")) {
		var tags = document.getElementById("mapImgMap").getElementsByTagName("area");
		for (var i = 0; i <  tags.length; i++) {
			var tag = tags[i];
			//if (tag.className == "trigger") {
			tag.onclick = function() {
				thisClass = this.className;
				thisAlt = this.alt;
				textId = thisClass.replace("map_", "text_")
				var tagsD = document.getElementById("texts_map").getElementsByTagName("div");
				for (var i = 0; i <  tagsD.length; i++) {
					var tagD = tagsD[i];
					tagD.style.display = "none";
				}
				document.getElementById("regioneStr").innerHTML = thisAlt;
				if (document.getElementById(textId)) {
					toggle(textId);
				}
			}
		}
	}
	if (document.getElementById("regione")) {
		var regione = document.getElementById("regione").value;
		if (regione != "") {
			document.getElementById('provincia_' + regione).style.display = "block";
			document.getElementById('provincia_' + regione).disabled = false;
		}
	}
}

function selectProv(prov) {
	var regione = document.getElementById("regione").value;
	if (regione != "") {
		var tags = document.getElementsByTagName("select");
		for (var i = 0; i <  tags.length  ; i++) {
			if (tags[i].className == "provincia") {
				thisId = tags[i].id;
				//alert(thisId);
				document.getElementById(thisId).style.display = "none";
				document.getElementById(thisId).disabled = true;
			}
		}
		document.getElementById(prov).style.display = "block";
		document.getElementById(prov).disabled = false;
	}
}


function clearLogin() {
	if (i_u.value == "username" && i_p.value == "********") {
		i_u.value = "";
		i_p.value = "";
	}
}

function renderSwfs() {
	//if (document.getElementById("swf_banner")) {
		//var params = {
			//wmode: "transparent"
		//};
		//swfobject.embedSWF("swf/banner_top.swf", "swf_banner", "490", "95", "9.0.0", "swf/expressInstall.swf", {}, params, {});
	//}
	if (document.getElementById("swf_deposito")) {
		var params = {
			wmode: "transparent"
		};
		swfobject.embedSWF("swf/cartina_deposito.swf", "swf_deposito", "400", "400", "9.0.0", "swf/expressInstall.swf", {}, params, {});
	}
	if (document.getElementById("swf_studio")) {
		var params = {
			wmode: "transparent"
		};
		swfobject.embedSWF("swf/cartina_studio.swf", "swf_studio", "400", "400", "9.0.0", "swf/expressInstall.swf", {}, params, {});
	}
	/*if (document.getElementById("swf_clickus")) {
		var params = {
			wmode: "transparent"
		};
		var nome = document.getElementById("swf_clickus").innerHTML;
		swfobject.embedSWF("swf/" + nome + ".swf", "swf_clickus", "682", "293", "9.0.0", "swf/expressInstall.swf", {}, params, {});
	}*/
}

function toggle(id_objs) {
	var id_obj_array  = id_objs.split(", ");
	for (n=0; n<id_obj_array.length;n++) {
		id_obj = id_obj_array[n];
		if (id_obj != "") {
			obj = document.getElementById(id_obj);
			obj.style.display = (obj.style.display == "block" ? "none" : "block");
		}
	}
}


function popUp(url,w,h) {
	window.open(url, 'popupWin', 'top=15,left=15,width=' + w + ',height=' + h).focus();
}
function popUpResize(url,w,h) {
	window.open(url, 'popupWin', 'top=15,left=15,resizable,scrollbars,width=' + w + ',height=' + h).focus();
}

function checkSize()  {
	window.resizeTo(document.images[0].width + 10, document.images[0].height + 30); window.focus();
}

function goBack() {
	history.back(-1)
}
	
function alertDelete() {
	return(confirm('Attenzione! La cancellazione non puņ essere annullata, vuoi procedere?'));
}

function checksize2()  {
	if (document.images[0].complete) {
		window.resizeTo(document.images[0].width+10,document.images[0].height+30); window.focus();
	} else {
		setTimeout('check()',250)
		}
}
