function openCalendar(varNo) 
{
posx=800;posy=300;

var theDate="";
var theStr;

theStr=document.forms[0].elements[varNo].name;

if(theStr.match("Date"))
{
	theDate= document.forms[0].elements[varNo].value;
	if (isDate(theDate)==false)
	{
	 document.forms[0].elements[varNo].focus();
  return false;
	}
}
else
{
	theDate= document.forms[1].elements[varNo].value;
	if (isDate(theDate)==false)
	{
	 document.forms[1].elements[varNo].focus();
  return false;
	}
}
//var ev=(!e)?window.event:e;//IE:Moz
var ev=window.event;//IE:Moz
if(!ev)
{
}
else
{



if (ev.pageX){//Moz
posx=ev.pageX+window.pageXOffset;
posy=ev.pageY+window.pageYOffset;
}
else if(ev.clientX){//IE
posx=ev.clientX+document.body.scrollLeft;
posy=ev.clientY+document.body.scrollTop;

}
}

 window.open("VRCalendar.asp?elem="+varNo+"&selDate="+theDate,null,    "height=165,width=270,top="+posy+",left="+posx+",title=yes,status=no,resizable =no,toolbar=no,menubar=no,location=no");
}
 
function openGallery(varNo,picNo) 
{
posx=60;posy=60;


//var ev=(!e)?window.event:e;//IE:Moz
var ev=window.event;//IE:Moz
if(!ev)
{
}
else
{



if (ev.pageX){//Moz
posx=ev.pageX+window.pageXOffset;
posy=ev.pageY+window.pageYOffset;
}
else if(ev.clientX){//IE
posx=ev.clientX+document.body.scrollLeft;
posy=ev.clientY+document.body.scrollTop;

}
}

 window.open("VRGallery.asp?theID="+varNo+"&theNumber="+picNo,null,    "height=524,width=760,top="+posy+",left="+posx+",title=yes,status=no,resizable =no,toolbar=no,menubar=no,location=no");
}

function runSearch() 
{
 //check dates
if (isDate(theform.CheckInDate.value)==false)
{
 theform.CheckInDate.focus();
  return false;
}
if (isDate(theform.CheckOutDate.value)==false)
{
 theform.CheckOutDate.focus();
  return false;
}
d1 = new Date(theform.CheckInDate.value);
d2 = new Date(theform.CheckOutDate.value);
d3 = new Date();
if (d1.getTime()<d3.getTime()) {
  alert('Check-in Date is in the past');
 theform.CheckInDate.focus();
  return false;
}
if (d2.getTime()<d3.getTime()) {
  alert('Check-out Date is in the past');
 theform.CheckOutDate.focus();
  return false;
}
if (d1.getTime()>d2.getTime()) {
  alert('Check-in Date is after Check-out Date');
 theform.CheckInDate.focus();
  return false;
}
 //create string
var sqlStr,availSQL;

//bedrooms
	sqlStr="p.NoOfBedrooms>="+theform.Bedrooms.value;
//people
	sqlStr=sqlStr+" AND p.Sleeps>="+(parseInt(theform.Adults.value)+parseInt(theform.Teens.value)+parseInt(theform.Children.value));


	document.location.href="VRBrowseList.asp?theFilter="+sqlStr+"&theStart="+theform.CheckInDate.value+"&theEnd="+theform.CheckOutDate.value+"&theB="+theform.Bedrooms.value+"&theA="+theform.Adults.value+"&theT="+theform.Teens.value+"&theC="+theform.Children.value;


}


function runAdvancedSearch() 
{
 //check dates

if (isDate(theform.CheckInDate.value)==false)
{
 theform.CheckInDate.focus();
  return false;
}
if (isDate(theform.CheckOutDate.value)==false)
{
 theform.CheckOutDate.focus();
  return false;
}
d1 = new Date(theform.CheckInDate.value);
d2 = new Date(theform.CheckOutDate.value);
d3 = new Date();
if (d1.getTime()<d3.getTime()) {
  alert('Check-in Date is in the past');
 theform.CheckInDate.focus();
  return false;
}
if (d2.getTime()<d3.getTime()) {
  alert('Check-out Date is in the past');
 theform.CheckOutDate.focus();
  return false;
}
if (d1.getTime()>d2.getTime()) {
  alert('Check-in Date is after Check-out Date');
 theform.CheckInDate.focus();
  return false;
}

	document.location.href="VRAdvancedSearch.asp?theStart="+theform.CheckInDate.value+"&theEnd="+theform.CheckOutDate.value+"&theB="+theform.Bedrooms.value+"&theA="+theform.Adults.value+"&theT="+theform.Teens.value+"&theC="+theform.Children.value;

}

function runRegister() 
{
	document.location.href="VRRegistration.asp";
}


function runLogin() 
{
	var thePath;

	thePath=document.location.href.split("?");

	if(thePath==document.location.href)
	{
		document.location.href=document.location.href+"?toLog=True";
	}
	else
	{
		document.location.href=document.location.href+"&toLog=True";
	}
}


