var ivsFormParams = '';
var ivsSessionId = '';
var ivsEntityId = 0;
var ivsSecurityKey = 'qbcz1t34h3h143215_d5ba_$2_drq9lsl3k';
var ivsType = 2;
var ivsPortal = 'website';
var ivsMapShownFl = 'N';

function ivsShowMainMap(bodyArg) {
	// Display map code in container then call google routines to display
    	var i=0, p=0, x=0, latd=44, longtd=-99, zoomlvl=4, nbrmarkers=1;
	var m = bodyArg;
    	p=m.indexOf(":");var latd=m.substring(0, p);m=m.substring(p+1);
    	p=m.indexOf(":");var longtd=m.substring(0, p);m=m.substring(p+1);
    	p=m.indexOf(":");var zoomlvl=m.substring(0, p);m=m.substring(p+1);
    	var nbrmarkers=m;
	var HTMLCode = "<Table width=625 align=center><tr><td align=center><span class='center'><a href='javascript:void(0)' onclick=ivsHideMainMap('" + bodyArg + "');return false;>Hide Map</a></span></td></tr><tr><td align=center><form name=attraction>&nbsp;&nbsp;&nbsp;Ski Areas&nbsp;<input type=checkbox name='skiareas' onClick='ivsProcessAttractions(1);'>&nbsp;&nbsp;&nbsp;Theme Parks&nbsp;<input type=checkbox name='themeparcs' onClick='ivsProcessAttractions(2);'>&nbsp;&nbsp;&nbsp;<a href='http://www.integratedvacationsystems.com/IVS/website/suggestions.htm' target=suggestions>suggest a new category....</a><div id='attractions'></div><input type='hidden' name='Map_Lat_Long' value=''><input type='hidden' name='Map_Latitude' value=" + latd + " ><input type='hidden' name='Map_Longitude' value=" + longtd + " ><input type='hidden' name='Map_Zoom_Level' value=" + zoomlvl + " ><input type='hidden' name='Search_Radius' value=50 ></form></td></tr><TR><TD align=center><a name='pan'><div id='mymap' style='width: 620px; height: 450px'></div></a></TD></TR></TABLE>";
	if (document.getElementById('mapcontainersmall')) {document.getElementById('mapcontainersmall').innerHTML = HTMLCode;}
	try {websiteLoad(bodyArg)} catch(e) {alert(e);};
	ivsMapShownFl = 'Y';
}

function ivsHideMainMap(bodyArg) {
	// Hide main map
        try {websiteUnload();} catch(e) {alert(e);}
	var HTMLCode = "<span class='center'><a href='javascript:void(0)' onclick=ivsShowMainMap('" + bodyArg + "');return false;>Show Map</a></span>";
	if (document.getElementById('mapcontainersmall')) {document.getElementById('mapcontainersmall').innerHTML = HTMLCode;}
	ivsMapShownFl = 'N';
}

function ivsMapit(bodyArg) {
	if (ivsMapShownFl == 'N') {
		ivsShowMainMap(bodyArg);
	}
	websiteMapit(bodyArg);
}

function ivsProcessAttractions(type) {
	if (document.getElementById('attractions')) {document.getElementById('attractions').innerHTML = '<font Size=3>Please wait ...</font';}
	try {websiteProcessAttractions(type)} catch(e) {alert(e);}
}

function ivsToggle(bodyArg) {
	websiteToggle(bodyArg);
}

function ivsValidateUSAZipCode(zipCode) {
	// Set and call to websitepro_address.pl elements
	ivsSwitch = 'Y';
	if (document.getElementById('addressZipCd')) {document.getElementById('addressZipCd').value = zipCode.value;}		
	ivsCreateCookie('addressdatazipcd',zipCode.value, '');
	websiteValidateUSAZipCode(zipCode.value);
}

function ivsValidateUSAZipCodeReturn(returnCode) {
	if (returnCode == 0) {
		// Error
		alert("The zip code entered does not exist.  Please  try again");
		if (document.getElementById('addressdatacity')) {document.getElementById('addressdatacity').value = '';}
		if (document.getElementById('addressCity')) {document.getElementById('addressCity').value = '';}
		ivsCreateCookie('addressdatacity','', '');
		if (document.getElementById('addressdatastatecd')) {document.getElementById('addressdatastatecd').value = '';}		
		if (document.getElementById('addressStateCd')) {document.getElementById('addressStateCd').value = '';}		
		ivsCreateCookie('addressdatastatecd','', '');
	}
	else {
		// Ok
		if (document.getElementById('addressdatacity')) {document.getElementById('addressdatacity').value = websiteZipCode.city;}
		if (document.getElementById('addressCity')) {document.getElementById('addressCity').value = websiteZipCode.city;}
		ivsCreateCookie('addressdatacity',websiteZipCode.city, '');
		if (document.getElementById('addressdatastatecd')) {document.getElementById('addressdatastatecd').value = websiteZipCode.stateCd;}		
		if (document.getElementById('addressStateCd')) {document.getElementById('addressStateCd').value = websiteZipCode.stateCd;}		
		ivsCreateCookie('addressdatastatecd',websiteZipCode.stateCd, '');
	}
}

function ivsGetCountryCodes() {
	// Set and call to websitepro_address.pl elements
	ivsSwitch = 'Y';
	websiteGetCountryCodes();
}

function ivsGetCountryCodesReturn(returnCode) {
	try{ivsFormatCountryCode(returnCode);} catch(e) {alert(e);}
}

function ivsFormatCountryCode(returnCode) {
	var numElements = websiteCountryCodes.length;
	var selectedCountry = ivsReadCookie('countryCd');
	if (selectedCountry == '') {selectedCountry = 1;}
	for (var x = 0; x<numElements; x++) {
		var countryId = websiteCountryCodes[x].countryId;
		var countryCd = websiteCountryCodes[x].countryCd;
		var countryTxt = websiteCountryCodes[x].countryTxt;
		var optNew = document.createElement('option');
		optNew.text = countryTxt;
		optNew.value = countryId;
		var select = document.getElementById('countryCd');
		try {
			select.add(optNew, null); // standards compliant; doesn't work in IE
		}
		catch(e) {
			select.add(optNew); // IE only
		}
		if (selectedCountry == countryId) {optNew.selected = true;}
	}
	ivsGetAddressElements(selectedCountry) ;
}

function ivsGetAddressElements(countryCode) {
	// Set and call to websitepro_address.pl elements
	ivsSwitch = 'Y';
	ivsCreateCookie('countryCd',countryCode, '');
	websiteGetAddressElements(countryCode, '');
}

