<!--
//generic window opener passing in two arguements url and name
var agt = navigator.userAgent.toLowerCase(); 
var is_aol = (agt.indexOf("aol") != -1); 
var windowOpener = null;
var propStr;

function popUp(url, title, w, h, isScrollable, notResizable) {
	if(w == null) { w = 457; }
	if(h == null) { h = 450; }
	if(is_aol) { h = 800; }
	
	var isScroll;
	// if isScrollable is omitted (default function call), scrollbars are displayed
	if (isScrollable == null)
		isScroll="yes";
	else if (isScrollable == true)
		isScroll="yes";
	else
		isScroll="no";
		
	var isResize;
	// if isResizable is omitted (default function call), scroll bars are displayed
	if (notResizable == null) {
		isResize="yes";
	} else if (notResizable == true) {
		isResize="no";
	} else {
		isResize="yes";
	}
	
	if(is_aol) {
		propStr = 'scrollbars=' + isScroll + ',menubar=no,resizable=' + isResize + ',status=no,width=' + w + ',height=' + h;
	} else {
		propStr = 'scrollbars=' + isScroll + ',menubar=no,resizable=' + isResize + ',status=no,width=' + w + ',height=' + h + ',top=30,left=40';
	}
	
	openWindow(url,title,propStr);
}


//generic window open function called by specific opener functions above
function openWindow(url, title, propStr){
	if(windowOpener == null) {
		windowOpener = window.open(url, title, propStr);
		self.name = "mainWin";
	} else if(windowOpener.closed){
		windowOpener = window.open(url, title, propStr);
		self.name = "mainWin";
	} else {
		windowOpener.close();
		windowOpener = window.open(url, title, propStr);
		windowOpener.focus();
	}	
}



var formReturn = window.name; 

// Passes link text from popup window to appropriate text field
function setFormField(Value){ 
	var preField = eval('window.opener.document.'+formReturn+'.currentCodeForm.value'); 		
	eval('window.opener.document.'+formReturn+'.'+preField+'.value = Value'); 
	window.close(); 
}

// Passes link text from popup window to appropriate text field
function passFormField(value, formName, formField){
	var valuePath = eval("window.opener.document." + formName + "." + formField);
	valuePath.value = value; 
	window.close();
}

function launchListPopup(url,formName){ 
	w = 457;
	h = 450;
	
	var codeWin = eval(window.open(url,formName,'width='+w+',height='+h+',scrollbars=yes,menu=no,resizable=yes'));
	codeWin.focus(); 
} 

function launchPopup(url, fieldName, formName){ 
	w = 457;
	h = 450;
	
	eval('document.'+formName+'.currentCodeForm.value = fieldName'); 
	eval('document.'+formName+'.currentCalForm.value = formName'); 
	var codeWin = eval(window.open(url,formName,'width='+w+',height='+h+',scrollbars=yes,menu=no,resizable=yes'));
	codeWin.focus(); 
} 

function launchPopup2(url, fieldName, formName, w, h){	
	var codeWin = eval(window.open(url,formName,'width='+w+',height='+h+',scrollbars=yes,menu=no,resizable=yes'));
	codeWin.focus(); 
} 

function resetForm() {
	document.powsearch.keywords.value = '';
	document.powsearch.keywordAndOr[0].checked = true;
	document.powsearch.author.value = '';
	document.powsearch.commentator.value = '';		
	document.powsearch.journal.value = '';		
	document.powsearch.PostedToArf.selectedIndex = 0;	
	document.powsearch.PubDateLowMonth.selectedIndex = 0;
	document.powsearch.PubDateLowYear.selectedIndex = 0;
	document.powsearch.PubDateHighMonth.selectedIndex = 0;	
	document.powsearch.PubDateHighYear.selectedIndex = 0;
	document.powsearch.commented.checked = false;	
	document.powsearch.ARFRec.checked = false;
	document.powsearch.milestone.checked = false;
	document.powsearch.sort.selectedIndex = 0;
}

function resetForm2() {
	document.searchcomment.keywords.value = '';
	document.searchcomment.commentator.value = '';		
	document.searchcomment.PubDateLowMonth.selectedIndex = 0;
	document.searchcomment.PubDateLowYear.selectedIndex = 0;
	document.searchcomment.PubDateHighMonth.selectedIndex = 0;	
	document.searchcomment.PubDateHighYear.selectedIndex = 0;
	document.searchcomment.approved.checked = true;	
	document.searchcomment.hold.checked = true;
	document.searchcomment.rejected.checked = false;
	document.searchcomment.sort.selectedIndex = 0;
}

function resetForm3() {
	document.comsearch.keywords.value = '';
	document.comsearch.commentator.value = '';		
	document.comsearch.PubDateLowMonth.selectedIndex = 0;
	document.comsearch.PubDateLowYear.selectedIndex = 0;
	document.comsearch.PubDateHighMonth.selectedIndex = 0;	
	document.comsearch.PubDateHighYear.selectedIndex = 0;
	document.comsearch.sort.selectedIndex = 0;
}

    
function goOpener(myLink,closeme,closeonly)
{
	if (! (window.focus && window.opener))
		return true;
	window.opener.focus();
	if (! closeonly) 
		window.opener.location.href=myLink.href;
	if (closeme) 
		window.close();
	return false;
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}

// called by Back and Prev links on paper search
function doSubmitPrevNext(whichDirection){
	//document.powsearch.innerHTML = document.powsearch.innerHTML + "<input type='hidden' name='whichDirection' value='" + whichDirection +"'>";
	document.powsearch.whichDirection.value = whichDirection;
	document.powsearch.submit();
}


// parameter citationsSelected is flagged as true if any citations were selected on previous pages
function doSubmitSendTo(citationsSelected, totalRows)
{
	if (totalRows == "" || parseInt(totalRows) < 1) {
		alert ("Please perform a search before selecting this option.");
		
		// select the "Send results to..." option in the dropdown list
		document.powsearch.sendTo.value = "-2";	
	}
	// if "Send selected to..."
	else if (parseInt(document.powsearch.sendTo.value) >= 1 && parseInt(document.powsearch.sendTo.value) <= 4 ) {
		var anyChecked = false;
		
		// in case only one result was found and selected
		if (document.powsearch.SendToCitIDs.length == null) {
			if (document.powsearch.SendToCitIDs.checked == true) {
				anyChecked = true;
			}
		}
		else {
			// are any checkboxes selected on the current page?
			for (var i=0; i < document.powsearch.SendToCitIDs.length; i++) {
				if (document.powsearch.SendToCitIDs[i].checked == true) {
					anyChecked = true;
				}
			}
		}

		//alert('citationsSelected= ' + citationsSelected);
		//alert('anyChecked= ' + anyChecked);

		// were any citations selected on previous pages OR are any checkboxes selected on the current page?
		if (citationsSelected == "False" && !anyChecked) {
			alert ("Please select the checkboxes of the citations you would like to send.");
			
			// select the "Send results to..." option in the dropdown list
			document.powsearch.sendTo.value = "-2";	
		}
		else {
			// select the "Send results to..." option in the dropdown list	
			document.powsearch.submit();
		}
	}
	// don't submit if invalid selection in dropdown is made
	else if (parseInt(document.powsearch.sendTo.value) > 0 ) {
		document.powsearch.submit();
	}
}
//-->
