﻿// JScript File

var isFF = navigator.userAgent.indexOf("Firefox") > 0;
var isIE = navigator.userAgent.indexOf("MSIE") > 0;

function ahb_resetMenus()
{
  //
  // this works for IE
  var mainPage = document.getElementById("mainPage");
  var mainTableLeftOffset = mainPage.offsetLeft;
  var offset = 200;
  
  //
  // hack fix for FF not handling centered main table 
  if (isFF && window.innerWidth > mainPage.width)
  {
    mainTableLeftOffset += (window.innerWidth - mainPage.width)/2;
  }
  
  document.getElementById('savingsdiv').style.left = (mainTableLeftOffset+offset) + "px";
  document.getElementById('checkingdiv').style.left = (mainTableLeftOffset+offset) + "px";
  document.getElementById('bankingdiv').style.left = (mainTableLeftOffset+offset) + "px";
  
  window.onresize = ahb_resetMenus;
}

function ahb_openCentered(URL, winWidth, winHeight, name, params) {
	var st = (screen.height - winHeight) / 2;
	var sl = (screen.width - winWidth) / 2;
	window.open(URL, name, 'width=' +winWidth+ ',height=' +winHeight+',top=' + st + ',left=' + sl + ',' + params);
}

function ahb_onlinedemo()
{
  ahb_openCentered("flash/flash.html", 900 + 2*0, 515 + 3*0 + 75, 
    "onlinedemo", 
    'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0');
}

function ahb_openCalc(targ,selObj,restore)
{
  // simulates MM_jumpMenu() functionality but in new centered window
  ahb_openCentered(selObj.options[selObj.selectedIndex].value, 800, 600,
    "calc",
    'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1');
  selObj.selectedIndex=0;
}

function ahb_openAccount(prodid)
{
//  window.location = "oac.aspx?prodid=" + prodid; return;

  ahb_openCentered("oac.aspx?prodid=" + prodid, 800, 600, "_blank", 
    'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1');
}

function ahb_prodPrint(prod, label)
{
  ahb_openCentered('ProductSheet.aspx?prod=' + prod + '&label=' + label, 600, 600, '_blank',
    'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1');
}

function ahb_ratesPrint()
{
  ahb_openCentered('RatesSheet.aspx', 600, 600, '_blank',
    'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1');
}