function show(ID){
	document.getElementById('welcome').style.display="none";
	document.getElementById('sub1').style.display="none";
	document.getElementById('sub2').style.display="none";
	document.getElementById('sub3').style.display="none";
	document.getElementById('sub4').style.display="none";
	obj1=document.getElementById(ID);
	obj1.style.display="";
}
function highlight(ID){
	document.getElementById('top_menu_1').style.backgroundColor="";
	document.getElementById('top_menu_2').style.backgroundColor="";
	document.getElementById('top_menu_3').style.backgroundColor="";
	document.getElementById('top_menu_4').style.backgroundColor="";
	obj1=document.getElementById(ID);
	obj1.style.backgroundColor="#003285";
}
/*--------------------SEARCHING------------------*/
var var_link='';
function change_searchbar_action(){
	var keyword='';
	if(document.searchbar.keyword2){
		keyword=document.searchbar.keyword2.value;
		if(keyword==' Enter Keyword if Desired'){
			keyword='';
		}
	}

		//Checks if keyword is a listing ID
 		ajaxCallFunction(prefs.ajax_url+"ajax.iml?mdl=check_search_for_id.aj&searchfor="+keyword+"&"+Date(),function(sc,st,rt,rxml){
		var found=getTagValue(rxml,'found');
		//If keyword matches ID then goes to listing page
		if(found>1){
			var_link='';document.searchbar.searchARG.value=found;document.searchbar.action='/'+found;document.searchbar.submit();
		}
		//if keyword does not match ID then perform following functions
		else{
			search_destination();search_resort(),search_keyword(keyword);search_beds();search_sleep();search_bath();search_type();search_loca();search_dates();
			search_rates();search_price();search_features();search_length();
			if(prefs.arg!=''){
			document.searchbar.action=prefs.arg+'/'+prefs.url_text+'/'+var_link;
			document.searchbar.searchARG.value=prefs.arg+','+prefs.url_text+','+var_link;
			}
			else{
			document.searchbar.action='/'+prefs.url_text+'/'+var_link;
			document.searchbar.searchARG.value=prefs.url_text+','+var_link;
			}
			document.searchbar.submit();	
		}
		});                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
}

function search_destination(){
	if(document.searchbar.destinations2){
		if(document.searchbar.destinations2.value!=''){
		var_link=var_link+document.searchbar.destinations2.value+'-'+prefs.url_text;
		}
		else{
		var_link=var_link+'show-all-'+prefs.url_text;
		}
	}	
	if(document.searchbar.city2){
		if(document.searchbar.city2.value!=''){
			var_link='';
			if(document.searchbar.city2.value.indexOf('_')){
				var_link=var_link+document.searchbar.city2.value;
			}
			else{
				var_link=var_link+document.searchbar.city2.value+'-'+prefs.url_text;
			}
		}
		else{
			if(!document.searchbar.destinations2)var_link=var_link+'show-all-'+prefs.url_text;
		}
	}
	if((!document.searchbar.destinations2)&&(!document.searchbar.city2))var_link='show-all-'+prefs.url_text;
	return var_link;
}

function search_resort(){
	if(document.searchbar.resort_id2){
		if(var_link!='')var_link=var_link+'_';
		if(document.searchbar.resort_id2.value!=''){
		var_link=var_link+'resort-'+document.searchbar.resort_id2.value;
		}
	}	
	return var_link;
}

function search_keyword(keyword){
	if(keyword!=''){
		if(var_link!='')var_link=var_link+'_';
		var text_keyword=keyword.toLowerCase();
		link_keyword = (text_keyword).replace(/\s/g, "-");
		var_link=var_link+'keyword-'+link_keyword;
		return var_link;
	}
}

