/* author: John Hallgren   */
/* Pleasant Forest Shores  */
/* Creation date: 01/31/05 */
/* Upd:02/15/06 Add LOCATE */
/* Upd:06/19/08 Add DELETE */
/* ****************************** */
/* Reload form fields from COOKIE */
/* debugger; <=Turn on here! */
function fillCRuser(){
	if (window != top) top.location.href=location.href; // Break out of frame 
	if (typeof document.cookie == "string"){
		var CD = locCookie("CRdata")			// Get data for MY cookie ONLY!
		if (CD == null)	{ 
			document.CRaddForm.CRuserName.focus();
			return; 				// None found? Can't reload!
		}
		var CDarray = CD.split("|");			// Break into "item:value" array
		for (x=0; x<CDarray.length; x++){		// Do each element
			CDsplit = CDarray[x].split(":");	// Break item from value
			CDvalue = unescape(CDsplit[1]);		// Recover data 
			CDitem	= eval("document.CRaddForm." + CDsplit[0]);	// Create doc item name
		  	CDitem.value = CDvalue;				// Load saved value into form
		}
	  	document.CRaddForm.CRuserComm.focus()	// Set cursor in TEXT	
	}	
	else {
		document.CRaddForm.CRuserName.focus() 	// Set cursor in NAME
	}	
}	
/* ************************************** */
/* Create COOKIE with user entered fields */
function saveCRuser(){
	if (typeof document.cookie == "string"){
		var CD  = "CRuserName:"  + escape(document.CRaddForm.CRuserName.value )	+ "|"
			+ "CRuserEmail:" + escape(document.CRaddForm.CRuserEmail.value) + "|"
			+ "CRuserCity:"  + escape(document.CRaddForm.CRuserCity.value )	+ "|"
			+ "CRuserState:" + escape(document.CRaddForm.CRuserState.value);
		expireDate = new Date();
		expireDate.setMonth(expireDate.getMonth() + 6);
		document.cookie = "CRdata=" + CD +  ";expires=" + expireDate.toGMTString();
    }	//so document.cookie is not string? bypass!
}
/* ************* */
/* Delete COOKIE */
function delCRuser(){
	if (typeof document.cookie == "string"){
		expireDate = new Date();
		expireDate.setYear(expireDate.getYear() - 1);
		document.cookie = "CRdata=DELETED" +  ";expires=" + expireDate.toGMTString();
    }	//so document.cookie is not string? bypass!
}
/* ***********************/
/* Locate desired COOKIE */
/* from PaulsPages.co.uk */
function locCookie(Name) {
	var DCdata = null;
	var DC = document.cookie;   
	if (DC.length > 0) {
		var CID = Name + "=";
		beg = DC.indexOf(CID);	// Find cookie beg pos, if any
		if (beg != -1) {
			beg += CID.length;			// Bump past 'Name=xxx'
			end = DC.indexOf(";", beg);	// Find cookie end pos
			if (end == -1)
				end = DC.length;
			DCdata = DC.substring(beg, end); // Extract data            
	}	}
return DCdata           
}