(function($) {
	$.fn.SelectEmpty=function(intRemaining){return this.each(function(){if(this.tagName=='SELECT')for(var i=this.options.length-1;i>=(intRemaining==null?0:intRemaining);i--)this.remove(i);});}
	$.fn.SelectFill=function(objAllData,intRemaining){return this.SelectEmpty(intRemaining).each(function(){if(this.tagName=='SELECT'){var objElement=this;$.each(objAllData,function(intIndex,objData){var objOpt=new Option(objData.text,objData.value);if($.browser.msie){objElement.add(objOpt);}else{objElement.add(objOpt,null);}});}});}
})(jQuery);

function GotoAddress(strURI) {
	if(strURI!="")document.location.href=strURI;
}
function GotoResultsPage(intOffset) { 
	$("input#page").val(intOffset);
	$("form#resultsfilter").submit();
}

function UpdateSearchType() {
	var intSearchType = $('input[name=searchtype]:checked').val();
	$.getJSON(PATHTO+'_dynamic/accommodationtypetocountry.php','step1='+intSearchType.toString(),function(data){$("select#country").SelectFill(data,1);$("select#country").val($("input#forcecountryto").val());UpdateSearchCountry();});
	$.getJSON(PATHTO+'_dynamic/accommodationtypetocountry.php','step3=0',function(data){$("select#golfcountry").SelectFill(data,1);$("select#country").val($("input#forcecountryto").val());UpdateSearchGolfCountry();});
}

function UpdatePropertySearchType() {
	var intSearchType = $('select#searchtype').val();
	$.getJSON(PATHTO+'_dynamic/accommodationtypetocountry.php','step1='+intSearchType.toString(),function(data){$("select#country").SelectFill(data,1);UpdatePropertySearchCountry();});
}

function UpdatePropertySearchCountry() {
	var intSearchType = $('select#searchtype').val();
	var intSearchCountry = $('select#country').val();
	$("div#regioncontainer").hide();
	$("select#region").val("");
	if ($("select#country").val()!="") {
		$.getJSON(PATHTO+'_dynamic/accommodationtypetocountry.php','step1='+intSearchType.toString()+'&step2='+intSearchCountry.toString(),function(data){$("select#region").SelectFill(data,1);$("div#regioncontainer").show();});
	}
}

function UpdateSearchGolfCountry() {
	var intSearchCountry = $('select#golfcountry').val();
	$("div#golfregioncontainer").hide();
	$("select#golfregion").val("");
	if ($("select#golfcountry").val()!="") {
		$.getJSON(PATHTO+'_dynamic/accommodationtypetocountry.php','step3='+intSearchCountry.toString(),function(data){$("select#golfregion").SelectFill(data,1);$("div#golfregioncontainer").show();});
	}
}

function UpdateSearchCountry() {
	var intSearchType = $('input[name=searchtype]:checked').val();
	var intSearchCountry = $('select#country').val();
	$("div#regioncontainer").hide();
	$("select#region").val("");
	if ($("select#country").val()!="") {
		$.getJSON(PATHTO+'_dynamic/accommodationtypetocountry.php','step1='+intSearchType.toString()+'&step2='+intSearchCountry.toString(),function(data){$("select#region").SelectFill(data,1);$("div#regioncontainer").show();});
	}
}

function SearchFormCountrySelect(strFrom,strTo) {
	SearchFormCopy("country",strFrom,strTo);
	$("select#region").hide();
	$("select#region").val("");
	$("select#region2").hide();
	$("select#region2").val("");
	if ($("select#country").val()!="") {
		$.getJSON(PATHTO+'_dynamic/accommodationtypetocountry.php','step1='+$("input#searchtype").val()+'&step2='+$("select#country").val(),function(data){$("select#region").SelectFill(data,1);$("select#region2").SelectFill(data,1);$("select#region").show();$("select#region2").show();});
	}
}
function SearchFormCopy(strVar,strFrom,strTo) {
	$("#"+strVar+strTo).val($("#"+strVar+strFrom).val());
}

