// JavaScript Document


function doSearch(actionURL, openNewWindow){
	var URLconstruct = actionURL;
	if(actionURL.indexOf('searchresults')!=-1){
		URLconstruct = URLconstruct + '?search=search&typeId=1';
	}else{
		if (Utils.$('town').value == '' || Utils.$('town').value == ' '){
			alert('Please enter the name of the City/Town you are hoping to stay at'); Utils.$('town').focus();
			return false; 
		}
		URLconstruct = URLconstruct + '?checkAvailability=Check+Availability&typeId=1';
	}
	
	if (Utils.$('calendarInput').value != '')
	{
		dateArray = Utils.$('calendarInput').value.split("/");

		y = parseInt(dateArray[2]);
		m = parseInt(dateArray[1]); if (m < 10) m = '0'+m;
		d = parseInt(dateArray[0]); if (d < 10) d = '0'+d;

		URLconstruct = URLconstruct + '&startdate='+y+m+d;
	}

	URLconstruct = URLconstruct + '&subTypeName='+Utils.$('subTypeName').value;
		 
	if (Utils.$('town').value != ''){
		URLconstruct = URLconstruct + '&town='+Utils.$('town').value;
	}
	if(openNewWindow=='Y'){
		window.open(URLconstruct, "blank");
	}else{
		location.href = URLconstruct;
	}
}
