<!--
	// Controlla la trasparenza delle immagini .png
	function correctPNG(){
		for(var i=0; i<document.images.length; i++){
			var img = document.images[i];
			var imgName = img.src.toUpperCase();
			if(imgName.substring(imgName.length-3, imgName.length) == "PNG"){
				var imgID = (img.id) ? "id='" + img.id + "' " : "";
				var imgClass = (img.className) ? "class='" + img.className + "' " : "";
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				var imgStyle = " display: inline-block" + img.style.cssText;
				var imgAttribs = img.attributes;
				for (var j=0; j<imgAttribs.length; j++){
					var imgAttrib = imgAttribs[j];
					if(imgAttrib.nodeName == "align"){
						if(imgAttrib.nodeValue == "left") imgStyle = "float: left;" + imgStyle;
						if(imgAttrib.nodeValue == "right") imgStyle = "float: right;" + imgStyle;
						break;
					}
				}
				var strNewHTML = "<span " + imgID + imgClass + imgTitle;
				strNewHTML += " style=\"" + "width: " + img.width + "px; height: " + img.height + "px;" + imgStyle + ";";
				strNewHTML += " filter:progid:DXImageTransform.Microsoft.AlphaImageLoader";
				strNewHTML += "(src='" + img.src + "', sizingMethod='image');\"";
				strNewHTML += "></span>";
				img.outerHTML = strNewHTML;
				i = i-1;
			}
		}
	}
	
	if(document.all)
		window.attachEvent("onload", correctPNG);
	
	window.onload = function(){
		if(navigator.appName == "Microsoft Internet Explorer"){
			var arrElements = new Array(3);
			arrElements[0] = "object";
			arrElements[1] = "embed";
			arrElements[2] = "applet";
			
			for(n=0; n<arrElements.length; n++){
				replaceObj = document.getElementsByTagName(arrElements[n]);
				
				for(i=0; i<replaceObj.length; i++){
					parentObj = replaceObj[i].parentNode;
					newHTML = parentObj.innerHTML;
					parentObj.removeChild(replaceObj[i]);
					parentObj.innerHTML = newHTML;
				}
			}
		}
	}
	
	// Controlla gli spazi vuoti nella compilazione dei campi di testo
	function trim(stringa){
		while(stringa.substring(0, 1) == " ")
			stringa = stringa.substring(1, stringa.length);
		
		while(stringa.substring(stringa.length-1, stringa.length) == " ")
			stringa = stringa.substring(0, stringa.length-1);
		
		return stringa;
	}
	
	// Googlemaps
	//<![CDATA[
	var WINDOW_HTML = '<div style="text-align: left;"><font style="font-family: Verdana; font-size: 11px; color: #000000;"><font style="font-weight: bold; color: #B69C54;">L\'EON</font><br /><br />Via Stelvio Ang. Morelli, 156/A<br />23017 Morbegno (SO)<br />Italia</font></div>';
	
	function initialize(){
		if(GBrowserIsCompatible()){
			var map = new GMap2(document.getElementById("mappa"));
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(46.134780, 9.574682), 13);
			var marker = new GMarker(new GLatLng(46.134780, 9.574682));
      map.addOverlay(marker);
      GEvent.addListener(marker, "click", function(){
        marker.openInfoWindowHtml(WINDOW_HTML);
      });
      marker.openInfoWindowHtml(WINDOW_HTML);
			var ovcontrol = new GOverviewMapControl(new GSize(150, 150)); 
      map.addControl(ovcontrol);
		}
	}
	
	function showLocation(){
		initialize();
  }
	//]]>
	
	// Swap immagini
	function MM_preloadImages(){
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
			var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	
	function MM_swapImgRestore(){
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_findObj(n, d){
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
			d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_swapImage(){
		var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
	// Submit di ricerca pagina nella gallery
	function passForIid(iidValue, pageValue, orderbyValue, senseValue){
		if(trim(iidValue) != "")
			window.location.href = 'index.php?cmd=gallery&iid=' + iidValue + '&page=' + pageValue + '';
		else
			window.location.href = 'index.php?cmd=gallery&page=' + pageValue + '&orderby=' + orderbyValue + '&sense=' + senseValue + '';
	}
	
	// Mostra/nasconde il display dell'elemento "id"
	function showHideDiv(id, who){
		if(document.getElementById('' + id + '').style.display == "none"){
			if(navigator.appName == "Microsoft Internet Explorer")
				document.getElementById('' + id + '').style.display = "block";
			else if(navigator.appName == "Netscape")
				document.getElementById('' + id + '').style.display = "table-row";
		}
		
		if(id == "subcat" && who == "sport"){
			document.getElementById('section_white').style.backgroundColor = "";
			document.getElementById('prod').style.display = "none";
			document.getElementById('categorie').style.backgroundImage = "url(images/bg_categorie_sport.gif)";
		}
		else if(id == "subcat" && who == "fish"){
			document.getElementById('section_white').style.backgroundColor = "";
			document.getElementById('prod').style.display = "none";
			document.getElementById('categorie').style.backgroundImage = "url(images/bg_categorie_fish.gif)";
		}
	}
	
	// Popup centrata
	function popupCenter(imageURL, imageTitle){
		var AutoClose = true;
		
		var w = 150;
		var h = 150;
		var l = 100;
		var t = 100;
		
		if(parseInt(navigator.appVersion.charAt(0))>=4){
			var isNN = (navigator.appName == "Netscape")?1:0;
			var isIE = (navigator.appName.indexOf("Microsoft")!=-1)?1:0;
		}
		
		var optNN = 'scrollbars=no, resizable=yes, width=' + w + ', height=' + h + ', left=' + l + ', top=' + t;
		var optIE = 'scrollbars=no, resizable=yes, width=' + w + ', height= ' + h + ', left=' + l + ', top=' + t;
		
		if(isNN)
			imgWin = window.open('about:blank', '', optNN);
		
		if(isIE)
			imgWin = window.open('about:blank', '', optIE);
		
		with(imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{padding: 0px; margin: 0px; background-color: #FFFFFF;}</style>');
			writeln('<sc' + 'ript>');
			writeln('var isNN, isIE;');
			writeln('if(parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN = (navigator.appName == "Netscape")?1:0;');
			writeln('isIE = (navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if(isIE){');
			writeln('window.resizeTo(100, 100);');
			writeln('width = 100-(document.body.clientWidth-document.images[0].width);');
			writeln('height = 100-(document.body.clientHeight-document.images[0].height);');
			writeln('window.resizeTo(width, height);}');
			writeln('if(isNN){');       
			writeln('window.innerWidth = document.images["lavoro"].width;');
			writeln('window.innerHeight = document.images["lavoro"].height;}}');
			writeln('function doTitle(){document.title = ":: www.leonbellessere.com - ' + imageTitle + ' ::";}');
			writeln('</sc' + 'ript>');
			
			if(!AutoClose)
				writeln('</head><body scroll="no" onload="javascript:reSizeToImage(); doTitle(); self.focus();">')
			else
				writeln('</head><body scroll="no" onload="javascript:reSizeToImage(); doTitle(); self.focus();" onblur="javascript:self.close();">');
			
			writeln('<img name="lavoro" src="' + imageURL + '" border="0" style="display: block;"></body></html>');
			close();
		}
	}
	
	// Controlla la compilazione della form in CONTATTI
	function checkForm(){
		var goodEmail = document.contatti.mail.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		
		if(document.contatti.nome.value == ""){
			alert("Attenzione!\nIl campo NOME non è stato compilato correttamente...");
			document.contatti.nome.focus();
		}
		else if(document.contatti.cognome.value == ""){
			alert("Attenzione!\nIl campo COGNOME non è stato compilato correttamente...");
			document.contatti.cognome.focus();
		}
		else if(!goodEmail){
			alert("Attenzione!\nIl campo E-MAIL non è stato compilato correttamente...");
			document.contatti.mail.focus();
		}
		else if(document.contatti.richiesta.value == ""){
			alert("Attenzione!\nIl campo RICHIESTA non è stato compilato correttamente...");
			document.contatti.richiesta.focus();
		}
		else if(document.contatti.privacy.checked == false)
			alert("Attenzione!\nIl campo PRIVACY non è stato contrassegnato...");
		else
			document.contatti.submit();
	}	
//-->
