
/*///////////
allows clearing of inputs after clicking
///////////*/

function clearwidgit(elem){
    elem.value = "";
}

/*///////////
homepage flash swappings
///////////*/

function openFlash(){
	$("#home-flash").addClass("open");
}
function closeFlash(){
	$("#home-flash").removeClass("open");
}
function openDivLayer(){
	$("#green-box").addClass("over");
}
function closeDivLayer(){
	$("#green-box").removeClass("over");
}

/*FAQ*/	
SSS_faq = {
	init : function() {
		$('div.faq .answer').not(':first').slideToggle('400');
		$('div.faq .question').click(function() { SSS_faq.toggle(this) });
	},
	
	toggle : function(elt) {
		$(elt).toggleClass('active');
		$(elt).siblings('.answer').slideToggle('400');
	}
}

/*

start jquery!

*/


$(function () {

    /*hash for two questions*/

    if (location.hash == "#password") {
        $("#faq-password").addClass("anchor-trigger");
    }
    if (location.hash == "#userid") {
        $("#faq-userid").addClass("anchor-trigger");
    }

    /*///////////
    homepage and inner login show and hide
    ///////////*/

    $("#personal-account-link").click(function (e) {
        e.preventDefault();
        $("#personal-account").slideDown("slow").css("display", "block");
    });
    $("#business-account-link").click(function (e) {
        e.preventDefault();
        $("#business-account").slideDown("slow").css("display", "block");
    });
    $("#inner-login-link").click(function (e) {
        e.preventDefault();
        $("#inner-login").slideDown("slow").css("display", "block");
    });
    $(".exit").click(function () {
        $("#business-account").slideUp("slow").css("display", "none");
        $("#personal-account").slideUp("slow").css("display", "none");
        $("#inner-login").slideUp("slow").css("display", "none");
    });

    /*///////////
    slideshow
    ///////////*/

    $("#buttons").tabs("#tabbed > .tabbed-content", {
        effect: 'fade',
        fadeInSpeed: 2500,
        rotate: true,
        autopause: true
    }).slideshow({
        interval: 6500,
        autoplay: true
    });

    $(".tabbed-content .button").click(function (e) {
        if (!e) var e = window.event;
        agent = jQuery.browser;
        if (agent.msie) {
            e.cancelBubble = true;
        } else {
            if (e.stopPropagation) e.stopPropagation();
        }
    });

    /*///////////
    nav hover tabs and blowup content functionality
    ///////////*/

    $("#nav-tabs").tabs("#nav-content div.nav-contents", { event: 'mouseover' });

    $("#nav-tabs").hoverIntent(function (e) {
        if (!e) var e = window.event;
        agent = jQuery.browser;
        if (agent.msie) {
            e.cancelBubble = true;
        } else {
            if (e.stopPropagation) e.stopPropagation();
        }
        $("#nav-content").css("display", "block");
    },function(){});

    $(document.body).mouseover(function (e) {
        $("#nav-content").css("display", "none");
    });
    $("#nav-content a").click(function (e) {
        $("#nav-content").css("display", "none");
    });

    $("#nav-content").mouseover(function (e) {
        if (!e) var e = window.event;
        e.cancelBubble = true;
        if (e.stopPropagation) e.stopPropagation();
    });

    /*///////////
    homepage jogger - slide left to right
    ///////////*/

    $(".jogger").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev"
    });

    /*///////////
    MODALS
    ///////////*/

    $('.personal-savings-rates').click(function (e) {
        e.preventDefault();
        $.get("modal-data/personal-savings-rates.html", function (data) {
            $('#modalTemplate #modalContentArea').html(data);
            $('#modalTemplate').modal({
                closeHTML: "<img src='images/clear.gif' class='modal-close' />",
                containerId: 'arm-request-small',
                opacity: 50,
                overlayClose: false,
                zIndex: 2000,
                onOpen: function (dialog) {
                    dialog.overlay.fadeIn(200, function () {
                        dialog.container.fadeIn(200, function () {
                            dialog.data.fadeIn(200, function () {
                            });
                        });
                    });
                },
                onClose: function (dialog) {
                    dialog.data.fadeOut(200, function () {
                        dialog.container.fadeOut(200, function () {
                            dialog.overlay.fadeOut(200, function () {
                                $.modal.close();
                            });
                        });
                    });
                }
            });
        });
    });

    $('.see-details').click(function (e) {
        e.preventDefault();
        $.get("modal-data/see-details.html", function (data) {
            $('#modalTemplate #modalContentArea').html(data);
            $('#modalTemplate').modal({
                closeHTML: "<img src='images/clear.gif' class='modal-close' />",
                containerId: 'arm-request-small',
                opacity: 50,
                overlayClose: false,
                zIndex: 2000,
                onOpen: function (dialog) {
                    dialog.overlay.fadeIn(200, function () {
                        dialog.container.fadeIn(200, function () {
                            dialog.data.fadeIn(200, function () {
                            });
                        });
                    });
                },
                onClose: function (dialog) {
                    dialog.data.fadeOut(200, function () {
                        dialog.container.fadeOut(200, function () {
                            dialog.overlay.fadeOut(200, function () {
                                $.modal.close();
                            });
                        });
                    });
                }
            });
        });
    });

    $('.meet-video').click(function (e) {
        e.preventDefault();
        $.get("modal-data/meet-video.html", function (data) {
            $('#modalTemplate #modalContentArea').html(data);
            $('#modalTemplate').modal({
                closeHTML: "<img src='images/clear.gif' class='modal-close' />",
                containerId: 'arm-request-alt',
                opacity: 50,
                overlayClose: false,
                zIndex: 2000,
                onOpen: function (dialog) {
                    dialog.overlay.fadeIn(200, function () {
                        dialog.container.fadeIn(200, function () {
                            dialog.data.fadeIn(200, function () {
                            });
                        });
                    });
                },
                onClose: function (dialog) {
                    dialog.data.fadeOut(200, function () {
                        dialog.container.fadeOut(200, function () {
                            dialog.overlay.fadeOut(200, function () {
                                $.modal.close();
                            });
                        });
                    });
                }
            });
        });
    });

    // preload images
    $('<img />')
    .attr('src', "../images/nav-hover-bg.png")
    .load(function () {
        $('body').append($(this));
    });

    //branch locator jquery
    $('#homepage-branchfinder-input,#inner-branchfinder-input').keypress(function (e) {
        if (e.keyCode == 13 && $(this).val() != '' && $(this).val() != 'Enter your zip code') {
            e.preventDefault();
            window.location = "/branchlocator.aspx?search=" + $(this).val();
        }
    });
    $('#homepage-branchfinder-button').click(function (e) {
        e.preventDefault();
        if ($('#homepage-branchfinder-input').val() != '' && $('#homepage-branchfinder-input').val() != 'Enter your zip code') {
            window.location = "/branchlocator.aspx?search=" + $('#homepage-branchfinder-input').val();
        }
    });
    $('#inner-branchfinder-button').click(function (e) {
        e.preventDefault();
        if ($('#inner-branchfinder-input').val() != '' && $('#inner-branchfinder-input').val() != 'Enter your zip code') {
            window.location = "/branchlocator.aspx?search=" + $('#inner-branchfinder-input').val();
        }
    });


    //FAQs initialize
    SSS_faq.init();

});

/*

end jquery!

*/

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
