function checkSearchButtonIsActive( ){
	if( document.getElementById('phdd_search').className = 'property-home-search-button-disabled'){
		alert('Please select a country before neginning your property search');
	}	
}
function closePopupSiteHelpMenu(){
	document.getElementById('site-help-popup-wrapper').style.display = 'none';
}
function createColouredIcon( strMarkerColour ){
	var googleMapsIcon = new GIcon();
	googleMapsIcon.image = "/images/icons/google-maps/" + strMarkerColour + ".png";
	googleMapsIcon.shadow = "/images/icons/google-maps/shadow50.png";
	googleMapsIcon.iconSize = new GSize(32, 32);
	googleMapsIcon.shadowSize = new GSize(37, 34);
	googleMapsIcon.iconAnchor = new GPoint(9, 34);
	googleMapsIcon.infoWindowAnchor = new GPoint(9, 2);
	googleMapsIcon.infoShadowAnchor = new GPoint(18, 25);
	googleMapsIcon.transparent = "/images/icons/google-maps/markerTransparent.png";
	return googleMapsIcon;
}
function createUrlMarker( intLat, intLong, strUrl, featureCode ) {
	var mapIcon, infoMarker, mapPoint;
	mapIcon = createColouredIcon( featureCode );
	mapPoint = new GLatLng(intLat, intLong);
   	infoMarker = new GMarker(mapPoint, mapIcon);
   	GEvent.addListener(infoMarker, "click",
      function() {
         document.location.href = strUrl;
      }
   );
  return infoMarker;
}
function createInfoMarker( intLat, intLong, popupText, featureCode ) {
	var mapIcon, mapPoint, infomarker;
	mapIcon = createColouredIcon( featureCode );
	mapPoint = new GLatLng( intLat, intLong );
   	infomarker = new GMarker(mapPoint, mapIcon);
   	GEvent.addListener(infomarker, "click",
      function() {
         infomarker.openInfoWindowHtml(popupText);
      }
   );
  return infomarker;
}
function get_radio_value( strRadioGroup ){
	var grpRadioButtons = MM_findObj( strRadioGroup );
	var rad_val = '';
	for (var i=0; i < grpRadioButtons.length; i++)
	   {
	   if ( grpRadioButtons[i].checked )
		  {
		  rad_val = grpRadioButtons[i].value;
		  }
	   }
	return rad_val;
}
function createRSSFeedUrl( strCountryName, strChannel ){
	var strRSSFeedUrl = '';
	if( strCountryName != '' || strChannel != '' ){
		if( strCountryName != '' ){
			if( strChannel != '' ){
				strRSSFeedUrl = '/' + strCountryName + '/property/news/channels/' + strChannel + '/rss/'
			}else{
				strRSSFeedUrl = '/' + strCountryName + '/property/news/rss/'
			}
		}else{
			strRSSFeedUrl = '/news/channels/' + strChannel + '/rss/'
		}
	}else{
		strRSSFeedUrl = '/rss/';
	}
	return strRSSFeedUrl;
}
function SwitchItems(str)
	{
		document.getElementById('overview').className = '';
		document.getElementById('development').className = '';
		document.getElementById('location').className = '';
		document.getElementById('images').className = '';
		document.getElementById('finance').className = '';
		document.getElementById('additional').className = '';
		if( document.getElementById('financequalification') != null ){
			document.getElementById('financequalification').className = '';
		}
		<!--document.getElementById('inspection').className = '';	-->		
		document.getElementById('overview_panel').style.display = 'none';
		document.getElementById('development_panel').style.display = 'none';
		document.getElementById('location_panel').style.display = 'none';
		document.getElementById('images_panel').style.display = 'none';
		document.getElementById('finance_panel').style.display = 'none';
		document.getElementById('additional_panel').style.display = 'none';
		document.getElementById('financequalification_panel').style.display = 'none';
		if( document.getElementById('financequalification') != null ){
			if ( str == 'financequalification' ){ 
				document.getElementById('report-right-menu').style.display = 'none';
			}else{
				document.getElementById('report-right-menu').style.display = 'block';
			}
		}
		<!--document.getElementById('inspection_panel').style.display = 'none';-->
		document.getElementById(str).className = 'current';
		document.getElementById(str + '_panel').style.display = 'block';
			
		if (str=='location' || str== 'overview' )
		{
			load() ;
		}	
	}
	
