

// Kontroller
var DL_country = document.getElementById('UC_HovedSoegBlok1_DropDownList_country');
var DL_region = document.getElementById('UC_HovedSoegBlok1_DropDownList_region');

var DL_destination = document.getElementById('UC_HovedSoegBlok1_DropDownList_destination');

var TB_startdate = document.getElementById('UC_HovedSoegBlok1_TextBox_startdate');

var DL_numberofdays = document.getElementById('UC_HovedSoegBlok1_DropDownList_numberofdays');
var DL_waterdistance = document.getElementById('UC_HovedSoegBlok1_DropDownList_waterdistance');
var DL_seaview = document.getElementById('UC_HovedSoegBlok1_DropDownList_seaview');
var DL_persons = document.getElementById('UC_HovedSoegBlok1_DropDownList_persons');
var DL_pets = document.getElementById('UC_HovedSoegBlok1_DropDownList_pets');
var DL_total = document.getElementById('UC_HovedSoegBlok1_DropDownList_total');
var DL_category = document.getElementById('UC_HovedSoegBlok1_DropDownList_category');
var DL_bedrooms = document.getElementById('UC_HovedSoegBlok1_DropDownList_bedrooms');
var DL_toilets = document.getElementById('UC_HovedSoegBlok1_DropDownList_toilets');
var DL_housem2 = document.getElementById('UC_HovedSoegBlok1_DropDownList_housem2');
var DL_swimmingpool = document.getElementById('UC_HovedSoegBlok1_DropDownList_swimmingpool');
var DL_jacuzzi = document.getElementById('UC_HovedSoegBlok1_DropDownList_jacuzzi');
var DL_satellite = document.getElementById('UC_HovedSoegBlok1_DropDownList_satellite');
var DL_seaview = document.getElementById('UC_HovedSoegBlok1_DropDownList_seaview');
var DL_skiing_lift = document.getElementById('UC_HovedSoegBlok1_DropDownList_skiing_lift');

var CB_satellite = document.getElementById('UC_HovedSoegBlok1_CheckBox_satellite');
var CB_woodburning_stove = document.getElementById('UC_HovedSoegBlok1_CheckBox_woodburning_stove');
var CB_washingmachine = document.getElementById('UC_HovedSoegBlok1_CheckBox_washingmachine');
var CB_tumbler = document.getElementById('UC_HovedSoegBlok1_CheckBox_tumbler');
var CB_dishwasher = document.getElementById('UC_HovedSoegBlok1_CheckBox_dishwasher');
var CB_internet = document.getElementById('UC_HovedSoegBlok1_CheckBox_internet');
var CB_seaview = document.getElementById('UC_HovedSoegBlok1_CheckBox_seaview');
var CB_seaviewground = document.getElementById('UC_HovedSoegBlok1_CheckBox_seaviewground');
var CB_swimmingpool = document.getElementById('UC_HovedSoegBlok1_CheckBox_swimmingpool');
var CB_jacuzzi = document.getElementById('UC_HovedSoegBlok1_CheckBox_jacuzzi');
var CB_sauna = document.getElementById('UC_HovedSoegBlok1_CheckBox_sauna');
var CB_sunbed = document.getElementById('UC_HovedSoegBlok1_CheckBox_sunbed');
var CB_freezer = document.getElementById('UC_HovedSoegBlok1_CheckBox_freezer');
var CB_wheelchair = document.getElementById('UC_HovedSoegBlok1_CheckBox_wheelchair');
var CB_phone = document.getElementById('UC_HovedSoegBlok1_CheckBox_phone');
var CB_energysafe = document.getElementById('UC_HovedSoegBlok1_CheckBox_energysafe');

var CB_aqualandhouses = document.getElementById('UC_HovedSoegBlok1_CheckBox_aqualandhouses');
var CB_offerhouses = document.getElementById('UC_HovedSoegBlok1_CheckBox_offerhouses');
var CB_fishinghouses = document.getElementById('UC_HovedSoegBlok1_CheckBox_fishinghouses');
var CB_wellnesshouses = document.getElementById('UC_HovedSoegBlok1_CheckBox_wellnesshouses');
var CB_businesshouses = document.getElementById('UC_HovedSoegBlok1_CheckBox_businesshouses');
var CB_golfwellnesshouses = document.getElementById('UC_HovedSoegBlok1_CheckBox_golfwellnesshouses');
var CB_castlehouses = document.getElementById('UC_HovedSoegBlok1_CheckBox_castlehouses');
var CB_wheelchairhouses = document.getElementById('UC_HovedSoegBlok1_CheckBox_wheelchairhouses');		

