function opener2(url)
{
var height=530;
     var width=650;
     var ytop = screen.height/2 - (height/2);
window.open(url, "mywindow", 'height='+height+',width='+width+',scrollbars=no');
}



function changeCountry(fm)
  {
  	if(fm.Country.selectedIndex != 93)
	{
		window.alert('Please enter the city where you live!')
		fm.City.focus();
		fm.CountryCode.disabled = false;
	}
	else
	{
		fm.CountryCode.disabled = true;
	}
  }



function isPhoneNumber(s) 
{

 // Check for correct phone number
 rePhoneNumber = new RegExp(/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/);
 //rePhoneNumber = new RegExp(/^\[1-9]\d{2}\\s?\d{3}\-\d{4}$/)
 
 if (!rePhoneNumber.test(s)) 
 {
  	//alert("Phone Number Must Be Entered As: (555) 555-1234");
    return false;
 }
	return true;
}


//------------------------------------------------Validate Function for Contact-Us-For-Resort-Rental-Answers.Asp------------------------
function check(fm)
{
var phone = "(" + fm.AreaCode.value + ")" + fm.PhoneNumber.value;

if(fm.FirstName.value=="")
  {alert("Please enter your first name")
   fm.FirstName.focus()
   return false
  }
 if(fm.LastName.value=="")
    {alert("Please enter your last name")
     fm.LastName.focus()
     return false
    }
 if(fm.LastName.value=="")
    {alert("Please enter your last name")
     fm.LastName.focus()
     return false
    }
 if(fm.Email.value=="")
    {alert("Please enter your E-Mail Address")
     fm.Email.focus()
     return false
    }
 if(!fm.Email.value=="" && fm.Email.value.indexOf("@")==-1)
    {alert("Please enter a valid email address")
     fm.Email.focus()
     return false
    }
 if(!fm.Email.value=="" && fm.Email.value.indexOf(".")==-1)
    {alert("Please enter a valid email address")
     fm.Email.focus()
     return false
    }
 if(fm.Address.value == "")
  {
	alert("Please enter your mailing address")
	fm.Address.focus()
	return false
  }
  /*else if(fm.City.value == "")
  {
	alert("Please enter your city")
	fm.City.focus()
	return false
  }
  */
 if(fm.State.value == "")
  {
	alert("Please enter your state")
	fm.State.focus()
	return false
  }
 if(fm.Zip.value == "")
  {
	alert("Please enter your zip code")
	fm.Zip.focus()
	return false
  }
 if(fm.AreaCode.value =="")
  {
    alert("Please enter the area code of your phone number")
	fm.AreaCode.focus()
    return false
  }
 if(fm.PhoneNumber.value =="")
  {
    alert("Please enter your phone number")
	fm.PhoneNumber.focus()
    return false
  }
 if(!isPhoneNumber(phone))
  {
  	 alert("Phone Number Must Be Entered As: (555) 555-1234");
	 fm.AreaCode.focus();
	 return false;
  }
   if(fm.Comments.value.length  > 150)
     {alert("You have entered too much information in the comments box. Please limit your comment to under 150 characters.")
      fm.Comments.focus()
      return false
     }
  else
    {fm.action="Contact-Us-For-Resort-Rental-Answers.Asp?SendMail=Yes"
     return true
    }
}

//-----------------------------------------------------Validate method for Resort-Rental-SubmittedInfo.Asp------------------------------


//----------------------------------Code fpr List-Property-With-Us.asp------------------------------------------------------------------
  var dtCh= "/";
cdate = new Date();
var minYear= 2005;
var maxYear= 2010;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr,datenum){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format for your " + datenum + " should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month for your " + datenum)
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day for your" + datenum)
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("The year for your " + datenum + " must be between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date for your " + datenum)
		return false
	}
return true
}

function ValidateForm(){
	var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }

  
function Action(fm)
{

cdate = new Date();
current= cdate.getMonth() + "/" + cdate.getDate() + "/" + cdate.getYear();
splitc =current.split("/");
cmonth=(splitc[0])
cday=(splitc[1])
cyear=(splitc[2])
c= Date.UTC(cyear, cmonth, cday)

//get users CheckInDate
user1=fm.CheckInDate.value
split1=user1.split("/");
umonth=(split1[0])
umonth=umonth - 1
uday=(split1[1])
uyear=(split1[2])
d1 = Date.UTC(uyear, umonth, uday) 

//get users CheckOutDate
user2=fm.CheckOutDate.value
split2=user2.split("/");
umonth2=(split2[0])
umonth2=umonth2 - 1
uday2=(split2[1])
uyear2=(split2[2])
d2 = Date.UTC(uyear2, umonth2, uday2)

var phone = "(" + fm.AreaCode.value + ")" + fm.PhoneNumber.value;

  if(fm.ResortLocation.value == "" )
  {
	alert("Please enter your resort or property location")
	fm.ResortLocation.focus()
	return false
  }
  if (fm.CheckInDate.value != "" && isDate(fm.CheckInDate.value,'Check In Date')==false)
    { alert("Your rental property's Check In Date is invalid!")
	fm.CheckInDate.focus();
     return false;
    }
  if (fm.CheckOutDate.value != "" && isDate(fm.CheckOutDate.value,'Check Out Date')==false)
    { alert("Your rental property's Check Out Date is invalid!")
	fm.CheckOutDate.focus();
     return false;
    }
  if(isNaN(fm.Bedrooms.value)==true)
    {alert("Bedrooms should be numeric")
     fm.Bedrooms.focus()
     return false
     }
  if(fm.FirstName.value == "")
  {
    alert("Please enter your first name")
    fm.FirstName.focus()
    return false
  }
  if(fm.LastName.value == "")
  {
	alert("Please enter your last name")
	fm.LastName.focus()
	return false
  }
  if(fm.Address.value == "")
  {
	alert("Please enter your address")
	fm.Address.focus()
	return false
  }
  /*if(fm.City.value == "")
  {
	alert("Please enter your city")
	fm.City.focus()
	return false
  }
  */
  if(fm.State.value == "")
  {
	alert("Please enter your state")
	fm.State.focus()
	return false
  }
  if(fm.Zip.value == "")
  {
    alert("Please enter your zip code")
    fm.Zip.focus()
    return false
  } 
  if(fm.Email.value == "")
  {
    alert("please enter your email address")
    fm.Email.focus()
    return false
  }
  if(!fm.Email.value=="" && fm.Email.value.indexOf("@")==-1)
    {alert("Please enter a valid email address")
     fm.Email.focus()
     return false
    }
  if(!fm.Email.value=="" && fm.Email.value.indexOf(".")==-1)
    {alert("Please enter a valid email address")
     fm.Email.focus()
     return false
    }
  if(fm.AreaCode.value =="")
  {
    alert("Please enter the area code of your phone number")
	fm.AreaCode.focus()
    return false
  }
  if(fm.PhoneNumber.value =="")
  {
    alert("Please enter your phone number")
	fm.PhoneNumber.focus()
    return false
  }
  if(!isPhoneNumber(phone))
  {
  	 alert("Phone Number Must Be Entered As: (555) 555-1234");
	 fm.AreaCode.focus();
	 return false;
  }
   if(fm.Comments.value.length  > 150)
     {alert("You have entered too much information in the comments box. Please limit your comment to under 150 characters.")
      fm.Comments.focus()
      return false
     }
  else
  {
    fm.action = "List-Property-With-Us.Asp?send=yes"
    return true
  }
}

