function validate_reservation(form)
{
  if (form.name.value == "")
  { 
    alert(alert1);

    form.name.focus(); 
    return; 
  }

  if (form.surname.value == "")
  { 
    alert(alert1);

    form.surname.focus(); 
    return; 
  }
  
  if (form.nif.value == "")
  {
    alert(alert1);

    form.nif.focus(); 
    return; 
  }
  
  if (form.country.value == "")
  {
    alert(alert1);

    form.country.focus(); 
    return; 
  }

  if (form.phone.value == "")
  {
    alert(alert1);

    form.phone.focus(); 
    return; 
  }
 
  if (form.acepto.checked) 
  {
  }
  else 
  {
    alert(alert2);
    
    form.acepto.focus(); 
    return; 
  }

  if (form.email.value == "")
  {
    alert(alert1);

    form.email.focus(); 
    return; 
  }
  
  if (form.email.value.indexOf('@', 0) == -1 ||
      form.email.value.indexOf('.', 0) == -1)
  { 
    alert(alert3);

    form.email.focus(); 
    return; 
  }

  if (form.payment.value == "")
  {
    alert(alert1);

    form.payment.focus(); 
    return; 
  }

  form.submit();
}

function Validate(form)
{
    if (form.email.value == "")
    { 
        alert(alert4); 
        form.email.focus(); 
        return; 
    }

    if (form.email.value.indexOf('@', 0) == -1 || form.email.value.indexOf('.', 0) == -1)
    {   
        alert(alert3);

        form.email.focus(); 
        return; 
    }
  
//    window.open('popups/subscribe_thanks.php','','scrollbars=no,width=300,height=100,left=400,top=200');
    form.submit();
}

function vContactForm(objForm) {
	
	if (objForm.firstName.value == '' || objForm.lastName.value == '' ||
			objForm.country.value == '' || objForm.phone.value == '' || objForm.email.value == '')
	{
		alert(alert1);
    	return false;
	}
	
	if (objForm.email != undefined)
	{ 
		if (objForm.email.value.indexOf('@', 0) == -1 || objForm.email.value.indexOf('.', 0) == -1)
		{
			alert(alert3);
			return false; 
		}
	}
	
	milisegundos = 1000*60*60*24;
    
    nfecha = objForm.datadesde.value.split("-");
    nfecha2 = objForm.datafins.value.split("-");  
    
    arrivaldate = new Date( nfecha[2], nfecha[1]-1, nfecha[0] );
    departuredate = new Date( nfecha2[2], nfecha2[1]-1, nfecha2[0] );
    
    hoy = new Date();
    
    arrivaldate.setHours( hoy.getHours() );
    arrivaldate.setMinutes( hoy.getMinutes() );
    arrivaldate.setSeconds( hoy.getSeconds() );
    arrivaldate.setMilliseconds( hoy.getMilliseconds() );

    if ( (arrivaldate < hoy) || (departuredate < hoy) )
    {
        alert(alert5);
        return false;
    }

    if ( (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) < 14) && (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) >= 0) )
    {
        alert(alert11);
        return false;
    }
    else
    {
        if (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) < 0 )
        {
            alert(alert7);
            return false;
        }
    }

    if ((objForm.datadesde.value=="") || (objForm.datafins.value==""))
    {
        alert(alert8);
        return false;
    }
    
    if ( Math.ceil( (departuredate.getTime()-arrivaldate.getTime())/milisegundos ) > 180) {
        alert(alert13);
        return false;
    }
    
    top_year = hoy.getFullYear() + 14;

    if ( ( nfecha[2] >= hoy.getFullYear() + 14 ) ||
         ( nfecha2[2] >= hoy.getFullYear() + 14 ) )
    {
        alert(alert10);
        return false;
    }
}