function ivsGetAddressElementsReturn(returnCode, telCode) {
	var addressElementsHTML = '<table width=100% align=center valign=top>';
	var numElements = websiteAddressElements.length;
	for (var x = 0; x<numElements; x++) {
		var elementRequiredFl = websiteAddressElements[x].elementRequiredFl;
		var elementValidation = websiteAddressElements[x].elementValidation;
		var valueOther = '';
		if (elementRequiredFl == 'R') {
			valueOther = ' readonly=readonly';
		}
		// Find other validation parameters
		var elementValidationAction = '';
		var elementRequiredText = '';
		// Combine for validation string
		if (elementRequiredFl == 'Y') {
			elementRequiredText = "<font color=red>*<font>";
		}
		var elementName = websiteAddressElements[x].elementName;
		var elementId = websiteAddressElements[x].elementName;
		var elementType = websiteDecodeElementType(websiteAddressElements[x].elementType );
		if (elementRequiredFl != 'R') {
			elementValidationAction = elementValidation;
		}
		if (elementValidationAction == '') {elementValidationAction = "onBlur='saveAddressValue(this);'";}
		var ivsIndex = elementValidationAction.indexOf("='") + 2;
		elementValidationAction = elementValidationAction.substring(0,ivsIndex) + 'ivs' + elementValidationAction.substring(ivsIndex,ivsIndex+1).toUpperCase() + elementValidationAction.substring(ivsIndex+1);
		if (websiteAddressElements[x].elementName == 'Address_Ln1') {elementId = "addressdataln1"; elementName = "addressdataln1";}
		if (websiteAddressElements[x].elementName == 'Address_Ln2') {elementId = "addressdataln2"; elementName = "addressdataln2";}
		if (websiteAddressElements[x].elementName == 'Address_City') {elementId = "addressdatacity"; elementName = "addressdatacity";}
		if (websiteAddressElements[x].elementName == 'Address_State_Cd') {elementId = "addressdatastatecd"; elementName = "addressdatastatecd";}
		if (websiteAddressElements[x].elementName == 'Address_Zip_Cd') {elementId = "addressdatazipcd"; elementName = "addressdatazipcd";}
		var elementValue = ivsReadCookie(elementName);
	      	addressElementsHTML = addressElementsHTML + " <tr><td align=left >" + websiteAddressElements[x].elementLabel + " " + elementRequiredText + "<br /><input type=" + elementType + " name=" + elementName + " id=" + elementId + " value='" + elementValue + "' "  + elementValidationAction + " size='" + websiteAddressElements[x].elementLength + "' maxlength='" + websiteAddressElements[x].elementEnterableLength + "'" + valueOther + " AUTOCOMPLETE=OFF ></td></tr>";
	}
	addressElementsHTML = addressElementsHTML + '</table>';
	if (document.getElementById('addressdata')) {document.getElementById('addressdata').innerHTML = addressElementsHTML;}
	if (document.getElementById('telCountryCd')) {document.getElementById('telCountryCd').value = telCode;}
}
function ivsSaveAgencyPlan(planTypeCd) {
	// Set and call to websitepro_signup.pl elements
	ivsCreateCookie('agencyplan',planTypeCd.value, '');
}

function ivsGetAgencyPlans(planType) {
	// Set and call to websitepro_signup.pl elements
	ivsSwitch = 'Y';
	websiteGetAgencyPlans(ivsPortal, ivsType, ivsEntityId, ivsSecurityKey, planType);
}

function ivsGetAgencyPlansReturn(returnCode) {
	try {ivsFormatAgencyPlans(returnCode);} catch(e) {alert(e);}
}

function ivsFormatAgencyPlans(returnCode) {
	var numElements = websiteAgencyPlans.length;
	var selectedPlan = ivsReadCookie('agencyplan');
	for (var x = 0; x<numElements; x++) {
		var planId = websiteAgencyPlans[x].planTypeCd + websiteAgencyPlans[x].websitePlanId;
		var planDesc = "";
		var trial = '';	
		if (websiteAgencyPlans[x].trialPeriodDays > 0 && websiteAgencyPlans[x].listingFeeMonthlyAmt > 0) {
			trial = " - "+ websiteAgencyPlans[x].trialPeriodDays + " Day FREE Trial";
		}
		if (websiteAgencyPlans[x].priceTypeCd == 'R') {
			if (websiteAgencyPlans[x].planTypeCd == 'L') {
				planDesc = "Listing plan for up to " + websiteAgencyPlans[x].nbrOfListingsAmt + " listing(s) (" + websiteAgencyPlans[x].currencySymbol + websiteAgencyPlans[x].listingFeeMonthlyAmt + "/" + websiteAgencyPlans[x].currencySymbol + websiteAgencyPlans[x].listingFeeSemiAmt + "/" + websiteAgencyPlans[x].currencySymbol + websiteAgencyPlans[x].listingFeeAnnualAmt + ")" + trial;
			}
			else {
				planDesc = "VRAPro plan for up to " + websiteAgencyPlans[x].nbrOfListingsAmt + " listing(s) (" + websiteAgencyPlans[x].currencySymbol + websiteAgencyPlans[x].listingFeeMonthlyAmt + "/" + websiteAgencyPlans[x].currencySymbol + websiteAgencyPlans[x].listingFeeSemiAmt + "/" + websiteAgencyPlans[x].currencySymbol + websiteAgencyPlans[x].listingFeeAnnualAmt + ")" + trial;
			}
		}
		else {
			planDesc = websiteAgencyPlans[x].currencySymbol + websiteAgencyPlans[x].listingFeeMonthlyAmt + "/" + websiteAgencyPlans[x].currencySymbol + websiteAgencyPlans[x].listingFeeSemiAmt + "/" + websiteAgencyPlans[x].currencySymbol + websiteAgencyPlans[x].listingFeeAnnualAmt + " Per listing" + trial;
		}
		var optNew = document.createElement('option');
		optNew.text = planDesc;
		optNew.value = planId;
		var select = document.getElementById('planTypeCd');
		try {
			select.add(optNew, null); // standards compliant; doesn't work in IE
		}
		catch(e) {
			select.add(optNew); // IE only
		}
		if (selectedPlan == planId) {optNew.selected = true;}
	}
	ivsGetCountryCodes(); 
}

function ivsSaveOwnerPlan(planTypeCd) {
	// Set and call to websitepro_aignup.pl elements
	ivsCreateCookie('ownerplan',planTypeCd.value, '');
}

function ivsGetOwnerPlans(planType) {
	// Set and call to websitepro_signup.pl elements
	ivsSwitch = 'Y';
	websiteGetOwnerPlans(ivsPortal, ivsType, ivsEntityId, ivsSecurityKey, planType);
}

function ivsGetOwnerPlansReturn(returnCode) {
	ivsFormatOwnerPlans(returnCode);
}

