function preloadSearch(method)
{	
	if (locationChanged == true)
	{ 
		jQuery("#mainSearchForm").submit();
		return false;
	}
	
	var scriptpath = "/xmlProcessing/preloadSearch.php?";
	if (onlySessionVars == 0)
	{
		if (typeof method != 'undefined') 
		{
			jQuery("#tabList").toggleClass('active');
			jQuery("#tabCompare").toggleClass('active');
			if (method == 'compare') jQuery("#compareMethod").val(1);
			else jQuery("#compareMethod").val(0);
		}
		
		if (typeof filenameType != 'undefined') scriptpath += '&filenameType=' + filenameType;
		if (typeof isRating != 'undefined' && isRating == true) scriptpath += '&isRating=Y';	
		if (typeof method != 'undefined' && typeof pageNumber != 'undefined' && pageNumber > 1) scriptpath += '&pageNumber=' + pageNumber;
		if (jQuery("#order").length > 0 && jQuery("#order").val() != '' && jQuery("#order").val() != null)  scriptpath += "&order=" + jQuery("#order").val();
		if (jQuery("#compareMethod").length > 0 && jQuery("#compareMethod").val() == 1)  scriptpath += "&compareMethod=1";	
		
		if (jQuery("#searchMethod").length > 0 && jQuery("#searchMethod").val() != '')  scriptpath += "&searchMethod=" + jQuery("#searchMethod").val();
		if (jQuery("#sfCountry").length > 0 && jQuery("#sfCountry").val() != '')  scriptpath += "&country=" + jQuery("#sfCountry").val();
		if (jQuery("#sfLevel1").length > 0 && jQuery("#sfLevel1").val() != '' && jQuery("#sfLevel1").val() != null)  scriptpath += "&level1=" + jQuery("#sfLevel1").val();
		if (jQuery("#sfLevel2").length > 0 && jQuery("#sfLevel2").val() != '' && jQuery("#sfLevel2").val() != null)  scriptpath += "&level2=" + jQuery("#sfLevel2").val();
		if (jQuery("#sfLevel3").length > 0 && jQuery("#sfLevel3").val() != '' && jQuery("#sfLevel3").val() != null)  scriptpath += "&level3=" + jQuery("#sfLevel3").val();
		if (jQuery("#sfLevel4").length > 0 && jQuery("#sfLevel4").val() != '' && jQuery("#sfLevel4").val() != null)  scriptpath += "&level4=" + jQuery("#sfLevel4").val();
		if (jQuery("#locationPlaces").length > 0 && jQuery("#locationPlaces").val() != '')  scriptpath += "&locationPlace=" + jQuery("#locationPlaces").val();
		if (jQuery("#hiddenLocationID").length > 0 && jQuery("#hiddenLocationID").val() != '')  scriptpath += "&hiddenLocationID=" + jQuery("#hiddenLocationID").val();
		
		if (jQuery("#objectCommercial0").length > 0 && jQuery("#objectCommercial0:checked").length > 0) scriptpath += "&objectCommercial=0";
		if (jQuery("#objectCommercialY").length > 0 && jQuery("#objectCommercialY:checked").length > 0) scriptpath += "&objectCommercial=Y";
		if (jQuery("#objectCommercialN").length > 0 && jQuery("#objectCommercialN:checked").length > 0) scriptpath += "&objectCommercial=N";
		
		if (jQuery("#sel_objectAgencyIDs").length > 0 && jQuery("#sel_objectAgencyIDs option:selected").length > 0) jQuery("#sel_objectAgencyIDs option:selected").each(function(index){scriptpath += "&objectAgencyIDs[]=" + this.value;});
		
		if (jQuery("#startDate").length > 0 && jQuery("#startDate").val().match(/\d{2}\.\d{2}\.\d{4}/))  scriptpath += "&startDate=" + jQuery("#startDate").val();
		if (jQuery("#durationSelect").length > 0 && jQuery("#durationSelect").val() != '')  scriptpath += "&duration=" + jQuery("#durationSelect").val();	
		if (jQuery("#hotels").length > 0 && jQuery("#hotels:checked").length > 0)  scriptpath += "&allHouseTypes=" + jQuery("#hotels").val();
		if (jQuery("#pets").length > 0 && jQuery("#pets:checked").length > 0) scriptpath += "&pets=1";
		if (jQuery("#pool").length > 0 && jQuery("#pool:checked").length > 0) scriptpath += "&pool=1";
		if (jQuery("#washer").length > 0 && jQuery("#washer:checked").length > 0) scriptpath += "&washer=1";
		if (jQuery("#garage").length > 0 && jQuery("#garage:checked").length > 0) scriptpath += "&garage=1";
		if (jQuery("#tv").length > 0 && jQuery("#tv:checked").length > 0) scriptpath += "&tv=1";
		
		if (jQuery("#house").length > 0 && jQuery("#house:checked").length > 0) scriptpath += "&detailObjectTypes[]=house";
		if (jQuery("#flat").length > 0 && jQuery("#flat:checked").length > 0) scriptpath += "&detailObjectTypes[]=flat";
		if (jQuery("#resort").length > 0 && jQuery("#resort:checked").length > 0) scriptpath += "&detailObjectTypes[]=resort";
		if (jQuery("#hotel").length > 0 && jQuery("#hotel:checked").length > 0) scriptpath += "&detailObjectTypes[]=hotel";
		if (jQuery("#pension").length > 0 && jQuery("#pension:checked").length > 0) scriptpath += "&detailObjectTypes[]=pension";
		if (jQuery("#farm").length > 0 && jQuery("#farm:checked").length > 0) scriptpath += "&detailObjectTypes[]=farm";
		if (jQuery("#camping").length > 0 && jQuery("#camping:checked").length > 0) scriptpath += "&detailObjectTypes[]=camping";
		if (jQuery("#boat").length > 0 && jQuery("#boat:checked").length > 0) scriptpath += "&detailObjectTypes[]=boat";
		if (jQuery("#motel").length > 0 && jQuery("#motel:checked").length > 0) scriptpath += "&detailObjectTypes[]=motel";
		if (jQuery("#hostel").length > 0 && jQuery("#hostel:checked").length > 0) scriptpath += "&detailObjectTypes[]=hostel";
		if (jQuery("#mobilehome").length > 0 && jQuery("#mobilehome:checked").length > 0) scriptpath += "&detailObjectTypes[]=mobilehome";

		if (jQuery("#selectRadius").length > 0 && jQuery("#selectRadius").val() > 0)  scriptpath += "&mapRadius=" + jQuery("#selectRadius").val();
		if (jQuery("#objectRatingAverage").length > 0 && jQuery("#objectRatingAverage").val() > 0)  scriptpath += "&objectRatingAverage=" + jQuery("#objectRatingAverage").val();
		if (jQuery("#detailPersonsMax").length > 0 && jQuery("#detailPersonsMax").val() > 0)  scriptpath += "&detailPersonsMax=" + jQuery("#detailPersonsMax").val();
		if (jQuery("#detailPersonsMin").length > 0 && jQuery("#detailPersonsMin").val() > 0)  scriptpath += "&detailPersonsMin=" + jQuery("#detailPersonsMin").val();
		if (jQuery("#detailPriceMax").length > 0 && jQuery("#detailPriceMax").val() > 0)  scriptpath += "&detailPriceMax=" + jQuery("#detailPriceMax").val();
		if (jQuery("#detailPriceMin").length > 0 && jQuery("#detailPriceMin").val() > 0)  scriptpath += "&detailPriceMin=" + jQuery("#detailPriceMin").val();
		if (jQuery("#detailRoomSleeping").length > 0 && jQuery("#detailRoomSleeping").val() > 0)  scriptpath += "&detailRoomSleeping=" + jQuery("#detailRoomSleeping").val();
		if (jQuery("#detailSquaremeters").length > 0 && jQuery("#detailSquaremeters").val() > 0)  scriptpath += "&detailSquaremeters=" + jQuery("#detailSquaremeters").val();
		if (jQuery("#detailSquaremetersOutdoor").length > 0 && jQuery("#detailSquaremetersOutdoor").val() > 0)  scriptpath += "&detailSquaremetersOutdoor=" + jQuery("#detailSquaremetersOutdoor").val();
		if (jQuery("#detailDistRestaurant").length > 0 && jQuery("#detailDistRestaurant").val() > 0)  scriptpath += "&detailDistRestaurant=" + jQuery("#detailDistRestaurant").val();
		if (jQuery("#detailDistShops").length > 0 && jQuery("#detailDistShops").val() > 0)  scriptpath += "&detailDistShops=" + jQuery("#detailDistShops").val();
		if (jQuery("#detailDistTouristinfo").length > 0 && jQuery("#detailDistTouristinfo").val() > 0)  scriptpath += "&detailDistTouristinfo=" + jQuery("#detailDistTouristinfo").val();
		if (jQuery("#detailDistCity").length > 0 && jQuery("#detailDistCity").val() > 0)  scriptpath += "&detailDistCity=" + jQuery("#detailDistCity").val();
		if (jQuery("#detailDistWater").length > 0 && jQuery("#detailDistWater").val() > 0)  scriptpath += "&detailDistWater=" + jQuery("#detailDistWater").val();
		if (jQuery("#detailDistBeach").length > 0 && jQuery("#detailDistBeach").val() > 0)  scriptpath += "&detailDistBeach=" + jQuery("#detailDistBeach").val();
		if (jQuery("#detailDistMarket").length > 0 && jQuery("#detailDistMarket").val() > 0)  scriptpath += "&detailDistMarket=" + jQuery("#detailDistMarket").val();
		if (jQuery("#detailDistAirport").length > 0 && jQuery("#detailDistAirport").val() > 0)  scriptpath += "&detailDistAirport=" + jQuery("#detailDistAirport").val();
		if (jQuery("#detailDistRailway").length > 0 && jQuery("#detailDistRailway").val() > 0)  scriptpath += "&detailDistRailway=" + jQuery("#detailDistRailway").val();
		if (jQuery("#detailDistSwimming").length > 0 && jQuery("#detailDistSwimming").val() > 0)  scriptpath += "&detailDistSwimming=" + jQuery("#detailDistSwimming").val();
		if (jQuery("#detailDistFishing").length > 0 && jQuery("#detailDistFishing").val() > 0)  scriptpath += "&detailDistFishing=" + jQuery("#detailDistFishing").val();
		if (jQuery("#detailDistSki").length > 0 && jQuery("#detailDistSki").val() > 0)  scriptpath += "&detailDistSki=" + jQuery("#detailDistSki").val();
		if (jQuery("#detailDistGolf").length > 0 && jQuery("#detailDistGolf").val() > 0)  scriptpath += "&detailDistGolf=" + jQuery("#detailDistGolf").val();
			
		if (jQuery("#detailSeaview").length > 0 && jQuery("#detailSeaview:checked").length > 0) scriptpath += "&detailSeaview=1";
		if (jQuery("#detailWellness").length > 0 && jQuery("#detailWellness:checked").length > 0) scriptpath += "&detailWellness=1";
		if (jQuery("#detailHolidayPark").length > 0 && jQuery("#detailHolidayPark:checked").length > 0) scriptpath += "&detailHolidayPark=1";
		if (jQuery("#detailPool").length > 0 && jQuery("#detailPool:checked").length > 0) scriptpath += "&detailPool=1";
		if (jQuery("#detailPetAllowed").length > 0 && jQuery("#detailPetAllowed:checked").length > 0) scriptpath += "&detailPetAllowed=1";
		if (jQuery("#detailSwimming").length > 0 && jQuery("#detailSwimming:checked").length > 0) scriptpath += "&detailSwimming=1";
		if (jQuery("#detailSkiing").length > 0 && jQuery("#detailSkiing:checked").length > 0) scriptpath += "&detailSkiing=1";
		if (jQuery("#detailFishing").length > 0 && jQuery("#detailFishing:checked").length > 0) scriptpath += "&detailFishing=1";
		if (jQuery("#detailBoat").length > 0 && jQuery("#detailBoat:checked").length > 0) scriptpath += "&detailBoat=1";
		if (jQuery("#detailGolf").length > 0 && jQuery("#detailGolf:checked").length > 0) scriptpath += "&detailGolf=1";
		if (jQuery("#detailTennis").length > 0 && jQuery("#detailTennis:checked").length > 0) scriptpath += "&detailTennis=1";
		if (jQuery("#detailParking").length > 0 && jQuery("#detailParking:checked").length > 0) scriptpath += "&detailParking=1";
		if (jQuery("#detailAircondition").length > 0 && jQuery("#detailAircondition:checked").length > 0) scriptpath += "&detailAircondition=1";
		if (jQuery("#detailFireplace").length > 0 && jQuery("#detailFireplace:checked").length > 0) scriptpath += "&detailFireplace=1";
		if (jQuery("#detailSolarium").length > 0 && jQuery("#detailSolarium:checked").length > 0) scriptpath += "&detailSolarium=1";
		if (jQuery("#detailSatTV").length > 0 && jQuery("#detailSatTV:checked").length > 0) scriptpath += "&detailSatTV=1";
		if (jQuery("#detailInternet").length > 0 && jQuery("#detailInternet:checked").length > 0) scriptpath += "&detailInternet=1";
		if (jQuery("#detailDishwasher").length > 0 && jQuery("#detailDishwasher:checked").length > 0) scriptpath += "&detailDishwasher=1";
		if (jQuery("#detailDryer").length > 0 && jQuery("#detailDryer:checked").length > 0) scriptpath += "&detailDryer=1";
		if (jQuery("#detailGarage").length > 0 && jQuery("#detailGarage:checked").length > 0) scriptpath += "&detailGarage=1";
		if (jQuery("#detailSauna").length > 0 && jQuery("#detailSauna:checked").length > 0) scriptpath += "&detailSauna=1";
		if (jQuery("#detailTV").length > 0 && jQuery("#detailTV:checked").length > 0) scriptpath += "&detailTV=1";
		if (jQuery("#detailWasher").length > 0 && jQuery("#detailWasher:checked").length > 0) scriptpath += "&detailWasher=1";
		if (jQuery("#objectCommercial").length > 0 && jQuery("#objectCommercial:checked").length > 0) scriptpath += "&objectCommercial=1";
	}
	else
	{
		scriptpath += "&onlySessionVars=1";
		onlySessionVars = 0;
	}
	
	var overlay=document.createElement('div');
	jQuery(overlay).html('<img src="/img/ajax-loader.gif"  style="display:block;margin:20px auto;"/>');
	jQuery(overlay).addClass('overlay');
	var overlayStyles='width:100%;position:absolute;left:0;z-index:500;background: url("/img/semi_trans.png") repeat scroll 0 0 transparent;';	
	jQuery(overlay).attr('style','top:'+(jQuery('#searchCriteria h2:first').height()+7)+'px;height:'+jQuery('#searchCriteria').height()+'px;'+overlayStyles);
	jQuery('#searchCriteria').append($(overlay));
	
	var objectsBoxOverlay=jQuery(overlay).clone().attr('style','height:'+jQuery('#objectsBox').height()+'px;top:0px;'+overlayStyles);
	
	//jQuery('#objectsBox').html('<div style="text-align: center; padding-top: 20px;height:'+jQuery('#objectsBox').height()+'px"><img src="/img/ajax-loader.gif"></div>').append(objectsBoxOverlay);
	jQuery('#objectsBox').append(objectsBoxOverlay);	
	jQuery('#objectsBox').attr('style','position:relative').append(objectsBoxOverlay);
	
	var activeFilterOverlay=jQuery(overlay).clone().attr('style','height:'+jQuery('#accomodations').height()+'px;top:'+(jQuery('#accomodations h2:first').height()+7)+'px;'+overlayStyles)
	//jQuery('#activeFilter').html('<div style="text-align: center; padding-top: 45px;"><img src="/img/ajax-loader.gif"></div>').append(activeFilterOverlay);	
	jQuery('#activeFilter').append(activeFilterOverlay);	
	
	jQuery.getScript(scriptpath,function(data, textStatus){
	   // toDebug(data); //data returned
	   // toDebug(textStatus); //success
	   // toDebug('Load was performed.');
	});
	
	if(typeof sc != 'undefined') {
		sc++;
		var urlsParts = document.location.href.split("#");
		document.location.href =  urlsParts[0] + "#" + sc;
	}	
	
}