function validar()
{
	if (document.form1.firstName != undefined)
	{
		if (document.form1.firstName.value == '' || document.form1.lastName.value == '' ||
			document.form1.address.value == '' || document.form1.postalCode.value == '' ||
			document.form1.phone.value == '' || document.form1.email.value == '')
		{
			alert(alert1);
        	return false;
		}
	}
	
	if (document.form1.email != undefined)
	{ 
		if (document.form1.email.value.indexOf('@', 0) == -1 || document.form1.email.value.indexOf('.', 0) == -1)
		{
			alert(alert3);
			return false; 
		}
	}
	
    if (document.form1.personas.value == 9)
    {
        window.open('popups/groups_contact_us.php','','scrollbars=no,width=300,height=100,left=400,top=200');
        return false;
    }    
    
    milisegundos = 1000*60*60*24;
    
    nfecha = document.form1.datadesde.value.split("-");
    nfecha2 = document.form1.datafins.value.split("-");  
    
    arrivaldate = new Date( nfecha[2], nfecha[1]-1, nfecha[0] );
    departuredate = new Date( nfecha2[2], nfecha2[1]-1, nfecha2[0] );
    
    hoy = new Date();
    
    arrivaldate.setHours( hoy.getHours() );
    arrivaldate.setMinutes( hoy.getMinutes() );
    arrivaldate.setSeconds( hoy.getSeconds() );
    arrivaldate.setMilliseconds( hoy.getMilliseconds() );

    if ( (arrivaldate < hoy) || (departuredate < hoy) )
    {
        alert(alert5);
        return false;
    }

    if ( (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) < 2) && (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) >= 0) )
    {
        alert(alert6);
        return false;
    }
    else
    {
        if (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) < 0 )
        {
            alert(alert7);
            return false;
        }
    }

    if ((document.form1.datadesde.value=="") || (document.form1.datafins.value==""))
    {
        alert(alert8);
        return false;
    }
    
    top_year = hoy.getFullYear() + 2;

    if ( ( nfecha[2] >= hoy.getFullYear() + 2 ) ||
         ( nfecha2[2] >= hoy.getFullYear() + 2 ) )
    {
        alert(alert10);
        return false;
    }
}

function validarEarlyBooking()
{
	if (document.form1.personas.value == 9)
    {
        window.open('popups/groups_contact_us.php','','scrollbars=no,width=300,height=100,left=400,top=200');
        return false;
    }    
    
    milisegundos = 1000*60*60*24;
    
    nfecha = document.form1.datadesde.value.split("-");
    nfecha2 = document.form1.datafins.value.split("-");  
    
    arrivaldate = new Date( nfecha[2], nfecha[1]-1, nfecha[0] );
    departuredate = new Date( nfecha2[2], nfecha2[1]-1, nfecha2[0] );
    
    hoy = new Date();
    firstDay = new Date( nfecha2[2], nfecha2[1]-1, nfecha2[0] );
    
    arrivaldate.setHours( hoy.getHours() );
    arrivaldate.setMinutes( hoy.getMinutes() );
    arrivaldate.setSeconds( hoy.getSeconds() );
    arrivaldate.setMilliseconds( hoy.getMilliseconds() );

    if ( (arrivaldate < hoy) || (departuredate < hoy) )
    {
        alert(alert5);
        return false;
    }
    
    if ( (arrivaldate < hoy) || (departuredate < hoy) )
    {
        alert(alert5);
        return false;
    }

    if ( (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) < 2) && (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) >= 0) )
    {
        alert(alert6);
        return false;
    }
    else
    {
        if (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) < 0 )
        {
            alert(alert7);
            return false;
        }
    }
    
    if ( Math.ceil( (arrivaldate.getTime()-hoy.getTime())/milisegundos ) < 22 ) {
        alert(alert12);
        return false;
    }

    if ((document.form1.datadesde.value=="") || (document.form1.datafins.value==""))
    {
        alert(alert8);
        return false;
    }
    
    top_year = hoy.getFullYear() + 2;

    if ( ( nfecha[2] >= hoy.getFullYear() + 2 ) ||
         ( nfecha2[2] >= hoy.getFullYear() + 2 ) )
    {
        alert(alert10);
        return false;
    }
}

