// global variables
var pic = null
var popImg = null  
var picTitle = null
var imgCount = 0
var imgWinName = "popImg"
var priorPic = new Array()
var noPic = 0


function submitForm(name)
{
	try { document.forms[name].onsubmit(); }
	catch(e){}
	
	document.forms[name].submit();
}


/*
function submitRegistrazione()
{
	try { document.forms['registrazione'].onsubmit(); }
	catch(e){}
	
	document.forms['registrazione'].submit();
}
*/

/*
function updateCarrello()
{
	try { document.forms['carrello'].onsubmit(); }
	catch(e){}
	
	document.forms['carrello'].submit();
}
*/

function Form_Validator(theForm) {

var strsublista = '';
var typelista = window.document.form1.typelista.value;
for (i=0; i < document.form1.elements.length; i++) {
            if ((document.form1.elements[i].name=='sublista[]')) {
                 if (document.form1.elements[i].checked)     
                      strsublista+=','+document.form1.elements[i].value;


            }

}


if ((strsublista=='') && (typelista=='sublista')){
     alert ('Selezionare almeno una sublista');
     return (false);
 }
 if (document.form1.nome.value == ""){
         alert ("Attenzione!!! Non è stato inserito il campo nome ");
         return (false);
         }if (document.form1.email.value == ""){


         alert ("Attenzione!!! Non è stato inserito il campo email ");
         return (false);
     }else{ 
        
        function isValidEmail(addressS){


                emailRegexp = RegExp('^[A-Za-z0-9._\-]+[@]\([A-Za-z0-9\-]+[.])+([A-za-z]{2,4})$', 'i');
                if (emailRegexp.test(addressS)){


                    //return (true);


                }else{
                    alert ("ATTENZIONE!!! Il formato della e-mail non è corretto!!!");
                    return (false);
                } 
            }
            
            return (isValidEmail(theForm.email.value))


     }}
	
function winOpen()
{
	if (popImg != null && popImg.closed != true)
	{
		return true;
	}  
	else
	{
		return false;
	}
}

// If existing pic with same name, pop it up else create new window & pop it up
function ImgFoto(picName,winWidth,winHeight)
{
	if (pic == picName && winOpen())
	{
		popImg.focus()
	}
  	else
  	{
		// close any pop up windows now open 
		if (navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion) >=4) //do not close if early IE
		if (popImg != null && !popImg.closed) popImg.close();
		
		// build new pop up window
		pic = picName;
		picTitle = '';
		imgWinName = "popImg" + imgCount++; //unique name for each pop-up window
		popImg = window.open("", imgWinName, "toolbar=no,scrollbars=no,resizable=no,width=" + winWidth + ",height=" + winHeight);

		var outStr = '<html><head><title>Hotel Alexander _ Gabicce Mare</title></head><body background=' + pic + '></body></html>';

   		popImg.document.open();
   		popImg.document.write(outStr);
   		popImg.document.close();
   	}

	return false;
}

function openItinerari(object)
{
	winItinerari = window.open(object.href, 'itinerari', 'width=540, height=445, scrollbars=yes');
	winItinerari.focus();
	return false;
}

function openItinerari2(object)
{
	winItinerari = window.open(object.href, 'itinerari2', 'width=540, height=445, scrollbars=yes');
	winItinerari.focus();
	return false;
}

function openMappa(object)
{
	var winHeight = (object.href.indexOf('itinerari_mappa1.htm') != -1) ? '425' : '588';


	winMappa = window.open(object.href, 'mappa', 'width=550, height='+ winHeight);
	winMappa.focus();
	return false;
}

function openPopUp(object)
{
	win = window.open(object.href, 'screenshot', 'width=250, height=200');
	win.focus();
	return false;
}

