// JavaScript Document

function doClear1()   
{   
document.form1.Sell_Price.value = "";   
}

function doClear2()   
{   
document.form1.Rent_Price.value = "";   
}

function doClear3()   
{   
document.form1.Email.value = "";   
}

function doClear4()   
{   
document.form1.Resort.value = "";   
}

function validateForm(form) { 
document.getElementById('button').innerHTML = "<img src='http://www.time-share-services.com/images/progress-bar.gif' />";
var oldbutton = "<input name='Submit' type='image' src='http://www.time-share-services.com/Images/processsurvey-button.gif'/>";

if (form.Bed.selectedIndex == 0) { 
   alert("The bedroom field is empty.");
   document.getElementById('button').innerHTML = oldbutton;
   form.Bed.focus( ); 
   return false; 
   }

if (form.Bath.selectedIndex == 0) { 
   alert("The bathroom field is empty.");
   document.getElementById('button').innerHTML = oldbutton;
   form.Bath.focus( ); 
   return false; 
   }
	
if (form.Week.selectedIndex == 0) { 
   alert("The week number field is empty.");
   document.getElementById('button').innerHTML = oldbutton;
   form.Week.focus( ); 
   return false; 
   }
   
if (form.Get_TS.selectedIndex == 0) { 
   alert("Where did you get your timeshare?");
   document.getElementById('button').innerHTML = oldbutton;
   form.Get_TS.focus( ); 
   return false; 
   }
   
if (form.Why_Buy.selectedIndex == 0) { 
   alert("Why did you buy your timeshare?");
   document.getElementById('button').innerHTML = oldbutton;
   form.Why_Buy.focus( ); 
   return false; 
   }
   
if (form.How_Often.selectedIndex == 0) { 
   alert("How often did you use your timeshare?");
   document.getElementById('button').innerHTML = oldbutton;
   form.How_Often.focus( ); 
   return false; 
   }
   
if (form.Resort.value == "") { 
   alert("The resort name field is empty.");
   document.getElementById('button').innerHTML = oldbutton;
   form.Resort.focus( ); 
   return false; 
   }
   
if (form.Considered.selectedIndex == 0) { 
   alert("Have you considered selling or renting your timeshare?");
   document.getElementById('button').innerHTML = oldbutton;
   form.Considered.focus( ); 
   return false; 
   }
   
if (form.Buy_More.selectedIndex == 0) { 
   alert("Would you buy more timeshare?");
   document.getElementById('button').innerHTML = oldbutton;
   form.Buy_More.focus( ); 
   return false; 
   }
   
if (form.Sell_Price.value == "Enter expected sale price" || form.Sell_Price.value == "") { 
   alert("How much would you like to receive for the sale of your timeshare?");
   document.getElementById('button').innerHTML = oldbutton;
   form.Sell_Price.focus( ); 
   return false; 
   }
   
if (form.Rent_Price.value == "Enter expected rental price" || form.Rent_Price.value == "") { 
   alert("How much would you like to receive for the rental of your timeshare?");
   document.getElementById('button').innerHTML = oldbutton;
   form.Rent_Price.focus( ); 
   return false; 
   }
   
if (form.Hear_About.selectedIndex == 0) { 
   alert("How did you hear about us?");
   document.getElementById('button').innerHTML = oldbutton;
   form.Hear_About.focus( ); 
   return false; 
   }
   
if (form.Email.value != ""){
	
	if (echeck(form.Email.value)==false){
	alert("Invalid e-mail address");
	document.getElementById('button').innerHTML = oldbutton;
	form.Email.value="";
	form.Email.focus();
	return false;
	} 
	
} else if (form.Email.value == "" || form.Email.value == "Enter Your Email Address") {

   alert("Please enter an e-mail address.");
   document.getElementById('button').innerHTML = oldbutton;
   form.Email.focus( ); 
   return false; 
	}

}


function echeck(str) {
document.getElementById('button').innerHTML = "<img src='http://www.time-share-services.com/images/progress-bar.gif' />";
var oldbutton = "<input name='Submit' type='submit' value='Submit' />";	
		
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		
		if (str.indexOf(at)==-1){
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false;
		}

		if (str.indexOf(at,(lat+1))!=-1){
		    return false;
		}

		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false;
		}

		if (str.indexOf(dot,(lat+2))==-1){
		    return false;
		}
		
		if (str.indexOf(" ")!=-1){
		    return false;
		}

 							
	}

document.write("<img src='http://www.time-share-services.com/images/surveyback.jpg'>");
document.write("<div style='padding-left:10px; border:1px #CCC solid;height:550px;width:360px'>");

document.write("<form style='text-align:left;height:560px;' name='form1' action='http://www.time-share-services.com/includes/survey_top.asp' method='post' onSubmit='return validateForm(this)'>");


