//reloads the main property page depending on what was selected in the drop down
function reload_destination(page) {
	
	urlLocation=page+'?action=listFind&selDestinationId='+ document.searchForm.selDestinationId[document.searchForm.selDestinationId.selectedIndex].value;
	document.location.href=urlLocation;
}

//reloads the main property page depending on what was selected in the drop down
function reload_resort(page) {
	
	urlLocation=page+'?action=listFind&selDestinationId='+ document.searchForm.selDestinationId[document.searchForm.selDestinationId.selectedIndex].value + '&resortId=' + document.searchForm.selResortId[document.searchForm.selResortId.selectedIndex].value;
	document.location.href=urlLocation;
}

function openIMGwin(imgURL) {
	var Wname = "popped";
	var exec = 'window.open("';
	// Set name of common html file here
	var URL   = "fullImageView.cfm?"+imgURL;
	exec+= URL;      exec+= '", "';
	exec+= Wname;    exec+= '", "';
	// default dimensions set next line
	exec+='width=400,height=400';
	exec+=',top=30,left=30,screenX=0,screenY=0,toolbar=0,location=0';
	exec+=',directories=0,resizable=1,status=0,menubar=0,scrollbars=0")';
	// eval() takes the string called exec built and executes as code
	eval (exec);
}

function switchImage(imgURL,imgALT) {
		//alert(imgURL);
		document.getElementById("mainImg").style.backgroundImage = "url('" + imgURL + "')"; 
		document.getElementById("imageDesc").innerHTML = imgALT;
}

// Function to populate the area codes for the state selected
function PopulateRoomTypes() {
   // Only process the function if the first item is not selected.
   if (document.PricingForm.depStationId.selectedIndex != 0) {
	  // Find the state abbreviation
	  var ThisOption = document.PricingForm.depStationId[document.PricingForm.depStationId.selectedIndex].value;
	  // Set the length of the arecode drop down equal to the length of the state's array
	  document.PricingForm.roomTypeId.length = eval("OptionsArray" + ThisOption + ".length");
	  // Put 'Select' as the first option in the area code drop-down
	  document.PricingForm.roomTypeId[0].value = "";
	  document.PricingForm.roomTypeId[0].text = "Select";
	  document.PricingForm.roomTypeId[0].selected = true;
	  // Loop through the state's array and populate the area code drop down.
	  for (i=1; i<eval("OptionsArray" + ThisOption + ".length"); i++) {
		 document.PricingForm.roomTypeId[i].value = eval("OptionsArrayValue" + ThisOption + "[i]");
		 document.PricingForm.roomTypeId[i].text = eval("OptionsArray" + ThisOption + "[i]");
	  }
   }
}
		
function ReselectDropDown(dd) {
	for(i=0; i<document.PricingForm.depStationId.options.length; i++) {
		if(document.getElementById('depStationId')[i].value==dd) {
			document.getElementById('depStationId').selectedIndex=i;
		}
	}
}

function vEnquiryForm() {
	var errMsg='';
	if(document.getElementById('firstnames').value.length==0) {
		errMsg+='- firstname\n';
	}
	if(document.getElementById('surname').value.length==0) {
		errMsg+='- surname\n';
	}
	if((document.getElementById('email1').value.length==0) || (document.getElementById('email2').value.length==0)) {
		errMsg+='- email\n';
	}
	if((document.getElementById('email1').value != document.getElementById('email2').value)) {
		errMsg+='- email addresses do not match';
	}
	if (errMsg.length>0) {
		errMsg='Please fix the errors below: \n\n' + errMsg;
		alert(errMsg);
		return false;
	}
	
}


