/***************************************************************************
* Pop-up Handler
* Modeled on Ian Loyd's 'Perfect Pop-Up Handler'
* See details at:
* http://www.sitepoint.com/article/perfect-pop-up
*
*
* Here's an example call to this function:
*
* <a href="my-pop-up-window.htm" onclick="popUp(this.href,'console',400,200);return false;" target="_blank">This is my link</a>
*
***************************************************************************/
var newWin = null;
function popUp(strURL, winName, strType, strHeight, strWidth) {
 
 self.name = "main"; // names current window as "main"

 if (newWin != null && !newWin.closed)
   newWin.close();
 var strOptions="";
 if (strType=="console") {
   strOptions="resizable,height="+strHeight+",width="+strWidth;
 }
 if (strType=="fixed") {
   strOptions="status,height="+strHeight+",width="+strWidth;
 }
 if (strType=="elastic") {
   strOptions="toolbar,menubar,scrollbars,"+"resizable,location,height="+strHeight+",width="+strWidth;
 }
 if (strType=="bareelastic") {
   strOptions="scrollbars,resizable,"+"height="+strHeight+",width="+strWidth;
 }
 if (strType=="barebones") {
   strOptions="height="+strHeight+",width="+strWidth;
 }
 newWin = window.open(strURL, winName, strOptions);
 //newWin.focus();
}

/****** popupCenter: Pop-up Window and (Approximately) Center Within Viewport ************************************************************************************/
// added by James Baker, December 2010
// example call: <a href="my-pop-up-window.htm" onclick="popupCenter(this.href,'winName',400,200);return false;" target="_blank">This is my link</a>
var childWin = null;
function popupCenter(childURL, childName, childHeight, childWidth) {
	self.name = "parent"; // names current window as "parent"
	
	if (childWin != null && !childWin.closed) {
		childWin.close();
	}
	
	// establish parent window position based on browser type
	var parentLeft = 0, parentTop = 0;
	if (typeof(window.screenLeft ) == 'number' ) {
		// supported by IE, Opera, and Safari
		parentLeft = window.screenLeft;
		parentTop = window.screenTop;
	} else {
		// supported by Firefox and Chrome
		parentLeft = window.screenX;
		parentTop = window.screenY;
	}
	
	// establish viewport size based on browser type
	var viewportWidth = 0, viewportHeight = 0;
	if (typeof(window.innerWidth ) == 'number' ) {
		// supported by Firefox
		viewportWidth = window.innerWidth;
		viewportHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		// supported by IE 6+, Opera, Safari
		viewportWidth = document.documentElement.clientWidth;
		viewportHeight = document.documentElement.clientHeight;
	}
    
	// calculate desired distance of popup from top and left edges of parent window
	var childTop = 0, childLeft = 0;
	childLeft = ((viewportWidth-childWidth)/2)+parentLeft;
	childTop = ((viewportHeight-childHeight)/2)+parentTop;
	
	// open new widnow
	var childOptions="";
	childOptions="scrollbars,resizable,height="+childHeight+",width="+childWidth+",left="+childLeft+",top="+childTop;

	childWin = window.open(childURL, childName, childOptions);

}/****** end popupCenter ********************************************************************************************************************************************/

/***************************************************************************
* Select "Jump" Lists
* See details at:
* http://www.bio.psu.edu/toolbox/toolbox/development_tool/jumplist/
***************************************************************************/
function jumpList(jump_form) {
var URL = document.jump_form.jump_select.options[document.jump_form.jump_select.selectedIndex].value;
window.location.href = URL;
}


/***************************************************************************
* funtction selectJump
* (The Semantic Version)
* Can be be used with any select on the site to use as navigation without
* also using a submit button in a form
***************************************************************************/
	//receive which window is to be used to display the result (targetWindow), which select was utilized 
	//by the user (select), and what option to be selected by default if the select is being re-rendered (defaultSelected)
	function SelectJump (targetWindow,select,defaultSelected) {
		//eval determines whether or not the argument is a valid string, then parses the string and executes the code it finds
		//what will be executed is a redirection of the target window to the value selected by the user
		eval (targetWindow+".location='?"+select.name+"="+select.options[select.selectedIndex].value+"'");
		//this will set the selects default-selected option 
		if (defaultSelected) {select.selectedIndex=defaultSelected};
	}
