﻿
//TMobile Navigation Plugin
//
// Create closure
//
(function($) {
    var tmNavData = null;
    var subnavT, dropdownT, activeNav, activeSubNav;

    //
    // Plugin definition
    //
    $.fn.TMobileNavigation = function(options) {


        // build main options before element iteration
        var opts = $.extend({}, $.fn.TMobileNavigation.defaults, options);

        // iterate and reformat each matched element
        return this.each(function() {

            $this = $(this);
            // build element specific options
            var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
            var thisId = $this.attr('id');
            var appId = $this.attr('appId');
            var supportspanish = $this.attr('supportspanish');
            var section = $this.attr('section');
            var isHomePage = section == null ? false : section == "Homepage" ? true : false;
            //alert(isHomePage);
            var tmopath = $this.attr('tmopath');

            if (appId == null && thisId == 'foot') {
                appId = $('#head').attr('appId');
                tmopath = $('#head').attr('tmopath');
            }
            else if (appId == null)
                appId = "tmobile";

            if (thisId == 'head') {
                $.getJSON(tmopath + "/htmlservices/navigation/TMobileNavigation.ashx?func=tmo&appId=" + appId + "&supportspanish=" + supportspanish + "&section=" + section + "&format=json&jsoncallback=?", function(navigationData) {
                    tmNavData = navigationData;

                    tmAddHeaderHTML();
                    tmNavSetFooter();
                    initSearch();
                    initNav();
                    tm_spanish_Check(tmNavData.SpanishUrl);
                });
            }
        });
    };

    // Keeps the footer properly lined up
    (function() {
        this.fixFooter = function() {
            try {
                var footElem = document.getElementById('bottom') ?
					document.getElementById('bottom') : document.getElementById('foot');

                var pageElem = document.getElementById('bottom') ?
					document.getElementById('wrapper') : document.getElementById('page');

                if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
                    // IE
                    var c = getClientHeight();
                    var f = footElem.offsetHeight;
                    if (c > f) {
                        pageElem.style.height = parseInt(c - f - 100) + 'px';
                    }
                }
                else if (!($.browser.msie)) {
                    pageElem.style.minHeight = parseInt(getClientHeight() - footElem.offsetHeight) + 'px';
                }
            }
            catch (ex) { }
        }
    }
    )();

    (function() {
        this.tmAddHeaderHTML = function() {
            var buf = "<script charset=\"utf-8\" type=\"text/javascript\">var mytmoUrl='";
            buf += tmNavData.MyTmoLoginUrl;
            buf += "';</script>";
            buf += "";
            buf += "<div id=\"head\">";
            buf += "<div id=\"brand\">";
            buf += "<div id=\"logo\"><h1><a href=\"" + tmNavData.AppPath + "\"><img src=\"";
            buf += tmNavData.AppPath;
            buf += "htmlservices/assets/images/logo_TMoDigit.jpg\" title=\"T-Mobile cell phones, cell phone plans, and cell phone accessories\" alt=\"T-Mobile cell phones, cell phone plans, and cell phone accessories\" width=\"174\" height=\"52\"/><span>T&#45;Mobile <span>stick together</span></span></a></h1></div>";
            buf += "</div>";

            //Top navigation begin
            if (tmNavData.IsHomePage) {
                buf += "<div id=\"topNavigation\" class=\"homePage\">";
            }
            else {
                buf += "<div id=\"topNavigation\">";
            }


            buf += "<a id=\"skipnav\" href=\"#area1\">Skip Navigation</a>";
            buf += "<ul class=\"topnav cf\">";

            var NavMenuItems = tmNavData.NavMainMenuItems;

            for (var i = 0; i < NavMenuItems.length; i++) {
                var menuItem = NavMenuItems[i];
                var subItems = menuItem.NavMenuItems;
                var sectionId = menuItem.Id;
                var selected = "Selected";
                var selectedClass = "";

                if (menuItem.Text.toUpperCase() == tmNavData.Section.toUpperCase()) {
                    selected = " selected"
                    selectedClass = "class=\"selected\"";
                }
                else {
                    selected = "";
                    selectedClass = "";
                }

                if (i == 0) {
                    buf += "<li class=\"first " + selected + "\">";
                }
                else if (i == NavMenuItems.length - 1)
                    buf += "<li class=\"last " + selected + "\">";
                else {
                    buf += "<li " + selectedClass + ">";
                }

                buf += "<a href=\"";

                //if (menuItem.Url.indexOf('http') != -1) {
                buf += tmNavData.AppPath;
                //}

                buf += menuItem.Url;
                if (menuItem.Tag && menuItem.Tag != '') {
                    buf += (menuItem.Url.indexOf('?') == -1 ? "?" : "&") + "WT.z_unav=" + menuItem.Tag;
                }

                buf += "\">";
                buf += menuItem.Text;
                buf += "</a>"

                if (subItems.length > 0) {
                    buf += "<ul class=\"secondlvl\">";
                }

                for (var n = 0; n < subItems.length; n++) {
                    var subMenuItem = subItems[n];

                    var hasDropMenu = false;
                    if ((!(subMenuItem.NavSubItems == null))) {
                        if (subMenuItem.NavSubItems.length > 0) {
                            hasDropMenu = true;
                        }
                    }
                    //Add level
                    if (hasDropMenu) {
                        if (n == 0) {
                            buf += "<li class=\"dropdown first\"><a href=\"";
                        }
                        else {
                            buf += "<li class=\"dropdown\"><a href=\"";
                        }
                    }
                    else {
                        buf += "<li><a href=\"";
                    }

                    if (subMenuItem.Url.indexOf('http') == -1) {
                        buf += tmNavData.AppPath;
                    }

                    buf += subMenuItem.Url;
                    if (!(subMenuItem.Tag == ""))
                        buf += (subMenuItem.Url.indexOf('?') == -1 ? "?" : "&") + "WT.z_unav=" + subMenuItem.Tag;

                    if (subMenuItem.Popup == 'True')
                        buf += "\" target=\"_blank\" ";
                    else
                        buf += "\"";

                    buf += "><span>";
                    buf += subMenuItem.Text;
                    buf += "</span></a>"

                    if (!(subMenuItem.NavSubItems == null)) {
                        if (subMenuItem.NavSubItems.length > 0) {
                            buf += "<ul class=\"thirdlvl\">";
                            for (var s = 0; s < subMenuItem.NavSubItems.length; s++) {
                                var dropItem = subMenuItem.NavSubItems[s];
                                if (s == 0) {
                                    buf += "<li class=\"first-list-item\"><a href=\"";
                                }
                                else if (s == subMenuItem.NavSubItems.length - 1) {
                                    buf += "<li class=\"last-list-item\"><a href=\"";
                                }
                                else {
                                    buf += "<li><a href=\"";
                                }

                                if (dropItem.Url.indexOf('http') == -1) {
                                    buf += tmNavData.AppPath;
                                }
                                buf += dropItem.Url;
                                if (!(dropItem.Tag == ""))
                                    buf += (dropItem.Url.indexOf('?') == -1 ? "?" : "&") + "WT.z_unav=" + dropItem.Tag;

                                if (dropItem.Popup == 'True')
                                    buf += "\" target='_blank' ";
                                else
                                    buf += "\"";

                                buf += ">";
                                buf += dropItem.Text;
                                buf += "</a></li>";
                            }
                            buf += "</ul>";
                        }
                    }
                    buf += "</li>";
                }
                if (subItems.length > 0) {
                    buf += "</ul>";
                }

                buf += "</li>";
            }

            buf += "</ul>";
            buf += "</div>";
            //Top navigation end

            //Util navigation begin
            var locationResult = "";
            buf += "<div id=\"utilityNavigation\" class=\"cf\">";
            buf += "<ul id=\"customerHelp\" class=\"horizontalNavigation cf noWrap\">";

            buf += "<li><a href=\"";
            buf += tmNavData.AppPath;
            buf += "coverage/pcc.aspx?WT.z_unav=mst_global_cvg\"><span>Coverage</span></a></li>";

            buf += "<li><a href=\"";
            buf += tmNavData.AppPath;
            buf += "PartnerServices.aspx?redirect=STORELOCATOR&WT.z_unav=mst_global_sl\"><span>Store Locator</span></a></li>";

            buf += "<li class=";
            var cartStyle = "";
            if (tmNavData.CartEmpty) {
                cartStyle = "\"cart\"";
            }
            else {
                cartStyle = "\"filledcart\"";
            }
            buf += cartStyle + "><a href=\"" + tmNavData.AppPath + "shop/cart/default.aspx?WT.z_unav=mst_global_cart\"><span>Cart</span></a></li>";

            buf += "<li class=\"last\"><a href=\"" + tmNavData.AppPath + "locator.aspx?WT.z_unav=mst_global_enter_loc&referer=%2fDefault.aspx\"><span>";
            if (!(tmNavData.City == "")) {
                if (!(tmNavData.State == "")) {
                    locationResult = tmNavData.City.replace("+", " ") + ", " + tmNavData.State;
                }
            }
            if (locationResult == "") {
                locationResult = "Enter Location";
            }
            buf += locationResult; buf += "</span></a></li>";

            buf += "</ul>";
            buf += "<fieldset class=\"simpleform\">";
            buf += "<span id=\"errMessage\" style=\"color:red;\"></span>";
            buf += "<fieldset id=\"myTMobilelogin\" class=\"simpleform\">";
            buf += "<span class=\"myTMobileloginend\">";
            buf += "<span class=\"legend\"><a href=\"" + tmNavData.AppPath + "MyTMobile?WT.z_unav=mst_global_mytmo\">My T-Mobile</a>:</span>";
            buf += "<label for=\"myTMobile-phone\">";
            buf += "Phone Number</label>";
            buf += "<input value=\"Phone #\" id=\"myTMobile-phone\" type=\"text\" class=\"smartval\" maxlength=\"10\" onkeypress=\"return isValidMSISDNCharacter(event)\" onkeyup=\"AutoFocus()\" />";
            buf += "<label for=\"password-clear\">Password</label>";
            buf += "<input id=\"password-clear\" type=\"text\" value=\"Password\" onfocus=\"changeTextToPass('password-clear','myTMobile-password');\" autocomplete=\"off\" />";
            buf += "<label for=\"myTMobile-password\">Password</label>";
            buf += "<input value=\"\" id=\"myTMobile-password\" type=\"password\"  onblur=\"restorePassToText('password-clear','myTMobile-password');\"  autocomplete=\"off\" />";
            buf += "<button id=\"myTMobile-login\" class=\"btnBlue\" onclick=\"handleLogin(); return false;\">";
            buf += "<span>Log in</span>";
            buf += "</button>";
            buf += "</span>";
            buf += "</fieldset>";


            var spanishMapping =
               { 'locator.t-mobile.com': 'http://es.t-mobile.com/enes/sdlocator/',
                   'www.myfaves.com': 'http://es.myfaves.com/enes/',
                   'www.sidekick.com': 'http://es.sidekick.com/enes/24/_www_sidekick_com/'
               };

            if (tmNavData.ShouldSpanishLinkDisplay) {
                buf += "<fieldset id=\"search\" class=\"simpleform\">";
            }
            else {
                buf += "<fieldset id=\"search\" class=\"simpleform noLanguage\">";
            }
            buf += "<ul id=\"language\" class=\"horizontalNavigation\">";
            buf += "<!-- mp_trans_disable_start -->";
            buf += "<li class=\"first\"><span id=\"English\"><a mpdisnav='href' onclick=\"tm_spanish_setCookie('TMobileSpanish', 'IsSpanishUser=false');\" href=\"" + tmNavData.EnglishUrl + "/PartnerServices.aspx?WT.z_unav=mst_global_english&redirect=ENGLISH" + tmNavData.PartnerServiceQuery + "\">English</a></span></li>";

            if (spanishMapping[window.location.hostname]) {
                buf += "<li class=\"last\"><span id=\"Spanish\"><a href=\"" + spanishMapping[window.location.hostname] + window.location.pathname + window.location.search + "\" onclick=\"tm_spanish_setCookie('TMobileSpanish', 'IsSpanishUser=true');\">Español</a></span></li>";
            } else {
            buf += "<li class=\"last\"><span id=\"Spanish\"><a onclick=\"tm_spanish_setCookie('TMobileSpanish', 'IsSpanishUser=true');\" href=\"" + tmNavData.AppPath + "PartnerServices.aspx?WT.z_unav=mst_global_spanish&redirect=SPANISH" + tmNavData.PartnerServiceQuery + "\">Español</a></span></li>";
            }
                        
            buf += "<!-- mp_trans_disable_end -->";
            buf += "</ul>";
            buf += "<fieldset class=\"search\">";
            buf += "<label for=\"SearchForaQuestion\">";
            buf += "Search</label>";
            buf += "<input value=\"Type your question here\" id=\"SearchForaQuestion\" type=\"text\" class=\"smartval\" onKeyPress=\"return checkSearchEnter(event);\" />";
            buf += "<button id=\"search-search\" class=\"btnGreen\" onclick=\"return doSearch();\">";
            buf += "<span>Search</span></button>";
            buf += "</fieldset>";
            buf += "</fieldset>";
            buf += "</fieldset>";
            buf += "</div>";

            //Util navigation end

            buf += "</div>";
            $('#head').html(buf);
        };
    })();

    (function() {
        this.checkSearchEnter = function(e) {

            try {
                var characterCode;
                if (e && e.which) {
                    e = e;
                    characterCode = e.which;
                }
                else {
                    e = event;
                    characterCode = e.keyCode;
                }

                if (characterCode == 13) {
                    doSearch();
                    return false;
                }
                else {
                    return true;
                }
            } catch (e) { return true; }
        };
    })();

    (function() {
        this.doSearch = function() {

            var question = document.getElementById('SearchForaQuestion').value;

            if (!(question.length) || question == 'Type your question here') {
                $('SearchForaQuestion').focus();
                return false;
            } else if (question.length > 200) {
                alert('Your question is too long. It may be truncated at 200 characters.');
            }
            var val = question.replace(/</g, "").replace(/>/g, "").replace(/\(/g, "").replace(/\)/g, "").replace(/&/g, "");
            window.location.href = tmNavData.AppPath + "/Search/?ui_mode=question&question_box=" + val;
            return false;
        };
    })();

    (function() {
        this.popLink = function(url, width, height) {
            window.open(url, 'popped', 'width=' + width + ',height=' + height + ',screenX=568,screenY=400,left=50,top=50,toolbar=no,location=no,menubar=no,status=no,resizable,scrollbars');
            return false;
        }
    })();

    (function() {
        this.tmNavSetFooter = function() {

            var buf = "";
            if (tmNavData.IsHomePage) {
                buf += "<div id=\"homefoot\">";
            }
            else {
                buf += "<div id=\"foot\">";
            }

            buf += "<div id=\"bottomNavigation\">";
            buf += "<ul id=\"\" class=\"horizontalNavigation cf\">"
            buf += "<li class=\"first\">Shop:</li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "orderstatus/default.aspx?WT.z_unav=ftr__checkorder\">Check Order Status</a></li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "\company/website/returnpolicy.aspx?WT.z_unav=ftr__returnpolicy\" onclick=\"return popLink('" + tmNavData.AppPath + "company/website/returnpolicy.aspx?WT.z_unav=ftr__returnpolicy',568,400);\">Return Policy</a></li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "partnerservices.aspx?redirect=HotSpot&WT.z_unav=ftr__hotspot\">HotSpot</a></li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "Business/Solutions.aspx?WT.z_unav=ftr__business\">Business</a></li>";
            buf += "<li class=\"last\"><a href=\"" + tmNavData.AppPath + "pr/?WT.z_unav=ftr__puertorico\">Puerto Rico</a></li>";
            buf += "</ul>";
            buf += "<ul id=\"\" class=\"horizontalNavigation cf\">";
            buf += "<li class=\"first\">T-Mobile for:</li>";
            buf += "<li><a href=\"http://developer.t-mobile.com?WT.z_unav=ftr__developers\">Developers</a></li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "RetailerOppertunities/?WT.z_unav=ftr__retailers\" onclick=\"return popLink('" + tmNavData.AppPath + "RetailerOppertunities/?WT.z_unav=ftr__retailers',980,980);\">Retailers</a></li>";
            buf += "<li class=\"last\"><a href=\"" + tmNavData.AppPath + "Company/Working.aspx?tp=Abt_Tab_AffiliateProgram&WT.z_unav=ftr__affiliates\">Affiliates</a></li>";
            buf += "</ul>";
            buf += "<ul id=\"\" class=\"horizontalNavigation cf\">";
            buf += "<li class=\"first\">Company:</li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "Company/?WT.z_unav=ftr__aboutTMO\">About T-Mobile</a></li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "Jobs/?WT.z_unav=ftr__jobs\">Jobs</a></li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "Company/PressReleases.aspx?tp=Abt_Tab_PressReleases&WT.z_unav=ftr__press\">Press</a></li>";
            buf += "<li><a href=\"http://www.telekom.com/?WT.z_unav=ftr__DT\">Deutsche Telekom</a></li>";
            buf += "<li><a href=\"http://www.t-mobile.net/?WT.z_unav=ftr__international\">International</a></li>";
            buf += "<li class=\"last\"><a href=\"" + tmNavData.AppPath + "Contact.aspx?WT.z_unav=ftr__contact\">Contact Us</a></li>";
            buf += "</ul>";
            buf += "<ul id=\"\" class=\"horizontalNavigation cf\">";
            buf += "<li class=\"first\">Legal:</li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "company/website/privacypolicy.aspx?WT.z_unav=ftr__privacypolicy\" onclick=\"return popLink('" + tmNavData.AppPath + "company/website/privacypolicy.aspx?WT.z_unav=ftr__privacypolicy', 757, 672);\">Privacy Policy</a></li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "Company/PrivacyResources.aspx?tp=Abt_Tab_IdentityTheft?WT.z_unav=ftr__privacyresources\">Privacy Resources</a></li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "Company/LanguageAssistance.aspx?WT.z_unav=ftr__langassist\">Language Assistance</a></li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "Company/Community.aspx?tp=Abt_Tab_Safety&tsp=Abt_Sub_PublicSafety?WT.z_unav=ftr__911\">Public Safety/911</a></li>";
            buf += "<li><a href=\"" + tmNavData.AppPath + "company/website/termsconditions.aspx?WT.z_unav=ftr__TC\" onclick=\"return popLink('" + tmNavData.AppPath + "company/website/termsconditions.aspx?WT.z_unav=ftr__TC', 568, 400);\">Terms &amp; Conditions</a></li>";
            buf += "<li class=\"last\"><a href=\"" + tmNavData.AppPath + "company/website/termsofuse.aspx?WT.z_unav=ftr__useterms\" onclick=\"return popLink('" + tmNavData.AppPath + "company/website/termsofuse.aspx?WT.z_unav=ftr__useterms', 568, 400);\">Terms of Use</a></li>";
            buf += "</ul>";
            buf += "<p class=\"copy\">";
            buf += "<a href=\"" + tmNavData.AppPath + "company/website/copyright.aspx?WT.z_unav=ftr__copywrite\" onclick=\"return popLink('" + tmNavData.AppPath + "company/website/copyright.aspx?WT.z_unav=ftr__copywrite',568,400);\">&copy;2002-2009 T-Mobile USA, Inc.</a>";
            buf += "</p>";
            buf += "</div>";
            buf += "<div id=\"siteMap\">";
            buf += "<a class=\"sitemap\" href=\"" + tmNavData.AppPath + "sitemap.aspx\"><span class=\"leftside\"><span>Site Map</span></span></a>";
            buf += "</div> ";
            buf += "</div>";
            $('#foot').html(buf);
        };
    })();


    function hideSubNav(obj) {

        obj = (obj == null || obj == 'undefined') ? $('.topnav .secondlvl') : $(obj);
        subnavT = setTimeout(function() {

            $(obj).hide();
            showSubNav(activeSubNav);
            $('.topnav > li').removeClass('selected');
            activeNav.addClass('selected');
        }, 500);
    }
    function showSubNav(obj) {
        clearTO(subnavT);
        if (obj) $(obj).show();
    }
    function clearTO(t) {
        if (t) {
            clearTimeout(t);
            t = null;
        }
    }


    function initNav() {
        /* init page components */
        $('.smartval').smartval();

        /* Init Site Navigation
        ############################################## 
        */

        $('.dropdown').hover(
        function() {
            $('.topnav > li').find('li.dropdown').removeClass('subnavactive');  // hides the dropdown if opened from a tab focus on a mouseover
            $('.topnav .secondlvl').find('li .thirdlvl li a').blur();  // removes the tab focus from an element on a mouseover
            $(this).addClass('subnavactive').setNav3Width(); ;
        },  // over
        function() {
            $(this).removeClass('subnavactive');
        }   // out
    );






        $('.topnav > li > .secondlvl').show().hide();  /* resets nav */
        // get defaults
        activeNav = $('.topnav > .selected');
        activeSubNav = $(activeNav).find('.secondlvl').show();

        // hover
        $('.topnav > li > a').hover(
				function() {                      // over
				    $('.topnav .secondlvl').hide();
				    showSubNav($(this).next());
				},
				function() { hideSubNav(); }      // out
  );
        $('.secondlvl').hover(
				function() { clearTO(subnavT); }, // over
				function() { hideSubNav(); } 		  // out
  );

        // keyboard access
        $('.topnav > li > a').focus(function() {
            clearTO(subnavT);
            $('.topnav > li').removeClass('selected');
            $(this).parent().addClass('selected');
            $('.topnav .secondlvl').hide();
            showSubNav($(this).next());

            // clears the dropdown style if shift-tabbing through the list
            $(this).parent().find('li:first-child').removeClass('subnavactive')

        });
        $('.topnav > li > a').blur(function() {
            hideSubNav();
        });
        $('.topnav .secondlvl > li > a').focus(function() {
            clearTO(subnavT);

            // clears the dropdown style if shift-tabbing through the list       
            $(this).parents('li').next().removeClass('subnavactive');

            if ($(this).parent('li').hasClass('dropdown')) {
                $(this).parent().addClass('subnavactive').setNav3Width();
            }

        });
        $('.topnav .secondlvl > li > a').blur(function() {
            hideSubNav();
        });

        $('.topnav .secondlvl > li.dropdown li:last-child a').blur(function() {
            $(this).parents('li.dropdown').removeClass('subnavactive');
        });

        // for shift-tabbing through a third-level dropdown list
        $('.topnav .secondlvl > li.dropdown li a').focus(function() {
            if (!$(this).parent('li').hasClass('subnavactive')) {
                $(this).parents('li.dropdown').addClass('subnavactive');
            }
        });


        // click enable
        $('.topnav > li > a').click(function(event) {
            $('.topnav > li').removeClass('selected');
            $(this).parent().addClass('selected');

            activeNav = $('.topnav > .selected');
            activeSubNav = $(activeNav).find('.secondlvl');
        });

        $('#password-clear').show();
        $('#myTMobile-password').hide();

        $('#password-clear').focus(function() {
            $('#password-clear').hide();
            $('#myTMobile-password').show();
            $('#myTMobile-password').focus();
        });
        $('#myTMobile-password').blur(function() {
            if ($('#myTMobile-password').val() == '') {
                $('#password-clear').show();
                $('#myTMobile-password').hide();
            }
        });

    }   

    function poptastic(url, height, width, top, left, toolbar, resize, scrollbars) {
        var pop = window.open(url, 'popup', 'height=' + height + ',width=' + width + ',top=' + top + ',left=' + left + ',toolbar=' + toolbar + ',resizable=' + resize + ',scrollbars=' + scrollbars);
        if (typeof window.focus != 'undefined') javascript: pop.focus();
    }
    //
    // End of closure
    //
})(jQuery);

