/* Alastair Grant - Nov 2007 */function loadCountryCityStateLocation(defaultCountry){		Element.hide('CountyOther');		Element.hide('CityOther');		Element.hide('CityLocationOther');		if (defaultCountry !== '') {			$('OfficeCountry').value = defaultCountry;			getCities('OfficeCountry','OfficeCity','OfficeCounty','CityOther');				}};function setCountryDiv(country){		$('SelectedCountry').innerHTML = country;}function checkCityLocation(fldvalue,togglesection) {	var ss = $(togglesection)	if (fldvalue == 'Other' | fldvalue == '') {					if(ss){						/* display the other field section */					      ss.style.display = 'block';									}						}else{				      ss.style.display = 'none';					}};function getCities( fldnamecountry,fldnamecity,fldnameclear,togglesection) {var country = $(fldnamecountry).value;var lkey = country;getCodesetJSON(lkey,'0','/lookup/','CodeSet-AllCitiesLookup-1324','2','2',fldnamecity,fldnamecity,fldnameclear,togglesection);   }function checkCity(fldvalue,togglesection) {	var ss = $(togglesection)	if (fldvalue == 'Other' | fldvalue == '') {					if(ss){						/* display the other field section */					      ss.style.display = 'block';								}				}else{					if(ss){						/* display the other field section */					      ss.style.display = 'none';									}							/* get the States */					var country = $('OfficeCountry').value;					var county =  $('OfficeCounty').value;					var city =  $('OfficeCity').value;					var lkey = country + '~' +  city;					/* need to run agent due to access rights 					updateOptionJSON(lkey,'/lookup/','CodeSet-AllCitiesLookup-1%2B3234','2','2','OfficeCounty','');   */					fldnameclear = '';					togglesection = '';					getCodesetJSON(lkey,'0','/lookup/','CodeSet-AllCitiesLookup-1%2B3234','2','2','OfficeCounty','OfficeCounty',fldnameclear,togglesection);   						}}function getStates( fldnamecountry,fldnamecity,fldnameclear,togglesection) {var country = $(fldnamecountry).value;var lkey = country;getCodesetJSON(lkey,'0','/lookup/','CodeSet-AllCitiesLookup-1234','2','2',fldnamecity,fldnamecity,fldnameclear,togglesection);   }function getCityLocation(fldvalue,togglesection) {	var ss = $(togglesection)	if (fldvalue == 'Other' | fldvalue == '') {					if(ss){						/* display the other field section */					      ss.style.display = 'block';								}				}else{					if(ss){						/* display the other field section */					      ss.style.display = 'none';									}							/* get the locations */					var country = $('OfficeCountry').value;					var city =  $('OfficeCity').value;					var lkey = country + '~' +  city;					getCodesetJSON(lkey,'0','/lookup/','CodeSet-Locations-1%2B234','2','2','Location','Location','','CityLocationOther');   	}}function checkState() {	var country = $('OfficeCountry').value;	var county =  $('OfficeCounty').value;	var city =  $('OfficeCity').value;	var lkey = country + '~' +  county;	updateOptionJSON(lkey,'/lookup/','CodeSet-AllCitiesLookup-1%2B234','3','3','OfficeCity','');   }function getCodesetJSON(key,ltype,codesetpath,codesetview,ot,ov,fieldid,fieldtgt,fieldclr,togglesection) {var targetfield = fieldtgt;var clearfield = fieldclr;var codesetcolumns = "";var url = codesetpath;if (ltype == '0'){	var url = url + 'doCSROLJSON?openagent';}else{	var url = url + 'doCSROLJSON?openpage';};/* set the global id to the passed id*/fieldnameid = fieldid;   /* check if specifc cols required */ if (ot != "" & ov != "")  {	 codesetcolumns = "&ot=" +ot + "&ov=" +ov;   } /* build the path */var params = 'key=' +  key +  '&spacer=1' + "&local=true" + "&view=" +codesetview + codesetcolumns + "&fld=" + fieldnameid;/* make the request */var myAjax = new Ajax.Request(			url, 			{				method: 'get', 				parameters: params,				onSuccess: function(originalRequest){				processCodesetResponseJSON(originalRequest,targetfield,clearfield,togglesection);				},				onFailure: processCodesetResponseJSON			});};function processCodesetResponseJSON(originalRequest,targetfield,clearfield,togglesection)	{  	/* create the object */	page = eval('(' + originalRequest.responseText+ ')');	       	/* get and clear the existing options */  	var dd = $(page.fld);  	var cc = $(clearfield);	var ss = $(togglesection);	     var fldother = $(page.fld + 'Other');	/* alert(page.fld); */	if(dd){	/* clear options  */	dd.options.length = 0;		if(cc){			cc.options.length = 0;				}	       if  (page['lookupresult'].length == 0) {	       	/* no results */	   			    dd.options[dd.options.length] = new Option('Other', 'Other');      				    /* display the section passed if we can  */    			    			if(ss){						/* display the other field section */					      ss.style.display = 'block';									}	          }else{          	          			if(ss){						/* hide the other field section */					      ss.style.display = 'none';									}										/* now loop through and create an option list from the object */				    dd.options[dd.options.length] = new Option('Select', '');  								    for(i = 0; i < page['lookupresult'].length; i++) {		    					dd.options[dd.options.length] = new Option(page['lookupresult'][i].optiontext , page['lookupresult'][i].optionvalue);	    				}						/* add in the spacer <option value="" class="spacer">_______________</option>  */				    dd.options[dd.options.length] = new Option('Other', 'Other');  	        }		}	}