// Funktioner
function clearsearchform(formid) {	
	document.cookie="SBCOOKIE=;PATH=/;expires=Thu, 01-Jan-1970 00:00:01 GMT";
	if(formid) {clearForm(document.forms[formid]);callAsyn(formid);}
	else {clearForm(document.forms[0]);DL_region.onchange();}
}


function clearForm(oForm) {    
	var elements = oForm.elements;     
	for(i=0; i<elements.length; i++) { 
		if(elements[i].name!=undefined) {
			if(elements[i].name.indexOf('numberofdays')>-1) {
				elements[i].value = 7;	
			} else {     
				field_type = elements[i].type.toLowerCase();	
				switch(field_type) { 
					case "radio":
					case "checkbox":
							if (elements[i].checked) elements[i].checked = false;			
						break;
					case "select-one":
					case "select-multi":
						elements[i].selectedIndex = 0;
						break;
				} 
			}
		}   
	}	
}

function RegionDropDownOnChange() {
    UdfyldDestinationerDropDown(DL_region.options[DL_region.selectedIndex].value,0);
}
function ChangeLRDImage(r) {
	var o=parseInt(r); 
	if(o!=0) MM_swapImage('ImgBase','','/gfx/dokort/dk_'+ o +'.gif',0);
    else MM_swapImage('ImgBase','','/gfx/dokort/dk_0.gif',0);
}
function LandImageOnClik(selected) {    
	if(DL_region) {
        for (var i=0;i < DL_region.length; i++) {
            if(DL_region.options[i].value==selected) {
                DL_region.options[i].selected = true;
                UdfyldDestinationerDropDown(selected, "0");
            }
        }        
    }
    else if(DL_destination) {
        for (var i=0;i < DL_destination.length; i++) {
            if(DL_destination.options[i].value==selected) {
                DL_destination.options[i].selected = true;
            }
        }
    }
        
}