function ivsFormatOwnerPlans(returnCode) {
	var numElements = websiteOwnerPlans.length;
	var selectedPlan = ivsReadCookie('ownerplan');
	for (var x = 0; x<numElements; x++) {
		var planId = websiteOwnerPlans[x].planTypeCd + websiteOwnerPlans[x].websitePlanId;
		var planDesc = "";
		var trial = '';	
		if (websiteOwnerPlans[x].trialPeriodDays > 0 && websiteOwnerPlans[x].listingFeeMonthlyAmt > 0) {
			trial = " - " + websiteOwnerPlans[x].trialPeriodDays + " Day FREE Trial";
		}
		if (websiteOwnerPlans[x].priceTypeCd == 'R') {
			if (websiteOwnerPlans[x].planTypeCd == 'L') {
				planDesc = "Listing plan for up to " + websiteOwnerPlans[x].nbrOfListingsAmt + " listing(s) (" + websiteOwnerPlans[x].currencySymbol + websiteOwnerPlans[x].listingFeeMonthlyAmt + "/" + websiteOwnerPlans[x].currencySymbol + websiteOwnerPlans[x].listingFeeSemiAmt + "/" + websiteOwnerPlans[x].currencySymbol + websiteOwnerPlans[x].listingFeeAnnualAmt + ")" + trial;
			}
			else {
				planDesc = "OwnerPro plan for up to " + websiteOwnerPlans[x].nbrOfListingsAmt + " listing(s) (" + websiteOwnerPlans[x].currencySymbol + websiteOwnerPlans[x].listingFeeMonthlyAmt + "/" + websiteOwnerPlans[x].currencySymbol + websiteOwnerPlans[x].listingFeeSemiAmt + "/" + websiteOwnerPlans[x].currencySymbol + websiteOwnerPlans[x].listingFeeAnnualAmt + ")" + trial;
			}
		}
		else {
			planDesc = websiteOwnerPlans[x].currencySymbol + websiteOwnerPlans[x].listingFeeMonthlyAmt + "/" + websiteOwnerPlans[x].currencySymbol + websiteOwnerPlans[x].listingFeeSemiAmt + "/" + websiteOwnerPlans[x].currencySymbol + websiteOwnerPlans[x].listingFeeAnnualAmt + " Per listing" + trial;
		}
		var optNew = document.createElement('option');
		optNew.text = planDesc;
		optNew.value = planId;
		var select = document.getElementById('planTypeCd');
		try {
			select.add(optNew, null); // standards compliant; doesn't work in IE
		}
		catch(e) {
			select.add(optNew); // IE only
		}
		if (selectedPlan == planId) {optNew.selected = true;}
	}
	ivsGetCountryCodes(); 
}
var ivsCheckOwnerOnly = 'N';
var ivsCheckVacationerOnly = 'N';
var ivsCheckVacationerAddAllowed = 'N';
var ivsCheckWebsiteOnly = 'N';
var ivsCheckAgencyOnly = 'N';
var ivsCheckJointOnly = 'N';

function ivsLoginVacationer() {
	if (document.getElementById('Login_Cd').value == '') {
		alert("Please enter a login code/email");
	}
	if (document.getElementById('Login_Password').value == '') {
		alert("Please enter a password");
	}
	document.vacationerloginform.userLoginCd.value = document.getElementById('Login_Cd').value;
	document.vacationerloginform.password.value = document.getElementById('Login_Password').value;
	ivsCheckLogin(document.vacationerloginform.userLoginCd.value, document.vacationerloginform.password.value, 'V');
}

function ivsLoginOwner() {
	if (document.getElementById('Login_Cd').value == '') {
		alert("Please enter a login code/email");
	}
	if (document.getElementById('Login_Password').value == '') {
		alert("Please enter a password");
	}
	document.ownerloginform.userLoginCd.value = document.getElementById('Login_Cd').value;
	document.ownerloginform.password.value = document.getElementById('Login_Password').value;
	ivsCheckLogin(document.ownerloginform.userLoginCd.value, document.ownerloginform.password.value, 'O');
}

function ivsLoginJoint() {
	if (document.getElementById('Login_Cd').value == '') {
		alert("Please enter a login code/email");
	}
	if (document.getElementById('Login_Password').value == '') {
		alert("Please enter a password");
	}
	document.jointloginform.userLoginCd.value = document.getElementById('Login_Cd').value;
	document.jointloginform.password.value = document.getElementById('Login_Password').value;
	ivsCheckLogin(document.jointloginform.userLoginCd.value, document.jointloginform.password.value, 'J');
}

function ivsLoginAgency() {
	if (document.getElementById('Login_Cd').value == '') {
		alert("Please enter a login code/email");
	}
	if (document.getElementById('Login_Password').value == '') {
		alert("Please enter a password");
	}
	document.agencyloginform.userLoginCd.value = document.getElementById('Login_Cd').value;
	document.agencyloginform.password.value = document.getElementById('Login_Password').value;
	ivsCheckLogin(document.agencyloginform.userLoginCd.value, document.agencyloginform.password.value, 'A');
}

function ivsLoginWebsite() {
	if (document.getElementById('Login_Cd').value == '') {
		alert("Please enter a login code/email");
	}
	if (document.getElementById('Login_Password').value == '') {
		alert("Please enter a password");
	}
	document.websiteloginform.userLoginCd.value = document.getElementById('Login_Cd').value;
	document.websiteloginform.password.value = document.getElementById('Login_Password').value;
	ivsCheckLogin(document.websiteloginform.userLoginCd.value, document.websiteloginform.password.value, 'W');
}

function ivsCheckLoginCode(loginCode) {
	ivsSwitch = 'Y';
	websiteCheckLoginCode(ivsPortal, ivsSessionId, ivsType, ivsEntityId, ivsSecurityKey, loginCode, '');
	var HTMLCode="<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center colspan=3><TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><BR />Please Wait While We Try To Find Your Login Information.....<BR /><BR /></TD></TR></TABLE></TD></TR></TABLE>";
	if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = HTMLCode;}
	HTMLCode="";
	if (document.getElementById('message')) {document.getElementById('message').innerHTML = HTMLCode;}
	if (document.getElementById('namefields')) {document.getElementById('namefields').innerHTML = HTMLCode;}
	if (document.getElementById('choosefields')) {document.getElementById('choosefields').innerHTML = HTMLCode;}
	if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = HTMLCode;}
}

