// JavaScript Document
var ChildWindow = null;
var browserName = navigator.appName;
var resolution = "&resWidth=" + screen.width + "&resHeight=" + screen.height;
var inetParameters = "?inetclient=true&Inst={1107769F-F3BB-44EE-EE6B-527CAD4EEEA5}&css=abk";
var inetParametersOpen = "?terminatesession=true&inetclient=true&Inst={1107769F-F3BB-44EE-EE6B-527CAD4EEEA5}&css=abk";
var systemUrl = "https://www.eahli.com/beamnetwebclientv5/Startup.aspx";

function OpenOnlineBankingInet() {
	if (ChildWindow != null) {
		try{
			ChildWindow.focus();
		}catch(e){
			startApplication(systemUrl + inetParametersOpen + resolution, "_blank");
		}
	}else{
		startApplication(systemUrl + inetParameters + resolution, "_blank");
	}
}

function startApplication(url, name){
	var y = screen.availWidth  - 10;		// Allow for borders
	var x = screen.availHeight - 50;		// Allow for taskbar
	var Middlex = (screen.availHeight / 2) - 150;
	var Middley = (screen.availWidth / 2) - 210;
	if (screen.availHeight > 768) x = 718;	// Don't worry about lost space...
	if (screen.availWidth > 1024) y = 1024;
	ChildWindow = window.open(url, name, "height=" + x + ",width=" + y + ",directories=no,scrollbars=yes,status=yes,resizable=yes,location=no,menubar=no,titlebar=no,toolbar=no,top=0,left=0");
	if (browserName!="Microsoft Internet Explorer"){
		ChildWindow.onunload = distroyChild;	
	}
	ChildWindow.focus();
	
	return true;
}

//============================= Google Anylatics ====================//

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18650551-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);   })();


//==================================================================//

var Menutimer;
var Menutimer1;
 $(document).ready(
  function () {
	  //=====START 1============
	  $('#MenuBTN1').hover(
	  function () {
		  window.clearTimeout(Menutimer);window.clearTimeout(Menutimer1);
		  $('#jqMenu1').slideDown(600);
	  window.setTimeout(function(){$('#jqMenu101').slideDown(400);},100);
	  window.setTimeout(function(){$('#jqMenu102').slideDown(400);},300);
	  window.setTimeout(function(){$('#jqMenu103').slideDown(400);},500);
	  window.setTimeout(function(){$('#jqMenu104').slideDown(400);},700);
	  },
	  function () {Menutimer = window.setTimeout(function(){$('#jqMenu1').slideUp(250);},100);
		  Menutimer1=window.setTimeout(function(){$('#jqMenu1 div').slideUp(250);},100);
		  });
      $('#jqMenu1').hover(
	  function () {window.clearTimeout(Menutimer);window.clearTimeout(Menutimer1);},
	  function () {
		  Menutimer = window.setTimeout(function(){$('#jqMenu1').slideUp(250);},100);
		  Menutimer1=window.setTimeout(function(){$('#jqMenu1 div').slideUp(250);},100);
	  });
	  
	  //=====END 1============
	  //=====START 2============
	  var Menutimer2;
	  $('#MenuBTN2').hover(
	  function () {$('#jqMenu2').slideDown(400);},
	  function () {Menutimer2 = window.setTimeout(function(){$('#jqMenu2').slideUp(250);},100);});
      $('#jqMenu2').hover(
	  function () {window.clearTimeout(Menutimer2);},
	  function () {Menutimer2 = window.setTimeout(function(){$('#jqMenu2').slideUp(250);},100);});
	  //=====END 2============
	  //=====START 4============
	  var Menutimer3;
	  var Menutimer31;
	  $('#MenuBTN4').hover(
	  function () {
	  window.clearTimeout(Menutimer3);window.clearTimeout(Menutimer31);
	  $('#jqMenu4').slideDown(400);
	  window.setTimeout(function(){$('#jqMenu401').slideDown(400);},100);
	  window.setTimeout(function(){$('#jqMenu402').slideDown(400);},300);
	  window.setTimeout(function(){$('#jqMenu403').slideDown(400);},500);
	  },
	  function () {Menutimer3 = window.setTimeout(function(){$('#jqMenu4').slideUp(250);},100);
	  Menutimer31=window.setTimeout(function(){$('#jqMenu4 div').slideUp(250);},100);});
      $('#jqMenu4').hover(
	  function () {window.clearTimeout(Menutimer3);window.clearTimeout(Menutimer31);},
	  function () {Menutimer3 = window.setTimeout(function(){$('#jqMenu4').slideUp(250);},100);
	  Menutimer31=window.setTimeout(function(){$('#jqMenu4 div').slideUp(250);},100);});
	  //=====END 4============
	  //=====START 5============
	  var Menutimer4;
	  var Menutimer41;
	  $('#MenuBTN5').hover(
	  function () {
	  window.clearTimeout(Menutimer4);window.clearTimeout(Menutimer41);
	  $('#jqMenu5').slideDown(400);
	  window.setTimeout(function(){$('#jqMenu501').slideDown(400);},100);
	  window.setTimeout(function(){$('#jqMenu502').slideDown(400);},300);
	  },
	  function () {Menutimer4 = window.setTimeout(function(){$('#jqMenu5').slideUp(250);},100);
	  Menutimer41=window.setTimeout(function(){$('#jqMenu5 div').slideUp(250);},100);});
      $('#jqMenu5').hover(
	  function () {window.clearTimeout(Menutimer4);window.clearTimeout(Menutimer41);},
	  function () {Menutimer4 = window.setTimeout(function(){$('#jqMenu5').slideUp(250);},100);
	  Menutimer41=window.setTimeout(function(){$('#jqMenu5 div').slideUp(250);},100);});
	  //=====END 5============
});


