function subWinFixed(urlname, width, height, windowname)
{
	var x = Math.round((screen.availWidth - width) / 2);
	var y = Math.round((screen.availHeight - height) / 2);
	popUp = window.open(urlname, windowname, 'left=' + x + ',' + 'top=' + y + ',' + 'width=' + width + ',height=' + height + ',status');
	popUp.focus();
}

function subWinCustom(urlname,width,height,windowname,options)
{
	var x=Math.round((screen.availWidth - width)/2),y=Math.round((screen.availHeight - height)/2);

	if (options!=null&&options!='')
		popUp=window.open(urlname,windowname,'left='+x+','+'top='+y+','+'width='+width+',height='+height+','+options);
	else // no options so don't include them
		popUp=window.open(urlname,windowname,'left='+x+','+'top='+y+','+'width='+width+',height='+height);

	popUp.focus();
}

function subWin(urlname, width, height, windowname)
{
	var x = Math.round((screen.availWidth - width) / 2);
	var y = Math.round((screen.availHeight - height) / 2);
	popUp = window.open(urlname, windowname, 'left=' + x + ',' + 'top=' + y + ',' + 'width=' + width + ',height=' + height + ',resizable,scrollbars,status');
	popUp.focus();
}

function checkEnter(e) // Obtained from the website: http://www.jennifermadden.com/162/examples/stringEnterKeyDetector.html
{
	var characterCode;

	// Obtaining key pressed
	if (e && e.which)
	{
		e = e;
		characterCode = e.which;
	}
	else
	{
		e = event;
		characterCode = e.keyCode;
	}

	// Checking if key pressed was the enter key
	if (characterCode == 13)
	{
 		return true;
	}

	return false;
}

/*
* Overcomes an issue with IE, whereby a multi-select element is not auto-scrolled when selected items appear outside the selection area
* An issue with IE when select properties are as follow: multiple="multiple"; size>="1"
*/
function searchBoxAutoScroll() {
	// Getting a reference to the filterPanel element
	var filterPanelElement = document.getElementById('filterPanel'); // see miniportal/jobboard/_filterPane.cfm for id value

	// Checking if the filterPanel element is on the page
	if(filterPanelElement != null) // is the filter panel element on the page? If so, ok to proceed
	{
		// Getting references to all the select elements within the filter panel element
		var selectElements = filterPanelElement.getElementsByTagName("SELECT"); // only dealing with SELECT elements
		
		// Looping through each select element
		for(var i = 0; i < selectElements.length; i++)
		{
			// Calling reSetSelectElementValues helper function, with the current select element as the argument
			reSetSelectElementValues(selectElements[i]);
		}
	}
}

/*
* A helper function of searchBoxAutoScroll(): Actually re-sets the select element's values so it is redrawn by the browser - Thus achieving the effect of select box auto-scrolling
*/
function reSetSelectElementValues(selectElement) {
	// Looping through the option elements for the supplied select element
	for (var j = 0; j < selectElement.options.length; j++)
	{
		// Re-setting the selected value(s) to the same value(s), to force a redraw of the select element so selected elements appearing outside the visible area become visible
		if (selectElement.options[j].selected) // Is this option select? If so, we need to work with it
		{
			// Setting the 'selected' property for the current option element to the same value, in order to achieve the auto-scrolling effect when finished
			selectElement.options[j].selected = selectElement.options[j].selected;
		}
	}
}
