﻿
// ####################### Used on the Search Form #######################
function PopHelp()  {
	var win;
	win = window.open("SearchHelp.asp","Help", "WIDTH=400,HEIGHT=350,top=50,left=50,statusbar=false,scrollbars=yes,toolbar=false");
}// end PopHelp
// ----------------------------------------------------

function ValidateKW()  {
	var strPushChars, strPopChars, chrNextChar;
	var myStack, i, x, hung, strData; 
	hung = "false";
	strPushChars = "[{(";
	strPopChars = "]})";
	strData = document.frmJobSearch.Keywords.value;
	myStack = new Array();
	
	if (strData == "")  {
		return true;
	}

	for (i=0; i < strData.length; i++)  {
		chrNextChar = strData.charAt(i);
		if( strPushChars.indexOf(chrNextChar) > -1 ) {
			myStack[myStack.length] = chrNextChar;  // PUSH
		} else {
			if(strPopChars.indexOf(chrNextChar) > -1) {   // POP
				if (chrNextChar == "]" && myStack[(myStack.length)-1] == "[")  {
					myStack = myStack.slice(0,myStack.length-1);
				} else {
					if (chrNextChar == ")" && myStack[(myStack.length)-1] == "(")  {
						myStack = myStack.slice(0,myStack.length-1);
					}  else  {
						if (chrNextChar == "}" && myStack[(myStack.length)-1] == "{")  {
							myStack = myStack.slice(0,myStack.length-1);
						}  else  {
							hung = "true";
						}
					}
				}
			} 
		}// end if-else
	}// end for
	if (myStack.length > 0 || hung == "true") {
		alert ("Please enter a valid keyword search.\nBe sure to close all parenthesis, braces, and brackets.");
		return false;
	}  else {
		return true;
	}
}// end ValidateKW


// ####################### Used on JobResponseForm.asp #######################

		
