﻿var SignupMessage = new Object();
SignupMessage.MorePics = "<div align=\"center\" style=\"font-size: 12px;\">In order to access the additional photos you must first create an account. Once you have an account you get much more than just photos, you also get:</div><ul style=\"font-size: 12px; margin: 1px;\"><li>Your own <span style=\"color: red\">Password Protected Personal Buyer Website</span></li><li><span style=\"color: red\">Save the Listings</span> that you like</li><li><span style=\"color: red\">Email Notifications for new listings</span> that come on the Market</li><li>Access all <span style=\"color: red\">Virtual tours</span></li><li>And more...</li></ul>This is a completely free service so sign up and get started today!<br />";
SignupMessage.SaveListing = "<div align=\"center\" style=\"font-size: 12px;\">In order to save this property you must first create an account. Once you have an account you get much more than simply a place to track your favorite properties, you also get:</div><ul style=\"font-size: 12px; margin: 1px;\"><li>Your own <span style=\"color: red\">Password Protected Personal Buyer Website</span></li><li><span style=\"color: red\">Email Notifications for new listings</span> that come on the Market</li><li>Access all <span style=\"color: red\">Virtual tours</span></li><li>And more...</li></ul>This is a completely free service so sign up and get started today!<br />";

/* Functions to Load All Form Elements with an ID into a Cookie for later retrieval */
var HtmlForm; // HtmlForm must be set manually in the page calling this script

var PageName = new String();

try {
	/* initialize the PageName Code/Identifier */
	PageName = self.location.href;
	PageName = PageName.substring(PageName.lastIndexOf("/") + 1, PageName.indexOf(".", PageName.lastIndexOf("/")));
} catch(e) {PageName = "HCError";}

/* *** IMPORTANT: It is good enough that the cookie is going to expire soon and that the lead is still on the agent's site
if (CurrentAgent && CurrentAgent.WebID) {
	PageName = PageName.toString() + "_" + CurrentAgent.WebID.toString();
}
*/

function RestoreFormState(showErrorOnMissingElement) {
	if (!HtmlForm) {return -1;}
	var struct = new Object();
	var FormViewState = new String();
	var i = new Number(0);
	FormViewState = _getCookie("HCFormState=" + PageName);
	// Verify that we found a cookie to load //
	if (!FormViewState || FormViewState.length < 2) {return -1;}

	struct = _readCookiePackage(FormViewState);
	/* Verify struct */
	if (!struct) {return -1;}

	for (key in struct) {
		var obj = document.getElementById(key);
		if (obj) {obj.value = struct[key]; i++ /* increment i counter */ } else {if (showErrorOnMissingElement) {alert('Error: Field NOT Found on Form!\n\nKey: ' + key + '\nValue: ' + struct[key]);}}
	}
	/* Remove the cookie now that we're done with it */
	_deleteCookie("HCFormState=" + PageName);
	return i;
}

function SaveFormState() {
	if (!HtmlForm) {return -1;}
	var struct = new Object();
	var FieldID = new String();
	var Fields = new Array();
	var FormViewState = new String();
	var FormElements = HtmlForm.elements;

	for (var i = 0; i < FormElements.length; i++) {
		FieldID = FormElements[i].id;
		// If we have a valid form element (not ASP.NET hidden form fields) - add it to the Array!
		if (FieldID && FieldID.indexOf("__") <= -1) {
			Fields.push(FieldID);
		}
	}
	// convert the values into a structure for storage in a cookie
	for( var i=0; i < Fields.length; i++ ) {
		struct[Fields[i]] = (document.getElementById(Fields[i]) ? unescape(document.getElementById(Fields[i]).value) : "");
		/* alert(i + ": " + Fields[i] + "\nValue: " + document.getElementById(Fields[i]).value); */
	}
	FormViewState = _createCookiePackage(struct);
	_setCookie("HCFormState=" + PageName, FormViewState);
	return struct.length;
}