document.write("<br />");
// Bedroom Dropdown


document.write("<select name='Bed'>");
document.write("<option value='' selected>Select Bedrooms</option>");
document.write("<option value='*'>Studio</option>");
document.write("<option value='1'>1 Bed</option>");
document.write("<option value='2'>2 Bed</option>");
document.write("<option value='3'>3 Bed</option>");
document.write("<option value='4'>4 Bed</option>");
document.write("</select>");
document.write("<br /><br />");
// Bathroom Dropdown
document.write("<select name='Bath'>");
document.write("<option value='' selected>Select Bathrooms</option>");
document.write("<option value='1'>1 Bath</option>");
document.write("<option value='2'>2 Bath</option>");
document.write("<option value='3'>3 Bath</option>");
document.write("<option value='4'>4 Bath</option>");
document.write("</select>");
document.write("<br /><br />");
// Week Number
document.write("<select name='Week'>");
document.write("<option value='' selected>Select Week Number</option>");
for (i=1;i<=53;i++)
{
document.write("<option value='" + i + "'>" + i + "</option>");
}
document.write("</select>");
document.write("<br /><br />");
// Where did they buy
document.write("<select name='Get_TS'>");
document.write("<option selected>Where did you get your timeshare?</option>");
document.write("<option value='1'>Purchased From Resort</option>");
document.write("<option value='2'>Purchased Privately</option>");
document.write("<option value='3'>Inherited From Family</option>");
document.write("</select>");
document.write("<br /><br />");
// Purchase Info
document.write("<select name='Why_Buy'>");
document.write("<option selected>Why did you purchase your timeshare?</option>");
document.write("<option value='Loved The Resort'>Great Resort</option>");
document.write("<option value='Investment Property'>Purchased as an investment</option>");
document.write("<option value='Vacation the same time every year.'>Vacation yearly same time.</option>");
document.write("</select>");
document.write("<br /><br />");
// How Often Vacation
document.write("<select name='How_Often'>");
document.write("<option selected>How often did you vacation there?</option>");
document.write("<option value='Frequently'>Frequently</option>");
document.write("<option value='Ocassionally'>Occasionally</option>");
document.write("<option value='Seldom'>Seldom</option>");
document.write("<option value='Never'>Never</option>");
document.write("</select>");
document.write("<br /><br />");
// Resort Name
document.write("<input type='text' id='Resort' name='Resort' value='Enter Resort Name Here' size='40' onClick= 'setResortName()'>");
document.write("<br /><br />");
// Consider Selling
document.write("<select name='Considered'>");
document.write("<option selected>Considered Selling or Renting Your Timeshare?</option>");
document.write("<option value='1'>Selling</option>");
document.write("<option value='2'>Renting</option>");
document.write("<option value='3'>Selling &amp; Renting</option>");
document.write("</select>");
document.write("<br /><br />");
// Consider Buying More
document.write("<select name='Buy_More'>");
document.write("<option selected>Would you buy more timeshare?</option>");
document.write("<option value='1'>Yes</option>");
document.write("<option value='2'>No</option>");
document.write("<option value='3'>Never!</option>");
document.write("</select>");
document.write("<br /><br />");
// How much do you want
document.write("<input type='text' size='30' name='Sell_Price' value='Enter expected sale price' onClick= 'doClear1()'>");
  

document.write("<br /><br />");
document.write("<input type='text' size='30' name='Rent_Price' value='Enter expected rental price' onClick= 'doClear2()'>");
document.write("<br /><br />");
// How did you hear about us
document.write("<select name='Hear_About'>");
document.write("<option selected>How did you hear about us?</option>");
document.write("<option value='Google'>Google</option>");
document.write("<option value='Yahoo'>Yahoo</option>");
document.write("<option value='MSN'>MSN</option>");
document.write("<option value='Lycos'>Lycos</option>");
document.write("<option value='Other Engine'>Other Search Engine</option>");
document.write("<option value='Website'>Website</option>");
document.write("<option value='Other'>Other</option>");
document.write("</select>");
document.write("<br /><br />");
// Email
document.write("<input type='text' size='30' name='Email' value='Enter Your Email Address' size='30' onClick= 'doClear3()'>");

//Hidden Fields
document.write("<input type='hidden'name='MM_Insert' value='true'>");
document.write("<input type='hidden'name='Resort_Id' value='" + resortid + "'>");
document.write("<input type='hidden'name='Site_Id' value='" + siteid + "'>");
document.write("<input type='hidden' name='Complete' value='0'>");
document.write("<input type='hidden' name='Survey_Date' value='" + xDate + "'>");

//Submit
document.write("<br /><br />");
document.write("<span id='button'><input name='Submit' type='image' src='http://www.time-share-services.com/Images/processsurvey-button.gif'/></span>");
document.write("</form></div>");
