var childWindow;
var childrenCount = 0;
var helperText = " (Please use the 'Select from List' link)";

<!-- // Common page functions -----------------------------------
function printPage() {
    var msg = 'ExecRelate is optimized for Landscape print:\n';
    msg += 'Have you selected Landscape print?\n\n';
    msg += '  - If so, click "OK" to print this page.\n';
    msg += '  - If not, click "Cancel", then, in your browser, select "File", "Page Setup",\n       "Landscape" orientation.' 
    if (confirm(msg))
        window.print();
    return;
}


function isExplorer() {
    if (window.navigator.appName.toUpperCase() == "MICROSOFT INTERNET EXPLORER")
		return true;
	else
		return false;
}

function registerEnter() {
    var i, j, frm
    for (i = 0; i < document.forms.length; i++) {
        frm = document.forms[i];
        for (j = 0; j < frm.elements.length; j++) {
	        frm.elements[j].onKeyPress = userPressed
        }
    }
}

function userPressed(event) {
    if (document.forms.length) {
/*
    for (i = 0; i < document.forms.length; i++) {
        alert(document.forms[i].name);
    }
*/
        var frm = document.forms[document.forms.length - 1]; // apply only to last form
        if (isExplorer()) {
		    if (window.event.keyCode == 13) {
		        if (typeof search == "function")
		            search();
		        else
		            frm.submit();
		    }
	    }
	    else {
		    if (event.which == 13) {
		        if (typeof search == "function")
		            search();
		        else
		            frm.submit();
		    }
	    }
	}
}

function signOn() {
	if (validate()) {
		document.signOn.action += "?Validate=1";
		document.signOn.submit();
	}
}

function validateSignOn() {
	var errors = "";//

	var username = String(document.signOn.username.value);
	var password = String(document.signOn.password.value);

	if (username.length < 4) errors += "- User name must be at least 4 characters long.\n";
	if (password.length < 4) errors += "- Password must be at least 4 characters long.\n";

	if (errors.length > 0) {
		window.alert("Errors: \n------------------------------------------\n" + errors);
		return false;
	}
	return true;
}

function popup(winurl, winname, width, height, winattribs) {
    if (typeof winattribs == "undefined") {
	    winattribs = 'toolbar=no, location=no, directories=no, status=yes, menubar=yes, resizable=yes, copyhistory=no, scrollbars=yes';
	}
	winattribs += ', width=' + width
	winattribs += ', height=' + height;
	// child open, close it first
	if (parseInt(childrenCount) > 0) {
		childWindow.close();
		childrenCount = 0;
	}
	childWindow = window.open(winurl, winname, winattribs);
	childrenCount = 1;
	childWindow.onUnload = childrenCount = 0;
	childWindow.focus();
}

function closeWindow() {
    if (document.all)
        window.open('','_parent','');
    window.close();
}

function signOff() {
    var msg = 'Select "OK" to Sign Off, or "Cancel" to remain Signed In.';
    if (confirm(msg))
        document.signOff.submit();
}

function navigate(pageAddress) {
    window.location.href = pageAddress;
    window.location.reload;
}

function setWindowOptions() {
	window.locationbar.visible = false;
	window.menubar.visible = false;
	window.personalbar.visible = false;
	window.scrollbars.visible = false;
	window.statusbar.visible = false;
	window.toolbar.visible = false;
}

function setWindowSize(winwidth, winheight) {
    window.resizeTo(winwidth, winheight)
}

function updateref() { // Handle form input to left navbar for project ID / search ref
	setCookie('searchRef', document.formProject.searchRef.value, 30, 'd');
}

function terms() {
    var url = "http://www.lexisnexis.com/terms/general/";
    popup(url, "navoption", 800, 600);
}

function privacy() {
    var url = "http://www.lexisnexis.com/terms/privacy/";
    popup(url, "navoption", 800, 600);
}

function copyright() {
    var url = "http://www.lexisnexis.com/terms/copyright/";
    popup(url, "navoption", 800, 600);
}

function requestTrial() {
    var url = "https://www.lexisnexis.com/trial/ExecRelate119902.asp";
    popup(url, "navoption", 800, 600);
}

function exploreExecRelate() {
//  var url = "http://www.chocreative.com/clients/preview/lexis/ExecRelate/5179L6e_LN_ExecRelate.html";
    var url = "../Nonsub/explore/demo.htm";
    popup(url, "navoption", 850, 600);
}

function exploreRelationMgr() {
    alert("This feature is no longer available."); 
}

function press(linknum) {
    var width = 800, url = "";
	switch (linknum) {
		case 0:
            url = "/nonsub/child/pressRelease.htm";
		    break;
		case 1:
            url = "http://newsbreaks.infotoday.com/nbReader.asp?ArticleId=37079";
		    break;
		case 2:
            url = "http://www.outsellinc.com/store/insights/3524";
            width = 1060;
		    break;
	}
    if (url.length > 0) {
        popup(url, "press", width, 600);
    }
}

function reloadParent() {
    // Reload parent window to remove any stale data displayed there
    var parentwin = window.opener;
    if (isExplorer())
        parentwin.navigate(parentwin.document.location.href);
    else
        parentwin.location.reload;

    // Close child window
    window.close();
}

