// JavaScript Document

var curNav = '';
var theSpeed = 500;
var isMoving = false;

function cancelLock() {
	isMoving = false;
}

function showMenu(theId) {
	if(curNav == theId ) return;	
	curItem = $('#' + curNav);
	if(isMoving) return;
	isMoving = true;
	if(curItem)	{							 
		curItem.removeClass('hover').next('.sub_menu').slideUp(theSpeed);
	}
	$('#' + theId).addClass('hover').next('.sub_menu').slideDown(theSpeed);
	curNav = theId;			
	setTimeout(cancelLock, theSpeed);
}

function quickMenu(theId) {
	$('#' + theId).addClass('hover').next('.sub_menu').show();	
	curNav = theId;			
}

$(document).ready(function() 
	{
		$('.sub_menu').hide();
		$('#content img:first').css({paddingBottom: '12px'});
		$('.nav').hover(
			function() {
				showMenu($(this).attr('id'));
			}, 
			function() {} 
			);
		var p = String(window.location);
		p = p.split('/');
		if(p[3]) {
			if(p[3] == 'onlinebank') quickMenu('nav_online_banking');
			if(p[3] == 'locations') quickMenu('nav_about_us');
			if(p[3] == 'business') quickMenu('nav_business_services');
			if(p[3] == 'invest') quickMenu('nav_retirement_invest');
			if(p[3] == 'loans') quickMenu('nav_loan_products');
			if(p[3] == 'personal') quickMenu('nav_personal_banking');
			if(p[3] == 'security') quickMenu('nav_about_us');
			if(p[3] == 'mortgages') quickMenu('nav_mortgages');
			if(p[3] == 'services') quickMenu('nav_special_services');
			if(p[3] == 'about') quickMenu('nav_about_us');
			if(p[3] == 'contests') quickMenu('nav_about_us');
			if(p[3] == 'education') quickMenu('nav_about_us');
			if(p[3] == 'contact') quickMenu('nav_about_us');
		}
	 //alert($('#content').height());
	 var h = $('#content').height();
	 if(h < 600)
		 $('#content').height( 600);
	});