// Opens a new window, centered on the screen

var retainLimit = 20

function launchCenter(url, name, height, width) {
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width +",resizable=1,scrollbars=1,toolbar=1,menubar=1,titlebar=1";
  if( document.documentElement && typeof 	document.documentElement.style.maxHeight!="undefined")
	{
  		str += ",width=" + width + ",innerWidth=" + width +",resizable=1,scrollbars=1,toolbar=1,menubar=1,titlebar=1,location=1";	
	}
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  var myWin = window.open(url, name, str);
  myWin.focus();
  return false;
}

function launchFixed(url, name, height, width) {
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width +",resizable=0,scrollbars=0,toolbar=0,menubar=0,titlebar=0";
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  var myWin = window.open(url, name, str);
  myWin.focus();
  return false;
}

function openWin(sHref){

if (document.win) {
	win.close()
}


	launchCenter(sHref, "URL", 400, 600)

}
function openWin2(sHref,name,height,width){

if (document.win) {
	win.close()
}


	launchCenter(sHref, "URL", height, width);

}

function openInfo(sPage){
	window.open(sPage,"info","width=560,height=325,left="+eval((screen.width - 560) / 2)+",top="+eval(((screen.height - 325) / 2) - 67)+",resizeable=1,scrollbars=1,toolbar=1,menubar=1");
}

function openTips(sPage){
	window.open(sPage,"tips","width=350,height=375,left="+eval((screen.width - 350) - 10)+",top="+eval((screen.height - 375) - 58)+",resizeable=1,scrollbars=1,toolbar=0,menubar=0");
}


function openFormhelp(pageToLoad,winName,width,height,center){
  args=getArgs(width,height,center,0,0,0);
  if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
    if(window.formhelp && !window.formhelp.closed){
      formhelp.close();
    }
  }

  formhelp=window.open(pageToLoad,winName,args);
  formhelp.focus();
  return false;
}


function openFormTop(pageToLoad,winName,width,height,offsetX,offsetY){
  var xPosition = offsetX; 
  var yPosition = offsetY;
  var args;
  
  if (xPosition == null) {
    xPosition = 10;
  }
  if (yPosition == null) {
    yPosition = 10;
  }
  
  args = "width=" + width + ",height=" + height
  + ",toolbar=0,menubar=0,screenx=" + xPosition + ",screeny=" + yPosition
  + ",left=" + xPosition + ",top=" + yPosition
  + ",resizable=1,scrollbars=1";
  
  if(window.formhelp && !window.formhelp.closed) {
    formhelp.close();
  }

  formhelp=window.open(pageToLoad,winName,args);
  formhelp.focus();
  return false;
}


function getArgs(width,height,center,menu,yoffset,xoffset){
xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ) && (center)){

xposition = (screen.width - width) - 10;
yposition = (screen.height - height) - 58;

xposition += xoffset;
yposition += yoffset;
}

function customize(page) {
        var address = page;

        var option = "toolbar=1 status=1 menubar=1 scrollbars=1 resizeable=1 width=120 height=222"

        var win3 = window.open("", "add", option);
        var win4 = window.open(address, "ad");
}

if (navigator.appName == 'Netscape'){
width = width + 25;
height = height + 25;
}

args="width="+width+",height="+height
+",toolbar="+menu+",menubar="+menu
+",screenx="+ xposition+",screeny="+yposition
+",left="+xposition+",top="+yposition
+",resizable=1,scrollbars=1,";
return args;
}
function signout()
{
var name = confirm('Are you sure you want to sign out of the LexisNexis™ research services and end your session?  Click the "OK" button to sign out, or the "Cancel" button to resume your session.')
if (name == true)
 {
  location="../CommonSignOut.asp"
 }
}

function changeDate(thisForm, relative)
{
	with(thisForm)
	{
		if(relative)
		{
			thisForm.date[0].checked=true;
			thisForm.dateTo.value = ""
			thisForm.dateFrom.value = ""
		}
		else
		{
			thisForm.date[1].checked=true;
			thisForm.dateRelative.selectedIndex = 0;
		}
	}
}

function srcInfo(sCSI)
{
	var USCS;



	if(sCSI == "")
	{
		alert("Please select a valid source.")
		return false;
	}


	if (new Date(2004,10,20) <= new Date()){
		searchURL = "/researchtasks/common/search.asp?srcinfo="+sCSI;
	}
	else{
		searchURL = "/researchtasks/common/search.asp?source=718dis;dguide&search=csi("+sCSI+")&view=full";
	}
	launchCenter(searchURL, "", "375", "600");
	return false;
}


function priceInfo(sCSI)
{
	
	if(sCSI == "")
	{
		alert("Please select a valid source.")
		return false;
	}
	else
		searchURL = "/researchtasks/common/search.asp?viewprice="+sCSI;
		
		
	
	launchCenter(searchURL, "", "375", "600");
	return false;
}




