function check_dates(bam,bad,bay,bdm,bdd,bdy)
{ 

var currentTime = new Date();
  var month = currentTime.getMonth() + 1;
  if(month<10)
  { month="0"+month;
  }
 
  if(bad<10)
  { bad="0"+bad;
  }
    if(bdd<10)
  { bdd="0"+bdd;
  }
  var day = parseInt(currentTime.getDate());
  var year = parseInt(currentTime.getFullYear());
  
  
  bad.value=parseInt(bad.value);
  bam.value=parseInt(bam.value);
  bay.value=parseInt(bay.value);
  bdd.value=parseInt(bdd.value);
  bdm.value=parseInt(bdm.value);
  bdy.value=parseInt(bdy.value);
  
  var t=parseInt(bdd.value)<parseInt(bad.value);
  
  if (parseInt(bam.value) < parseInt(bdm.value)) {
     var q = false;
  }
  else {
     var q=parseInt(bdd.value)<parseInt(day);
  }
var p=parseInt(bad.value)<parseInt(day);

  if(parseInt(bay.value)<year)
  { alert("Arrival date must be after today");
  	return false;
  }
  if(parseInt(bay.value)==year && parseInt(bam.value)<month)
  { alert("Arrival date must be after today");
    return false;
  }
  if(parseInt(bay.value)==year && parseInt(bam.value)==month && p)
  { alert("Arrival date must be after today");
    return false;
  }
  if(parseInt(bdy.value)<year)
  { 

alert("Departure date must be after today");
  	return false;
  }
  if(parseInt(bdy.value)==year && parseInt(bam.value)<month)
  { 

alert("Departure date must be after today");
    return false;
  }
  if(parseInt(bdy.value)==year && parseInt(bam.value)==month && q)
  { 

alert("Departure date must be after today");
    return false;
  }
  if(parseInt(bdy.value)<parseInt(bay.value))
  { alert("Departure date must be after Arrival date");
  	return false;
  }
  if(parseInt(bdy.value)==parseInt(bay.value) && parseInt(bdm.value)<parseInt(bam.value))
  { alert("Departure date must be after Arrival date");
    return false;
  }
  if(parseInt(bdy.value)==parseInt(bay.value) && parseInt(bdm.value)==parseInt(bam.value) && t)
  { alert("Departure date must be after Arrival date");
    return false;
  }
  
  return true;
}

function GoToUrl(obj,noa,noc,bam,bad,bay,bdm,bdd,bdy)
{	
	var d = obj.options[obj.selectedIndex].value;
	//var arrivalString = arrivalDate.split("-");
	//var departureString = departureDate.split("-");
	if (d != null || d != "")
	{
	d += "&arrive="+bam.options[bam.selectedIndex].value+"/"+bad.options[bad.selectedIndex].value+"/"+bay.options[bay.selectedIndex].value+"&depart="+bdm.options[bdm.selectedIndex].value+"/"+bdd.options[bdd.selectedIndex].value+"/"+bdy.options[bdy.selectedIndex].value+"&Adult="+noa.options[noa.selectedIndex].value+"&Child="+noc.options[noc.selectedIndex].value;

	//d += "&noa="+noa.options[noa.selectedIndex].value+"&noc="+noc.options[noc.selectedIndex].value+"&bam="+arrivalString[0]+"&bad="+arrivalString[1]+"&bay="+arrivalString[2]+"&bdm="+departureString[0]+"&bdd="+departureString[1]+"&bdy="+departureString[2];
		if (d != "")
		{	//window.top.location.href = d;
			if(check_dates(bam,bad,bay,bdm,bdd,bdy) == true)
			{ window.top.location.href = d;
			}
		}
	}
	return false;
}

function GoToUrl2(package,obj,noa,noc,bam,bad,bay,bdm,bdd,bdy)
{	

	alert (package);
	var d = obj.options[obj.selectedIndex].value;
	//var arrivalString = arrivalDate.split("-");
	//var departureString = departureDate.split("-");
	if (d != null || d != "")
	{
	d += "&arrive="+bam.options[bam.selectedIndex].value+"/"+bad.options[bad.selectedIndex].value+"/"+bay.options[bay.selectedIndex].value+"&depart="+bdm.options[bdm.selectedIndex].value+"/"+bdd.options[bdd.selectedIndex].value+"/"+bdy.options[bdy.selectedIndex].value+"&Adult="+noa.options[noa.selectedIndex].value+"&Child="+noc.options[noc.selectedIndex].value;

	//d += "&noa="+noa.options[noa.selectedIndex].value+"&noc="+noc.options[noc.selectedIndex].value+"&bam="+arrivalString[0]+"&bad="+arrivalString[1]+"&bay="+arrivalString[2]+"&bdm="+departureString[0]+"&bdd="+departureString[1]+"&bdy="+departureString[2];
		if (d != "")
		{	//window.top.location.href = d;
			if(check_dates(bam,bad,bay,bdm,bdd,bdy) == true)
			{ window.top.location.href = d;
			}
		}
	}
	return false;
}

function GoToUrl3(obj,noa,noc,bam,bad,bay,bdm,bdd,bdy) {	
   var d = obj.value;
   
   if (d != null || d != "") {
      d += "&arrive="+bam.options[bam.selectedIndex].value+"/"+bad.options[bad.selectedIndex].value+"/"+bay.options[bay.selectedIndex].value+"&depart="+bdm.options[bdm.selectedIndex].value+"/"+bdd.options[bdd.selectedIndex].value+"/"+bdy.options[bdy.selectedIndex].value+"&Adult="+noa.options[noa.selectedIndex].value+"&Child="+noc.options[noc.selectedIndex].value;

      if (d != "") {
         if(check_dates(bam,bad,bay,bdm,bdd,bdy) == true) {
            window.top.location.href = d;
         }
      }
   }
   return false;
}

function openWindow2(url) {location.href=url;}