function ReadNews(numberOfNews,shorten)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","news.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 


var x=xmlDoc.getElementsByTagName("item");
var NewsNumber=numberOfNews;
if(numberOfNews>x.length)
{
NewsNumber=x.length;
}
for (i=0;i<NewsNumber/*x.length*/;i++)
  {
  if( shorten || x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue.length < 50)
  {
  document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
  document.write("<br /><a href='");
  }
  else
  {
  document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue.substring(0, 49));
  document.write("...<br /><a href='");
  }
  
  document.write(x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue);
  document.write("'>Read More</a>");
  document.write("<br /><br />");
  }
  

}

function ReadNewsFULL()
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","news.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 


var x=xmlDoc.getElementsByTagName("item");
for (i=0;i<x.length;i++)
  {
  document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
  document.write("<br><a href='");
  document.write(x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue);
  document.write("'>Read More</a>");
  document.write("<br><br>");
  }
  
document.write("<br>");
}


/********** NEWS AND PROMOTIONS ******************/
function SelectPromotion()
                            {
                            $('#NewsDiv').hide();
                            $('#PromoDiv').show();
                            $('#NewsBTN').attr("class","NewsAndPromo");
                            $('#PromoBTN').attr("class","NewsAndPromoSelect");
                            }
function SelectNews()
                            {
                            $('#NewsDiv').show();
                            $('#PromoDiv').hide();
                            $('#NewsBTN').attr("class","NewsAndPromoSelect");
                            $('#PromoBTN').attr("class","NewsAndPromo");
                            }
                            
/*******************PROMOTION READ***********************/
function ReadPROMO(numberOfNews,shorten)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","promo.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 


var x=xmlDoc.getElementsByTagName("item");
var NewsNumber=numberOfNews;
if(numberOfNews>x.length)
{
NewsNumber=x.length;
}
for (i=0;i<NewsNumber/*x.length*/;i++)
  {
  
  if( shorten || x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue.length < 50)
  {
  document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
  document.write("<br /><a href='");
  }
  else
  {
  document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue.substring(0, 49));
  document.write("...<br /><a href='");
  }
  document.write(x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue);
  document.write("'>Read More</a>");
  document.write("<br><br>");
  }
  

}

function ReadPROMOFULL()
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","promo.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 


var x=xmlDoc.getElementsByTagName("item");
for (i=0;i<x.length;i++)
  {
  document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
  document.write("<br><a href='");
  document.write(x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue);
  document.write("'>Read More</a>");
  document.write("<br><br>");
  }
  
document.write("<br>");
}
/********** CHAT WINDOW ******************/

function chat()
{
	var ChatWindow = window.open('http://www.eahli.com/abk/chat/default.aspx','popup','width=700,height=500,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=70,top=80');
	ChatWindow.focus();
}

function popitup(url,name,width,height,resizable,scrollbars)
{
   newwindow = window.open(url,name,'height='+ height +',width=' +width+ ',left=210,top=2,resizable='+ resizable + ',scrollbars=' + scrollbars);
   
}
   
