function popWindow(theURL,winName,features) {
  var newWin
  newWin = window.open(theURL,winName,features);
  newWin.focus();
}

function IsIE() {
	return (navigator.appName == "Microsoft Internet Explorer")
}

function focusSearchBox() {
	//try standard search
	var searchBox = document.getElementById('SearchControl_txtQueryStandard');
	if (eval(searchBox)) {
		searchBox.focus();
		return;
	}
	//try advanced search
	searchBox = document.getElementById('SearchControl_txtQueryAdvanced');
	if (eval(searchBox)) {
		searchBox.focus();
		return;
	}
	//try header search
	searchBox = document.getElementById('ucHeader_SearchField_txtSearch');
	if (eval(searchBox)) {
		searchBox.focus();
		return;
	}
	//try geysernet header search
	searchBox = document.getElementById('ucheader__ctl0__ctl0_txtSearch');
	if (eval(searchBox)) {
		searchBox.focus();
		return;
	}
}

//checks the search box to make sure at least 3 chars
function checkForm(textboxName) {
	var peopleradio;
	var textbox = document.getElementById(textboxName);
	var arrInput = document.all.tags("INPUT");
	
	for(var i=0;i<arrInput.length;i++) {
		if(arrInput[i].id.indexOf("rbPeopleSearch") > -1 ) {
			peopleradio = arrInput[i];
			break;
		}
	}
	if (eval(peopleradio)) 
		if(peopleradio.checked) 
			return true;
	
	if (eval(textbox)) {
		if (textbox.value.length < 3) {
			alert("You must enter at least 3 characters to search.");
			textbox.focus();
			return false;
		}
		return true;
	}	
}

// checks the search box or either of two selection input is populated
function checkPeopleForm(textboxName, dropdownOneName, dropdownTwoName) {
	var textbox = document.getElementById(textboxName);
	var dropdownOne = document.getElementById(dropdownOneName);
	var dropdownTwo = document.getElementById(dropdownTwoName);
	
	if(eval(textbox) && eval(dropdownOne) && eval(dropdownTwo)) {
		if((textbox.value.length == 0 && dropdownOne.selectedIndex == 0 && dropdownTwo.selectedIndex == 0)) {
			alert("You must enter a name or select a position title or department to search");
			return false;
		}
		return true;
	}	
}

//checks if pressed enter in the text box
function doEnter(textboxName, buttonName) {
//alert('a');
	var textbox = document.getElementById(textboxName);
	var searchButton = document.getElementById(buttonName);
	if (eval(searchButton)) {
		var NS = (window.navigator.appName.toLowerCase() == "netscape"? true : false);
		/*if (NS) { 
			document.captureEvents(Event.KEYDOWN); 
			document.onkeydown = getkey;
		}
		else */
if (event.keyCode && event.keyCode == 13) { 
			event.cancel = true;
			event.returnValue = false;
			searchButton.click();
		}
	}
}

//for NS
function getkey(k) {
	if (k.which && k.which == 13) {
		btn.click();
	}
	return false;	
}

//trims white space from beginning and end of word
function trim(sString) {
	//trim from beginning
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	//trim from end
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