function ivsCheckLoginCodeReturn(returnCode, name, age, first, last, telNbr, vacationerFl, websiteFl, agencyFl, ownerFl, jointFl) {
	// Return from websiteCheckLoginCode call
	if (ivsCheckOwnerOnly == 'Y') {ivsCheckOwnerLoginCodeReturn(returnCode, name, ownerFl); return;}
	if (ivsCheckVacationerOnly == 'Y') {ivsCheckVacationerLoginCodeReturn(returnCode, name, age, first, last, telNbr, vacationerFl); return;}
	if (ivsCheckWebsiteOnly == 'Y') {ivsCheckWebsiteLoginCodeReturn(returnCode, name, websiteFl); return;}
	if (ivsCheckAgencyOnly == 'Y') {ivsCheckAgencyLoginCodeReturn(returnCode, name, agencyFl); return;}
	if (ivsCheckJointOnly == 'Y') {ivsCheckJointLoginCodeReturn(returnCode, name, jointFl); return;}

	var messageHTMLCode = '';
	var loginHTMLCode = '';
	var nameHTMLCode = '';
	var buttonsHTMLCode = '';
	var chooseHTMLCode = '';
	var logins = 0;
	if (vacationerFl == 'Y') {logins++;}
	if (websiteFl == 'Y') {logins++;}
	if (agencyFl == 'Y') {logins++;}
	if (ownerFl == 'Y') {logins++;}
	if (jointFl == 'Y') {logins++;}
	if (returnCode == 0) {
		// Found login.  Ask for password and details
		messageHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><font size=4><b>Welcome Back " + name + "!<br />Please enter your password below and then click the login link.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Your Password&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Password Size=30 Maxlength=25 id=Login_Password Name=Login_Password value='' >&nbsp;&nbsp&nbsp;</TD></TR></TABLE>";
		if (logins > 1) {
			chooseHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><b>The email address entered is valid for more than one portal.  After you enter your password please select the portal you wish to login to by clicking on the link below.</b></TD></TR></TABLE>";
		}
		else {
			chooseHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><b>After you enter your password please click on the link below to login.</b></TD></TR></TABLE>";
		}
		buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR>";
		if (vacationerFl == 'Y') {
			buttonsHTMLCode = buttonsHTMLCode + "<td align=center><center><a href='onclick=ivsLoginVacationer();' target=vacationer>Vacationer Portal</a><br />( <a href='http://www.integratedvacationsystems.com/cgi-bin/IVS/vacationer/presentforgottenlogin.pl?websiteId=" + ivsEntityId + "&userLoginCd=" + document.getElementById('Login_Cd').value + "' target=vacationer>forgotten password</a> )</center></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		}
		if (websiteFl == 'Y') {
			buttonsHTMLCode = buttonsHTMLCode + "<td align=center><center><a href='onclick=ivsLoginWebsite();' target=website>Website Portal</a><br />( <a href='http://www.integratedvacationsystems.com/cgi-bin/IVS/website/presentforgottenlogin.pl?websiteId=" + ivsEntityId + "&userLoginCd=" + document.getElementById('Login_Cd').value + "' target=website>forgotten password</a> )</center></td ><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		}
		if (agencyFl == 'Y') {
			buttonsHTMLCode = buttonsHTMLCode + "<td align=center><center><a href='onclick=ivsLoginAgency();' target=agency>Agency Portal</a><br />( <a href='http://www.integratedvacationsystems.com/cgi-bin/IVS/agency/presentforgottenlogin.pl?websiteId=" + ivsEntityId + "&userLoginCd=" + document.getElementById('Login_Cd').value + "' target=agency>forgotten password</a> )</center></td ><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		}
		if (ownerFl == 'Y') {
			buttonsHTMLCode = buttonsHTMLCode + "<td align=center><center><a href='onclick=ivsLoginOwner();' target=owner>Owner Portal</a><br />( <a href='http://www.integratedvacationsystems.com/cgi-bin/IVS/owner/presentforgottenlogin.pl?websiteId=" + ivsEntityId + "&userLoginCd=" + document.getElementById('Login_Cd').value + "' target=owner>forgotten password</a> )</center></td ><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		}
		if (jointFl == 'Y') {
			buttonsHTMLCode = buttonsHTMLCode + "<td align=center><center><a href='onclick=ivsLoginJoint();' target=owner>Joint Owners</a><br />( <a href='http://www.integratedvacationsystems.com/cgi-bin/IVS/owner/presentforgottenlogin.pl?websiteId=" + ivsEntityId + "&userLoginCd=" + document.getElementById('Login_Cd').value + "' target=owner>forgotten password</a> )</center></td ><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
		}
		buttonsHTMLCode = buttonsHTMLCode + "</TR></TABLE>";		

		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('choosefields')) {document.getElementById('choosefields').innerHTML = chooseHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
		document.getElementById('Login_Password').focus();
	}
	else {
		// Didn't find person.  Ask for repeat fields.
		messageHTMLCode = "<TABLE cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><br /><br /><b>This email address was not found on our system.  Please check that it is correct.  If you are not currently a member please click the Sign-Up link in the top right hand corner of the screen to set up an account.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "";
		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('choosefields')) {document.getElementById('choosefields').innerHTML = chooseHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
		document.loginform.Login_Cd.focus();
	}
}

function ivsCheckLogin(loginCd, loginPassword, type) {
	ivsSwitch = 'Y';
	websiteCheckLogin(ivsPortal, ivsSessionId, ivsType, ivsEntityId, ivsSecurityKey, loginCd, loginPassword, type);
}

function ivsCheckLoginReturn(returnCode, type) {
	if (returnCode == 0) {
		// Login good.  Log the user in
		if (type == 'V') {
			document.vacationerloginform.submit();
		}
		if (type == 'O') {
			document.ownerloginform.submit();
		}
		if (type == 'A') {
			document.agencyloginform.submit();
		}
		if (type == 'W') {
			document.websiteloginform.submit();
		}
		if (type == 'J') {
			document.jointloginform.submit();
		}
	}
	else {
		// Invalid login.
		messageHTMLCode = "<TABLE cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><b>This email address/password combination was not found on our system.  Please check that it is correct.</b></font></TD></TR></TABLE>";
		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
	}
}

function ivsCheckOwnerLoginCode(loginCode) {
	ivsCheckOwnerOnly = 'Y';
	ivsCheckLoginCode(loginCode);
}

function ivsCheckOwnerLoginCodeReturn(returnCode, name, ownerFl) {
	// Return from websiteCheckLoginCode call
	var messageHTMLCode = '';
	var loginHTMLCode = '';
	var nameHTMLCode = '';
	var buttonsHTMLCode = '';
	if (returnCode == 0 && ownerFl == 'Y') {
		// Found login.  Ask for password and details
		messageHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><font size=4><b>Welcome Back " + name + "!<br />Please enter your password below and then click the login link.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Your Password&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Password Size=30 Maxlength=25 id=Login_Password Name=Login_Password value='' >&nbsp;&nbsp&nbsp;</TD></TR></TABLE>";
		buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR>";
		buttonsHTMLCode = buttonsHTMLCode + "<td align=center><center><a href='javascript:void(0)' onclick=ivsLoginOwner(); target=owner>Owner Portal</a><br />( <a href='http://www.integratedvacationsystems.com/cgi-bin/IVS/owner/presentforgottenlogin.pl?websiteId=" + ivsEntityId + "&userLoginCd=" + document.getElementById('Login_Cd').value + "' target=owner>forgotten password</a> )</center></td >";
		buttonsHTMLCode = buttonsHTMLCode + "</TR></TABLE>";

		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
		document.getElementById('Login_Password').focus();
	}
	else {
		// Didn't find person as owner.  Ask for repeat fields.
		messageHTMLCode = "<TABLE cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><b>This email address was not found on our system.  Please check that it is correct.  If you are not currently a member please use one of the links below to set-up an account.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "";
		messageHTMLCode = "<TABLE cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><br /><br /><b>This email address was not found on our system.  Please check that it is correct.  If you are not currently a member please click the Sign-Up link in the top right hand corner of the screen to set up an account.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "";
		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
		document.loginform.Login_Cd.focus();
	}
}

function ivsCheckJointLoginCode(loginCode) {
	ivsCheckJointOnly = 'Y';
	ivsCheckLoginCode(loginCode);
}

function ivsCheckJointLoginCodeReturn(returnCode, name, jointFl) {
	// Return from websiteCheckLoginCode call
	var messageHTMLCode = '';
	var loginHTMLCode = '';
	var nameHTMLCode = '';
	var buttonsHTMLCode = '';
	if (returnCode == 0 && jointFl == 'Y') {
		// Found login.  Ask for password and details
		messageHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><font size=4><b>Welcome Back " + name + "!<br />Please enter your password below and then click the login link.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Your Password&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Password Size=30 Maxlength=25 id=Login_Password Name=Login_Password value='' >&nbsp;&nbsp&nbsp;</TD></TR></TABLE>";
		buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR>";
		buttonsHTMLCode = buttonsHTMLCode + "<td align=center><center><a href='javascript:void(0)' onclick=ivsLoginJoint(); target=owner>Joint Owners Portal</a><br />( <a href='http://www.integratedvacationsystems.com/cgi-bin/IVS/owner/presentforgottenlogin.pl?websiteId=" + ivsEntityId + "&userLoginCd=" + document.getElementById('Login_Cd').value + "' target=owner>forgotten password</a> )</center></td >";
		buttonsHTMLCode = buttonsHTMLCode + "</TR></TABLE>";

		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
		document.getElementById('Login_Password').focus();
	}
	else {
		// Didn't find person as owner.  Ask for repeat fields.
		messageHTMLCode = "<TABLE cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><b>This email address was not found on our system.  Please check that it is correct.  If you are not currently a member please use one of the links below to set-up an account.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "";
		messageHTMLCode = "<TABLE cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><br /><br /><b>This email address was not found on our system.  Please check that it is correct.  If you are not currently a member please click the Sign-Up link in the top right hand corner of the screen to set up an account.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "";
		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
		if (document.getElementById('logincd')) {document.getElementById('logincd').focus();}
	}
}

function ivsCheckVacationerLoginCode(loginCode) {
	ivsCheckVacationerReturn = 'L';
	ivsCheckVacationerOnly = 'Y';
	ivsCheckVacationerAddAllowed = 'N';
	ivsCheckLoginCode(loginCode);
}

function ivsCheckVacationerLoginCodeWithAdd(loginCode) {
	ivsCheckVacationerReturn = 'L';
	ivsCheckVacationerOnly = 'Y';
	ivsCheckVacationerAddAllowed = 'Y';
	ivsCheckLoginCode(loginCode);
}

function ivsCheckVacationerLoginCodeWithAddShort(loginCode) {
	if (ivsValidateEmail(loginCode)  == -1 ) {
		return;
	}
	ivsCheckVacationerReturn = 'S';
	ivsCheckVacationerOnly = 'Y';
	ivsCheckVacationerAddAllowed = 'Y';
	ivsCheckLoginCode(loginCode);
}

function ivsCheckVacationerLoginCodeReturn(returnCode, name, age, first, last, telNbr, vacationerFl) {
	if (ivsCheckVacationerReturn == 'L') {
		ivsCheckVacationerLoginCodeReturnLong(returnCode, name, age, first, last, telNbr, vacationerFl);
	}
	else {
		ivsCheckVacationerLoginCodeReturnShort(returnCode, name, age, first, last, telNbr, vacationerFl);
	}
}

function ivsCheckVacationerLoginCodeReturnLong(returnCode, name, age, first, last, telNbr, vacationerFl) {
	var messageHTMLCode = '';
	var loginHTMLCode = '';
	var nameHTMLCode = '';
	var buttonsHTMLCode = '';
	if (returnCode == 0 && vacationerFl == 'Y') {
		// Found login.  Ask for password and details
		if (ivsCheckVacationerAddAllowed == 'N') {
			messageHTMLCode = "<TABLE width=90% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><font size=4><b>Welcome Back " + name + "!<br />Please enter your password below and then click the login link.</b></font></TD></TR></TABLE>";
			buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR><td align=center><center><a href='javascript:void(0)' onclick=ivsLoginVacationer(); target=vacationer>Vacationer Portal</a><br />( <a href='http://www.integratedvacationsystems.com/cgi-bin/IVS/vacationer/presentforgottenlogin.pl?websiteId=" + ivsEntityId + "&userLoginCd=" + document.getElementById('Login_Cd').value + "' target=vacationer>forgotten password</a> )</center></td></TR></TABLE>";
		}
		else {
			messageHTMLCode = "<TABLE width=90% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><font size=4><b>Welcome Back " + name + "!<br />Please enter your password below.</b></font></TD></TR></TABLE>";
			buttonsHTMLCode = "";
		}
		loginHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Your Password&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Password Size=30 Maxlength=25 id=Login_Password Name=Vacationer_Login_Password value='' onBlur=ivsSaveVacationerValue(this);>&nbsp;&nbsp&nbsp;</TD></TR></TABLE>";

		if (document.getElementById('vacationerFirstNm')) {document.getElementById('vacationerFirstNm').value = first;}
		if (document.getElementById('vacationerLastNm')) {document.getElementById('vacationerLastNm').value = last;}
		if (document.getElementById('vacationerAgeCd')) {document.getElementById('vacationerAgeCd').value = age;}
		if (document.getElementById('vacationerHomeTelNbr')) {document.getElementById('vacationerHomeTelNbr').value = telNbr;}

		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
		if (document.getElementById('loginpassword')) {document.getElementById('loginpassword').focus();}
	}
	else {
		// Didn't find person as vacationer.  Ask for repeat fields.
		if (ivsCheckVacationerAddAllowed == 'N') {
			messageHTMLCode = "<TABLE width=90% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><b>This email address was not found on our system.  Please check that it is correct.  If you are not currently a member please use one of the links below to set-up an account.</b></font></TD></TR></TABLE>";
		}
		else {
			messageHTMLCode = "<TABLE width=90% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><b>This email address was not found on our system.  Please check that it is correct.  If you are not currently a member please enter data in the fields below and an account will be set-up for you.</b></font></TD></TR></TABLE>";
		}
		if (ivsCheckVacationerAddAllowed == 'N') {
			loginHTMLCode = "";
		}
		else {
			loginHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Reapeat Your Email Address&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Text Size=50 Maxlength=70 Name=Repeat_Login_Cd id=repeatlogincd value='' onBlur=ivsSaveVacationerValue(this);></TD></TR><TR><TD align=left>Your Password&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Password Size=20 Maxlength=15 Name=Vacationer_Login_Password id=loginpassword value='' onBlur=ivsSaveVacationerValue(this);></TD></TR><TR><TD align=left>Repeat Password &nbsp;<font color='#FF0000'>*</font><br /><Input Type=Password Size=20 Maxlength=15 Name=Repeat_Login_Password id=repeatpassword value='' onBlur=ivsSaveVacationerValue(this);></TD></TR></TABLE><TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Name&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Text Size=25 Maxlength=20 Name=Vacationer_First_Nm id=firstnm value='' onBlur=ivsSaveVacationerValue(this);>&nbsp;<Input Type=Text Size=25 Maxlength=20 Name=Vacationer_Last_Nm id=lastnm value='' onBlur=ivsSaveVacationerValue(this);></TD></TR><TR><TD align=left>Your Age Range<br /><Select Name=Vacationer_Age_Cd id=agecd onChange=ivsSaveVacationerValue(this);><Option value=18 >Under 21</option><Option value=21 >21 to 25</option><Option value=25 >25-30</option><Option value=30 >Over 30</option></TD></TR><TR><TD align=left>Phone Number&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Text Size=15 Maxlength=10 Name=Vacationer_Home_Tel_Nbr id=hometelnbr value='' onBlur=ivsSaveVacationerValue(this);></TD></TR></TABLE>";
		}
		buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR>";
		buttonsHTMLCode = buttonsHTMLCode + "<td align=center><a href='vacationer_signup.html' target=vacationer><img src=images/signupnoww.gif></a><br /></td><td><img src=images/spacer.gif width=50 height=10></td>";
		buttonsHTMLCode = buttonsHTMLCode + "</TR></TABLE>";
		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
		if (document.getElementById('logincd')) {document.getElementById('logincd').focus();}
	}
}

function ivsCheckVacationerLoginCodeReturnShort(returnCode, name, age, first, last, telNbr, vacationerFl) {
	var messageHTMLCode = '';
	var loginHTMLCode = '';
	var nameHTMLCode = '';
	var buttonsHTMLCode = '';
	if (returnCode == 0 && vacationerFl == 'Y') {
		// Found login
		messageHTMLCode = "<TABLE width=90% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><font size=4><b>Welcome Back " + name + "!</b></font></TD></TR></TABLE>";
		if (document.getElementById('vacationerFirstNm')) {document.getElementById('vacationerFirstNm').value = first;}
		if (document.getElementById('vacationerLastNm')) {document.getElementById('vacationerLastNm').value = last;}
		if (document.getElementById('vacationerAgeCd')) {document.getElementById('vacationerAgeCd').value = age;}
		if (document.getElementById('vacationerHomeTelNbr')) {document.getElementById('vacationerHomeTelNbr').value = telNbr;}
	}
	else {
		loginHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Reapeat Your Email Address&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Text Size=50 Maxlength=70 Name=Repeat_Login_Cd id=repeatlogincd value='' onBlur=ivsSaveVacationerValue(this);></TD></TR></TABLE>";
	}

	var selected18 = '';
	var selected21 = '';
	var selected25 = '';
	var selected30 = '';
	if (age == 18) {selected18 = 'selected=selected';}
	if (age == 21) {selected21 = 'selected=selected';}
	if (age == 25) {selected25 = 'selected=selected';}
	if (age == 30) {selected30 = 'selected=selected';}

	loginHTMLCode = loginHTMLCode + "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Name&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Text Size=25 Maxlength=20 Name=Vacationer_First_Nm id=firstnm value='" + first + "' onBlur=ivsSaveVacationerValue(this);>&nbsp;<Input Type=Text Size=25 Maxlength=20 Name=Vacationer_Last_Nm id=lastnm value='" + last + "' onBlur=ivsSaveVacationerValue(this);></TD></TR><TR><TD align=left>Your Age Range<br /><Select Name=Vacationer_Age_Cd id=agecd onChange=ivsSaveVacationerValue(this);><Option value=18 " + selected18 + " >Under 21</option><Option value=21 " + selected21 + " >21 to 25</option><Option value=25 " + selected25 + " >25-30</option><Option value=30 " + selected30 + " >Over 30</option></TD></TR><TR><TD align=left>Phone Number&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Text Size=15 Maxlength=10 Name=Vacationer_Home_Tel_Nbr id=hometelnbr value='" + telNbr + "' onBlur=ivsSaveVacationerValue(this);></TD></TR></TABLE>";
	buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR>";
	buttonsHTMLCode = buttonsHTMLCode + "<td align=center><a href='vacationer_signup.html' target=vacationer><img src=images/signupnoww.gif></a><br /></td><td><img src=images/spacer.gif width=50 height=10></td>";
	buttonsHTMLCode = buttonsHTMLCode + "</TR></TABLE>";

	if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
	if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
	if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
	if (document.getElementById('repeatlogincd')) {document.getElementById('repeatlogincd').focus();}

}

function ivsCheckAgencyLoginCode(loginCode) {
	ivsCheckAgencyOnly = 'Y';
	ivsCheckLoginCode(loginCode);
}

function ivsCheckAgencyLoginCodeReturn(returnCode, name, agencyFl) {
	// Return from websiteCheckLoginCode call
	var messageHTMLCode = '';
	var loginHTMLCode = '';
	var nameHTMLCode = '';
	var buttonsHTMLCode = '';
	if (returnCode == 0 && agencyFl == 'Y') {
		// Found login.  Ask for password and details
		messageHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><font size=4><b>Welcome Back " + name + "!<br />Please enter your password below and then click the login link.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Your Password&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Password Size=30 Maxlength=25 id=Login_Password Name=Login_Password value='' >&nbsp;&nbsp&nbsp;</TD></TR></TABLE>";
		buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR>";
		buttonsHTMLCode = buttonsHTMLCode + "<td align=center><center><a href='javascript:void(0)' onclick=ivsLoginAgency(); target=agency>Agency Portal</a><br />( <a href='http://www.integratedvacationsystems.com/cgi-bin/IVS/agency/presentforgottenlogin.pl?websiteId=" + ivsEntityId + "&userLoginCd=" + document.getElementById('Login_Cd').value + "' target=agency>forgotten password</a> )</center></td >";
		buttonsHTMLCode = buttonsHTMLCode + "</TR></TABLE>";		

		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
		document.getElementById('Login_Password').focus();
	}
	else {
		// Didn't find person.  Ask for repeat fields.
		messageHTMLCode = "<TABLE cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><b>This email address was not found on our system.  Please check that it is correct.  If you are not currently a member please use one of the links below to set-up an account.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "";
		messageHTMLCode = "<TABLE cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><br /><br /><b>This email address was not found on our system.  Please check that it is correct.  If you are not currently a member please click the Sign-Up link in the top right hand corner of the screen to set up an account.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "";
		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
		document.loginform.Login_Cd.focus();
	}
}

function ivsValidateEmail(loginCode) {
	if (loginCode == '') {return -1;}
	if (loginCode.indexOf('@') == -1) {alert('Please enter a valid email address in the Your Email Address field'); return -1;}
	return 0;
}
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }
String.prototype.startsWith = function(s) { return this.substring(0,s.length - 1) == s; }
String.prototype.endsWith = function(s) { return this.length >= s.length && this.substring(this.length - s.length) == s; }

Array.prototype.destroy=function() {
  this.length=0;
  return this;
};

function AssocArray(){
}

AssocArray.prototype.size = function() {
	var result = 0;
	for (i in this) {
		if(this[i].startsWith) {
			result++;
		}
	}
	return result;
}

AssocArray.prototype.keys = function(){
	var result = new Array();
	for (i in this) {
		if(this[i].startsWith) {
			result[result.length] = i;
		}
	}
	return result;
}

AssocArray.prototype.values = function(){
	var result = new Array();
	for (i in this) {
		if(this[i].startsWith) {
			result[result.length] = this[i];
		}
	}
	return result;
}

function ivsGetCurrentDate () {
	var myDate = Date().getFullYear() + '-' + Date().getMonth() + '-' + Date().getDate();
	return myDate;
}

function ivsSaveAddressValue(element) {
	// used to save dynamic (i.e. fields that are displayed or hidden via javascript) field values to non-dynamic fields
	var name = element.name;
	var value = element.value;
	ivsCreateCookie(name,value,'');
	if (name == 'addressdataln1') {if (document.getElementById('addressLn1')) {document.getElementById('addressLn1').value = value;}}
	if (name == 'addressdataln2') {if (document.getElementById('addressLn2')) {document.getElementById('addressLn2').value = value;}}
	if (name == 'addressdatacity') {if (document.getElementById('addressCity')) {document.getElementById('addressCity').value = value;}}
	if (name == 'addressdatastatecd') {if (document.getElementById('addressStateCd')) {document.getElementById('addressStateCd').value = value;}}
	if (name == 'addressdatazipcd') {if (document.getElementById('addressZipCd')) {document.getElementById('addressZipCd').value = value;}}
}

function ivsSaveVacationerValue(element) {
	// used to save dynamic (i.e. fields that are displayed or hidden via javascript) field values to non-dynamic fields
	var name = element.name;
	var value = element.value;
	ivsCreateCookie(name,value,'');
	if (name == 'Repeat_Login_Cd') {if (document.getElementById('repeatLoginCd')) {document.getElementById('repeatLoginCd').value = value;}}
	if (name == 'Vacationer_Login_Password') {if (document.getElementById('vacationerLoginPassword')) {document.getElementById('vacationerLoginPassword').value = value;}}
	if (name == 'Repeat_Login_Password') {if (document.getElementById('repeatLoginPassword')) {document.getElementById('repeatLoginPassword').value = value;}}
	if (name == 'Vacationer_First_Nm') {if (document.getElementById('vacationerFirstNm')) {document.getElementById('vacationerFirstNm').value = value;}}
	if (name == 'Vacationer_Last_Nm') {if (document.getElementById('vacationerLastNm')) {document.getElementById('vacationerLastNm').value = value;}}
	if (name == 'Vacationer_Age_Cd') {if (document.getElementById('vacationerAgeCd')) {document.getElementById('vacationerAgeCd').value = value;}}
	if (name == 'Vacationer_Home_Tel_Nbr') {if (document.getElementById('vacationerHomeTelNbr')) {document.getElementById('vacationerHomeTelNbr').value = value;}}
}

function ivsCreateCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else {
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function ivsReadCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') { c = c.substring(1,c.length);}
		if (c.indexOf(nameEQ) == 0) {return c.substring(nameEQ.length,c.length); }
	}
	return '';
}

function ivsEraseCookie(name) {
	ivsCreateCookie(name,"",-1);
}

function ivsGetFormParameters () {
	ivsFormParams = location.href.substring((location.href.indexOf('?')+1), location.href.length);
	if(location.href.indexOf('?') < 0) {ivsFormParams = new AssocArray(); return;}
	var paramssplit = ivsFormParams.split('&');
	ivsFormParams = new AssocArray();

	for(var i = 0; i < paramssplit.length; i++){
			var namevalue = paramssplit[i].split('=');
			namevalue[1] = namevalue[1].replace(/\+/g, ' ');
			ivsFormParams[namevalue[0]] = unescape(namevalue[1]);
	}
}

function ivsFormatMoney (argNumber, argCurrencySymbol, argDigitsAfterDecimal) {

	if (argNumber == '') {argNumber = 0;}

	// Check sign
	var sign = '';
	if (argNumber < 0) {
		sign = '-';
		argNumber = argNumber * -1;
	}

	// Add commas etc to a number
	var length = argNumber.toString().length;
	var endDigits = '';
	var dp = argNumber.toString().indexOf('.');
	if (dp > 0) {endDigits = argNumber.toString().substr(dp+1, length-dp-1); argNumber = argNumber.toString().substr(0, dp);}

	length = argNumber.toString().length;
	var i=length-3;
	var commas=0;
	while (i > 0) {
		var n=length-i-commas;
		if (n == (Math.floor(n) / 3) * 3) {
			// Add in comma
			argNumber = argNumber.toString().substr(0, i) + ',' + argNumber.toString().substr(i, length-i);
			commas++;
			length++;
			i=i-2;
		}
		i--;
	}

	if (argDigitsAfterDecimal > 0) {
		l = endDigits.toString().length;
		i = 0;
		var oldEndDigits = endDigits;
		endDigits = '.';
		while (i < argDigitsAfterDecimal) {
			// Add in digit
			if (i < l) {
				endDigits = endDigits + oldEndDigits.toString().substr(i, 1);
			}
			else {
				endDigits = endDigits + '0';
			}
			i++;
		}
	}
	else {
		endDigits = '';
	}

	if (length > 0) {
		// Add currency symbol
			argNumber = argCurrencySymbol + argNumber;
	}

	argNumber = argNumber + endDigits;

	if (sign == '-') {
		argNumber = '(' + argNumber + ')';
	}

	return argNumber;

}

var ivsAllowOnlineReservationsFl = 'N';

function ivsSetAllowOnlineReservationsFl (value) {
	ivsAllowOnlineReservationsFl = value;
}

function ivsGetVacationerData(loginCode) {
	ivsSwitch = 'Y';
	try {websiteGetVacationerData(ivsPortal, ivsSessionId, ivsType, ivsWebsiteId, ivsSecurityKey, '', loginCode, '');} catch(e) {alert(e);}
	var HTMLCode="<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center colspan=3><TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><BR />Please Wait While We Try To Find Your Login Information.....<BR /><BR /></TD></TR></TABLE></TD></TR></TABLE>";
	if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = HTMLCode;}
	HTMLCode="";
	if (document.getElementById('namefields')) {document.getElementById('namefields').innerHTML = HTMLCode;}
	if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = HTMLCode;}
}

