var myGlobalHandlers = {		onCreate: function() { showsystemworking(); },		onComplete: function() { if(Ajax.activeRequestCount == 0) { hidesystemworking(); } },		onException: function() { hidesystemworking(); }	};Ajax.Responders.register(myGlobalHandlers);function submitsearch(which) {	vgeneral.reset();	vspecific.reset();	if(which=='specific' & document.forms['specific'].townlist.value=="" & document.forms['specific'].townchoice.selectedIndex!=-1) {		document.forms['specific'].townlist.value = document.forms['specific'].townchoice[document.forms['specific'].townchoice.selectedIndex].text	}	if (which=='general') {valid = vgeneral.validate()} else {valid = vspecific.validate()};	if (valid==false) return;	if(which=='search') if (document.forms['search'].freetext.value=='') { alert('Nothing to search for.  Please try again'); return;}	var url = '/(SearchAJAX)?openagent'														// remember openagent is lowercase !!!!	allNodes = "userunid=" + currentuserunid + "&";	allNodes += "which=" + which + "&";	x = Form.serialize(which);	allNodes += (x != "") ? x + "&" : ""	allNodes += "uniquetime=" + new Date().getTime()     var myAjax = new Ajax.Request(url, {method: 'post', 	postBody: allNodes,		onComplete: submitajax_response });}function submitajax_response(req)	{	try { var reqJSON = eval('(' + req.responseText + ')') } catch(x) {  alert("NOT A NORMAL RETURN - \n" + req.responseText) }	if (reqJSON.returnCode == "Error") {		alert(reqJSON.errorText)	} else if (reqJSON.returnCode == "Not Found") {		alert("The name you entered could not be found")	} else if (reqJSON.returnCode == "OK") {		// window.location.href = "/0/" + reqJSON.unid		window.location.href = "/sr/0/" + reqJSON.unid	// sr refers to the search results DB	} else {		alert("Invalid Response - \n" + req.responseText)	}}var prevcounty = null;function showtowns(choice) {	townchoice = document.forms['specific'].townchoice;//	if (prevcounty==choice) return;	prevcounty=choice;	townchoice.options.length = 0;												// empty previous settings	var db = regiondb[choice];	townchoice.options[0] = new Option("- Whole of " + choice + " -", "", true, false);		// insert default first item	if (choice != "" & choice != "- Whole of " + choice + " -" & db != "") {		for (var i = 0; i < db.length; i++) {										// loop through array of the hash table entry, and populate options			townchoice.options[i + 1] = new Option(db[i], db[i]);		}	}	document.forms['specific'].townchoice.selectedIndex=0}function addtolist(town) {	var specific = document.forms['specific'].townlist.value	if(specific.indexOf(town + ", ")) document.forms['specific'].townlist.value += town + ", "}function MM_findObj(n, d) { //v4.01  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);  if(!x && d.getElementById) x=d.getElementById(n); return x;}function showhide() {  var i,p,v,obj,args=showhide.arguments;  for (i=1; i<(args.length); i++) if ((obj=MM_findObj(args[i]))!=null) { v=args[0];    if (obj.style) { obj=obj.style; v=(v=='show')?'':(v=='hide')?'none':v; }    obj.display=v; }}function selectregion(which) {	townchoice = document.forms['specific'].townchoice;	townchoice.options.length = 0;	$('general').style.display = (which=="uk") ? "" : "none"	$('townlist').style.display = (which=="uk") ? "none" : ""	showhide('hide','uk','ne','east','yorks','em','e','se','sw','wm','wales','nw','lon','Scotland')	showhide('show',which)}