function citationFormat2(sSearchTerm)
{

	searchURL = "http://www.lexis.com/research/";

	if(sSearchTerm != "" | " ")
		searchURL += "xlink?cfaFindStr=" + sSearchTerm;
	else
		searchURL += "cfaget";


	launchCenter(searchURL, "", "375", "600");
	return false;
}
function citationFormat()
{

	searchURL = "http://www.lexis.com/research/cfaget";

	launchCenter(searchURL, "", "375", "600");
	return false;
}
function confirmDelete(pageIndex, pageName)
{
	var pageChecked = false;

	if(typeof document.frmEdit.pageList.length == "undefined" && document.frmEdit.pageList.checked)
	{
		pageChecked = true;

	}
	else
	{
		for(var x=0; x<document.frmEdit.pageList.length; x++)
		{
			if(document.frmEdit.pageList[x].value == pageIndex && document.frmEdit.pageList[x].checked)
			{
				pageChecked = true;
				break;
			}
		}
	}

	if (!pageChecked)
	{
		if (document.frmEdit.txtCount.value == "1")
		{
			if (confirm("This will delete "+"\""+pageName+"\""+" from your Recently Accessed Pages list.\n\nThis is the last page in your Recently Accessed Pages list. If you click OK, the \"Recently Accessed Pages\" form will be removed from the Research Tasks and will not be shown again until you access another page."))
				return true;
		}
		else
		{
			if (confirm("This will delete "+"\""+pageName+"\""+" from your Recently Accessed Pages list."))
				return true;
		}
	}
	return false;
}

function toggle(oCheckBox)
{
	var sString, oLink, oPage
	var totalChecked = 0;

	sString = oCheckBox.value

	oLink = document.getElementById("link"+sString);
	oPage = document.getElementById("page"+sString);

	for(var i=0; i < oCheckBox.form.pageList.length; i++)
	{
		if(oCheckBox.form.pageList[i].checked)
			totalChecked++;
	}

	if(totalChecked == 20)
	{
		alert("Retain Limit Reached!\nNo more recently accessed pages will be stored.");
	}


	if (oCheckBox.checked)
	{
		oLink.className = "inactive";
		oPage.className = "retainItem";


	}
	else
	{
		oLink.className = "hot";
		oPage.className = "editList";

	}



}

function signout()
{
	var name = confirm('Are you sure you want to sign out of the LexisNexis™ research services and end your session?  Click the "OK" button to sign out, or the "Cancel" button to resume your session.');

	if (name == true)
	{
		location="../CommonSignOut.asp"
	}
}

function gotoRecentPage(thisForm)
{
	var recLoc = thisForm.selRecent.options[thisForm.selRecent.selectedIndex].value;

	if(recLoc != "NA")
		document.location = "/researchtasks/" + recLoc;

	return false;
}

/*
addSrch is an additional search or segment search that is to be used with the terms value or not
to use a segment search make sure it ends with a '(' (i.e. if 'NAME' was the segment you would send int "NAME("
if it is not a segment search then the addSrch will just be anded with the terms value*/
function generalSearch(thisForm,csi,pp,com,addSrch)
{
	var srchStr = "/researchtasks/common/search.asp?interface=on&source=" + csi;
	var terms = thisForm.terms.value;




		if(addSrch.charAt(addSrch.length - 1) == "(" && (terms != "" && terms != " "))
		{
		   srchStr += "&search=" + addSrch + escape(terms) + ")";
		}
		else if(addSrch != "")
		{
			srchStr += "&search=" + escape(addSrch);

			if (terms != "" && terms != " ")
				srchStr += " and " + escape(terms);

		}
		else if (terms != "" && terms != " ")
		{
		    srchStr += "&search=" + escape(terms);
		}

	srchStr = srchStr  + "&tocdisplay=off&autosubmit=yes&com=" + com + "&pp=" + pp + "&topframe=on&powernav=on";
	//alert(srchStr);
   	launchCenter(srchStr, 'center', 425, 550);
	return false;

}
//srctype is what kind of source is being use i.e. a source, sub, or category
//addSrch is used to add on a search parameter if needed
function generalSourceSearch(csi,pp,com,srctype)
{
	var srchStr = "/researchtasks/common/search.asp?interface=on&" + srctype + "=" + csi;

	srchStr = srchStr  + "&autosubmit=yes&com=" + com + "&pp=" + pp + "&topframe=on&powernav=on";

   	launchCenter(srchStr, 'center', 425, 550);
	return false;

}
/*
checks for wildcards in a NL search string
*/
function checkNLString(keyword)
{
	if(keyword.indexOf("!")!= -1 || keyword.indexOf("*") != -1)
	{
		alert("Please do not enter the symbols * or ! in a natural language search.");
		return true;
	}
	return false;
}
function isDev()
{
	var currentURL = location.href;
	if(currentURL.indexOf("csint") != -1)
		return true;
	else
		return false;
}

//DEPRECATED!  Use isDevLocal()
function isDev8080()
{
	var currentURL = location.href;
	if(currentURL.indexOf("csintdev") != -1)
		return true;
	else
		return false;
}

function isDevLocal()
{
	var currentURL = location.href;
	if(currentURL.indexOf("csintdev") != -1)
		return true;
	else
		return false;
}