//*********************************************************************************************//
// USER.JS 
//*********************************************************************************************//

	var onUserUtilNavKey = '';
	var toUserUtilNav = null;

	var pauseUserUtilNav = 350;			  // pause time

	function pauseHideUserUtilNav() {
		toUserUtilNav = setTimeout("showHideUserUtilNav()", pauseUserUtilNav);
	}

	function changeUserUtilNav(key,state) {
		if (state) {
			if (toUserUtilNav) {
				clearTimeout(toUserUtilNav);
				toUserUtilNav = null;
			}
		} else {
			pauseHideUserUtilNav();
		}
		showHideUserUtilNav(key,state)
	}

	function showHideUserUtilNav(key) {
		if (key == onUserUtilNavKey) {
			
		} else {
			
			if (onUserUtilNavKey == '') {
			
			} else {
				showHideLayers('',onUserUtilNavKey,'hidden');
			}
			if (key == '') {
			
			} else {
				showHideLayers('',key,'visible');
			}
			onUserUtilNavKey = key;
		}
	}

// Functions related to SIGN IN	
	function showConversationWin() {
		showSignUp();
//		document.getElementById('conversationWin').style.display = 'inline';
	}
	
	function showSignUp() {

		showCover();
		showProcessing();
		
		loadExternalFile('utility','/include/utilityForms/formSignUp.php');
		//showHideLayers('','utility','visible');
	}

	
	function showEditProfile () {
		externalFileName = '/include/utilityForms/formEditProfile.php';
		
		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	}
	
	function showEditProfileEmail () {
		externalFileName = '/include/utilityForms/formEditProfileEmail.php';
		
		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	}
	
	function showEditProfilePassword () {
		externalFileName = '/include/utilityForms/formEditProfilePassword.php';
		
		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	}
	
	
	

	function showForgotPwd () {
		document.getElementById('signInWin').style.display = 'none';
		document.getElementById('conversationWin').style.height = '150px';
		document.getElementById('forgotPwdWin').style.display = 'block';		
	}
	
	function closeWin() {
		hideCover();
		clearExternalFile('utility');
		showHideLayers('','utility','hidden');
	}


