// JavaScript Document

rolls = new Array();

preLoad = function(imgid, path, ext) {
	imgidOver = imgid + "Over";
	rolls[imgid] = imgid;
	rolls[imgidOver] = imgidOver;
	rolls[imgid] = new Image;
	rolls[imgidOver] = new Image;
	rolls[imgid].src = path + imgid + "." + ext;
	rolls[imgidOver].src = path + imgid + "-over." + ext;
}

rollOver = function(source,id) {
	document.getElementById(id).src = rolls[source].src;
}

mainNavs = new Array ("about", "personal", "business", "investment", "insurance", "locations");

bottomNavs = new Array ("contact", "apps", "calculators", "employment", "pressroom");
for (i=0;i<bottomNavs.length;i++) {
	preLoad(bottomNavs[i], "images/bottomnav/", "gif");
}
alertPNG = new Image;
alertPNG.src = "images/bottomnav/alerts-over.png";

preLoad("alerts", "images/bottomnav/", "png");
preLoad("chat-close", "images/sidenav/", "jpg");
preLoad("chat-pic", "images/sidenav/", "jpg");

contactNavs = new Array ("branch", "callus", "emailus");
for (i=0;i<contactNavs.length;i++) {
	preLoad(contactNavs[i], "images/header/contactnav/", "gif");
}


showDiv = function(divname) {
	document.getElementById(divname).style.visibility = "visible";
}

hideDiv = function(divname) {
	document.getElementById(divname).style.visibility = "hidden";
	document.getElementById(divname).innerHTML='';
}

lastIndex = 10;

showSubnav = function(subname) {
	for (i=0;i<mainNavs.length;i++) {
		if (currentPage!=mainNavs[i]) {
			hideSubnav(mainNavs[i]);
		}
	}
	tabname = "tab-" + subname;
	subnavname = "subnav-" + subname;
	lastIndex = document.getElementById(tabname).style.zIndex;
	document.getElementById(tabname).style.visibility = "visible";
	document.getElementById(tabname).style.zIndex = 20;
	document.getElementById(subnavname).style.visibility = "visible";
	document.getElementById(subnavname).style.zIndex = 20;	
	if (currentPage=="home") {
		document.getElementById("subnav-shadow").style.visibility = "visible";
	}
}

hideSubnav = function(subname) {
	tabname = "tab-" + subname;
	subnavname = "subnav-" + subname;
	document.getElementById(tabname).style.visibility = "hidden";
	document.getElementById(tabname).style.zIndex = lastIndex;
	document.getElementById(subnavname).style.visibility = "hidden";
	document.getElementById(subnavname).style.zIndex = lastIndex;	
	if (currentPage=="home") {
		document.getElementById("subnav-shadow").style.visibility = "hidden";
	}
}

showTabOnly = function(subname) {
	for (i=0;i<mainNavs.length;i++) {
		if (currentPage!=mainNavs[i]) {
			hideSubnav(mainNavs[i]);
		}
	}
	tabname = "tab-" + subname;
	lastIndex = document.getElementById(tabname).style.zIndex;
	document.getElementById(tabname).style.visibility = "visible";
	document.getElementById(tabname).style.zIndex = 9;
	if (currentPage=="home") {
		document.getElementById("subnav-shadow").style.visibility = "hidden";
	}
}

hideTabOnly = function(subname) {
	tabname = "tab-" + subname;
	document.getElementById(tabname).style.visibility = "hidden";
	document.getElementById(tabname).style.zIndex = lastIndex;
	if (currentPage=="home") {
		document.getElementById("subnav-shadow").style.visibility = "hidden";
	}
}



