Event.observe(window, 'load', page_loaded, false);function page_loaded(evt) { if ($('gallery')) $$('.imglist li img').each(function(e) { Event.observe(e, "click", item_clicked, false) } ) }function item_clicked(evt){	var child = Event.element(evt);	if(child.tagName=="LI") return false;	$$('.imglist li ').invoke('removeClassName','active')	child.parentNode.className = "active"	if (child.src.indexOf('t_')==-1) {					// no t_ therefore it's a URL		$('gallerypic').innerHTML = '<a href="' + child.alt +'" target=_new title="open the website in a new window"><img src=' +child.src + '></a><p>' + child.title + '</p>' 	} else {		img_m = child.src.split('t_')[0] + 'm_' + child.src.split('t_')[1]		img_l = (child.src.indexOf('ht_')>-1) ? child.src.split('ht_')[0]+child.src.split('t_')[1] : child.src.split('t_')[0] + 'l_' + child.src.split('t_')[1]		$('gallerypic').innerHTML = '<a href="' + img_l + '" target=_new title="open the original image in a new window"><img src=' +img_m + '><p>' + child.title + '</p></a>' 	}	Event.stop(evt); //avoid another call related to 'parent_node' itself}function panel(change) {	$('panel'+cur_panel).hide();	cur_panel = cur_panel+change	$('panel'+cur_panel).show();	if(cur_panel==1) { $('prevpanel').hide() } else { $('prevpanel').show() }	if(cur_panel==panels) { $('nextpanel').hide() } else { $('nextpanel').show() }	if(cur_panel>1) {Event.observe('panel'+cur_panel, 'click', item_clicked, false);}}var myGlobalHandlers = {		onCreate: function() { showsystemworking(); },		onComplete: function() { if(Ajax.activeRequestCount == 0) { hidesystemworking(); } },		onException: function() { hidesystemworking(); }	};Ajax.Responders.register(myGlobalHandlers);var currform = null;var currdiv = null;function divtoggle(thename) {	if(currdiv==thename | currdiv!=null) {		$('div_'+currdiv).hide(); $('btn_'+currdiv).removeClassName('active');		if (currdiv==thename) { currdiv=null; return false; }	}	$('div_'+thename).show(); $('btn_'+thename).addClassName('active');	currdiv=thename;		if (currform !=null) { currform.reset() };	currform = new Validation('frm_' + thename, {immediate : false,	onSubmit:false} );		$("popupcalendar").hide()	if ($('califrame')) $("califrame").hide()	if (currentuserunid=="") {		$('frm_' + thename).insert({top:$('registersection')})			$('signin_opt').hide()		$('signin_req').show()		$('signin_req_s').show()		$('signin_req_r').hide()		$('registerdiv').show()		$('signindiv').hide()		$('frm_' + thename + '_body').show()				$('registersection').show()	}		return true;}var submittingform = nullfunction submitform(formname) {	submittingform = formname	var url, sout;		if($('registerdiv') != null) {	// user is registering at the same time as submission  so...		// these fields are hidden for possible later user but still need to be set for the agents that are called later on.		if ($('registerdiv').style.display != 'none') {			var names = $('fullname').value.split(" ")			$('firstname').value = names[0]			$('lastname').value = names[names.length-1]			$('emailconfirm').value = $('email').value			$('passwordconfirm').value = $('passwordcv').value		}	}		switch(formname) {		case "frm_cv": url = '/(prop_contactvendor)?openagent'; sout = "Contacting Vendor ......"; break;		case "frm_f": url = '/(prop_feedback)?openagent'; sout = "Sending Feedback  ......"; break;		case "frm_av": url = '/(prop_arrangeviewing)?openagent'; sout = "Sending Request  ......"; break;		case "frm_mo": url = '/(prop_makeoffer)?openagent'; sout = "Sending Offer  ......"; break;		case "frm_stf": url = '/(prop_sendtofriend)?openagent'; sout = "Sending To Friend  ......"; break;		case "frm_amp": url = '/(prop_addtofavourites)?openagent'; sout = "Adding to Favourites ......"; break;	}	$('systemworking').innerHTML = sout	allNodes = "docid=" + docid + "&"	allNodes += "userunid=" + currentuserunid + "&"	x = Form.serialize(formname)	allNodes += (x != "") ? x + "&" : ""	allNodes += "uniquetime=" + new Date().getTime()	     var myAjax = new Ajax.Request(url, {method: 'post', 	postBody: allNodes,		onComplete: response_submitform });}function response_submitform(req)	{	try { var reqJSON = eval('(' + req.responseText + ')') } catch(x) {  alert( "Caught a problem ....\n" + req.responseText); hidesystemworking(); return false; }	if (reqJSON.returnCode == "Error") {		alert("Error\n" + reqJSON.errorText)	} else if (reqJSON.returnCode == "Not Found") {		alert("Not Found\nThe name you entered could not be found")	} else if (reqJSON.returnCode == "OK") {		alert(reqJSON.responseText)	} else if (reqJSON.returnCode == "RegFail") {		hidesystemworking()		$(reqJSON.errorfield).addClassName('validation-failed')		$(reqJSON.errorfield).activate()		alert(reqJSON.errormessage)		return false;	} else {		alert("Invalid Response")	}		try {		trimmed = submittingform.split('_')[1]		$("popupcalendar").hide()		if ($('califrame')) $("califrame").hide()		$("div_" + trimmed).hide()		jscss('remove', $('btn_' + trimmed), 'active')	} catch(x) {}	if (reqJSON.urlout) {		window.location.href = reqJSON.urlout	}}function barf(err){  alert(err);   return;  }/* ----------------------------------------------------------------------------------------------------------- */function getaccountdetails() {	var url = '/(getaccountdetails)?openagent'	var a=$H(	{			userunid: currentuserunid,			something : new Date().getTime()					} );     var myAjax = new Ajax.Request(url, {method: 'get', 	parameters: a.toQueryString(), 	onComplete: response_getaccountdetails});     }function response_getaccountdetails(originalRequest)	{	try{ details = eval('(' + originalRequest.responseText + ')')}catch(e){barf(e.message)}	if (details.error) { barf(view.error); }	document.forms['frm_cv'].cv_phone.value = details.phone}/* ----------------------------------------------------------------------------------------------------------- */function checkcounter() {	var IncParam='';	TimeOutSeconds=7200;																// set to 2 hours	var now=new Date();	var iLen = String(window.location.href).length;	var Account = String(window.location.href).substring(iLen, iLen - 32);	var cookiename='DomCountLastVisit'+Account	var index=document.cookie.indexOf(cookiename);	if (index==-1) {																	// no cookie present, therefore first visit to page		updatecounter();	} else {		var countbegin=(document.cookie.indexOf("=",index)+1);									// DomCountLastVisit cookie exists, get date/time value		var countend=document.cookie.indexOf(";", index);		if (countend == -1) countend = document.cookie.length;		var LastVisit=new Date(document.cookie.substring(countbegin, countend));		var elapsed=Math.round((now-LastVisit)/1000);										// calculate seconds elapsed between last visit and now				if (elapsed >=TimeOutSeconds) {													// user timed out of same session			updatecounter()		}	}	document.cookie=cookiename+"="+now;													// set LastVisit cookie value (after above tests)}function updatecounter() {	var url = '/(webcounter)!openagent&x=' + new Date().getTime()     var myAjax = new Ajax.Request(url, {method: 'get', 	onComplete: doresponse});		//, onComplete: doresponse  parameters: a.toQueryString(), 	}function doresponse(originalRequest)	{//	alert(originalRequest.responseText)}function barf(err){  alert(err);   return;  }function gototab(which) {	if (which==1) {		$('mo_tab2').hide(); $('mo_tab1').show()		return;	}	if (which==2) {		if (currform.validate()) {			$('mo_offerprice_out').innerHTML = formatNumber($F('mo_offerprice'),0,',','','\u00A3','','','');			if ($F('mo_status')=="Other") {				$('mo_status_out').innerHTML = $F('mo_status_other')			} else if ($F('mo_status')=="Selling home privately") {				var statout = "Selling home privately - "				if ($F('mo_depend1')=="Yes") { 					statout += "purchasing depends on selling mine and "					if ($F('mo_buyer1') == "Yes") {statout += "my buyer has a house to sell."}					if ($F('mo_buyer2') == "No") {statout += "my buyer doesn't have a house to sell."}					if ($F('mo_buyer3') == "Don't know") {statout += "I don't know if my buyer has a house to sell or not."}				} else {					statout += "purchasing does not depend on selling mine first."				}				$('mo_status_out').innerHTML = statout			} else {				$('mo_status_out').innerHTML = $F('mo_status') + "."			}			$('mo_tab1').hide(); $('mo_tab2').show()		}	}}// Removes leading whitespacesfunction LTrim( value ) {	var re = /\s*((\S+\s*)*)/;	return value.replace(re, "$1");}// Removes ending whitespacesfunction RTrim( value ) {	var re = /((\s*\S+)*)\s*/;	return value.replace(re, "$1");}// Removes leading and ending whitespacesfunction Trim( value ) {	return LTrim(RTrim(value));}