// Functions related to MY LOCALE	
	//function showAccountWin() {
	//	document.getElementById('accountWin').style.display = 'block';
	//}

	//function closeAcctWin() {
	//	document.getElementById('accountWin').style.display = 'none';
	//}
	
	
	
	function showSaveSearch (searchUrlStr, searchName) {
		externalFileName = '/include/utilityForms/formSaveSearch.php';
		externalFileName += '?searchUrlStr=' + encodeURIComponent(searchUrlStr);
		externalFileName += '&searchName=' + encodeURIComponent(searchName);
		
		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	}
	
	function showDeleteSearch (searchUrlStr, searchName, siteId, recId) {
		externalFileName = '/include/utilityForms/formDeleteSearch.php';
		externalFileName += '?searchUrlStr=' + encodeURIComponent(searchUrlStr);
		externalFileName += '&searchName=' + encodeURIComponent(searchName);
		externalFileName += '&siteId=' + siteId;
		
		if (recId) {
			externalFileName += '&recId=' + recId;
		}
	
		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	}


	
	function showSaveProperty (prop_id) {
		externalFileName = '/include/utilityForms/formSaveProperty.php';
		externalFileName += '?prop_id=' + prop_id;
		
		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	}
	
	function showRemoveProperty (propId, siteId) {
		externalFileName = '/include/utilityForms/formDeleteProperty.php';
		externalFileName += '?propId=' + propId + '&siteId=' + siteId;
		
		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	}



	function showSaveResource (client_id) {
		externalFileName = '/include/utilityForms/formSaveResource.php';
		externalFileName += '?client_id=' + client_id;
		
		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	}
	
	function showRemoveResource (clientId, siteId) {
		externalFileName = '/include/utilityForms/formDeleteResource.php';
		externalFileName += '?clientId=' + clientId + '&siteId=' + siteId;
		
		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	}
	
	function showEmailToFriend (id,type,source) { 
		showCover();
		showProcessing();
		
		externalFileName = '/include/utilityForms/formEmailAFriend.php';
		externalFileName += '?send_id=' + id +'&send_type='+ type +'&source='+ source +'&referer='+ encodeURI(self.location.href);
		
		loadExternalFile('utility',externalFileName);
	}
	
	function validateEmailToFriendForm (frm, urchinTrackerEntityKey) {
		// hide all possible visible errors - reset
		hideLayerBlock('utilWinErrorMsg');
		
		hideLayerBlock('utilWinFrmErrorToEmail');
		hideLayerBlock('utilWinFrmErrorFromEmail');
		hideLayerBlock('utilWinFrmErrorComments');
		
		rtn = true;
		urchinErrStr = '';
		
		if (!validateEmailField(frm.elements['zszeznzdz_ztzoz'].value)) {
			showLayerBlock('utilWinFrmErrorToEmail');
			
			rtn = false;
			urchinErrStr = urchinErrStr +'invalidToEmail';
		}
		
		if (!validateEmailField(frm.elements['zszeznzdz_zfzrzozmz'].value)) {
			showLayerBlock('utilWinFrmErrorFromEmail');
			
			rtn = false;
			urchinErrStr = urchinErrStr +'invalidFromEmail';
		}
		
		if (frm.elements['zczozmzmzeznztzsz'].value.length > 350) {
			showLayerBlock('utilWinFrmErrorComments');
			
			rtn = false;
			urchinErrStr = urchinErrStr +'commentsTooLong';
		}
		
		if (!rtn) {
			showLayerBlock('utilWinErrorMsg');
			
			// log to urchin
			urchinTracker('/email+a+friend/error/'+ urchinTrackerEntityKey + urchinErrStr);
		}
		
		return rtn;
	}
	
	function processEmailToFriend (frm, urchinTrackerEntityKey) {
		showCover();
		
		endShortTimeoutEval = 'displayStandardSuccessResult()';
		showProcessing('Sending your email...');
		
		// asynchronous email handling
		externalFileName = '/include/utilityForms/formEmailAFriend.php';
		externalFileName += '?'+  parseForm(frm);
		
		executeExternalFile(externalFileName);
		
		// log to urchin
		urchinTracker('/email+a+friend/thankyou/'+ urchinTrackerEntityKey);
	}
	
	
	function showAdQuickContact(id,type,source,extra,adid)
	{
		showQuickContact (id,type,source);
		var url = '/include/adQuickContact.php?id=' + adid + '&url=http://www.locale.com&extra=' + extra;
		loadXMLDoc(url,'');
	}
	
	
	function adClickThruHandler(response)
	{
		response = '';
	}
		
	
	function showQuickContact (id,type,source,agent) {
		showCover();
		showProcessing();
		
		externalFileName = '/include/utilityForms/formQuickContact.php';
		externalFileName += '?send_id=' + id +'&send_type='+ type +'&source='+ source +'&agent=' + agent + '&referer='+ encodeURI(self.location.href);
		
		loadExternalFile('utility',externalFileName);
	}
	
	
	function validateQuickContactForm (frm, urchinTrackerEntityKey) {
		// hide all possible visible errors - reset
		if (frm.elements['autoClose'].value == 'yesPlease') {
				hideLayerBlock('utilWinVisErrorMsg');
		
				hideLayerBlock('utilWinVisFrmErrorName');
				hideLayerBlock('utilWinVisFrmErrorEmail');
				hideLayerBlock('utilWinVisFrmErrorComments');
			} else {
				hideLayerBlock('utilWinErrorMsg');
		
				hideLayerBlock('utilWinFrmErrorName');
				hideLayerBlock('utilWinFrmErrorEmail');
				hideLayerBlock('utilWinFrmErrorComments');
			}
		
		
		
		rtn = true;
		urchinErrStr = '';
		
		if (frm.elements['znzazmzez'].value == '') {
			if (frm.elements['autoClose'].value == 'yesPlease') {
				showLayerBlock('utilWinVisFrmErrorName');
			} else {
				showLayerBlock('utilWinFrmErrorName');
			}
			
			rtn = false;
			urchinErrStr = urchinErrStr +'missingName';
		}
		
		if (!validateEmailField(frm.elements['zezmzazizlz'].value)) {
			if (frm.elements['autoClose'].value == 'yesPlease') {
				showLayerBlock('utilWinVisFrmErrorEmail');
			} else {
				showLayerBlock('utilWinFrmErrorEmail');
			}
			
			rtn = false;
			urchinErrStr = urchinErrStr +'invalidEmail';
		}
		
		if (frm.elements['zczozmzmzeznztzsz'].value.length > 350) {
			if (frm.elements['autoClose'].value == 'yesPlease') {
				showLayerBlock('utilWinVisFrmErrorComments');
			} else {
				showLayerBlock('utilWinFrmErrorComments');
			}
			
			rtn = false;
			urchinErrStr = urchinErrStr +'commentsTooLong';
		}
		
		if (!rtn) {
			if (frm.elements['autoClose'].value == 'yesPlease') {
				showLayerBlock('utilVisWinErrorMsg');
			} else {
				showLayerBlock('utilWinErrorMsg');
			}
			
			// log to urchin
			urchinTracker('/quick+contact/error/'+ urchinTrackerEntityKey + urchinErrStr);
		}
		
		return rtn;
	}
	
	
	function processQuickContact (frm, urchinTrackerEntityKey) {
		
		showCover();
		
		if (frm.elements['autoClose'].value == 'yesPlease') {
			endShortTimeoutEval = 'displayStandardSuccessResultVisibleForm()';
		} else {
			endShortTimeoutEval = 'displayStandardSuccessResult()';
		}
		
		showProcessing('Sending your request...');
		
		// asynchronous email handling
		externalFileName = '/include/utilityForms/formQuickContact.php';
		externalFileName += '?'+  parseForm(frm);
		
		executeExternalFile(externalFileName);
		
		if (frm.elements['autoClose'].value == 'yesPlease') {
			hideCover();
		}	
			
		// log to urchin
		urchinTracker('/quick+contact/thankyou/'+ urchinTrackerEntityKey);
	}	
	
	
	
	
	
	function showMortgageQuote (price) {

		externalFileName = '/include/utilityForms/formMortgageQuote.php';
		externalFileName += '?loanValue=' + price;
		
		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	}
	
	function processMortgageQuote (frm) {
	
		externalFileName = '/include/utilityForms/formMortgageQuote.php';
		externalFileName += '?'+  parseForm(frm) ;

		showCover();
		showProcessing();
		loadExternalFile('utility',externalFileName);
	
	}
	
	
	
	
	function displayStandardSuccessResult() {
		hideLayerBlock('utilWinFormBlock');
		
		showLayerBlock('utilWinSuccessMsg');
		
		hideProcessing();
	}
	
	function displayStandardSuccessResultVisibleForm() {
		hideLayerBlock('utilWinVisFormBlock');
		
		showLayerBlock('utilWinVisSuccessMsg');
		
		hideProcessing();
	}

//*********************************************************************************************//
// HTTP_REQUEST.JS 
//*********************************************************************************************//


var req = false;


/* source: http://www.webpasties.com/xmlHttpRequest/xmlHttpRequest_tutorial_1.html */

function getXMLHttpRequestObject() {

  var xmlhttp;

  /*@cc_on

  @if (@_jscript_version >= 5)

    try {

      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {

      try {

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (E) {

        xmlhttp = false;

      }

    }

  @else

  xmlhttp = false;

  @end @*/

  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

    try {
      xmlhttp = new XMLHttpRequest();

    } catch (e) {
      xmlhttp = false;

    }
  }

  return xmlhttp;

}


// ??? not sure why there's two similar functions here ???

function getXmlHttpObj() { 

	var objXMLHttp=null

	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}

	return objXMLHttp

}



function processReqChange() {

	// only if req shows "complete"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
			// ...processing statements go here...
			response = req.responseXML.documentElement;

			method = response.getElementsByTagName('method')[0].firstChild.data;

			result = response.getElementsByTagName('result')[0].firstChild.data;

			eval(method + '(result)');

		} else {

			alert("Error: status code is " + req.status);

		}
	}
}


function loadXMLDoc(url) {
	
	req = getXMLHttpRequestObject(); // We create the HTTP Object
	
	if (req) {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send(null);
	}

}



function loadExternalFile (intoDiv,url) {

	var reqLoadExternalFile = null;
	reqLoadExternalFile = getXmlHttpObj();
	
	reqLoadExternalFile.onreadystatechange = function(){
		if (reqLoadExternalFile.readyState == 4){
			if (reqLoadExternalFile.status == 200){
//				getElmById(intoDiv).innerHTML = req.responseText;
				
				postProcess(reqLoadExternalFile, intoDiv);
//				document.getElementById(intoDiv).innerHTML = req.responseText;
			} else {
				reqLoadExternalFile.errorString = "An error prevented this view from loading.";
				postProcess(reqLoadExternalFile);
//				getElmById(intoDiv).innerHTML = "An error prevented this view from loading.";
//				document.getElementById(intoDiv).innerHTML = "There was an error... =(";
			}
		}
	};
	reqLoadExternalFile.open("GET", url, true);
	reqLoadExternalFile.send(null);

}



// don't care about response
function executeExternalFile (url) {

	var reqExecuteExternalFile = null;
	reqExecuteExternalFile = getXmlHttpObj();

	reqExecuteExternalFile.open("GET", url, true);
	reqExecuteExternalFile.send(null);

}



function clearExternalFile (intoDiv) {

	getElmById(intoDiv).innerHTML = '';
//	document.getElementById(intoDiv).innerHTML = '';

}

function getElmById (id) {

	var el = null; 

	if (document.getElementById) {
		// isMozilla || isIE5
		el = document.getElementById(id) 
	} else if (document.layers) {
		// isNetscape4
		el = document.layers[id] 
	} else if (document.all) {
		// isIE4
		el = document.all[id]; 
	}

	return el; 

}


//*********************************************************************************************//
// USER_PROCESSING.JS 
//*********************************************************************************************//


var pwd1;
var pwd2;
var url;
var htmlString;


var STANDARD_CLOSE_WINDOW_TIMEOUT = 500;

function errorMsg(r) {
	alert (r);
}

// Process FORM DATA
function parseForm (frm) {

	var string = '';

	for (i = 0; i < frm.elements.length; i++) {
		elm = frm.elements[i]
		
		if (elm.type == 'checkbox') {
			if (elm.checked) {
				string += '&'+ frm.elements[i].name +'='+ encodeURIComponent(frm.elements[i].value);
			}
		} else if (elm.type == 'radio') {
			if (elm.checked) {
				string += '&'+ frm.elements[i].name +'='+ encodeURIComponent(frm.elements[i].value);
			}
		} else if (elm.type == 'select') {
			if (elm.selectedindex >= 0) {
				string += '&'+ frm.elements[i].name +'='+ encodeURIComponent(frm.elements[i].options[elm.selectedIndex].value);
			}
		} else {
			string += '&'+ frm.elements[i].name +'='+ encodeURIComponent(frm.elements[i].value);
		}
	
	}

	return string

}

// Functions related to SIGN IN and OUT
function processSignIn(frm) {
	url = '/include/users/processSignIn.php'
	url += '?'+ parseForm(frm);
	
	loadXMLDoc(url);	
}

function signedIn (r) {
	htmlString = "You are signed in.";
	personalUrl = r;
	
	document.getElementById('signInWin').innerHTML = htmlString;
	t = setTimeout("closeWin()",1000); // Close all pop overs
	
	document.getElementById('signInOut').innerHTML = '<a class="userNav" rel="nofollow" href="javascript:processSignOut();" title="Sign Out of My Locale"><img src="/images/nav/userNav_signOut.png" alt="Sign Out" width="50" height="21" border=0></a>';
	document.getElementById('accountLink').href = personalUrl;
	document.getElementById('accountLink').innerHTML = "<b>My Locale</b>";
}



function processSignOut() {
	url = '/include/users/processSignOut.php';
	
	loadXMLDoc(url);	
}


function signOut(r) {
	// success - hard code redirect to home page
	window.location = '/';	
}


// Functions related to SIGN UP / REGISTRATION
function checkPwdMatch(frm) {
	pwd1 = frm.pwd1.value;
	pwd2 = frm.pwd2.value;
	
	if (pwd1 == pwd2) {
		processRegistration(frm);
	}else{
		alert ('Password entries must match.')
	}
	
}


function checkPwdMatchForEdit(frm) {
	pwd1 = frm.pwd1.value;
	pwd2 = frm.pwd2.value;
	
	if (pwd1 == pwd2) {
		processEditProfilePassword(frm);
	}else{
		alert ('New password entries must match.')
	}
	
}

function processRegistration(frm) {
	url = '/include/users/processRegistration.php';
	url += '?'+ parseForm(frm);
	
	loadXMLDoc(url);
}

function registrationProcessed(r) {
	// success - hard code redirect to my locale home
	window.location = '/my+locale/';	
}




// Functions related to EDIT PROFILE

function processEditProfile(frm) {
	url = '/include/users/processEditProfile.php';
	url += '?'+ parseForm(frm);

	loadXMLDoc(url);
}


function processEditProfileEmail(frm) {
	url = '/include/users/processEditProfileEmail.php';
	url += '?'+ parseForm(frm);

	loadXMLDoc(url);
}

function processEditProfilePassword(frm) {
	url = '/include/users/processEditProfilePassword.php';
	url += '?'+ parseForm(frm);

	loadXMLDoc(url);
}


function editProcessed (r) {
	alert ("Your information has been updated!");
	
	// success -just reload my locale home
	window.location = '/my+locale/?open=1';	
}







// Functions related to FORGOT PASSWORD
function processForgotPwd(frm) {
	url = '/include/users/processForgotPwd.php'
	url += '?'+ parseForm(frm);
	//url += '?email=' + self.document.forgotPwdForm.email.value;
	
	loadXMLDoc(url);	
}

function sentForgotPwdEmail(r) {
	document.getElementById('forgotPwdWin').innerHTML = '<div class="userQuestion" style="padding-top: 60px;">'+ r +'</div>';
	t1 = setTimeout("closeWin()",3500); // Close all pop overs
}




// Functions related to FORMS
function fillForm () {
	url = '/include/users/processFormInfo.php';

	loadXMLDoc(url);
}




// Functions related to SAVING to MY LOCALE

// Search
function processSaveSearch(frm) {
	url = '/include/users/processSaveSearch.php';
	url += '?'+  parseForm(frm);
	//url += '?searchUrlStr='+ frm.searchUrlStr.value;
	//url += '&searchName='+ frm.searchName.value;
		
	loadXMLDoc(url);	
}

function savedSearch (r) {
	// Close all pop overs
	t = setTimeout("closeWin()", STANDARD_CLOSE_WINDOW_TIMEOUT); 

	// Change "save" link to "remove"
	hrefStr = "javascript:showDeleteSearch(" + r + ")";
	titleStr = "Remove this Real Estate Property Search from Your Favorites";
	if (document.getElementById('searchActionLink')) {
		document.getElementById('searchActionLink').href = hrefStr;
		document.getElementById('searchActionLink').title = titleStr;
		
		document.getElementById('searchActionLink').innerHTML = "<b>Remove Search from Favorites</b>";
	} else if (document.getElementById('searchActionLink_btn')) {
		document.getElementById('searchActionLink_btn').href = hrefStr;	
		document.getElementById('searchActionLink_btn').title = titleStr;
		
		document.getElementById('searchActionLink_btn').innerHTML = '<img src="/sister_images/buttons/btn_remove_from_favorites.gif" width="176" height="21" border=0>';
	}
	
}

function processDeleteSearch(frm) {
	url = '/include/users/processDeleteSearch.php';
	url += '?'+  parseForm(frm);
		
	loadXMLDoc(url);	
}

function deletedSearch (r) {
	// Close all pop overs
	t = setTimeout("closeWin()", STANDARD_CLOSE_WINDOW_TIMEOUT); 
	
	//alert(r +'::'+ r.indexOf(','));
	
	// if return doesn't contain a comma, then recId based
	if (r.indexOf(',') == -1) {
		// if on my locale list view, hide the display block
		if (document.getElementById('savedSearchDisplayDiv_'+ r)) {
			document.getElementById('savedSearchDisplayDiv_'+ r).style.display = 'none';
		}

	// otherwise, change link, if exists
	} else {
		// Change "remove" link to "save"
		hrefStr = "javascript:showSaveSearch(" + r + ")";
		titleStr = "Save this Real Estate Property Search to Your Favorites";
		if (document.getElementById('searchActionLink')) {
			document.getElementById('searchActionLink').href = hrefStr;
			document.getElementById('searchActionLink').title = titleStr;
			
			document.getElementById('searchActionLink').innerHTML = "<b>Save Search to Favorites</b>";
		} else if (document.getElementById('searchActionLink_btn')) {
			document.getElementById('searchActionLink_btn').href = hrefStr;	
			document.getElementById('searchActionLink_btn').title = titleStr;
			
			document.getElementById('searchActionLink_btn').innerHTML = '<img src="/sister_images/buttons/btn_save_search.gif" width="141" height="21" border=0>';
		}
	}
}

// Property 
function processSaveProperty(frm) {
	url = '/include/users/processSaveProperty.php';
	url += '?'+  parseForm(frm);
	//url += '?propId='+  propId + '&siteId=' + siteId;
		
	loadXMLDoc(url);	
}

function savedProperty (r) {

	t = setTimeout("closeWin()", STANDARD_CLOSE_WINDOW_TIMEOUT); // Close all pop overs
	
	// only passing back propId now
	//inputArr = r.split("-");
	
	linkName = 'propertyActionLink_' + r;
	linkNameBtn = 'propertyActionLink_btn_' + r;
	
	// Change "save" link to "remove"
	hrefStr = "javascript:showRemoveProperty('"+ r +"')";
	titleStr = "Remove this Property Listing from Your Favorites";
	// Change to remove text or button depending on what was there before
	if (document.getElementById(linkName)) {				
		document.getElementById(linkName).href = hrefStr;
		document.getElementById(linkName).title = titleStr;
														
		document.getElementById(linkName).innerHTML = "<img src=\"/images/gen/bug_PR_saveListing.gif\" width=\"20\" height=\"20\" alt=\"Remove this Property Listing\" border=\"0\" hspace=3 align=absmiddle><span style=\"text-decoration: underline;\">Delete from Favorites</span>";
	} else if (document.getElementById(linkNameBtn)) {				
		document.getElementById(linkNameBtn).href = hrefStr;
		document.getElementById(linkNameBtn).title = titleStr;
		
		document.getElementById(linkNameBtn).innerHTML = "<img src='/images/buttons/btn_remove_from_favorites.gif' border='0' alt='Remove this Property from your Favorites'>";
	}
}

function processDeleteProperty(frm) {
	url = '/include/users/processDeleteProperty.php';
	url += '?'+  parseForm(frm);
	//url += '?propId='+  propId + '&propName=' + propName + '&siteId=' + siteId;
		
	loadXMLDoc(url);	
}

function deletedProperty (r) {
	
	t = setTimeout("closeWin()", STANDARD_CLOSE_WINDOW_TIMEOUT); // Close all pop overs
	
	// only passing back propId now
	//inputArr = r.split("-");
	
	
	// if on my locale list view, hide the display block
	if (document.getElementById('savedPropertyDisplayDiv_'+ r)) {
		document.getElementById('savedPropertyDisplayDiv_'+ r).style.display = 'none';
		
	// otherwise, change link, if exists
	} else {
		
		linkName = 'propertyActionLink_' + r;
		linkNameBtn = 'propertyActionLink_btn_' + r;
		
		hrefStr = "javascript:showSaveProperty('" + r + "')";
		titleStr = "Save this Property Listing to Your Favorites";
		// Change to save text or button depending on what was there before
		if (document.getElementById(linkName)) {
			document.getElementById(linkName).href = hrefStr;
			document.getElementById(linkName).title = titleStr;
			
			document.getElementById(linkName).innerHTML = "<img src=\"/images/gen/bug_PR_saveListing.gif\" width=\"20\" height=\"20\" alt=\"Save this Property Listing\" border=\"0\" hspace=3 align=absmiddle><span style=\"text-decoration: underline;\">Save to Favorites</span>";
		} else if (document.getElementById(linkNameBtn)) {
			document.getElementById(linkNameBtn).href = hrefStr;
			document.getElementById(linkNameBtn).title = titleStr;
			
			document.getElementById(linkNameBtn).innerHTML = "<img src=\"/sister_images/buttons/btn_add_to_favorites.gif\" border='0' alt='Save this Property to your Favorites'>";
		}		
	}
}