balloonOn = function(event,msg) {
	if (msg=="thirdpartymsg") {
		balloontext = "<p>This link will take you to a<br>third-party website.<br>View our privacy policy for<br>more information.</p>";
	}
	if (msg=="aprmsg") {
		balloontext = "<p>APR (Annual Percentage Rate). Credit lines are based on credit worthiness and are subject to approval.</p>";
	}
	if (msg=="apymsg") {
		balloontext = "<p>APY (Annual Percentage Yield). Earnings may be reduced if fees are incurred.</p>";
	}
	if (msg=="primemsg") {
		balloontext = "<p>APR may vary.<br>Prime = 5.25% as of March 19, 2008.</p>";
	}
	if (msg=="sharecertmsg") {
		balloontext = "<p>Additional deposits permitted in increments of $250 or more, up to amount of original deposit on specified certificates.</p>";
	}
	if (msg=="specialmsg") {
		balloontext = '<p>Access Restricted to brand and ATM individuals only with Arsenal Government ID</p>';
	}
	leftpos = event.clientX;
	toppos = event.clientY-100;
	document.getElementById('balloon').style.left = leftpos + "px";
	document.getElementById('balloon').style.top = toppos + "px";
	document.getElementById('balloon').innerHTML = balloontext;
	document.getElementById('balloon').style.visibility = "visible";
	document.getElementById('balloon').style.zIndex = "99";
	document.getElementById('balloon').style.position = "absolute";
}

balloonOff = function() {
	document.getElementById('balloon').style.visibility = "hidden";
}

openPop = function(url,width,height) {
	var e = window.open(url,                'popWindow','width='+width+',height='+height+',resizable=1,scrollbars=auto,menubar=no,status=no');
}

showChat = function() {
	topdiv = document.getElementById('chattop');
	bottomdiv = document.getElementById('chatbottom');
	middlediv = document.getElementById('chatmiddle');
	newsdiv = document.getElementById('news');
	newscontentdiv = document.getElementById('newscontent');
	topdiv.innerHTML = "<a href=\"javascript:liveOp();\" onmouseover=\"rollOver('chat-picOver','snChat-pic');\" onmouseout=\"rollOver('chat-pic','snChat-pic');\"><img style=\"position:absolute;top:6px\" src=\"images/sidenav/chat-click.jpg\" alt=\"click here for a live operator\"></a>";
	bottomdiv.innerHTML = "<a href=\"javascript:hideChat();\" onmouseover=\"rollOver('chat-closeOver','snChat-close');\" onmouseout=\"rollOver('chat-close','snChat-close');\"><img style=\"position:absolute;top:0px\" id=\"snChat-close\" src=\"images/sidenav/chat-close.jpg\" alt=\"close this window\"></a><br><img style=\"position:absolute;top:17px\" src=\"images/sidenav/chat-sitemax.jpg\" alt=\"Live Chat by Sitemax\">";
	topdiv.style.top = "0px";
	middlediv.style.visibility = "visible";
	bottomdiv.style.top = "163px";
	newsdiv.style.top = "330px";
	newsdiv.style.height = "175px";
	newscontentdiv.style.height = "130px";
	liveOp();
}

hideChat = function() {
	topdiv = document.getElementById('chattop');
	bottomdiv = document.getElementById('chatbottom');
	middlediv = document.getElementById('chatmiddle');
	newsdiv = document.getElementById('news');
	newscontentdiv = document.getElementById('newscontent');
	topdiv.innerHTML = "<a href=\"javascript:showChat();\"><img src=\"images/sidenav/chat-click.jpg\" alt=\"click here for a live operator\"></a>";
	bottomdiv.innerHTML = "<img style=\"position:absolute;top:0px\" src=\"images/sidenav/chat-close-off.jpg\" alt=\"\"></a><br><img style=\"position:absolute;top:17px\" src=\"images/sidenav/chat-sitemax.jpg\" alt=\"Live Chat by Sitemax\">";
	topdiv.style.top = "0px";
	bottomdiv.style.top = "30px";
	middlediv.style.visibility = "hidden";
	middlediv.style.display = "collapse";
	newsdiv.style.top = "203px";
	newsdiv.style.height = "302px";
	newscontentdiv.style.height = "257px";
}

liveOp = function() {
	openPop("https://lc4.sightmaxondemand.com/Sunmarkfcu/SightMaxAgentInterface/PreChatSurvey.aspx?accountID=201&siteID=217&queueID=448",500,455);
}

/*
z-indices for tabs
personal: 10-12
*/