function openInfo(object)
{
	win = window.open(object.href, 'screenshot', 'width=402, height=320, scrollbars=yes');
	win.focus();
	return false;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function setchecksublista() {
	document.form1.ckecksublista.value='si';
}

function Form_Validator(theForm)
{
	 if (document.form1.ckecksublista.value==''){
	         alert ('Occorre selezionare almeno una lista');
         	return (false);
     	}
     	if (document.form1.nome.value == ""){
         alert ("Attenzione!!! Non è stato inserito il campo nome ");
         return (false);
         }if (document.form1.email.value == ""){

         alert ("Attenzione!!! Non è stato inserito il campo email ");
         return (false);
     }else{ 
        
        function isValidEmail(addressS){

                emailRegexp = RegExp('^[A-Za-z0-9._-]+[@]([A-Za-z0-9-]+[.])+([A-za-z]{2,4})$', 'i');
                if (emailRegexp.test(addressS)){

                    //return (true);

                }else{
                    alert ("ATTENZIONE!!! Il formato della e-mail non è corretto!!!");
                    return (false);
                } 
            }
            
            return (isValidEmail(theForm.email.value))
	}
}

function Form_Validator_En(theForm) {
	if (document.form1.ckecksublista.value=='') {
		alert ('Occorre selezionare almeno una lista');
		return (false);
	}
	if (document.form1.nome.value == "") {
		alert ("Attention!!!  It has not been inserted the field name");
		return (false);
	}
	if (document.form1.email.value == ""){
		alert ("Attention!!!  It has not been inserted the field email");
		return (false);
	}else{
		function isValidEmail(addressS){
			emailRegexp = RegExp('^[A-Za-z0-9._-]+[@]([A-Za-z0-9-]+[.])+([A-za-z]{2,4})$', 'i');
			if (emailRegexp.test(addressS)) {
				//return (true);
			}else{
				alert ("ATTENTION!!!  The format of the email is not corrected!!!");
				return (false);
			} 
		}
		
		return (isValidEmail(theForm.email.value))
	}
}

function Form_Validator_Fr(theForm) {
	if (document.form1.ckecksublista.value=='') {
		alert ('Occorre selezionare almeno una lista');
		return (false);
	}
	if (document.form1.nome.value == "") {
		alert ("Attention!!!  Ce n'a pas été inséré le champ nom");
		return (false);
	}
	if (document.form1.email.value == ""){
		alert ("Attention!!!  Ce n'a pas été inséré le champ email");
		return (false);
	}else{
		function isValidEmail(addressS){
			emailRegexp = RegExp('^[A-Za-z0-9._-]+[@]([A-Za-z0-9-]+[.])+([A-za-z]{2,4})$', 'i');
			if (emailRegexp.test(addressS)) {
				//return (true);
			}else{
				alert ("ATTENTION!!!  Le format de l'email n'est pas corrigé!!!");
				return (false);
			} 
		}
		
		return (isValidEmail(theForm.email.value))
	}
}

function Form_Validator_De(theForm) {
	if (document.form1.ckecksublista.value=='') {
		alert ('Occorre selezionare almeno una lista');
		return (false);
	}
	if (document.form1.nome.value == "") {
		alert ("Aufmerksamkeit!!!  Es ist nicht dem Feld eingesetzt worden name");
		return (false);
	}
	if (document.form1.email.value == ""){
		alert ("Aufmerksamkeit!!!  Es ist nicht dem Feld eingesetzt worden email");
		return (false);
	}else{
		function isValidEmail(addressS){
			emailRegexp = RegExp('^[A-Za-z0-9._-]+[@]([A-Za-z0-9-]+[.])+([A-za-z]{2,4})$', 'i');
			if (emailRegexp.test(addressS)) {
				//return (true);
			}else{
				alert ("AUFMERKSAMKEIT!!!  Das Format des email wird nicht behoben!");
				return (false);
			} 
		}
		
		return (isValidEmail(theForm.email.value))
	}
}


function tellafriend()
{
	d = document;
	var email = d.forms["tellafriend"].email.value;
	var msg = d.forms["tellafriend"].msg.value;
	var subject = d.forms["tellafriend"].subject.value;
	window.location.href = "mailto:"+email+"?subject="+subject+"&body="+msg+'';
	return false;
}