/* <!-- mp_trans_disable_start --> */
function tm_spanish_setCookie(B, A) {
    document.cookie = B + '=' + A + ';path=/;domain=t-mobile.com;';
}

function tm_spanish_Check(spanishUrl) {
    
    if (window.location.href.toLowerCase().indexOf(spanishUrl) != -1) {
        tm_spanish_setCookie('TMobileSpanish', 'IsSpanishUser=true');
        document.getElementById('Spanish').innerHTML = 'Español';
    }
    else {
        tm_spanish_setCookie('TMobileSpanish', 'IsSpanishUser=false');
        document.getElementById('English').innerHTML = 'English';
    }
}
/* <!-- mp_trans_disable_end --> */


$(document).ready(function() {
$('#head').TMobileNavigation();

window.onresize = fixFooter;
fixFooter();

});

$(document).ajaxError(function(event, request, settings) {
    //alert(request);
    //alert(event);
    //alert(settings);
});
$(document).ajaxStop(function() {
    //alert(this);
});

jQuery.fn.setNav3Width = function() {
    var currentWidest = this.find('a:first-child').width() + 20;
    this.find('ul.thirdlvl, ul.thirdlvl li').css({ 'width': 'auto', 'min-width': '0px' });
    this.find('ul.thirdlvl li').each(function() {
        if (jQuery(this).width() > currentWidest) { currentWidest = jQuery(this).width(); }
    }).css('width', currentWidest + "px");
    return this;
}