function search_beds(){
var bed_link='';
if(document.searchbar.beds_max2){
	if(document.searchbar.beds2){
		if(document.searchbar.beds2.value!=''){
			if(parseInt(document.searchbar.beds2.value) > parseInt(document.searchbar.beds_max2.value)){
			var bedsmax=parseInt(document.searchbar.beds2.value);
			var beds=parseInt(document.searchbar.beds_max2.value);
			}
			else {
			var bedsmax=parseInt(document.searchbar.beds_max2.value);
			var beds=parseInt(document.searchbar.beds2.value);
		
			}
			if(bedsmax==1000)bedsmax=4;
			for(i=beds;i<=bedsmax;i++){
		
				if(bed_link!=''){
					bed_link=bed_link+'_'+i+'-bedrooms';
				}	
				else {
					bed_link=i+'-bedrooms';
				}
			}
		}
	}
	else {
		if(parseInt(document.searchbar.beds_max2.value)==1000)document.searchbar.beds_max2.value=4;
		bed_link=document.searchbar.beds_max2.value+'-bedrooms';
	}
}
else if(document.searchbar.beds2){
		if(document.searchbar.beds2.value!=''){
			if(bed_link!=''){
				bed_link=bed_link+'_'+document.searchbar.beds2.value+'-bedrooms';
			}
			else {
				bed_link=document.searchbar.beds2.value+'-bedrooms';
			}
		}
}

if(bed_link!=''){
if(var_link!='')var_link=var_link+'_';
var_link=var_link+bed_link;
}
return var_link;
}

function search_sleep(){
	if(document.searchbar.sleeps2){
		if(document.searchbar.sleeps2.value!=''){
		if(var_link!='')var_link=var_link+'_';
		var_link=var_link+'sleeps-'+document.searchbar.sleeps2.value;
		}
	return var_link;
	}
}

function search_bath(){
	if(document.searchbar.bath2){
		if(document.searchbar.bath2.value!=''){
		if(var_link!='')var_link=var_link+'_';
		var_link=var_link+document.searchbar.bath2.value+'-bathrooms';
		}
	return var_link;
	}
}

function search_type(){
	if(document.searchbar.checktype2){
		if(document.searchbar.checktype2.type=="select-one"){
			if(document.searchbar.checktype2.value!=''){
				if(var_link!='')var_link=var_link+'_';
				var_link=var_link+'type-'+document.searchbar.checktype2.value;
			}
		}
		else if(document.searchbar.checktype2.type=="checkbox"){
			if(document.searchbar.checktype2.length){
				for(var i=0; i<document.searchbar.checktype2.length; i++)
				if(document.searchbar.checktype2[i].checked){
					if(var_link!='')var_link=var_link+'_';
					var_link=var_link+'type-'+document.searchbar.checktype2[i].value;
				}
			}
			else {
				if(document.searchbar.checktype2.checked){
					if(var_link!='')var_link=var_link+'_';
					var_link=var_link+'type-'+document.searchbar.checktype2.value;
				}
			}
		}
	return var_link;
	}
}

function search_loca(){
	if(document.searchbar.checkloca2){
		if(document.searchbar.checkloca2.type=="select-one"){
			var view=document.searchbar.checkloca2.value;
			if(view!=''){
				view_link = (view).replace(/\s/g, "-");
				if(var_link!='')var_link=var_link+'_';
				var_link=var_link+'location-'+view_link;
			}
		}
	return var_link;
	}
}

function search_dates(){
	if(document.searchbar.arrive2){
		if(document.searchbar.arrive2.value!=''){
		if(var_link!='')var_link=var_link+'_';
		var new_arrive=document.searchbar.arrive2.value.replace(/[/]/g,"-");
		var_link=var_link+'arrive-'+new_arrive;
		}
	}
	if(document.searchbar.depart2){
		if(document.searchbar.depart2.value!=''){
		if(var_link!='')var_link=var_link+'_';
		var new_depart=document.searchbar.depart2.value.replace(/[/]/g,"-");
		var_link=var_link+'depart-'+new_depart;
		}
	}
return var_link;
}

function search_rates(){
	if(document.searchbar.pricenight2){
		if(document.searchbar.pricenight2.value!=''){
		if(var_link!='')var_link=var_link+'_';
		var new_pricenight=document.searchbar.pricenight2.value.replace(/[:]/g,"-");
		var_link=var_link+'pricenight-'+new_pricenight;
		}
	}
	if(document.searchbar.priceweek2){
		if(document.searchbar.priceweek2.value!=''){
		if(var_link!='')var_link=var_link+'_';
		var new_priceweek=document.searchbar.priceweek2.value.replace(/[:]/g,"-");
		var_link=var_link+'priceweek-'+new_priceweek;
		}
	}
return var_link;
}

