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

   
   
   
    function showAddress(address)
    {
    	if (GBrowserIsCompatible()) 
    	{
        	map = new GMap2(document.getElementById("map"));
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
	       // map.setCenter(new GLatLng(37.4419, -122.1419), 13);
    	    geocoder = new GClientGeocoder();
      	}
      	if (geocoder) 
      	{
        	geocoder.getLatLng
        		(
		          address,
        		  function(point) 
        		  {
		            if (!point) 
		            {
		              alert(address + ": indirizzo errato o non esistente");
        		    } 
        		    else 
        		    {
		              map.setCenter(point, 13);
        		      var marker = new GMarker(point);
		              map.addOverlay(marker);
        		      marker.openInfoWindowHtml(address);
            		}
          		}
        	);
      	}
    }


// pop-up function
var newWin = null;
function closeWin(){
	if (newWin != null){
		if(!newWin.closed)
			newWin.close();
	}
}
function popUp(strURL,strType,strHeight,strWidth) {
closeWin();
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
}


//over e out di immagini
function menuOver(pulsante) {
	pulsante.src= pulsante.src.replace('_off_', '_on_');
	
}
function menuOut(pulsante) {
	pulsante.src= pulsante.src.replace('_on_', '_off_');
}




 function Form_Validator_De(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 (document.form1.privacy.checked==false)
//	{
//         alert ("Sie müssen uns die Ermächtigung für Ihre persönlichen Daten geben");
//         return (false);
//    }
    
    	
if ((strsublista=='') && (typelista=='sublista')){
     alert ('Wählen mindestens eine Unterliste');
     return (false);
 }
 
  if (document.form1.nome.value == ""){
     alert ("Aufmerksamkeit!!!  Es ist nicht dem Feld eingesetzt worden nome");
     return (false);
     }
 	if (document.form1.privacy.checked==false)
	{
         alert ("Sie müssen uns die Ermächtigung für Ihre persönlichen Daten geben");
         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 Form_Validator_It(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 (document.form1.privacy.checked==false)
//	{
//         alert ("E' necessario prestare il consenso al trattamento dei dati personali");
//         return (false);
//    }	
    
    
 if (document.form1.nome.value == ""){
         alert ("Attenzione!!! Non è stato inserito il campo nome");
         return (false);
         }	
	if ((strsublista=='') && (typelista=='sublista')){
	alert ('Selezionare almeno una sublista');
	return (false);
	}
	if (document.form1.privacy.checked==false)
	{
         alert ("E' necessario prestare il consenso al trattamento dei dati personali");
         return (false);
    }	
	if (document.form1.email.value == ""){
	 alert ("Attenzione!!! Non e' 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 e' corretto!!!");
		    return (false);
		} 
	    }
	    return (isValidEmail(theForm.email.value))
	}
}

function Form_Validator_Fr(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 (document.form1.privacy.checked==false)
//{
//     alert('Vous devez nous donner l\'autorisation pour vos données personnelles');
//     return (false);
//}	

if ((strsublista=='') && (typelista=='sublista')){
alert ('Sélectionnez sans faute une sous liste');
return (false);
}
 if (document.form1.nome.value == ""){
     alert ("Attention!!!  Ce n'a pas été inséré le champ nome");
     return (false);
     }
if (document.form1.privacy.checked==false)
{
     alert('Vous devez nous donner l\'autorisation pour vos données personnelles');
     return (false);
}	
if (document.form1.email.value == ""){

  alert ("ATTENTION!!!  Le format de l'email n'est pas corrigé!!! ");
  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_En(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 (document.form1.privacy.checked==false)
//{
//     alert('You have to give us the authorization for your personal data');
//     return (false);
//}

	
if ((strsublista=='') && (typelista=='sublista')){
alert ('Select one sublist at least');
return (false);
}
if (document.form1.privacy.checked==false)
{
     alert('You have to give us the authorization for your personal data');
     return (false);
}
 if (document.form1.nome.value == ""){
         alert ("Attention!!!  It has not been inserted the field nome");
         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 submitGuestBook()
	{
	var d = new Date()
	param = d.getTime();

	document.forms['guestbooksign'].secure.value = param;
	
	try { document.forms['guestbooksign'].onsubmit(); }
	catch(e){}

	document.forms['guestbooksign'].submit();
	}


function submitnews()
{
	try { document.forms['form1'].onsubmit(); }
	catch(e){}
	
	document.forms['form1'].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) {

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 ('Wählen mindestens eine Unterliste');
     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;
}