// Begin form validation
function validateForm(form)	{
	if ((document.getElementById) || (document.all)) {
		for (var loop=0; loop < bgColorArray.length; loop++) {
			var path = eval("document.frmTipSearch." + bgColorArray[loop] + ".style");
			path.backgroundColor = '#FFFFFF';					
		}
		for (var loop=0; loop < bgColorArray.length; loop++) {
			bgColorArray[loop] = "";
		}
	}						
		
		form.tipsSearchWord.value = Trim(form.tipsSearchWord.value);		
		var output = "";
		
		if (!validateAlphaNum(form.tipsSearchWord.value,1,50)) {
				output += "* Tips Search Keyword \n";
				setFocus(form.tipsSearchWord);
				if ((document.getElementById) || (document.all)) {
					bgColorArray[arrayCounter] = "tipsSearchWord";
					arrayCounter += 1;
				}
			}
						
		//final validation error message
		if (output != "")
			{
				alert("The following information was missing or incorrect:\n\n"+output);
				focusItem.focus();
				focusItem = "";
				if ((document.getElementById) || (document.all)) {
					bgColorArray.length = arrayCounter;
					arrayCounter = 0;
					
					//loop through to change background color of incorrect items
					for (var loop=0; loop < bgColorArray.length; loop++) {
						var path = eval("document.frmTipSearch." + bgColorArray[loop] + ".style");
						path.backgroundColor = '#FFFFCC';					
					}
				}
				return false;
			}
		
		return true;		
	}
//  End form validation 

// Begin form validation Submit a Travel Tip
// setting focus on the first item that was invalid on the form
var focusItem2 = "";
var bgColorArray2 = new Array(); // array for changing background color of invalid items
var arrayCounter2 = 0;

function setFocus2(item2) {
	if (focusItem2 == "") focusItem2 = item2; 
}
function validateForm2(form)	{
	if ((document.getElementById) || (document.all)) {
		for (var loop=0; loop < bgColorArray2.length; loop++) {
			var path = eval("document.frmSubmitTip." + bgColorArray2[loop] + ".style");
			path.backgroundColor = '#FFFFFF';					
		}
		for (var loop=0; loop < bgColorArray2.length; loop++) {
			bgColorArray2[loop] = "";
		}
	}		
		
		form.tip.value = Replace(form.tip.value, '\r\n', ' ');
		form.tip.value = Replace(form.tip.value, '\r', ' ');
		form.tip.value = Replace(form.tip.value, '\n', ' ');	
		form.tip.value = Trim(form.tip.value);
		
		var tipCategoryIndex = form.tipCategory.selectedIndex;
		var output = "";
		
		if (tipCategoryIndex == "0" || tipCategoryIndex == "1") {
			output += "* Choose a Tip Category\n";
			setFocus2(form.tipCategory);
			if ((document.getElementById) || (document.all)) {
				bgColorArray2[arrayCounter2] = "tipCategory";
				arrayCounter2 += 1;
			}
		}
		if (form.tip.value.length > 250) {
			output += "* Travel Tip -- Your entry exceeds the limit of 250 characters. Please shorten your entry.\n";
			setFocus2(form.tip);
			if ((document.getElementById) || (document.all)) {
				bgColorArray2[arrayCounter2] = "tip";
				arrayCounter2 += 1;
			}
		}
		else if (!validateString(form.tip.value,1,250)) {
			output += "* Travel Tip\n";
			setFocus2(form.tip);
			if ((document.getElementById) || (document.all)) {
				bgColorArray2[arrayCounter2] = "tip";
				arrayCounter2 += 1;
			}
		}
						
		if (!valEmail(form.email1.value)) {
			output += "* E-mail Address\n";
			setFocus2(form.email1);
			if ((document.getElementById) || (document.all)) {
				bgColorArray2[arrayCounter2] = "email1";
				arrayCounter2 += 1;
			}
		}
				
		if (output != "")
			{
				alert("The following information was missing or incorrect:\n\n"+output);
				focusItem2.focus();
				focusItem2 = "";
				if ((document.getElementById) || (document.all)) {
					bgColorArray2.length = arrayCounter2;
					arrayCounter2 = 0;
					
					//loop through to change background color
					for (var loop=0; loop < bgColorArray2.length; loop++) {
						var path = eval("document.frmSubmitTip." + bgColorArray2[loop] + ".style");
						path.backgroundColor = '#FFFFCC';					
					}
				}
				return false;
			}
			else {
			// replace all double quotes with single quotes
			
						
			return true;
			}
	}
//  End form validation

// end hiding -->