function SwitchSecureExitItems(str)
	{
		document.getElementById('overview').className = '';
		document.getElementById('secure').className = '';
		document.getElementById('development').className = '';
		document.getElementById('location').className = '';	
		document.getElementById('overview_panel').style.display = 'none';
		document.getElementById('secure_panel').style.display = 'none';
		document.getElementById('development_panel').style.display = 'none';
		document.getElementById('location_panel').style.display = 'none';
		document.getElementById(str).className = 'current';
		document.getElementById(str + '_panel').style.display = 'block';
		
	}
	
function SwitchLosPandosItems(str)
	{
		document.getElementById('investmentoverview').className = '';
		document.getElementById('redevelopmentplan').className = '';
		document.getElementById('founderssyndicate').className = '';
		document.getElementById('financials').className = '';
		document.getElementById('investorbenefits').className = '';
		document.getElementById('risksecurity').className = '';
		document.getElementById('investmentoverview_panel').style.display = 'none';
		document.getElementById('redevelopmentplan_panel').style.display = 'none';
		document.getElementById('founderssyndicate_panel').style.display = 'none';
		document.getElementById('financials_panel').style.display = 'none';
		document.getElementById('investorbenefits_panel').style.display = 'none';
		document.getElementById('risksecurity_panel').style.display = 'none';
		document.getElementById(str).className = 'current';
		document.getElementById(str + '_panel').style.display = 'block';
		
	}
	
function SwitchFractionalItems(str)
	{
		document.getElementById('investmentoverview').className = '';
		document.getElementById('redevelopmentplan').className = '';
		document.getElementById('imagegallery').className = '';
		document.getElementById('financials').className = '';
		document.getElementById('investorbenefits').className = '';
		document.getElementById('risksecurity').className = '';
		document.getElementById('investmentoverview_panel').style.display = 'none';
		document.getElementById('redevelopmentplan_panel').style.display = 'none';
		document.getElementById('imagegallery_panel').style.display = 'none';
		document.getElementById('financials_panel').style.display = 'none';
		document.getElementById('investorbenefits_panel').style.display = 'none';
		document.getElementById('risksecurity_panel').style.display = 'none';
		document.getElementById(str).className = 'current';
		document.getElementById(str + '_panel').style.display = 'block';
	}
function SwitchDistressedPortfolioItems(str)
	{
		document.getElementById('investmentoverview').className = '';
		document.getElementById('redevelopmentplan').className = '';
		document.getElementById('imagegallery').className = '';
		document.getElementById('investmentoverview_panel').style.display = 'none';
		document.getElementById('redevelopmentplan_panel').style.display = 'none';
		document.getElementById('imagegallery_panel').style.display = 'none';
		document.getElementById(str).className = 'current';
		document.getElementById(str + '_panel').style.display = 'block';
		
	}
	
function switchFundItems(str)
	{
		document.getElementById('overview').className = '';
		document.getElementById('development').className = '';
		document.getElementById('location').className = '';
		document.getElementById('images').className = '';
		document.getElementById('howtoinvest').className = '';
		document.getElementById('finance').className = '';
		document.getElementById('additional').className = '';
		document.getElementById('inspection').className = '';
		document.getElementById('overview_panel').style.display = 'none';
		document.getElementById('development_panel').style.display = 'none';
		document.getElementById('location_panel').style.display = 'none';
		document.getElementById('images_panel').style.display = 'none';
		document.getElementById('howtoinvest_panel').style.display = 'none';
		document.getElementById('finance_panel').style.display = 'none';
		document.getElementById('additional_panel').style.display = 'none';
		document.getElementById('inspection_panel').style.display = 'none';
		document.getElementById(str).className = 'current';
		document.getElementById(str + '_panel').style.display = 'block';
	}
	
function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
}
function showBrowserWindow( URLStr,w,h,sbars )  {
	var popUpWin = 0;
	stname = Math.floor(Math.random()*10000);
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	popUpWin = open( URLStr, stname, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + sbars + ',resizable=no,copyhistory=no,width='+w+',height='+h+',left='+LeftPosition+', top='+TopPosition+',screenX=220,screenY=180');
}
function showGraph( URLStr )  {
  var popUpWin = 0;
  popUpWin = open( URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width=520,height=520,left=180, top=180,screenX=180,screenY=180');
}
function convertCurrency( amount, from, to ){
  conPopUpWin = open( 'http://www.moneycorp.com/tools/currency_converter/autoConverterIndex.cfm?amount=' + amount  + '&fromCurrency='+ from +'&toCurrency='+ to + '&ReferringAgentID=10004788', 'conPopUpWin', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbar=yes,resizable=yes,copyhistory=yes,width=335,height=370,left=180, top=180,screenX=180,screenY=180');
}
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 MM_validateForm() { //v4.0
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	for (i=0; i<(args.length-2); i+=3) { 
  		test=args[i+2];
		val=MM_findObj(args[i]);
    	if (val) { 
			nm=val.name; 
			if ((val=val.value)!="") {
				if (test.indexOf('isEmail')!=-1) { 
					p=val.indexOf('@');
        			if (p<1 || p==(val.length-1)) errors+='- '+stripFormIdentifiers(nm)+' must contain an e-mail address.\n';
      			} 
				else if (test!='R') { 
					if (test.indexOf('isDropDown') != -1) { 
						p=MM_findObj(args[i]);
						p = p.selectedIndex;
          				if (p==0) errors+='- Select a valid '+stripFormIdentifiers(nm)+'.\n';
    				}
					if (test.indexOf('isPrivacyBox') != -1) { 
						p=MM_findObj(args[i]);
          				if (p.checked == false) errors+='- You must read and understand our privacy statement.\n';
    				}
					if (test.indexOf('isCheckBox') != -1) { 
						p=MM_findObj(args[i]);
          				if (p.checked == false) errors+='- '+stripFormIdentifiers(nm)+' must be checked.\n';
    				}
					if (test.indexOf('isRadio') != -1) {
						p=get_radio_value( args[i] );
						if (p=='') errors+='- '+stripFormIdentifiers(args[i])+' must be checked.\n';
					}
				} 
			} 
			else if (test.charAt(0) == 'R') errors += '- '+stripFormIdentifiers(nm)+' is required.\n'; 
		}
	} 
	if (errors) alert('Please correct the following before continuing:\n\n'+errors);
  	document.MM_returnValue = (errors == '');
}
function MM_validatePropertyDetailForm() { //v4.0
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validatePropertyDetailForm.arguments;
	for (i=0; i<(args.length-2); i+=3) { 
  		test=args[i+2];
		val=MM_findObj(args[i]);
    	if (val) { 
			nm=val.name; 
			val=val.value;
			if (val!="" && val!="First Name" && val!="Surname" && val!="Email Address" && val!="Telephone Number") {
				if (test.indexOf('isEmail')!=-1) { 
					p=val.indexOf('@');
        			if (p<1 || p==(val.length-1)) errors+='- '+stripFormIdentifiers(nm)+' must contain an e-mail address.\n';
      			} 
			} 
			else if (test.charAt(0) == 'R') errors += '- '+stripFormIdentifiers(nm)+' is required.\n'; 
		}
	} 
	if (errors) alert('Please correct the following before continuing:\n\n'+errors);
  	document.MM_returnValue = (errors == '');
}
	
function MM_validateExtendEnquiryForm() { 
	var errors = '';
	if( MM_findObj('ER_Property').checked == false && MM_findObj('ER_Mortgages').checked == false && MM_findObj('ER_Foreign_Exchange').checked == false && MM_findObj('ER_Insurance').checked == false && MM_findObj('ER_Furniture_Packs').checked == false && MM_findObj('ER_Fractional').checked == false ){
	
		errors = 'You must select at least one service before submitting.';
	}
	if (errors) alert('Please correct the following before continuing:\n\n'+errors);
  	document.MM_returnValue = (errors == '');
}
function MM_validatePropertySearchForm() { //v4.0
	var errors = '';
	if( MM_findObj('loc').value == ''){
	}
	else if( MM_findObj('loc').value.length < 3){
	}
	if (errors) alert(errors);
  	document.MM_returnValue = (errors == '');
}
function MM_validateIpinSignupForm() { //v4.0
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateIpinSignupForm.arguments;
	for (i=0; i<(args.length-2); i+=3) { 
  		test=args[i+2];
		val=MM_findObj(args[i]);
    	if (val) { 
			nm=val.name; 
			if ((val=val.value)!="") {
      			if (test.indexOf('isEmail')!=-1) { 
					p=val.indexOf('@');
        			if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      			} 
				else if (test!='R') { 
					if (test.indexOf('isDropDown') != -1 && test.indexOf('isDropDown') != 0) { 
						p=MM_findObj(args[i]);
						p = p.selectedIndex;
          				if (p==0){
							if (nm == 'CountryOfResidence') nm = 'Country of residence';
							errors+='- '+nm+' is required.\n';
						}
    				}
					if (test.indexOf('isPrivacyBox') != -1) { 
						p=MM_findObj(args[i]);
          				if (p.checked == false) errors+='- You must read and understand our privacy statement.\n';
    				}
				} 
			} 
			else{ 
				if (test.charAt(0) == 'R'){
					if (nm == 'firstName') nm = 'First name';
					if (nm == 'surname') nm = 'Surname';
					if (nm == 'EmailAddress') nm = 'Email address';
					if (nm == 'ConfirmPassword') nm = 'Confirm Password';
					errors += '- '+nm+' is required.\n'; 
				}
			}
		}
	} 
	if (errors) alert('Please correct the following before continuing:\n\n'+errors);
  	document.MM_returnValue = (errors == '');
}
function MM_validateAlternateIpinSignupForm() { //v4.0
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateAlternateIpinSignupForm.arguments;
	for (i=0; i<(args.length-2); i+=3) { 
  		test=args[i+2];
		//alert('Testing the ' + args[i]);
		val=MM_findObj(args[i]);
		//alert('found the obj ' + val.name );
    	if (val) { 
			nm=val.name; 
			if ((val=val.value)!="") {
      			if (test.indexOf('isEmail')!=-1) { 
					p=val.indexOf('@');
        			if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      			} 
				else if (test!='R') { 
					if (test.indexOf('isDropDown') != -1 && test.indexOf('isDropDown') != 0) { 
						p=MM_findObj(args[i]);
						p = p.selectedIndex;
          				if (p==0){
							if (nm == 'CountryOfResidence') nm = 'Country code';
							errors+='- '+nm+' is required.\n';
						}
    				}
					if (test.indexOf('isPrivacyBox') != -1) { 
						p=MM_findObj(args[i]);
          				if (p.checked == false) errors+='- You must read and understand our privacy statement.\n';
    				}
				} 
			} 
			else{ 
				if (test.charAt(0) == 'R'){
					if (nm == 'firstName') nm = 'First name';
					if (nm == 'surname') nm = 'Surname';
					if (nm == 'EmailAddress') nm = 'Email address';
					if (nm == 'ConfirmPassword') nm = 'Confirm Password';
					errors += '- '+nm+' is required.\n'; 
				}
			}
		}
	} 
	if (errors) alert('Please correct the following before continuing:\n\n'+errors);
  	document.MM_returnValue = (errors == '');
}
function stripFormIdentifiers( strElement ){
	strElement = strElement.substring( 3, strElement.length );
	i = strElement.indexOf('_');
	while (i > -1){
		strElement = strElement.replace( '_', " " );
		i = strElement.indexOf('_');
	}
	return strElement;
}
var list; 
var tickerObj; 
var hex = 255;
function fadeText(divId) {
  if(tickerObj)
  {
    if(hex>0) {
      hex-=5; // increase color darkness
      tickerObj.style.color="rgb("+hex+","+hex+","+hex+")";
      setTimeout("fadeText('" + divId + "')", fadeSpeed); 
    } else
      hex=255; //reset hex value
  }
}
function initialiseList(divId) {
  tickerObj = document.getElementById(divId);
  if(!tickerObj)
    reportError("Could not find a div element with id \"" + divId + "\"");
  list = tickerObj.childNodes;
  if(list.length <= 0)
    reportError("The div element \"" + divId + "\" does not have any children");
  for (var i=0; i<list.length; i++) {
    var node = list[i];
    if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 
              tickerObj.removeChild(node);
  }
  run(divId, 0);
}
function run(divId, count) {
  fadeText(divId);
  list[count].style.display = "block";
  if(count > 0)
    list[count-1].style.display = "none";
  else
    list[list.length-1].style.display = "none";
  count++;
  if(count == list.length)
    count = 0;
  window.setTimeout("run('" + divId + "', " + count+ ")", interval*1000);
}
function reportError(error) {
  alert("The script could not run because you have errors:\n\n" + error);
  return false;
}
function toggleLayer( whichLayer ){  
	var elem, vis;  
	if( document.getElementById ) 
		elem = document.getElementById( whichLayer );  
	else if( document.all ) 
		elem = document.all[whichLayer];  
	else if( document.layers ) 
	elem = document.layers[whichLayer];  vis = elem.style;  
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
function switchOffLayer( whichLayer ){
	var elem, vis;  
	if( document.getElementById ) 
		elem = document.getElementById( whichLayer );  
	else if( document.all ) 
		elem = document.all[whichLayer];  
	else if( document.layers ) 
		elem = document.layers[whichLayer];  vis = elem.style;  
	vis.display = 'none';
}
function activateSearchTab( whichTab ){
	switchOffLayer( 'section-search-basic-container' );
	switchOffLayer( 'section-search-ipin-container' );
	switchOffLayer( 'section-search-submit-container' );
	switch(whichTab){
		
	
		case 'section-search-basic-container':
	  		toggleLayer( 'section-search-basic-container' );
			toggleLayer( 'section-search-submit-container' );
	  		break;    
	
		case 'section-search-advanced-container':
	  		toggleLayer( 'section-search-basic-container' );
			toggleLayer( 'section-search-submit-container' );
	  		break;
	
		case 'section-search-ipin-container':
	  		toggleLayer( 'section-search-ipin-container' );
	  		break;
	}
	
}
function checkCountry( intIndex, strSourceRef ){
	
	if( intIndex == 'Select a Country...' ){
			alert('To begin a search, please first select a country');
			return false;
	}else{
		
		setFormDestination(Left(document.searchform.fldCountry.options[document.searchform.fldCountry.selectedIndex].value,1));
		return true;
	}
}
function setFormDestination( strCountryStatus ){
	if( strCountryStatus == '1'){
		document.searchform.fldCountry.options[document.searchform.fldCountry.selectedIndex].value = Right(document.searchform.fldCountry.options[document.searchform.fldCountry.selectedIndex].value,(document.searchform.fldCountry.options[document.searchform.fldCountry.selectedIndex].value.length-2))
		strCountry = document.searchform.fldCountry.options[document.searchform.fldCountry.selectedIndex].value;
		if( strCountry == 'Cape Verde'){ strCountry = 'CapeVerde'; }
		document.searchform.action = '/' + strCountry.toLowerCase() + '/property/search.asp';
	}
	else{
		document.searchform.fldCountry.options[document.searchform.fldCountry.selectedIndex].value = Right(document.searchform.fldCountry.options[document.searchform.fldCountry.selectedIndex].value,(document.searchform.fldCountry.options[document.searchform.fldCountry.selectedIndex].value.length-2))
		strCountry = document.searchform.fldCountry.options[document.searchform.fldCountry.selectedIndex].value;
		document.searchform.action = '/' + strCountry.toLowerCase() + '/default.asp';
	}
	
}
function toggleAdvancedInput(){
	if( document.searchform.fldShowAdvanced.value == '0' ){ document.searchform.fldShowAdvanced.value = '1'; }
	else{ document.searchform.fldShowAdvanced.value = '0'; }
}
function getXmlHttp(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}
function getUrl(url, cb) {
  var xmlhttp = getXmlHttp();
  xmlhttp.open("GET", url);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4) {
      cb(xmlhttp.status, 
         xmlhttp.getAllResponseHeaders(), 
         xmlhttp.responseText);
      }
  }
  xmlhttp.send(null);
}
function hitUrl(url) {
  //alert('starting');
  var xmlhttp = getXmlHttp();
  xmlhttp.open("GET", url);
  xmlhttp.onreadystatechange = function() {
	  if (xmlhttp.readyState == 4) {
	  }
  }
  xmlhttp.send(null);
}
function updateSaveDiv( status, headers, result ){
		var intPropertyId = parseInt(result);
		if( intPropertyId < 0 ){
			intPropertyId = ( intPropertyId * -1 );
			document.getElementById('SaveProperty_' + intPropertyId.toString()).innerHTML = '<img src="/images/save-property-icon.gif" alt="Saved Properties" hspace="5" border="0" align="absmiddle" />You are not signed in. <a href="/member-sign-in.asp" title="Click here to sign in">Sign In</a>';
		}else{
			document.getElementById('SaveProperty_' + intPropertyId.toString()).innerHTML = '<img src="/images/save-property-icon.gif" alt="Saved Properties" hspace="5" border="0" align="absmiddle" />Saved to My Properties';
		}
}
function updateRefineSearchLocaleDropDown( status, headers, result ){
	document.getElementById('phdd_loader_le').style.display='block';
	var regions = result.split("#");
	var ddRegions = document.getElementById('rsle');
	var ddPrimaryRegions = document.getElementById('rsfl');
	var ddSecondaryRegions = document.getElementById('rssl');
	if( ddSecondaryRegions.value == -1 && ddSecondaryRegions.disabled == false ){
		
		ddRegions.options.length = 0;
		ddRegions.disabled = true;
		
	}else{
		ddRegions.options.length = 0;
		ddRegions.options[ddRegions.options.length] = new Option('All Cities/Towns/Areas','-1');
		for (i=0; i<(regions.length-1); i+=2) {
			ddRegions.options[ddRegions.options.length] = new Option(regions[i],regions[i+1]);
		}
		ddRegions.options[0].selected = true;
		ddRegions.disabled = false;
	}
	document.getElementById('phdd_loader_sl').style.display='none';
	document.getElementById('phdd_loader_le').style.display='none';
}
function updateRefineSearchFirstLevelDropDown( status, headers, result ){
	resetRefineSearchDropDown('rsfl');
	resetRefineSearchDropDown('rssl');
	resetRefineSearchDropDown('rsle');
	var regions = result.split("#");
	if( regions.length == 1){
		document.getElementById('rsfl').disabled = true;
		document.getElementById('rsfl').options.length = 0;
		document.getElementById('rsfl').options[document.getElementById('rsfl').options.length] = new Option('All Regions','-1');
		if(document.getElementById('phdd_search') != null){
			document.getElementById('phdd_search').disabled = true;
			document.getElementById('phdd_search').className = 'property-home-search-button-disabled';
			}
	}else{
		
		document.getElementById('rsfl').disabled = false;
		if(document.getElementById('phdd_search') != null){
			document.getElementById('phdd_search').disabled = false;
			document.getElementById('phdd_search').className = 'property-home-search-button';
		}
		var ddRegions = document.getElementById('rsfl');
		ddRegions.options.length = 0;
		ddRegions.options[ddRegions.options.length] = new Option('All Regions','-1');
		for (i=0; i<(regions.length-1); i+=2) {
			ddRegions.options[ddRegions.options.length] = new Option(regions[i],regions[i+1]);
		}
		ddRegions.options[0].selected = true;
		ddRegions.disabled = false;
	}
	
	document.getElementById('phdd_loader_c').style.display='none';
}
function resetRefineSearchDropDown( strDropDown ){
	var strMessage = '';
	
	switch(strDropDown){
		case 'rsc':
			strMessage = 'Select Country';
			break;
		case 'rsfl':
			strMessage = 'Select Region';
			break;
		case 'rssl':
			strMessage = 'Select Secondary Region';
			break;
		case 'rsle':
			strMessage = 'Select City/Town/Area';
			break;
	}
			
	document.getElementById(strDropDown).options.length = 0;
	document.getElementById(strDropDown).options[document.getElementById(strDropDown).options.length] = new Option(strMessage,'-1');
	document.getElementById(strDropDown).disabled = true;
}
function updateRefineSearchSecondLevelDropDown( status, headers, result ){
	
	resetRefineSearchDropDown('rssl');
	resetRefineSearchDropDown('rsle');
	var ddSecondaryRegions = document.getElementById('rssl');
	var ddLocales = document.getElementById('rsle');
	var ddRegions = document.getElementById('rsfl');
	if( ddRegions.value == -1 ){
		
		ddSecondaryRegions.options.length = 0;
		ddSecondaryRegions.disabled = true;
		ddLocales.options.length = 0;
		ddLocales.disabled = true;
		
	}else{
		var regions = result.split("#");
		if( regions.length == 1 ){
			ddSecondaryRegions.options.length = 0;
			ddSecondaryRegions.options[ddSecondaryRegions.options.length] = new Option('No Secondary Regions','-1');
			ddSecondaryRegions.disabled = true;
			document.getElementById('phdd_loader_sl').style.display='none';
			document.getElementById('phdd_loader_le').style.display='block';
			getUrl('/xmlhttp/get-locales.asp?rsfl=' + document.getElementById('rsfl').value + '&rssl=', updateRefineSearchLocaleDropDown);
		}else{
			ddSecondaryRegions.options.length = 0;
			ddSecondaryRegions.options[ddSecondaryRegions.options.length] = new Option('All Secondary Regions','-1');
			for (i=0; i<(regions.length-1); i+=2) {
				ddSecondaryRegions.options[ddSecondaryRegions.options.length] = new Option(regions[i],regions[i+1]);
			}
			ddSecondaryRegions.options[0].selected = true;
			ddSecondaryRegions.disabled = false;
		}
	}
	
	document.getElementById('phdd_loader_fl').style.display='none';
}
function selectLocationInDropDown( strDropDown, itemToSelect ){
	var myDropdownList = document.getElementById(strDropDown);
    for (iLoop = 0; iLoop< myDropdownList.options.length; iLoop++)
    {    
      if (myDropdownList.options[iLoop].value == itemToSelect)
      {
        myDropdownList.options[iLoop].selected = true;
        break;
      }
    }
	
}
function showPropertyHomeBasicTab(){
	document.getElementById('ph_basic_tab').style.display = 'block'; 
	document.getElementById('ph_advanced_tab').style.display = 'none'; 
}
function showPropertyHomeAdvancedTab(){
	
	document.getElementById('ph_basic_tab').style.display = 'none'; 
	document.getElementById('ph_advanced_tab').style.display = 'block'; 
	
}
function showPropertySearchBasicTab(){
	
	document.getElementById('ph_basic_tab_header').style.display = 'block'; 
	document.getElementById('ph_location_tab_header').style.display = 'none'; 
	document.getElementById('ph_advanced_tab_header').style.display = 'none'; 
	document.getElementById('ph_location_panel').style.display = 'none'; 
	document.getElementById('ph_easy_filter_options_panel').style.display = 'block'; 
	document.getElementById('ph_basic_options_panel').style.display = 'none'; 
	document.getElementById('ph_advanced_options_panel').style.display = 'none'; 
	document.getElementById('geo-search-button-panel').style.display = 'none'; 
}
function showPropertySearchLocationTab(){
	
	document.getElementById('ph_basic_tab_header').style.display = 'none'; 
	document.getElementById('ph_location_tab_header').style.display = 'block'; 
	document.getElementById('ph_advanced_tab_header').style.display = 'none'; 
	document.getElementById('ph_location_panel').style.display = 'block'; 
	document.getElementById('ph_easy_filter_options_panel').style.display = 'none'; 
	document.getElementById('ph_basic_options_panel').style.display = 'none'; 
	document.getElementById('ph_advanced_options_panel').style.display = 'none'; 
	document.getElementById('geo-search-button-panel').style.display = 'block'; 
	
}
function showPropertySearchAdvancedTab(){
	
	document.getElementById('ph_basic_tab_header').style.display = 'none'; 
	document.getElementById('ph_location_tab_header').style.display = 'none'; 
	document.getElementById('ph_advanced_tab_header').style.display = 'block'; 
	document.getElementById('ph_location_panel').style.display = 'none'; 
	document.getElementById('ph_easy_filter_options_panel').style.display = 'none'; 
	document.getElementById('ph_basic_options_panel').style.display = 'block'; 
	document.getElementById('ph_advanced_options_panel').style.display = 'block'; 
	document.getElementById('geo-search-button-panel').style.display = 'block'; 
	
}
function updateRegionDropDown( status, headers, result ){
	var regions = result.split("#");
	var region_div = document.getElementById('region_div');
	region_div.style.display = 'block';
	var ddRegions = document.getElementById('fldRegionFilter');
	ddRegions.options.length = 0;
	ddRegions.options[ddRegions.options.length] = new Option('All Regions','-1');
	for (i=0; i<(regions.length-1); i+=2) {
		ddRegions.options[ddRegions.options.length] = new Option(regions[i],regions[i+1]);
	}
	ddRegions.options[0].selected = true;
}
function updateTownDropDown( status, headers, result ){
	var towns = result.split("#");
	var town_div = document.getElementById('town_div');
	town_div.style.display = 'block';
	var ddTowns = document.getElementById('fldTownId');
	ddTowns.options.length = 0;
	ddTowns.options[ddTowns.options.length] = new Option('All Towns','-1');
	for (i=0; i<(towns.length-1); i+=2) {
		ddTowns.options[ddTowns.options.length] = new Option(towns[i],towns[i+1]);
	}
}
function updateRegionOfPreferenceDropDown( status, headers, result ){
	var regions = result.split("#");
	var region_div = document.getElementById('region_of_preference_div');
	region_div.style.display = 'block';
	var ddRegions = document.getElementById('PAF_Region_Of_Preference');
	ddRegions.options.length = 0;
	ddRegions.options[ddRegions.options.length] = new Option('All Regions','-1');
	for (i=0; i<(regions.length-1); i+=2) {
		ddRegions.options[ddRegions.options.length] = new Option(regions[i],regions[i+1]);
	}
	ddRegions.options[0].selected = true;
}
function updateTownOfPreferenceDropDown( status, headers, result ){
	//Split the results by comma
	var towns = result.split("#");
	//Get the containing div
	var town_div = document.getElementById('town_of_preference_div');
	town_div.style.display = 'block';
	//Get the drop down element
	var ddTowns = document.getElementById('PAF_Town_Of_Preference');
	//Clear the current options in the dropdown
	ddTowns.options.length = 0;
	//Add the first option
	ddTowns.options[ddTowns.options.length] = new Option('All Towns','-1');
	//Loop through the result set 2 at a time as every first element is a name and every second element is a value
	for (i=0; i<(towns.length-1); i+=2) {
		//Add a new option
		ddTowns.options[ddTowns.options.length] = new Option(towns[i],towns[i+1]);
	}
}
function updateSearchIndexRegionOfPreferenceDropDown( status, headers, result ){
	var regions = result.split("#");
	var region_div = document.getElementById('region_of_preference_div');
	var ddRegions = document.getElementById('PAF_Region_Of_Preference');
	ddRegions.options.length = 0;
	ddRegions.options[ddRegions.options.length] = new Option('All Regions','-1');
	for (i=0; i<(regions.length-1); i+=2) {
		ddRegions.options[ddRegions.options.length] = new Option(regions[i],regions[i+1]);
	}
	ddRegions.options[0].selected = true;
}
function updateSearchIndexTownOfPreferenceDropDown( status, headers, result ){
	var towns = result.split("#");
	var town_div = document.getElementById('town_of_preference_div');
	var ddTowns = document.getElementById('PAF_Town_Of_Preference');
	ddTowns.options.length = 0;
	ddTowns.options[ddTowns.options.length] = new Option('All Towns','-1');
	for (i=0; i<(towns.length-1); i+=2) {
		ddTowns.options[ddTowns.options.length] = new Option(towns[i],towns[i+1]);
	}
}
function focusElement( element ){
	document.getElementById(element).focus();
}
function updateListingsFound( ){
	
}
function updateSearchButton( status, headers, result ){
	document.getElementById('sbt_btn').value = 'View ' + result + ' Listings';
}
function getSearchFieldValue( whichField, fieldType ){
	if( document.getElementById ) 
		var elem = document.getElementById( whichField );  
	else if( document.all ) 
		var elem = document.all[whichField];  
	else if( document.layers ) 
		var elem = document.layers[whichField];
	var elem = document.getElementById(whichField);
	if( fieldType == 1 ){ 
		if (elem.options.length > 0 ){
			return elem.options[elem.selectedIndex].value;
		}
		else{
			return -1;
		}
	}
	else if( fieldType == 2 ){ 
		return elem.value;
	}
}
function checkGraphDate(){
	
	var ddGraph = document.getElementById('dateselect');
	if( ddGraph.selectedIndex == '-1') {
		alert('Please select a date before procedding');
		return false;
	}
	else return true;
}
function emptyTownDropDown(){
	var ddTowns = document.getElementById('fldTownId');
	ddTowns.options.length = 0;
}
function emptyTownOfPreferenceDropDown(){
	var ddTowns = document.getElementById('PAF_Town_Of_Preference');
	ddTowns.options.length = 0;
}
function automateCountryDropDown(intIndex){
	var dd = document.getElementById('fldCountry');
	dd.selectedIndex = intIndex;
	dd.style.backgroundColor = '#99c0db';
	dd.fireEvent('onChange');
		intInterval = setInterval("flashCountryDropDown()", 100);
		setTimeout( 'clearInterval(intInterval)', 1000 );
}
function flashCountryDropDown(){ 
	if (!document.all) return;
	var objCountryDropDown = document.getElementById('fldCountry');
	if (objCountryDropDown.style.backgroundColor == "#99c0db")
		objCountryDropDown.style.backgroundColor = "#ffffff";
	else 
		objCountryDropDown.style.backgroundColor = "#99c0db";
}
function Left(str, n)
        {
                if (n <= 0)     
                        return "";
                else if (n > String(str).length)   
                        return str;                
                else 
                        return String(str).substring(0,n);
        }
function Right(str, n)
        {
                if (n <= 0)     
                   return "";
                else if (n > String(str).length)   
                   return str;                     
                else { 
                   var iLen = String(str).length;
                   return String(str).substring(iLen, iLen - n);
                }
        }
		
function popupWindow( URLStr, intWidth, intHeight )  {
  var popUpWin = 0;
  popUpWin = open( URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=' + intWidth + ',height=' + intHeight + ',left=180, top=180,screenX=180,screenY=180');
}
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
function popupMiniGoogleMap( strIdentifier, intLatitude, intLongitude ){
		var note1=document.getElementById(strIdentifier);
		note1.style.left=event.clientX;
		note1.style.top=event.clientY;
		alert(event.clientX + ', ' + event.clientY);
		note1.style.visibility='visible';
		note1.style.display = 'block';
}
