/*********************************************************************
Filename:   common.js
Project:    NewBridge Bank
Purpose:    Sitewide Scripts
Date        Developer   Version
08/10/2011  TDB         1.0
*********************************************************************/
$(document).ready(function(){
    //Dropdown Menu
    $('ul.dropdown').removeClass('noscript');
    $('.dropdown li.dropdownItems span').click(function(){
        $(this).parent().find('ul').toggle();
    });
    $('.dropdown li.dropdownItems ul li a').click(function(){
        var url = $(this).attr('href');
        $(this).parent().parent().hide();
        if ($(this).attr('target') === '_blank') {  window.open(url); return false; }
        else if (url.indexOf('http://') >= 0 === false) window.location.href = url;
        else window.location.href = window.location.href.split(window.location.pathname)[0] + url;          
    });         
    $(document).bind('click',function(e){
        var $clicked = $(e.target);
        if(!$clicked.parents().hasClass('dropdown')) $('.dropdown li.dropdownItems ul').hide();
    });
    //Clear Input Boxes
    $(".cleardefaultA").focus(function(){if($(this).val() === 'zip code'){$(this).val('');}});
    $(".cleardefaultA").blur(function(){if($(this).val() === ''){$(this).val('zip code');}}); 
    $(".cleardefaultB").focus(function(){if($(this).val() === 'search'){$(this).val('');}});
    $(".cleardefaultB").blur(function(){if($(this).val() === ''){$(this).val('search');}});
    //Top Navigation - Enable drop down for JS-browsers and calcualte positioning for each tab's dropdown
    $('#header').removeClass('hideFlow');
    $('.topNavigationDropDown').each(function(){ $(this).removeClass('hidden') });
    $('#topNavigation li').mouseover(function(){
        var start = document.getElementById('topNavigation').offsetLeft;
        var xpos = (start - this.offsetLeft)+1; 
        $('.topNavigationDropDown').css('left',xpos+'px');
    });
    //Disable text-highlighting in dropdown
    disableHighlights(document.getElementById('chooseAcct'));
});
/*Disables highlighting text in leftNavDropDown*/
function disableHighlights(target){
    if(typeof target.onselectstart!="undefined") target.onselectstart=function(){return false} //IE
    else if(typeof target.style.MozUserSelect!="undefined") target.style.MozUserSelect="none" //FF
    else target.onmousedown=function(){return false}
    target.style.cursor = "pointer";
}
/*Handles SEO Sitemap in Footer*/
var seo = false;
function seoSitemap(){
    if(!seo){ seo = true; $('#footerSEO').animate({height:'175px'}); $('#seo-expand').attr('src','/global/images/minus.png');   }
    else{ seo = false; $('#footerSEO').animate({height:'20px'}); $('#seo-expand').attr('src','/global/images/plus.png');        }
}

//code to hide/unhide store locator additional search options
$("#searchOptions").ready(function(){
    $("#searchOptions").find(".link").show();
    $("#searchOptions").find(".more-options").hide();
});
function show_options(){
        $("#searchOptions").find(".link").hide();
    $("#searchOptions").find(".more-options").show();
}
