// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;} function posTop() {return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;} function posRight() {return posLeft()+pageWidth();} function posBottom() {return posTop()+pageHeight();}

function show(obj , nLeft , nTop){
	if (nLeft != null){
		obj.style.left = nLeft;
	}
	if (nTop != null){
		obj.style.top = nTop;
	}
	if ( obj.style.display == "none") {
		obj.style.display = "";
	} else {
		obj.style.display = "none";
	}
}


/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Indirizzo email non valido ! \nImpossibile inviare la richiesta")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Indirizzo email non valido ! \nImpossibile inviare la richiesta")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Indirizzo email non valido ! \nImpossibile inviare la richiesta")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Indirizzo email non valido ! \nImpossibile inviarela richiesta")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Indirizzo email non valido ! \nImpossibile inviare la richiesta")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Indirizzo email non valido ! \nImpossibile inviare la richiesta")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Indirizzo email non valido ! \nImpossibile inviare la richiesta")
		    return false
		 }

 		 return true					
	}

function ValidateForm(obj){
	var emailID=document.getElementById(obj);
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Inserire un indirizzo email valido")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }


