function $get(id)
{
	if (document.getElementById)
	    var returnVar = document.getElementById(id);
	else if (document.all)
	    var returnVar = document.all[id];
	else if (document.layers)
	    var returnVar = document.layers[id];
	return returnVar;
}
function changeImgSrc(mapPath)
{
	$get('IHMap').src = mapPath;
}
function switchMapView(country_id, region_id){	
	document.frmSelfCatMain.country_id.value=country_id;	
	document.frmSelfCatMain.region_id.value=region_id;
	if(region_id!=''){
		fnComboSearch_Region();
	}else{
		if(country_id!=''){
			fnComboSearch_Country();
		}else{
			document.frmSelfCatMain.submit();
		}		
	}
  return false;		
}
function showSearchOptions(){
	document.frmSelfCatMain.ShowSearchOptions.value='True';	
	document.frmSelfCatMain.Page.value=document.frmSelfCatMain.page_modify_search.value;
	document.frmSelfCatMain.submit();
}
function submitAdvancedSearch(){    
	$get('ShowSearchOptions').value='True';
	$get('showAdvancedSearch').value='1';	
	$get('frmSelfCatMain').submit();
}
function toggleStandardSearch(id){
  if(document.frmSelfCatMain.hideStandardSearch.value!=''){    
    document.frmSelfCatMain.hideStandardSearch.value='';
  }else{    
    document.frmSelfCatMain.hideStandardSearch.value=true;
  }
  showhide(id);
}
function toggleAdvancedSearch(id){
  if($get('showAdvancedSearch').value=='0'){            
    $get('showAdvancedSearch').value='1';
    $get('toggle_advanced_search').value='Hide advanced search';    
  }else{            
    $get('showAdvancedSearch').value='0';
	  $get('toggle_advanced_search').value='Show advanced search';
  }
  showhide(id);
}
function forceShow(id){
	if (document.getElementById){ 
		obj = document.getElementById(id);  
		obj.style.display = "block"; 		
	}
}
function showhide(id){   
 	if (document.getElementById){ 
 		obj = document.getElementById(id); 
 		if(obj!=null){
  		if (obj.style.display == "none"){ 
  			obj.style.display = "block"; 			
  		} else { 
  		obj.style.display = "none"; 
  		}
    }   	
  } 
}
function fnComboSearch_Country()
{
  showhide('countryPleaseWait');
	document.frmSelfCatMain.region_id.value = "";
	document.frmSelfCatMain.place.value = "";
	document.frmSelfCatMain.nref.value = "";	
	document.frmSelfCatMain.submit();
}
function fnComboSearch_Region()
{
  showhide('regionPleaseWait');
	document.frmSelfCatMain.place.value = "";
	document.frmSelfCatMain.nref.value = "";	
	document.frmSelfCatMain.submit();
}
function fnComboSearch_Place()
{
  showhide('placePleaseWait');
	document.frmSelfCatMain.nref.value = "";	
	document.frmSelfCatMain.submit();
}
function resultSort(){
	document.frmSelfCatMain.Page.value = 0;
	document.frmSelfCatMain.TableID.value = "";
	document.frmSelfCatMain.submit();
}
function advancedSearch(){
	document.frmSelfCatMain.Page.value = 0;
	document.frmSelfCatMain.TableID.value = "";
	document.frmSelfCatMain.submit();
}
function fnMapSearch(){
	var strLocation='';
	var nZoomLevel=4;
	var optionText;
	if($get('nref').value!=''){
		strLocation=$get('nref').value;
		nZoomLevel=13;
	}else{
		if($get('setResortOrNref').value!=''){
			strLocation=$get('setResortOrNref').value;
			nZoomLevel=13;
		}
	}
	if(strLocation==''){
		if($get('country_name').value!=''){
			strLocation+=$get('country_name').value + ',';
			nZoomLevel=6;
		}else{
			if($get('country_id').value!=''){
				optionText=$get('country_id').options[$get('country_id').selectedIndex].text;
				if(optionText!=''){
					strLocation+=optionText + ',';
					nZoomLevel=6;
				}
			}
		}
		if($get('region_name').value!=''){
			strLocation+=$get('region_name').value + ',';		
			nZoomLevel=7;
		}else{
			if($get('region_id').value!=''){
				optionText=$get('region_id').options[$get('region_id').selectedIndex].text;		
				if(optionText!=''){
					strLocation+=optionText + ',';
					nZoomLevel=7;
				}
			}
		}
		if($get('place').value!=''){
			optionText=$get('place').options[$get('place').selectedIndex].text;
			if(optionText!=''){
				strLocation+=optionText;
				nZoomLevel=13;
			}
		}
	}
	$get('mapZoomLevel').value=nZoomLevel;
	$get('strLocation').value=strLocation;
	$get('SelfCatAction').value='true';
	//$get('FormAction').value='Interactive';
	$get('FormAction').value='LocationSC';
	$get('frmSelfCatMain').action='/route_planner.asp';
	$get('frmSelfCatMain').submit();
}
function fnRouteSearch(){
  document.frmSelfCatMain.FormAction.value = "";
	document.frmSelfCatMain.action='/route_planner.asp';
	document.frmSelfCatMain.submit();
}
function fnWarnSelfCatSearchNotFound(){
	var strWarn='';	
  strWarn+='Sorry, no properties could be found for your search request.\n\n';
  strWarn+='Please check your spelling or type another destination nearby in case\n';
  strWarn+='there are no properties in the requested destination.\n\n';
  strWarn+='Please also check and update any advanced search selections\n';
  strWarn+='that may prevent properties from being displayed.';
	//strWarn+='The destination has not been recognised.\n\n';
	//strWarn+='Please check your spelling or type another destination nearby in case\n';
	//strWarn+='there are no properties in the requested destination.';
	alert(strWarn);
	return false;
}
function MapWindow(URL){
	popupWin = window.open(URL, 'SelfCateringMap','scrollbars=0,width=525,height=525,top=40,left=40');
}
function toggleSelfCatResorts(id){
  if($get('showSelfCatResorts').value=='0'){            
    $get('showSelfCatResorts').value='1';
    $get('toggle_selfcat_resorts').value='Hide self-catering resort list';    
  }else{            
    $get('showSelfCatResorts').value='0';
	  $get('toggle_selfcat_resorts').value='Show self-catering resort list';
  }
  showhide(id);
}