/*
<!-- parser stop -->
*/

	function submitForm(frm, url, target, popupoptions) {
		if(!validateForm(frm)) {
			return false;
		}
		if(target=='popup') {
			popup(url, popupoptions+',target='+target);
			frm.submit();
			return false;
		}
		return true;
	}
	
	function validateForm(frm) {
		var d = parseInt( frm.SrchFromDay.value )
		var m = parseInt( frm.SrchFromMonth.value )
		var j = parseInt( frm.SrchFromYear.value )

		if ( !checkDate(d,m,j) ) {
			alert("Datum inkorrekt!") ;
			frm.SrchFromDay.focus();
			return false;
		}
		return true;
	}

	function checkDate( d, m, j ) {
		var dt = new Date( j, m-1, d )
		if ( dt.getDate() != d || dt.getMonth()+1 != m ) return false;
		return true;
	}

	function setCurrentDay(frm) {
		//
		// Set Quickfinder date to current day
		//
		var today = new Date();
		var today_day   = today.getDate();
		var today_month = today.getMonth();
		var today_year  = today.getFullYear();

		window.document[frm].SrchFromDay.options[today_day-1].selected = true;
		window.document[frm].SrchFromMonth.options[today_month].selected = true;
		window.document[frm].SrchFromYear.options[0].value = today_year;
		window.document[frm].SrchFromYear.options[0].text = today_year;
	}
	
	function setCurrentLanguage(frm) {
		var languages=new Array();
		languages['de']=1;
		languages['en']=2;
		languages['fr']=3;
		languages['it']=4;
		languages['es']=5;
		languages['nl']=6;
		languages['sl']=7;
		languages['bg']=8;
		languages['sk']=9;
		languages['cs']=10;
		languages['hu']=11;
		languages['pl']=12;

		window.document[frm].LG.value=languages[lang];
	}
	
	function setLocation(frm, ctrl) {
		var code=ctrl.options[ctrl.selectedIndex].value;
		if(!code) return alert('Invalid location');
		
		var codes=code.split('__', 2);
		if(codes.length !=2) return alert('Invalid location');
		window.document[frm].RG.value=codes[0];
		window.document[frm].ID.value=codes[1];
	}
	
	function changeRoom(ctrl, roomtype) {
		var frm=ctrl.form;
		if(roomtype=='apartment') {
			if(frm.SrchDays.childElementCount && frm.SrchDays.options[0].selected == true) {
				frm.SrchDays.options[6].selected = true;
			}
			else if(frm.SrchDays.value ==1) {
				frm.SrchDays.value=7;
			}
			frm.SrchRooms.disabled=true;
		}
		else {
			frm.SrchRooms.disabled=false;
		}
	}

