//perform validation on quick search
function submitQuickSearch(){
	var oForm = document.forms["frmQuickSearch"];
	if(oForm){
		var sCategory = oForm.typecat.value;
		var sRegion = oForm.island.value;
		if(sCategory.length<1 || sRegion.length<1){
			alert("Search Requires Both Category and Island");
		}else{
			oForm.submit();
		}
	}
}

//generates clicks from info pages to listing details
function getListing(listingId){
	var sPath = "http://previewhawaii.com/cgi-perl/prevhi/search.pl?page=detail;id=" + listingId;
	window.location = sPath;
}

function checkEnter(){
	ev = window.event;
	el = window.event.srcElement;
	iKey = ev.keyCode;
	if(iKey == 13){
		try{
			submitQuickSearch();
		}catch(e){}
	}
}

function setFocus(){
	try{
		document.forms[0].elements[0].focus();
	}catch(e){}
}


function submitPseudoForm(sAddElementId,sQueryString){														
	var sValue = document.getElementById(sAddElementId).value;
	if(sValue==""){
		alert("Please enter a value");
	}else{
		var sSubmit = sQueryString + sValue;
		launch(sSubmit);
	}
}

function buildElementsCollection(oContainer){
	var arrElements = new Array();
	var colElements = oContainer.getElementsByTagName("INPUT");
	for (i=0;i<colElements.length;i++){
		//if(colElements[i].type.toUpperCase() != 'BUTTON' && colElements[i].type.toUpperCase() != 'SUBMIT' && colElements[i].type.toUpperCase() != 'RESET'){
			arrElements.push(colElements[i]);
		//}
	}

	var colElements = oContainer.getElementsByTagName("SELECT");
	for (i=0;i<colElements.length;i++){
		arrElements.push(colElements[i]);
	}
	
	var colElements = oContainer.getElementsByTagName("TEXTAREA");
	for (i=0;i<colElements.length;i++){
		arrElements.push(colElements[i]);
	}
	return arrElements;
}