function ivsGetVacationerDataReturn(returnCode) {
	var messageHTMLCode = '';
	var loginHTMLCode = '';
	var nameHTMLCode = '';
	var buttonsHTMLCode = '';
	if (returnCode == 0) {
		// Found vacationer.  Ask for password and  details
		var ageCdSelected18 = '';
		if (websiteVacationer.vacationerAgeCd == 18) {ageCdSelected18 = 'selected';}
		var ageCdSelected21 = '';
		if (websiteVacationer.vacationerAgeCd == 21) {ageCdSelected21 = 'selected';}
		var ageCdSelected25 = '';
		if (websiteVacationer.vacationerAgeCd == 25) {ageCdSelected25 = 'selected';}
		var ageCdSelected30 = '';
		if (websiteVacationer.vacationerAgeCd == 30) {ageCdSelected30 = 'selected';}
		messageHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=center><font size=4><b>Welcome Back " + websiteVacationer.vacationerFirstNm + " " + websiteVacationer.vacationerLastNm + "!</b></font></TD></TR></TABLE>";
		loginHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Your Password&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Password Size=20 Maxlength=15 Name=Vacationer_Login_Password id=loginpassword value='" + websiteVacationer.vacationerLoginPassword + "' onBlur=ivsSaveVacationerValue(this);>&nbsp;&nbsp&nbsp;<a href='http://www.integratedvacationsystems.com/IVS/vacationer/forgottenlogin.htm' target=vacationer>forgotten password</a></TD></TR></TABLE>";
		nameHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left >Name&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Text Size=25 Maxlength=20 Name=Vacationer_First_Nm id=firstnm value='" + websiteVacationer.vacationerFirstNm + "' onBlur=ivsSaveVacationerValue(this);>&nbsp;<Input Type=Text Size=25 Maxlength=20 Name=Vacationer_Last_Nm id=lastnm value='" + websiteVacationer.vacationerLastNm + "' onBlur=ivsSaveVacationerValue(this);></TD></TR><TR><TD align=left>Your Age Range<br /><Select Name=Vacationer_Age_Cd id=agecd  onChange=ivsSaveVacationerValue(this);><Option value=18 " + ageCdSelected18 + ">Under 21</option><Option value=21 " + ageCdSelected21 + ">21 to 25</option><Option value=25 " + ageCdSelected25 + ">25-30</option><Option value=30 " + ageCdSelected30 + ">Over 30</option></TD></TR><TR><TD align=left>Phone Number&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Text Size=15 Maxlength=10 Name=Vacationer_Home_Tel_Nbr id=hometelnbr value='" + websiteVacationer.vacationerHomeTelNbr + "' onBlur=ivsSaveVacationerValue(this);></TD></TR></TABLE>";
		if (ivsAllowOnlineReservationsFl == 'Y') {
			buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR><TD align=center><input type=Submit value='Continue'><img src='http://www.integratedvacationsystems.com/IVS/images/spacer.gif' width='8' height='5' /><input type=Reset value=Reset>\n</TD></TR></TABLE>";
		}
		else {
			buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR><TD align=center><input type=Submit value='Submit Reservation Request'><img src='http://www.integratedvacationsystems.com/IVS/images/spacer.gif' width='8' height='5' /><input type=Reset value=Reset>\n</TD></TR></TABLE>";
		}

		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('namefields')) {document.getElementById('namefields').innerHTML = nameHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
	}
	else {
		// Didn't find vacationer.  Ask for repeat fields.
		messageHTMLCode = "<TABLE cellspacing=0 cellpadding=0 border=0 align=center><TR><TD><font color='#FF0000'><b>This email address was not found on our system.  Please check that it is correct.  If this is the first time using our website to make a reservation request then please enter the required information below and click the continue button.  A login will be created for future use.</b></font></TD></TR></TABLE>";
		loginHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Your Password&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Password Size=20 Maxlength=15 Name=Vacationer_Login_Password id=loginpassword value='" + websiteVacationer.vacationerLoginPassword + "' onBlur=ivsSaveVacationerValue(this);></TD></TR><TR><TD align=left>Repeat Password &nbsp;<font color='#FF0000'>*</font><br /><Input Type=Password Size=10 Maxlength=15 Name=Repeat_Login_Password id=repeatpassword value='" + websiteVacationer.repeatLoginPassword  + "' onBlur=ivsSaveVacationerValue(this);></TD></TR></TABLE>";
		nameHTMLCode = "<TABLE width=100% cellspacing=0 cellpadding=0 border=0 align=center><TR><TD align=left>Name&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Text Size=25 Maxlength=20 Name=Vacationer_First_Nm id=firstnm value='" + websiteVacationer.vacationerFirstNm + "' onBlur=ivsSaveVacationerValue(this);>&nbsp;<Input Type=Text Size=25 Maxlength=20 Name=Vacationer_Last_Nm id=lastnm value='" + websiteVacationer.vacationerLastNm + "' onBlur=ivsSaveVacationerValue(this);></TD></TR><TR><TD align=left>Your Age Range<br /><Select Name=Vacationer_Age_Cd id=agecd onChange=ivsSaveVacationerValue(this);><Option value=18 " + ageCdSelected18 + ">Under 21</option><Option value=21 " + ageCdSelected21 + ">21 to 25</option><Option value=25 " + ageCdSelected25 + ">25-30</option><Option value=30 " + ageCdSelected30 + ">Over 30</option></TD></TR><TR><TD align=left>Phone Number&nbsp;<font color='#FF0000'>*</font><br /><Input Type=Text Size=15 Maxlength=10 Name=Vacationer_Home_Tel_Nbr id=hometelnbr value='" + websiteVacationer.vacationerHomeTelNbr + "' onBlur=ivsSaveVacationerValue(this);></TD></TR></TABLE>";
		if (websiteVacationer.vacationerLoginCd != '') {
			if (ivsAllowOnlineReservationsFl == 'Y') {
				buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR><TD align=center><input type=Submit value='Continue'><img src='http://www.integratedvacationsystems.com/IVS/images/spacer.gif' width='8' height='5' /><input type=Reset value=Reset>\n</TD></TR></TABLE>";
			}
			else {
				buttonsHTMLCode = "<TABLE cellspacing=0 align=center border=0><TR><TD align=center><input type=Submit value='Submit Reservation Request'><img src='http://www.integratedvacationsystems.com/IVS/images/spacer.gif' width='8' height='5' /><input type=Reset value=Reset>\n</TD></TR></TABLE>";
			}
		}
		if (document.getElementById('message')) {document.getElementById('message').innerHTML = messageHTMLCode;}
		if (document.getElementById('loginfields')) {document.getElementById('loginfields').innerHTML = loginHTMLCode;}
		if (document.getElementById('namefields')) {document.getElementById('namefields').innerHTML = nameHTMLCode;}
		if (document.getElementById('buttonfields')) {document.getElementById('buttonfields').innerHTML = buttonsHTMLCode;}
	}
}