function search_price(){
	if(document.searchbar.askingprice2){
		if(document.searchbar.askingprice2.value!=''){
		if(var_link!='')var_link=var_link+'_';
		var new_askingprice=document.searchbar.askingprice2.value.replace(/[:]/g,"-");
		var_link=var_link+'price-'+new_askingprice;
		}
	}
return var_link;
}

function search_features(){
	if(document.searchbar.spec_feat_select){
		if(document.searchbar.spec_feat_select.value!=''){
		if(var_link!='')var_link=var_link+'_';
		var_link=var_link+'feature-'+document.searchbar.spec_feat_select.value;
		}
	}
	if(document.searchbar.features2){
		if(document.searchbar.features2.length){
			for(var i=0; i<document.searchbar.features2.length; i++)
				if(document.searchbar.features2[i].checked){
					if(var_link!='')var_link=var_link+'_';
					var_link=var_link+'feature-'+document.searchbar.features2[i].value;
				}
			}
		else {
			if(document.searchbar.features2.checked){
				if(var_link!='')var_link=var_link+'_';
				var_link=var_link+'feature-'+document.searchbar.features2.value;
			}
		}
		return var_link;	
	}
}
//if the var_link variable is too long then this function will break it up
function search_length(){
	if(var_link.length>259){
		var split_at=var_link.lastIndexOf("_",259);
		var first_half=var_link.substring(0,split_at);
		var second_half=var_link.substring(split_at+1,var_link.length);
			if(second_half.length>259){
				var second_split=second_half.lastIndexOf("_",259);
				var third_half=second_half.substring(0,second_split);
				var fourth_half=second_half.substring(second_split+1,var_link.length);
					if(fourth_half.length>259){
						var third_split=fourth_half.lastIndexOf("_",259);
						var fifth_half=fourth_half.substring(0,third_split);
						var sixth_half_half=fourth_half.substring(third_split+1,var_link.length);
					}
					else{
					var_link=first_half+"/"+third_half+"/"+fourth_half;
					}
			}
			else{
			var_link=first_half+"/"+second_half;
			}
		return var_link;
	}
}
/*-----------------------END SEARCHING CODE-------------------*/

function validateForm(){

if(7>document.contact_us.phone1.value.length){alert("Please enter your phone number");return false}
if(2>document.contact_us.email.value.indexOf('@')){alert("Not a vaild email address");return false}
   return true
  }
  
  function change_action2(){
var var_link='';
		if(document.searchbar.beds2.value!=''){
			if(document.searchbar.beds2.value!='Select One'){
				var_link=var_link+'_'+document.searchbar.beds2.value+'-bedrooms';
			}
		}
		if(document.searchbar.checktype2.value!=''){
			if(document.searchbar.checktype2.value!='Select One'){
				var_link=var_link+'_type-'+document.searchbar.checktype2.value;
			}
		}
		if(document.searchbar.checkloca2.value!=''){
			if(document.searchbar.checkloca2.value!='Select One'){
				var_link=var_link+'_location-'+document.searchbar.checkloca2[i].value;
			}
		}
if(document.sort_results.sort.value)var_link=var_link+'_sort-'+document.sort_results.sort.value;

document.sort_results.action=prefs.orig_link+var_link;
document.sort_results.searchARG.value=prefs.searchARG+var_link;
}	

  function auto_fill(country,city){
	if(city!=0){
		if(country){
		fillCity(country,city);
		}
	}
	else{
		if(country){
		fillCity(country);
		}
	}
  }

  function fillCity(country,city){
  if(!city)var city=0;
 ajaxCallFunction(prefs.ajax_url+"ajax.iml?mdl=design3/fill_cities.aj&DEBUG=1&country="+country+"&city="+city+"&"+Date(),function(sc,st,rt,rxml){
	el('cities').innerHTML=rt;
}); 
  }
  
 function fillCountry(city){
 if(document.searchbar.city2.value==''){
 ajaxCallFunction(prefs.ajax_url+"ajax.iml?mdl=design3/fill_countries.aj&DEBUG=1&city="+city+"&"+Date(),function(sc,st,rt,rxml){
	el('countries').innerHTML='';
	el('countries').innerHTML=rt;
	
}); 
}
}
