// JavaScript Document
	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;
	}
	
	function validateDate(dateval) {
		
		var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
		if ((dateval.match(RegExPattern)) && (dateval!='')) {
			return true; 
		} else {
			return false;
		} 
	}
	
	function validateEmail(strEmail){
		var emailRegxp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		
		if (emailRegxp.test(strEmail) != true) {
			return false;
		} else {
			return true;
		}
	}
	
	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
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle	+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"	+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
				img.outerHTML = strNewHTML
				i = i-1
			}
		}
	}
	
	var imgHeight;
	var imgWidth;
	var topDiv;
	var leftDiv;
	var browserName = navigator.appName;
	var checked = false;
	var glbImgSrc;
	
	function aprifoto(imgPath) {
		if(imgPath == undefined) {
			imgPath = glbImgSrc;
			
		}
			
		var divFoto = document.getElementById('fotoZoom');
		var closeHtml = '<br><br><a href="javascript:void(0)" onClick="chiudiFoto();"><b>chiudi x</b></a><br><br>';
		var myImage = new Image();
		myImage.src = imgPath;		
		myImage.name = imgPath;
		myImage.id = imgPath;
		myImage.onload = getWidthAndHeight;
		myImage.onerror = loadFailure;
		
		divFoto.innerHTML = '';
		
		if (browserName == "Microsoft Internet Explorer") {
		
			divFoto.innerHTML = '<img src="' + myImage.src + '" name="' + myImage.name + '" id="' + myImage.id + '">';
		
		} else {
		
			divFoto.appendChild(myImage);
		
		}
				
		divFoto.innerHTML += closeHtml;
				
		fillDiv(myImage.src,myImage.name,imgWidth,imgHeight,closeHtml);
				
	}
	
	function getWidthAndHeight() {
	
		leftDiv = null;
		topDiv = null;
	    
		var clientWidth = document.body.clientWidth;
		var clientHeight = document.body.clientHeight;
		var contentOffsetLeft = document.getElementById('contentContainer').offsetLeft;
		var contentDivWidth = document.getElementById('contentContainer').offsetWidth;
		var contentOffsetRight = clientWidth - contentDivWidth - contentOffsetLeft;
				
		imgHeight = this.height;
		imgWidth = this.width;
	
		topDiv = Math.round((clientHeight - imgHeight) / 2);
		
		if (browserName == "Microsoft Internet Explorer") {
		
			leftDiv = Math.round((clientWidth - imgWidth) / 2) - 110;
			
		} else {
		
			leftDiv = Math.round((contentDivWidth - imgWidth) / 2) + contentOffsetLeft;
		
		}
		
	    return true;
		
	}
	
	function loadFailure() {
	
	    alert("'" + this.name + "' failed to load.");
	    return true;
		
	}
	
	function fillDiv(imgsrc,imgid,imgw,imgh,closediv) {
		
		var divFoto = document.getElementById('fotoZoom');
		
		if ((browserName == "Microsoft Internet Explorer") && (!checked)) {
		
			checked = true;
			glbImgSrc = imgsrc;
			setTimeout('aprifoto()',500);
		
		} else {
		
			setTimeout('adjustFotoDiv()',500);
			
		}
			
	}
		
	function adjustFotoDiv() {
	
		document.getElementById("fotoZoom").style.top = topDiv + 'px';		
		document.getElementById("fotoZoom").style.left = leftDiv + 'px';
		document.getElementById("fotoZoom").style.display = 'block';
		
		
	}
	
	function chiudiFoto() {
	
		document.getElementById('fotoZoom').style.display = 'none';
	
	}
	

function show_hide(id){
			var elemento = document.getElementById(id);
			if (elemento.style.display == '') {
				elemento.style.display = "none";
				elemento='';
			}
			
			else if (elemento.style.display == "none") {
				elemento.style.display = '';
				elemento='';
			}
		}
		