// JavaScript Document
function countryChanged() {
	var url=buildURL('co');
	
	frmUpdate('search_results.php?'+url);
	document.forms['search_form'].changed.value='co';
	document.forms['search_form'].submit();
	
}

function regionChanged() {
	var url=buildURL('re');
	
	frmUpdate('search_results.php?'+url);
	document.forms['search_form'].changed.value='re';
	document.forms['search_form'].submit();

}

function cityChanged(aMethod) {
	var url=buildURL('ci');

	frmUpdate('search_results.php?'+url);
	document.forms['search_form'].changed.value='ci';
	document.forms['search_form'].submit();
}

function kindChanged(aMethod) {
	var url=buildURL('ak');

	frmUpdate('search_results.php?'+url);
	document.forms['search_form'].submit();
}

function numberChanged(aMethod) {
	var url=buildURL('num');
	
	frmUpdate('search_results.php?'+url);
	document.forms['search_form'].submit();
}

function fromDateChanged(aMethod) {
	document.forms['search_form'].submit();
}

	

function searchAvailability() {
	var url=buildURL('av');
	frmUpdate('search_results.php?'+url);
}

function buildURL(aMethod) {
	var result='';
	var country=document.forms['search_form'].country.options[document.forms['search_form'].country.selectedIndex].value;
	var region=document.forms['search_form'].region.options[document.forms['search_form'].region.selectedIndex].value;
	var city=document.forms['search_form'].city.options[document.forms['search_form'].city.selectedIndex].value;
	var kind=document.forms['search_form'].acco_kind.options[document.forms['search_form'].acco_kind.selectedIndex].value;
	var number_of_persons=document.forms['search_form'].number_of_persons.options[document.forms['search_form'].number_of_persons.selectedIndex].value;
	//var from_day=document.forms['search_form'].from_day.options[document.forms['search_form'].from_day.selectedIndex].value;
	//var from_month=document.forms['search_form'].from_month.options[document.forms['search_form'].from_month.selectedIndex].value;
	//var from_year=document.forms['search_form'].from_year.options[document.forms['search_form'].from_year.selectedIndex].value;
	//var to_day=document.forms['search_form'].to_day.options[document.forms['search_form'].to_day.selectedIndex].value;
	//var to_month=document.forms['search_form'].to_month.options[document.forms['search_form'].to_month.selectedIndex].value;
	//var to_year=document.forms['search_form'].to_year.options[document.forms['search_form'].to_year.selectedIndex].value;
	//var from_date=document.forms['search_form'].from.value;
    //var to_date=document.forms['search_form'].to.value;
    //result='method='+aMethod+'&country='+country+'&region='+region+'&city='+city+'&accokind='+kind+'&fromdate='+from_date+'&todate='+to_date+'&number='+number_of_persons;
    result='method='+aMethod+'&country='+country+'&region='+region+'&city='+city+'&accokind='+kind+'&number='+number_of_persons;

    return result;
}

function frmUpdate(page) {
	top.results.location=page;
}

function pageLoaded() {
	//get the method
	var method=document.forms['search_form'].method.value;

	var URL=buildURL(method);

	document.forms['search_form'].changed.value=method;
	document.forms['search_form'].submit();
	
	frmUpdate('search_results.php?'+URL);
	
}

function formSubmitted() {
alert("In form submitted()");
		var method=document.forms['search_form'].method.value;
alert("FormSubmitted() method is "+method);
	var URL=buildURL(method);

	document.forms['search_form'].changed.value=method;
	//document.forms['search_form'].submit();
	
	frmUpdate('search_results.php?'+URL);
}
