var d = document;
var onLoaded=false;
var FM = new Object(); // "namespace" to isolate core template scripts
FM.getLeft = function(el)
{
  if (FM.ypMenus)
  {
    for (var lx=0,ly=0;el!=null;lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
    return {x:lx,y:ly}
  }
}
FM.cssMode = function()
{
  var boxMode;
  if (d.getElementById && !d.all && navigator.userAgent.toLowerCase().indexOf("gecko")>-1) boxMode = 1;
  else if (d.doctype && d.doctype.name.indexOf(".dtd")>-1) boxMode = 1;
  else if (d.compatMode == "CSS1Compat") boxMode = 1;
  else boxMode = 0;
  return boxMode;
}
FM.ypMenus = (!d.layers && (d.all || d.getElementById) && typeof ypSlideOutMenu != "undefined") ? 1 : 0;
FM.geck = (navigator.userAgent.indexOf("Gecko") != -1) ? 1 : 0;
FM.mac = (navigator.userAgent.indexOf("Mac") != -1) ? 1 : 0;
FM.lOffSet = (FM.geck || FM.mac) ? 1 : 0;
FM.topOff = FM.mac ? 116 : 118;
FM.oTop = FM.mac ? 30 : 31;
FM.lastMenu = FM.cssMode() ? 243 : 245;
if (FM.ypMenus)
{
  FM.ddMenus = [
    new ypSlideOutMenu("doBiz", "down", 0, FM.topOff, 267, 107),
    new ypSlideOutMenu("about", "down", 0, FM.topOff, 226, 107),
    new ypSlideOutMenu("homeFin", "down", 0, FM.topOff, FM.lastMenu, 107)
  ]
  // apply rollovers (requires part.js)
  for (var i = 0; i < FM.ddMenus.length; i++) {
    FM.ddMenus[i].onactivate = new Function("Part.use('" + FM.ddMenus[i].id + "o','" + FM.ddMenus[i].id + "');hideDiv(1);");
    FM.ddMenus[i].ondeactivate = new Function("Part.use('" + FM.ddMenus[i].id + "','" + FM.ddMenus[i].id + "');hideDiv(0);");
  }
}
/* menu setup function */
FM.macFix = 0;
FM.doMacFix = function()
{
  if (FM.macFix)
  {
    FM.macFix = 0;
    location.reload();
  }
  if (!FM.macFix && FM.mac && (navigator.userAgent.indexOf("MSIE") != -1))
  {
    d.getElementById("center").style.width = "760px";
    FM.macFix = 1;
  }
}
function setup()
{
  FM.doMacFix();
  if (FM.ypMenus)
  {
    FM.doBizLeft = FM.getLeft(d.getElementById("doBiz")).x;
    FM.aboutLeft = FM.getLeft(d.getElementById("about")).x;
    FM.homeFinLeft = FM.getLeft(d.getElementById("homeFin")).x;
    d.getElementById("doBizContainer").style.left = (FM.doBizLeft+1) - FM.lOffSet + "px";
    d.getElementById("aboutContainer").style.left = (FM.aboutLeft+1) - FM.lOffSet + "px";
    d.getElementById("homeFinContainer").style.left = (FM.homeFinLeft+1) - FM.lOffSet + "px";

    onLoaded=true; //This is true because this function is called once the html file is loaded
  }
}
// HOMEPAGE ONLY
function setupHome()
{
    FM.doMacFix();
}

function openWin1() {
newWin = window.open('/corporate/adobe/box_adobe_pdf.html','smallwin',"resizable =yes,scrollbars,width=600,height=350")
}

//***************
//
// PrintMe/PrinterFriendly Functions
//
//***************

//-------------------------
// Variables associated with the page
// to be displayed in a printer-friendly format.
//-------------------------

var filePath="";
var loc=location.pathname;
var pathElements=loc.split("/");
var fileName=pathElements[(pathElements.length-1)];

var fullPath =location.href;
var fullPathQueryElements =fullPath.split("?");
var fullPathQueryString =fullPathQueryElements[1];

var isCGIFile =fileName.indexOf('.cgi') !=-1?true:false;
var isJSPFile =fileName.indexOf('.jsp') !=-1?true:false;
var pathHasQueryString =fullPath.indexOf('?') !=-1?true:false;

var brochure = null;

//***************
// function printMe();
// <no arguments>
//
// This function creates the file path and error-checks
// file variables associated with the page to be displayed in a
// printer-friendly format. It also displays the printMe HTML.
//
//***************

function printMe() {

	var output="";

	//-------------------------
	//Check for instances where a url points to a directory instead
	//of a page. A directory's default page is always index.html.
	//-------------------------

	if (fileName=="" || fileName==null)
	{
		fileName="index.html";
	}

	//-------------------------
	// Determine the file's directory path.
	//-------------------------

	filePath = loc.replace(fileName, "");

	//-------------------------
	// Prepare and write the sweet-smelling output.
	// If the filename contains the string ".cgi", the url will simply call
	// itself, appending the value pair "pf=1". Otherwise, the file is
	// assumed to be .htm or .html and print_page.cgi is called instead.
	//-------------------------
        // approved code will not display this table
	//displayPrintMeDeveloperTable();

	if (printme_enabled == "true")
	{
		if (isCGIFile || isJSPFile)
		{
	          var printURL = filePath + fileName +"?pf=1";
	          if (pathHasQueryString)
	          {
	          	printURL +="&" + fullPathQueryString;
	          }
		}
		else {
			var printURL = "/cgi-bin/printme/print_page.cgi?fileName="+fileName+"&filePath="+filePath;
		}
		output+='<a href="javascript:openPrintWindow(\'' + printURL + '\');" class="global">';
		output+=printme_text;
		output+='</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;';
		d.write(output);
	}

}//end function

//***************
// function printModule();
// <no arguments>
//
//***************

function printModule() {

	var output="";

	if (printmodule_enabled == "true")
	{
		var printURL = "/cgi-bin/printme/print_module.cgi?fileName="+fileName+"&filePath="+filePath;
		output+='<a href="javascript:openPrintWindow(\'' + printURL + '\');" class="global">';
		output+=printmodule_text;
		output+='</a>';
		d.write(output);
	}

}//end function

//***************
//
// FUNCTION openPrintWindow
// (<no arguments>)
//
// This function opens the printer-friendly or print-module window.
//
//***************
function openPrintWindow (printURL)
 {
   var myLeft = (screen.width - 642)/2;
   var screenBuffer = 100;
   var myHeight = 500;
   var myTop = (screen.height - 580)/2;

   if (!brochure || brochure.closed)
       brochure = window.open(printURL,'showbrochure','location=no,toolbar=no,scrollbars=yes,resizable=yes,width=642,height='+myHeight+',top='+myTop+',left='+myLeft);
   else
     {
       brochure.focus();
       brochure.location.href = printURL;
     }
 }

/* Part = Preload Artwork v1.0 */
var Part =
{
  c:new Object(),
  l:function(a)
  {  if (Part.d)
    {  rslt = new Image();
      rslt.src = Part.path + a;
      return rslt; }  },
  load:function(n,i) { Part.c[n] = Part.l(i); },
  use:function(n,t) { if (Part.d) document[t].src = Part.c[n].src; }
}
Part.d = (d.images) ? 1 : 0;
Part.path = IMGPath + "/topnav/";
if (d.location.pathname.length > 1 && d.location.pathname != "/index.html")
{   //problem: if the site is called as something else ... ?
    Part.load("doBiz","nav_dobiz.gif"); Part.load("doBizo","nav_dobiz_on.gif");
    Part.load("about","nav_aboutfm.gif"); Part.load("abouto","nav_aboutfm_on.gif");
    Part.load("homeFin","nav_homefin.gif"); Part.load("homeFino","nav_homefin_on.gif");
}

//***************
//
// FUNCTION hideApps(tf)
// (<tf>)
//
// This function hides an applet on mouseover
//
//***************
function hideApps(tf)
{
	if (!d.getElementsByTagName) return true;
	var app = d.getElementsByTagName("div")["stockTicker"];
	if (app)
	{
		if (tf) d.getElementsByTagName("div")["stockTicker"].style.visibility = "hidden";
		else d.getElementsByTagName("div")["stockTicker"].style.visibility = "visible";
	} else return true;
}
//***************
//
// FUNCTION hideDangerous(tf)
// (<tf>)
//
// This function hides any div with the hiddenClass class
//
//***************
function hideDiv(tf)
{
	if (!d.getElementsByTagName) return true;
	var divList = d.getElementsByTagName("div");
	if (!divList)  return true;
	for (i=0;i< divList.length;i++)
	{
		if (divList[i].className=="hiddenClass")
		{
			if (tf) d.getElementsByTagName("div")[i].style.visibility = "hidden";
			else d.getElementsByTagName("div")[i].style.visibility = "visible";
		}
	}

}
//***************
//
// Popup Functions
//
//***************

function closePopup()
{
	window.close();
}

function validateSearchField(elem)
{
	var str=elem.value;
	if (str==null || str.length==0)
	{
		return false;
	}
	else
	{
		return true;
	}
}