function unsetCriteria(id,defaultVal)
{
	
	if (typeof id != 'object')
	{ 
		ids = new Array();
		ids.push(id);
	}else ids = id;
	
	for (var i = 0; i < ids.length; i++)
	{
		id = ids[i];		
		if (id.search('sel_objectAgencyIDs:') != -1)
		{			
			keys = id.split(':');			
			jQuery("#" + keys[0] + " option[value = '" + keys[1] + "']").attr('selected', false);
		}else if (jQuery("#" + id).length > 0)
		{ 
			if (jQuery("#" + id).attr('type') == 'checkbox') jQuery("#" + id).attr('checked', false);			
			else if (jQuery("#" + id).attr('type') == 'radio') jQuery("#" + id).attr('checked', false);
			else jQuery("#" + id).val('');		
			toDebug(jQuery("#" + id + ' option:selected'))		
			if(jQuery("#" + id + ' option:selected').length>0){
				jQuery("#" + id + ' option:selected').attr('selected', false);
				jQuery("#" + id).val(defaultVal);
			}
		}
	}
	preloadSearch();
}

function changePart(objectNumber, active)
{
    var i = 0;
    if (jQuery("#price_" + objectNumber).length > 0)
    {
    	jQuery("#price_" + objectNumber + " div").hide();
    	jQuery("#price_" + objectNumber + "_" + active).show();
    }
}

function showAdminCoordinateWindow() 
{
	locationID = jQuery("#hiddenLocationID").val();
	country = jQuery("#hiddenCountryID").val();
	adminCoordinateWindow = window.open("http://www.tourist-online.de/admintools/locationCoordinates/?locationID="+locationID+"&countryID="+country, "locationCoordinates", "width=860,height=596,location=0");
	adminCoordinateWindow.focus();
}