function runLogout() 
{
	document.location.href="VRLogout.asp";
}



function validateRequestReservationData()
{
 //check dates
if (isDate(theform.CheckInDate.value)==false)
{
 theform.CheckInDate.focus();
  return false;
}
if (isDate(theform.CheckOutDate.value)==false)
{
 theform.CheckOutDate.focus();
  return false;
}
d1 = new Date(theform.CheckInDate.value);
d2 = new Date(theform.CheckOutDate.value);
d3 = new Date();
if (d1.getTime()<d3.getTime()) {
  alert('Check-in Date is in the past');
 theform.CheckInDate.focus();
  return false;
}
if (d2.getTime()<d3.getTime()) {
  alert('Check-out Date is in the past');
 theform.CheckOutDate.focus();
  return false;
}
if (d1.getTime()>d2.getTime()) {
  alert('Check-in Date is after Check-out Date');
 theform.CheckInDate.focus();
  return false;
}
if (d1.getTime()==d2.getTime()) {
  alert('Check-in Date cannot be the same date as the Check-out Date');
 theform.CheckOutDate.focus();
  return false;
}
}

function validateRegistrationData()
{
 //full name
if (theform.txtName.value=="")
{
	alert("Please enter your name.");
	theform.txtName.focus();
	return false;
}

//user name
if (theform.txtUserName.value=="")
{
	alert("Please enter a user name.");
	theform.txtUserName.focus();
	return false;
}
if (theform.txtUserName.value.length<8)
{
	alert("User name must be at least eight characters.");
	theform.txtUserName.focus();
	return false;
}

//password
if (theform.txtPassword.value=="")
{
	alert("Please enter a password for your account.");
	theform.txtPassword.focus();
	return false;
}
if (theform.txtPassword.value.length<8)
{
	alert("Password must be at least eight characters.");
	theform.txtPassword.focus();
	return false;
}

//email
if (theform.txtEmail.value=="")
{
	alert("Please enter an email address.");
	theform.txtEmail.focus();
	return false;
}
if ((theform.txtEmail.value.indexOf(".") > 2) && (theform.txtEmail.value.indexOf("@") > 0))
{
}
else
{
	alert("Please enter a valid email address.");
	theform.txtEmail.focus();
	return false;
}

//home phone
if (theform.txtPhone1.value=="")
{
	alert("Please enter a contact phone number.");
	theform.txtPhone1.focus();
	return false;
}


if (theform.txtName.value.length>50)
 {
  alert("Name cannot be longer than 50 characters.");
  theform.txtName.focus();
  return false;
 } 
if (theform.txtUserName.value.length>50)
 {
  alert("User Name cannot be longer than 50 characters.");
  theform.txtUserName.focus();
  return false;
 }
 if (theform.txtPassword.value.length>50)
 {
  alert("Password cannot be longer than 50 characters.");
  theform.txtPassword.focus();
  return false;
 }
 if (theform.txtEmail.value.length>50)
 {
  alert("Email cannot be longer than 50 characters.");
  theform.txtEmail.focus();
  return false;
 }
 if (theform.txtPhone1.value.length>50)
 {
  alert("Home or Preferred Phone cannot be longer than 50 characters.");
  theform.txtPhone1.focus();
  return false;
 }
 if (theform.txtPhone2.value.length>50)
 {
  alert("Work Phone cannot be longer than 50 characters.");
  theform.txtPhone2.focus();
  return false;
 }
 if (theform.txtPhone3.value.length>50)
 {
  alert("Cell Phone cannot be longer than 50 characters.");
  theform.txtPhone3.focus();
  return false;
 }
 if (theform.txtAddress1.value.length>50)
 {
  alert("Address 1 cannot be longer than 50 characters.");
  theform.txtAddress1.focus();
  return false;
 }
 if (theform.txtAddress2.value.length>50)
 {
  alert("Address 2 cannot be longer than 50 characters.");
  theform.txtAddress2.focus();
  return false;
 }
 if (theform.txtAddress3.value.length>50)
 {
  alert("Address 3 cannot be longer than 50 characters.");
  theform.txtAddress3.focus();
  return false;
 }
 if (theform.txtCity.value.length>50)
 {
  alert("City cannot be longer than 50 characters.");
  theform.txtCity.focus();
  return false;
 }
 if (theform.txtState.value.length>50)
 {
  alert("State cannot be longer than 50 characters.");
  theform.txtState.focus();
  return false;
 }
 if (theform.txtZipCode.value.length>50)
 {
  alert("Zip Code cannot be longer than 50 characters.");
  theform.txtZipCode.focus();
  return false;
 }
 if (theform.txtCountry.value.length>50)
 {
  alert("Country cannot be longer than 50 characters.");
  theform.txtCountry.focus();
  return false;
 }

}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}



