// trim functionality
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}

function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

// form focus
function setFormFocus(frmName) {
	// set focus on first form input field
	focusSet = false
	if (document.forms[frmName]) {
		for (elix=0; elix < document.forms[frmName].elements.length && !focusSet; elix++) {
			FormField = document.forms[frmName].elements[elix]
			if (FormField.disabled == false && ((FormField.tagName == "INPUT") && (FormField.type == "text")) || ((FormField.tagName == "TEXTAREA") && (FormField.type == "textarea") && (FormField.id != "dhtmleditor")))	{
				FormField.focus()
				focusSet = true
			}
		}
	}
}

// validation
function checkSearchFrm(default_txt_where, default_txt_what) {
	frm = document.forms['searchForm']
	
	if	( (trim(frm.location.value).length == 0 || trim(frm.location.value) == default_txt_where) && (trim(frm.keyword.value).length == 0 || trim(frm.keyword.value) == default_txt_what) && (frm.segment_id.selectedIndex == 0) ) {
		alert("Geef aan waar of wat u wilt zoeken of selecteer een categorie!")
		return false
	}
	/*
	if(trim(frm.location.value).length == 0 || trim(frm.location.value) == 'plaats, provincie of postcode') {
		alert("Geef aan waar u wilt zoeken!")
		return false
	}
	*/
	else {		
		if(trim(frm.keyword.value) == 'product of merk') frm.keyword.value = ''
		//alert('goed zo')
		frm.submit()
	}
}