// Resources

function processSaveResource(frm) {
	url = '/include/users/processSaveResource.php';
	url += '?'+  parseForm(frm);
	//url += '?resourceId='+  resourceId + '&siteId=' + siteId + '&type=' + type; 
		
	loadXMLDoc(url);	
}

function savedResource (r) {
	
	t = setTimeout("closeWin()", STANDARD_CLOSE_WINDOW_TIMEOUT); // Close all pop overs
	
	// only passing back clientId now
	//inputArr = r.split("-");
	
	
	linkName = 'resourceActionLink_' + r;
	linkNameBtn = 'resourceActionLink_btn_' + r;

	// Change "save" link to "remove"
	hrefStr = "javascript:showRemoveResource('" + r + "')";
	titleStr = "Remove this Real Estate Resource from Your Favorites";
	// Change to remove text or button depending on what was there before
	if (document.getElementById(linkName)) {				
		document.getElementById(linkName).href = hrefStr;
		document.getElementById(linkName).title = titleStr;
		
		document.getElementById(linkName).innerHTML = "<img src=\"/images/gen/bug_PR_saveListing.gif\" width=\"20\" height=\"20\" alt=\"Remove this Resource\" border=\"0\" hspace=3 align=absmiddle><span style=\"text-decoration: underline;\">Delete from Favorites</span>";
	} else if (document.getElementById(linkNameBtn)) {		
		document.getElementById(linkNameBtn).href = hrefStr;	
		document.getElementById(linkNameBtn).title = titleStr;
		
		document.getElementById(linkNameBtn).innerHTML = "<img src='/images/buttons/btn_remove_from_favorites.gif' border='0' alt='Remove this Resource from your Favorites'>";
	}
}

function processDeleteResource(frm) {
	url = '/include/users/processDeleteResource.php';
	url += '?'+  parseForm(frm);
	//url += '?resourceId='+  resourceId + '&siteId=' + siteId;
		
	loadXMLDoc(url);	
}

function deletedResource (r) {
	
	t = setTimeout("closeWin()", STANDARD_CLOSE_WINDOW_TIMEOUT); // Close all pop overs
	
	// only passing back resourceId now
	//inputArr = r.split("-");
	
	
	// if on my locale list view, hide the display block
	if (document.getElementById('savedResourceDisplayDiv_'+ r)) {
		document.getElementById('savedResourceDisplayDiv_'+ r).style.display = 'none';
		
	// otherwise, change link, if exists
	} else {
		
		linkName = 'resourceActionLink_' + r;
		linkNameBtn = 'resourceActionLink_btn_' + r;
		
		hrefStr = "javascript:showSaveResource('" + r + "')";
		titleStr = "Save this Real Estate Resource to Your Favorites";	
		// Change to save text or button depending on what was there before
		if (document.getElementById(linkName)) {
			document.getElementById(linkName).href = hrefStr;
			document.getElementById(linkName).title = titleStr;
			
			document.getElementById(linkName).innerHTML = "<img src=\"/images/gen/bug_PR_saveListing.gif\" width=\"20\" height=\"20\" alt=\"Save this Resource Listing\" border=\"0\" hspace=3 align=absmiddle><span style=\"text-decoration: underline;\">Save to Favorites</span>";
		} else if (document.getElementById(linkNameBtn)) {
			document.getElementById(linkNameBtn).href = hrefStr;
			document.getElementById(linkNameBtn).title = titleStr;
			
			document.getElementById(linkNameBtn).innerHTML = "<img src=\"/sister_images/buttons/btn_add_to_favorites.gif\" border='0' alt='Save this Resource to your Favorites'>";
		}																					
	}
}
