//function PreloadImages() { //v3.0
//  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
//   var i,j=d.MM_p.length,a=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 NewWindow(contenuto,w,h) {
	win2=window.open(contenuto,"NewWindow","toolbar=no,directories=no,menubar=no,scrollbars=no,width="+w+",height="+h+",top=50,left=50")
}

//function PopUpPhoto(id,lang){
//	var winOpts = 'resizeable=no,scrollbars=no,location=no,width=565,height=520,top=50,left=50';
//	p = window.open('photo.asp?id='+id+'&ver='+lang,'Foto',winOpts); 
//}

function printit(){  
if (NS) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);
WebBrowser1.outerHTML = "";  
}
}

function emailValidation(frm){
var esito = true;
Lang = frm.ver.value;
with (frm.txtMail){
 	if (value.length > 0){
		apos=value.indexOf("@"); 
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		spacepos=value.indexOf(" ");
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2 || spacepos>-1) {		
			esito = false;
		}
	}
}

if (esito==false)
{
	if (Lang=="it")	{alert("e-mail non valida");}
	if (Lang=="en")	{alert("e-mail not valid");}
	if (Lang=="de")	{alert("e-mail Adresse nicht Korrekt");}
	if (Lang=="fr")	{alert("e-mail non valables");}
	if (Lang=="es")	{alert("e-mail no válida");}
}

return esito
}


function DateValidation(frm){
var esito=true;
Lang = frm.ver.value;
with (frm){
	//se non inserisco alcuna data il form viene validato comunque
	if (selGG.value == "none" && selMM.value == "none" && selAA.value == "none" ) {
		esito=true;
	}
	else {
		esito = true;
		// se inserisco una data in cui mancano il giorno o il mese o l'anno il form non viene validato
		if (selGG.value == "none" || selMM.value == "none" || selAA.value == "none" ) {
			esito = false;
		}
		//se ho inserito tutti i valori della data, verifico che questa esistita
		else {
			var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);    
			g=eval(selGG.value);
			m=eval(selMM.value);
			y=eval(selAA.value);
			
			if (g > monthDays[m-1]) {
				esito=false
			}
			if(m == 2) {
			  var resto = (y-(400*(parseInt(y/400))));
			  var resto1 = (y-(100*(parseInt(y/100))));
			  var resto2 = (y-(4*(parseInt(y/4))));

			  if ( resto==0 || (resto1!=0 && resto2==0)) {
				if (!(g <= 29)) esito = false;
			  } else if (!(g <= 28)) esito = false;
			}		
		}
		if (esito==false) {
			if (Lang=="it")	{alert("Data non valida");}
			if (Lang=="en")	{alert("Date not valid");}
			if (Lang=="de")	{alert("Datum unzul&auml;ssig");}
			if (Lang=="fr") {alert("Date non exacte");}
			if (Lang=="es")	{alert("Fecha no válida");}
		}

	}
}
return esito;
}



function DataValida(gg,mm,aa,Lang){
var esito=true;
	
	//se non inserisco alcun valore la data non viene validata
	if (gg == "none" && mm == "none" && aa == "none" ) {
		esito=false;
	}
	else {
		esito = true;
		// se inserisco una data in cui mancano il giorno o il mese o l'anno il form non viene validato
		if (gg == "none" || mm == "none" || aa == "none" ) {
			esito = false;
		}
		//se ho inserito tutti i valori della data, verifico che questa esistita
		else {
			var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);    
			g=eval(gg);
			m=eval(mm);
			y=eval(aa);
			
			if (g > monthDays[m-1]) {
				esito=false
			}
			if(m == 2) {
			  var resto = (y-(400*(parseInt(y/400))));
			  var resto1 = (y-(100*(parseInt(y/100))));
			  var resto2 = (y-(4*(parseInt(y/4))));

			  if ( resto==0 || (resto1!=0 && resto2==0)) {
				if (!(g <= 29)) esito = false;
			  } else if (!(g <= 28)) esito = false;
			}		
		}
	}

	if (esito==false) {
		if (Lang=="it")	{alert("Data non valida");}
		if (Lang=="en")	{alert("Date not valid");}
		if (Lang=="de")	{alert("Datum unzul&auml;ssig");}
		if (Lang=="fr") {alert("Date non exacte");}
		if (Lang=="es")	{alert("Fecha no válida");}
	}
return esito;
}