function validarLastMinute()
{   
    milisegundos = 1000*60*60*24;  
    nfecha = document.lastMinute.datadesde.value.split("-");
    nfecha2 = document.lastMinute.datafins.value.split("-");  

    arrivaldate = new Date( nfecha[2], nfecha[1]-1, nfecha[0] );
    departuredate = new Date( nfecha2[2], nfecha2[1]-1, nfecha2[0] );
    
    hoy = new Date();

    arrivaldate.setHours( hoy.getHours() );
    arrivaldate.setMinutes( hoy.getMinutes() );
    arrivaldate.setSeconds( hoy.getSeconds() );
    arrivaldate.setMilliseconds( hoy.getMilliseconds() );
    
    if ( (arrivaldate < hoy) || (departuredate < hoy) )
    {
        alert(alert5);
        return false;
    }
    
    if ( (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) < 2) && (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) >= 0) )
    {
        alert(alert6);
        return false;
    }
    else
    {
        if (Math.ceil((departuredate.getTime()-arrivaldate.getTime())/milisegundos) < 0 )
        {
            alert(alert7);
            return false;
        }
    }
}

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

function suscripcion() 
{
    window.open('popups/subscribe_info.php','','scrollbars=no,width=300,height=100,left=400,top=300');
}

function popup() 
{
    window.open('popups/finestra.php','','scrollbars=no,width=320,height=250,left=400,top=200');
}

function inserta() 
{
    window.open('popups/msinserta.php','','scrollbars=no,width=300,height=100,left=400,top=200');
}

function MM_reloadPage(init) 
{  //reloads the window if Nav4 resized
    if (init==true) with (navigator) 
    {
        if ((appName=="Netscape")&&(parseInt(appVersion)==4)) 
        {
            document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; 
        }
    }
    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) 
        location.reload();
}

function iva() 
{
    window.open('popups/iva.php','','scrollbars=no,width=300,height=100,left=400,top=300');
}

function getLastMinuteDaysArrivalRange()
{
    var today = new Date();
    
    for ( i=0; i<20; i++ )
    {
        document.forms['lastMinute'].datadesde.options[i] = new Option( today.getDate()+"-"+(today.getMonth()+1)+"-"+(1900+today.getYear()), today.getDate()+"-"+today.getMonth()+"-"+(1900 + today.getYear()) );
        today.setDate(today.getDate()+1);
    }
    
    var today2 = new Date();
    today2.setDate(today2.getDate()+2);
    
    for ( i=0; i<20; i++ )
    {
        document.forms['lastMinute'].datafins.options[i] = new Option( today2.getDate()+"-"+(today2.getMonth()+1)+"-"+(1900+today2.getYear()), today2.getDate()+"-"+today2.getMonth()+"-"+(1900 + today2.getYear()) );
        today2.setDate(today2.getDate()+1);
    }
}

function checkAll()
{
    
        for ( var i = 0; i < document.forms['update_prices'].elements.length; i++ )
        {
            var e = document.forms['update_prices'].elements[i];

            if ( ( e.name != 'check_all') && ( e.name != 'groupInvoices') && ( e.name != 'filter_days[]' ) && ( e.name != 'all_filter_days' ) && (e.type=='checkbox' ) )
                e.checked = document.forms['update_prices'].elements['check_all'].checked;
        }
    
}

function checkElements( formname, elementName, currentToggler )
{
	var element_checked = false;
	
	if ( currentToggler.checked )
		element_checked = true;
	
	with( formname )
	{
		for( var i=0; i<elements.length; i++ )
		{
			if( elements[i].type == 'checkbox' && elements[i].name == elementName && elements[i].disabled == "" )
				elements[i].checked = element_checked;
		}
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_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=MM_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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function checkAllForm( objForm ) {
	
	for (i=0; i < objForm.elements.length; i++) {
		
		if ( objForm.elements[i].checked ) {
		
			objForm.elements[i].checked=0;
		} else {
			objForm.elements[i].checked=1;
		}
	}
}
