﻿/*
This particular file contains all the logic for the banner.  I have left it so that if we decide
to make the banner a little more flashy we can (fade in/fade out effect).  If this isn't working
odds are its because jQuery is not fully loaded.
*/
//Similar to setTabsImg, only handles the links below tabs.
function linkToggle(tab) {
    switch (tab) {
        case 'a':
            $('#myaccountcell span').css('display', 'inline');
            $('#electricservices span').css('display', 'none');
            $('#waterservices span').css('display', 'none');
            break;
        case 'e':
            $('#myaccountcell span').css('display', 'none');
            $('#electricservices span').css('display', 'inline');
            $('#waterservices span').css('display', 'none');
            break;
        case 'w':
            $('#myaccountcell span').css('display', 'none');
            $('#electricservices span').css('display', 'none');
            $('#waterservices span').css('display', 'inline');
            break;
        case 'd':
            $('#myaccountcell span').css('display', 'none');
            $('#electricservices span').css('display', 'none');
            $('#waterservices span').css('display', 'none');
            break;
    }
}
//TODO:  Need to get the nav bar tiler stuff working., get the links under the tabs vanishing and re-appearing, working, test other localization. then the rest is css and the banner partial view should be done.
//The default to change Tabs
function setTabsImg(tabSrc) {
    linkToggle(tabSrc);
    //Three options: a for accountTab, e for electricTab, and w for waterTab.
    switch (tabSrc) {
        case 'a':
            $('#submenu').css('background-image', 'url(/SRP.Graphics/banner/AccountNavBarTiler.gif)', 'background-repeat', 'repeat-x');
            $('#MyAccountTabImg').attr('src', l("%myaccounttabon"));
            $('#ElectricServicesTabImg').attr('src', l("%electrictaboff"));
            $('#WaterServicesTabImg').attr('src', l("%watertaboff"));
            break;
        case 'e':
            $('#MyAccountTabImg').attr('src', l("%myaccounttaboff"));
            $('#ElectricServicesTabImg').attr('src', l("%electrictabon"));
            $('#WaterServicesTabImg').attr('src', l("%watertaboff"));
            $('#submenu').css('background-image', 'url(/SRP.Graphics/banner/ElectricNavBarTiler.gif)', 'background-repeat', 'repeat-x');
            break;
        case 'w':
            $('#MyAccountTabImg').attr('src', l("%myaccounttaboff"));
            $('#ElectricServicesTabImg').attr('src', l("%electrictaboff"));
            $('#WaterServicesTabImg').attr('src', l("%watertabon"));
            $('#submenu').css('background-image', 'url(/SRP.Graphics/banner/WaterNavBarTiler.gif)', 'background-repeat', 'repeat-x');
            break;
        case 'd':
            $('#submenu').css('background-image', 'url(/SRP.Graphics/banner/DefaultNavBarTiler.gif)', 'background-repeat', 'repeat-x');
            $('#MyAccountTabImg').attr('src', l("%myaccounttaboff"));
            $('#ElectricServicesTabImg').attr('src', l("%electrictaboff"));
            $('#WaterServicesTabImg').attr('src', l("%watertaboff"));
            break;
    }
    bannercallback = function () {
        getLocalBannerText();
        setTabsImg(tabSrc);
    };
}

//Big ugly method that will assign all the banner text.
function getLocalBannerText() {
     $('#login').text(l('%login'));
     $('#logout').text(l('%logout'));
     $('#technicalhelp').html(l('%technicalhelp'));
     $('#contactus').text(l('%contactus'));
     $('#searchbutton').attr('src', l('%searchbutton'));
     $('#srpimg').attr('src', l('%srpimg'));
     $('#srchtipslink').text(l('%srchtipslink'));
     $('#sitemap').text(l('%sitemap'));
     $('#contactus').text(l('%contactus'));
     $('#backtohome').html(l('%backtohome'));
     $('#electriclink').text(l('%electriclink'));
     $('#waterlink').text(l('%waterlink'));
     $('#electricres').text(l('%residential'));
     $('#electricbiz').text(l('%electricbiz'));
     $('#waterres').text(l('%residential'));
     $('#waterbiz').text(l('%waterbiz'));
     $('#sitemap').text(l('%sitemap'));
     $('#srchtipslinks').text(l('%srchtipslink'));
     $('#searchtext').html(l('%searchtext'));
 }
//In case the user changes locale we'll make it as seamless as possible.
 function changeBannerText(p) {
    getLocalBannerText();
    setTabsImg(p);
}
function setBannerDefaults() {
    setTabsImg('d');
    getLocalBannerText();
}

//onLoad
$(function () {
    setBannerDefaults();
});



