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

	function submitForm(frm, url, target, popupoptions, linkkey) {
		if(!validateForm(frm)) {
			return false;
		}

		var linkkey=frm.linkkey.value;
		linkkey=linkkey.replace(/(hotel|fewo)$/, '');
		var newlinkkey=linkkey;
		if(frm.SrchAcctype[0].checked) {
			newlinkkey+='fewo';
		}
		else {
			newlinkkey+='hotel';
		}
		url=url.replace(new RegExp('/'+linkkey+'/'), '/'+newlinkkey+'/');
		frm.linkkey.value=newlinkkey;

		if(url.match(/^http:\/\/web\.deskline\.net/)) {
			var newurl=url+'?';
			if(frm.RG.value && frm.ID.value) {
				newurl+='RG='+frm.RG.value+'&ID='+frm.ID.value+'&';
			}
			else {
				newurl+='CLR_ALL=true&';
			}
			newurl+='qfdArrivalDate='+frm.SrchFromYear.value+frm.SrchFromMonth.value+frm.SrchFromDay.value+'&qfdNights='+frm.SrchDays.value+'&qfdAdults='+frm.SrchPax.value+'&qfdNumberOfUnits='+frm.SrchRooms.value;
			if(frm.SrchBookOnly.checked) { newurl+='&qfdOnlyBookable=1'; }
			url=newurl;
			frm.action=url;
		}

		if(target=='popup') {
			popup(url, popupoptions+',target='+target);
			frm.submit();
			return false;
		}

		if(target=='lightbox') {
			hs.htmlExpand(frm, {src: url, objectType: 'iframe', minWidth: 720, objectHeight: 800});
			return false;
		}

		frm.submit();
		return false;
		
		return true;
	}
	
	function validateForm(frm) {
		var d = parseInt( frm.SrchFromDay.value, 10 );
		var m = parseInt( frm.SrchFromMonth.value, 10 );
		var j = parseInt( frm.SrchFromYear.value, 10 );

		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 setLocation(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');
		var frm=ctrl.form;
		frm.RG.value=codes[0];
		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;
		}
	}