function reloadPage() {
    // Reload parent window to remove any stale data displayed there
    if (isExplorer()) {
        window.location.href = window.location.href;
    }
    else {
        // window.location.reload();
        window.location.href = window.location.href;
    }
}

//--------------------------------------------------------------->


<!-- // Cookie functions ------------------------------------------- 
function setCookie(name, value, expires, interval, path, domain, secure) {
	var factor, today = new Date();
	today.setTime(today.getTime()); // set the time in milliseconds
	if (expires) {
		if (!interval) interval = 'm';
		switch (interval.toLowerCase()) {
			case 'd': factor = 1000 * 60 * 60 * 24; break;
			case 'h': factor = 1000 * 60 * 60; break;
			default: factor = 1000 * 60;
		}
		expires = expires * factor; // convert expires to minutes
	}
	var expires_date = new Date(today.getTime() + (expires));
	// write the cookie
	document.cookie = name + "=" + escape( value ) + 
	((expires) ? ";expires=" + expires_date.toGMTString() : "") + 
	((path)    ? ";path="    + path : "") + 
	((domain)  ? ";domain="  + domain : "") +
	((secure)  ? ";secure" : "");
}

function getCookie(name) {
	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;
	if ((!start) && (name != document.cookie.substring(0, name.length))) return null;
	if (start == -1) return null;
	var end = document.cookie.indexOf(";", len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len, end));
}

function deleteCookie(name, path, domain) {
	if (getCookie(name)) document.cookie = name + "=" +
	((path) ? ";path=" + path : "") +
	((domain) ? ";domain=" + domain : "") +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
//--------------------------------------------------------------->


<!-- // MacroMedia image preload functions ----------------------
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//--------------------------------------------------------------->


<!-- // Input handling functions ---------------------------------
function isValidEmailList(str) {
    var email, arrEmail = str.split(',');
    for (var idx = 0; idx < arrEmail.length; idx++) {
        email = Trim(arrEmail[idx]);
        if ((email.length > 0) && (!checkEmail(email)))
            return false;
    }
    return true;
}

function checkEmail(str) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   return reg.test(str)
}

function Trim(str) {
	str = String(str)
	var retString = "";
	var wasLetter = false;
	for (i = 0; i <= str.length; i++) {
		if (wasLetter || (str.charAt(i) != ' ')) {
			retString = retString + str.charAt(i);
			wasLetter = true;
		}
	}
	wasLetter = false;
	str = retString;
	retString = ""
	for (i = str.length - 1; i >= 0; i--) {
		if (wasLetter || (str.charAt(i) != ' ')) {
			retString = str.charAt(i) + retString;
			wasLetter = true;
		}
	}
	return String(retString);
}

function trim(str) {
	return Trim(str);
}

function replace(strOrig, oldStr, newStr) {
	var firstPart = strOrig.substring(0, strOrig.indexOf(oldStr));
	var lastPart = strOrig.substring(strOrig.indexOf(oldStr) + oldStr.length, strOrig.length);
	return (firstPart + newStr + lastPart);
}

function safetyTest(input) {
   	if (input.length == 0)
   	    return true;

	// prevent cross-site JavaScripting (detect <, >, /)
	var srchPattern = '(<)|(\%3C)|(>)|(\%3E)|(\/)|(\%2F)';
	// prevent SQL injection (detect ', =, ;, --)
	srchPattern += '|(\')|(\%27)|(=)|(\%3D)|(;)|(\%3B)|(\-\-)|(\%23\%23)';

	var myRegExp = new RegExp(srchPattern, "i");
	if (myRegExp.test(input))
	    return false;
	else
	    return true;
}

function populateParentInput(label, selection, uid) {
    if (typeof uid == 'undefined') {
        uid = '-1';
    }
    else {
        var hiddenElement = eval("window.opener.document.formPOST." + inputName + "Hidden");
    }
	var msg;
	var inputElement = eval("window.opener.document.formPOST." + inputName);
	
	if (String(inputElement.value).indexOf("" + selection) < 0) {
        var inpval = String(inputElement.value);
		if ((inpval.length > 0) && (inpval != helperText)) {
			inputElement.value += "; " + selection + "";
            if (uid != '-1')
                hiddenElement.value += "; " + uid + "";
		}
		else {
    		inputElement.value = selection + "";
            if (uid != '-1')
                hiddenElement.value = uid + "";
        }
		msg = '"' + selection + '" added.';
	} else {
		msg = '"' + selection + '" already selected.';
	}
	msg = label + " " + msg + "\n\n";

	var pluralLabel, lastChar = label.charAt(label.length - 1);
	switch(lastChar) {
	case "y":
	    pluralLabel = label.substr(0, label.length - 1) + 'ies';
	    break;
	case "s":
	    pluralLabel = label + "'";
	    break;
	default:
	    pluralLabel = label + 's';
	}
		
	msg += "Click [OK] to continue selecting " + pluralLabel + ",\n";
	msg += " or [Cancel] when done selecting " + pluralLabel + ".";
	if (confirm(msg) == false) {
	    window.opener.focus();
	    window.close();
    }
}
//--------------------------------------------------------------->