// This file contains the javascript functions needed for the site
<!--
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;
}

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 OpenLibraryWindow(spage)
{
	if (screen.width <= 640)
		var newwin = window.open(spage,'Library',config='width=540,height=400,top=0,left=0,toolbar=no,menubar=no,status=1,resizable=yes,scrollbars=yes,location=yes,directories=no,alwaysRaised=Yes');
	else if (screen.width > 640 && screen.width < 800)
		var newwin = window.open(spage,'Library',config='width=540,height=400,top=0,left=0,toolbar=no,menubar=no,status=1,resizable=yes,scrollbars=yes,location=yes,directories=no,alwaysRaised=Yes');
	else if (screen.width >= 800 && screen.width < 1024)
		var newwin = window.open(spage,'Library',config='width=700,height=400,top=0,left=0,toolbar=no,menubar=no,status=1,resizable=yes,scrollbars=yes,location=yes,directories=no,alwaysRaised=Yes');
	else if (screen.width >= 1024 && screen.width < 1280)
		var newwin = window.open(spage,'Library',config='width=924,height=580,top=0,left=0,toolbar=no,menubar=no,status=1,resizable=yes,scrollbars=yes,location=yes,directories=no,alwaysRaised=Yes');
	else if (screen.width >= 1280)
		var newwin = window.open(spage,'Library',config='width=1180,height=824,top=0,left=0,toolbar=no,menubar=no,status=1,resizable=yes,scrollbars=yes,location=yes,directories=no,alwaysRaised=Yes');
	else
		var newwin = window.open(spage,'Library',config='width=1180,height=824,top=0,left=0,toolbar=no,menubar=no,status=1,resizable=yes,scrollbars=yes,location=yes,directories=no,alwaysRaised=Yes');

	newwin.focus();
}

function OpenEmailWindow(spage)
{
	var newwin = window.open(spage,'EmailWSI',config='width=700,height=480,top=0,left=0,toolbar=no,menubar=no,status=1,resizable=yes,scrollbars=yes,location=no,directories=no,alwaysRaised=Yes');
	newwin.focus();
}

function OpenNewWindow(spage, winName, options)
{
     /*This is an example of the options to be passed in
     
     width=700,height=480,top=0,left=0,
     screenY=0,screenX=0,
     toolbar=no,menubar=no,status=yes,
     resizable=yes,scrollbars=yes,location=no,
     directories=no,alwaysRaised=yes
     */
            
     var newWindow = window.open(spage, winName, options);
     newWindow.focus();
}

function FactorFictionAnswer(sans,lid)
{
	location = "enewsletter/index.asp?forfans=" + sans + "&forfid=" + lid;
}

function trimSpaces(field)
{
     var oneChar;
     var newField = "";
     for(var i = 0; i < field.value.length; i++)
     {
          oneChar = field.value.charAt(i);
  
          if(oneChar != " ")
          {
               newField += oneChar;
          }
     }

     return newField;
}

/*******************************************************************************
Name:  PopUpPublications
Purpose: Open up PDF File in a separate web window  
Input:  strUrl (url where the PDF resides)
Output:  None
*******************************************************************************/
//function PopUpWindow(strURL, pageName)
//{
//    var win_handle = PopupWSIWindow(strURL, pageName, "l", "t", -100, -100, 3, true);
//    win_handle.focus();
//}


/************************************************************
Name:		PopUpNewWSIWindow
Purpose:	To popup new window where developer specifies

Input:	strURL - the url where the pop-ups source resides
		strWinName - the name of the window
		strHortAlign ("l","c" or "r") left, center, right
		strVertAlign ("t","c" or "b") top, center, bottom
		intWinWidth  - Inputted Width
		intWinHeight - Inputted Height
		intRelativeToParent
				0 - Inputted width / Inputted height
				1 - Inputted width + parent's width / Inputted height
				2 - Inputted width / Inputted height + parent's width
				3 - Inputted width + parent's width / Inputted height + parent's height
		blnShowToolbars  - Should the pop-up have a toolbar true/false
          options - toolbar=no,menubar=no,status=yes,
                    resizable=yes,scrollbars=yes,location=no,
                    directories=no,alwaysRaised=yes
Output:	Window Handle
************************************************************/ 
function PopupWSIWindow(strURL, strWinName, strHortAlign, strVertAlign, intWinWidth, intWinHeight, intRelativeToParent, blnShowToolbars)
{
	var parent = new Array(4);	// array to hold our parent window coordinates
	var child	= new Array(4);	// array to hold our help window coordinates
	var childWindow = null;		// window handle for pop-up window							
	var strAttributes = ""	     // string that states if a toolbar is needed for the pop-up
	var intNNOffset = 0;
	if (document.all)									// Internet Explorer
	{
		//parent[0] = window.screenLeft;
		parent[0] = 0;                     				// main window X coordinate
		//parent[1] = window.screenTop;
		parent[1] = 0;           						// main window Y coordinate
		parent[2] = window.document.body.clientWidth;		// main window Width
		//parent[3] = window.document.body.clientHeight;		// main window Height
		parent[3] = document.documentElement.clientHeight;
		
		if(blnShowToolbars)
		{
		    parent[3] -= 95;
		}
	}
	else //if (document.layers)								// Netscape Navigator
	{
		//parent[0] = window.screenX;							// main window X coordinate
		parent[0] = 0;
		//parent[1] = window.screenY;							// main window Y coordinate
		parent[1] = 0;
		parent[2] = window.innerWidth;						// main window Width
		parent[3] = window.innerHeight;						// main window Height
		
		if(blnShowToolbars)
		{
			parent[3] -= 50;
			intNNOffset = window.outerHeight - parent[3]-95;
		}
		else
		{
		    intNNOffset=window.outerHeight - parent[3]-24;	

		}
	}

	if (intRelativeToParent == 1 || intRelativeToParent == 3)
	{	//Make sure that the width is a positive and viewable size	parent2 is width
		if((intWinWidth + parent[2]) > 100)
		{ 
			intWinWidth += parent[2];	//Add the specified width to the parent window
		}
	}
	
	if (intRelativeToParent >= 2)
	{	//Make sure that the height is a positive and viewable size
		if((intWinHeight + parent[3]) > 100)
		{
			intWinHeight += parent[3];//Add the specified height to parent window
		}
	}
	child[2] = intWinWidth;	// Assign the window width
	child[3] = intWinHeight;	// Assign the window height
		
	child[0] = parent[0]; 

	//If win centered horizontally
	if(strHortAlign == "c")
	{ 
		child[0] += (parent[2]/2 - intWinWidth/2);
	}
	//If win right aligned horizontally
	else if (strHortAlign=="r")
	{
		child[0] += (parent[2] - intWinWidth);
	}
	
	child[1] = parent[1];
	
	//If win centered vertically
	if(strVertAlign=="c")
	{
		child[1] += (parent[3]/2 - intWinHeight/2);
	}		
	//If win aligned vertically to the bottom of the parent
	else if(strVertAlign=="b")
	{
		child[1] += (parent[3] - intWinHeight -5);
	}
	
	if (document.all)	// Internet Explorer
	{	// Adjusting child window width
		child[2] +=10;
		child[3] -=10;
	}
	else
	{	//Making adjustments X-Coord, Y-Coord, Width and Height
	//	child[0] += 5; child[1] += intNNOffset;
		child[2] -= 10;	child[3] -= 10;
	}
	
	if(childWindow)
	{
		childWindow.close();
	}
	
	if((blnShowToolbars !== void(0)) && (blnShowToolbars))
	{
		strAttributes="toolbar=yes,location=yes, menubar=yes";
	}	
	else 
	{
	    strAttributes="toolbar=no,location=no, menubar=no";
	}

	var strOptions = "";
	strOptions = "width=" + child[2] + ", height=" + child[3];
	strOptions += ", top=" + child[1] + ", screenY=" + child[1];
	strOptions += ", left=" + child[0] + ", screenX=" + child[0];
	strOptions += ", resizable, scrollbars, " + strAttributes;
	//alert("strOptions = " + strOptions);
		
	childWindow = window.open(strURL, strWinName, strOptions);
	return childWindow;
}



//-->