function UdfyldDestinationerDropDown(r, d) {   
    if(DL_destination && arr_destinations.length > 1) {
        DL_destination.options.length = 0;        
        var n = 0;
        for (i=0;i<arr_destinations.length;i++) {
            var element = arr_destinations[i].split('*');
            DL_destination.options[n] = new Option(element[1],element[2]);                    
            if (element[2] == d) DL_destination.options[n].selected = true;        
            n++; 
        }
    }
      
}


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_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null)  {
	    document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

function selectElement(obj, selected) {
	var f=false;var i=0;
	while(!f && i<obj.options.length) {
		if(obj.options[i].value==selected) {
			obj.options[i].selected = true;
			f=true;
		}
		i++;
	}	
	if(f) return i;
	else return -1;
}
function UdfyldDropDown(obj, arr, selected) {
    if(obj) {
        for(var i=0;i<arr.length;i++) {
            var element = arr[i].split('*');
            obj.options[i] = new Option(element[0],element[1]);
            if (element[1] == selected) obj.options[i].selected = true;
        }
    }
}
function SetCheckBox(arr) {
    if(arr) {    
        for(var i=0;i<arr.length;i++)
            if(arr[i]) arr[i].checked = true; 
    }
}
function clearDate() {
	TB_startdate.value="Ikke vigtig";	
}
var tmp_regions ="All regions*0#Sealand*9";var arr_regions = tmp_regions.split("#");
var tmp_destinations ="0*All destinations*0#9*Buresø*282#9*Dalby Huse*204#9*Dronningmølle*213#9*Gilleleje*214#9*Helsingør*288#9*Hornbæk*350#9*Hundested*217#9*Kulhuse*218#9*Liseleje*216#9*Melby*332#9*Nykøbing Sjælland*462#9*Over Dråby Strand*219#9*Rågeleje*215#9*Sjællands Odde*198#9*Skibby*249#9*Smidstrup Strand*355#9*Tikøb*389#9*Tisvildeleje*322#9*Udsholt Strand*465#9*Ålsgårde*212";var arr_destinations = tmp_destinations.split("#");
var tmp_numberofdays ="2 nights*2#3 nights*3#4 nights*4#5 nights*5#7 nights*7#8 nights*8#9 nights*9#10 nights*10#11 nights*11#12 nights*12#13 nights*13#14 nights*14#15 nights*15#16 nights*16#17 nights*17#18 nights*18#19 nights*19#20 nights*20#21 nights*21#22 nights*22#23 nights*23#24 nights*24#25 nights*25#26 nights*26#27 nights*27#28 nights*28";
var tmp_waterdistance="Not important*0#Max. 150 meters*150#Max. 500 meters*500#Max. 1000 meters*1000#Max. 2000 meters*2000#Max. 5000 meters*5000#Max. 10000 meters*10000";
var tmp_seaview="Not important*#Yes*yes#No*no";
var tmp_persons="Not important*0#Persons (3+ years)*0#1 person*1#2 persons*2#3 persons*3#4 persons*4#5 persons*5#6 persons*6#7 persons*7#8 persons*8#9 persons*9#10 persons*10#11 persons*11#12 persons*12#13 persons*13#14 persons*14#15 persons*15#16 persons*16#17 persons*17#18 persons*18#19 persons*19#20 persons*20#21+ persons*21";
var tmp_pets="Not important*0#1 pet*1#2 pets*2#3 pets or more*3#No pets*no";
var tmp_total="Not important*0#EUR 300,-*300#EUR 400,-*400#EUR 500,-*500#EUR 600,-*600#EUR 700,-*700#EUR 800,-*800#EUR 900,-*900#EUR 1000,-*1000#EUR 1100,-*1100#EUR 1200,-*1200#EUR 1800,-*1800#EUR 2000,-*2000#EUR 2500,-*2500#EUR 3000,-*3000";
var tmp_category="Not important*#Standard class*A#Standard plus class*P#Special class*S#Top class*T#Exclusiv*X";
var tmp_bedrooms="Not important*0#Min. 1 bedroom*1#Min. 2 bedrooms*2#Min. 3 bedrooms*3#Min. 4 bedrooms*4#Min. 5 bedrooms*5";
var tmp_toilets="Not important*#Min. 1 toilet*1#Min. 2 toilets*2#Min. 3 toilets*3#Min. 4 toilets*4";
var tmp_swimmingpool="Not important*#Swimming pool*#Yes please*yes#No please*no#Private, indoor*private#Shared, indoor*shared#Only indoor*indoor#Only outdoor*outdoor";
var tmp_jacuzzi="Not important*#Yes please*yes#No please*no#Only indoor*indoor#Only outdoor*outdoor";
var tmp_housem2="Not important*#Min. 50 qm*50#Min. 200 qm*200#Min. 300 qm*300#Min. 500 qm*500";

function SBInit() { 
UdfyldDropDown(DL_region, arr_regions,0);
UdfyldDestinationerDropDown(0,0);
TB_startdate.value="11-09-2010";
UdfyldDropDown(DL_numberofdays, tmp_numberofdays.split("#"),7);
UdfyldDropDown(DL_waterdistance, tmp_waterdistance.split("#"),'null');
UdfyldDropDown(DL_seaview, tmp_seaview.split("#"),'null');
UdfyldDropDown(DL_persons, tmp_persons.split("#"),'null');
UdfyldDropDown(DL_pets, tmp_pets.split("#"),'null');
UdfyldDropDown(DL_total, tmp_total.split("#"),'null');
UdfyldDropDown(DL_category, tmp_category.split("#"),'null');
UdfyldDropDown(DL_bedrooms, tmp_bedrooms.split("#"),'null');
UdfyldDropDown(DL_toilets, tmp_toilets.split("#"),'null');
UdfyldDropDown(DL_swimmingpool, tmp_swimmingpool.split("#"),'null');
UdfyldDropDown(DL_jacuzzi, tmp_jacuzzi.split("#"),'null');
UdfyldDropDown(DL_housem2, tmp_housem2.split("#"),'null');

}
SBInit();
