﻿$(document).ready(function() {
    $(".txtSearchCompany").autocomplete("/TeamManager/Gateway/companysearch.aspx", { minChars: 3 });

    $('a[@rel*=lightbox]').lightBox();

    InitToolTip();

    $('.showhide a').click(function() {
        var el = $(this);
        if ($(el).hasClass("hidden")) {
            $(el).attr("title", "Show Details");
            $(this).parent().next().animate({ opacity: 'hide' });
            $(".showhideInfo").show();
            //$(el).find("img").attr("src", "../Images/global/btn_show.gif");
            $(el).find("img").attr({ "src": "../Images/global/btn_show.gif", "alt": "Show" });
        } else {
            $(el).attr("title", "Hide Details");
            $(this).parent().next().animate({ opacity: 'show' });
            $(".showhideInfo").hide();
            $(el).find("img").attr({ "src": "../Images/global/btn_hide.gif", "alt": "Hide" });
        }
        $(el).toggleClass("hidden");

        // Refresh the tooltip 
        $(el).tooltip({
            track: true,
            delay: 0,
            showURL: false,
            showTitleOnly: true,
            opacity: .5,
            fixPNG: false,
            showBody: " - ",
            extraClass: "icontooltip",
            top: 5,
            left: 15
        });
    });
    $(":checkbox").addClass("nobg nobd");

    $('#editPanel #teamsContainer table tr:not(#headerRow)').hover(
        function() {
            $(this).css({ 'background-color': '#ffffff' });
        },
        function() {
            $(this).css({ 'background-color': '#e6f0c6' });
        }
    )

    $(".ellipsis").ellipsis(true);

    $(".teamsSearch").focus(function() {
        $(this).css('color', '#000000');
    });

    $(".teamsSearch").blur(function() {
        if ($(this).val() == 'search text') {
            $(this).css('color', '#aaaaaa');
        }
    });
});

function renderNav() {
    if (typeof sIFR == "function") {
        sIFR.replaceElement(named({ sSelector: "ul.rmRootGroup li.rmItem span.rmText", sFlashSrc: "/assets/burbank.swf", sColor: "#FFFFFF", sWmode: "transparent", nPaddingTop: 0, nPaddingBottom: 0 }));
    };
}

function InitToolTip() {
     $(".tooltip").tooltip({
         track: true,
         delay: 0,
         showURL: false,
         showTitleOnly: true,
         opacity: .9,
         fixPNG: false,
         showBody: " - ",
         extraClass: "icontooltip",
         top: 5,
         left: 15
     });
 }

 function OnAjaxError(xhr, errorElement) {
     var errorMsg = "Unexpected Error:\n";
     errorMsg += $.parseJSON(xhr.responseText).Message;
     if (errorElement != undefined && errorElement != null) {
         $(errorElement).html(errorMsg);
     }
     else {
         alert(errorMsg);
     }
 }

 function renderMenu() {
     if (typeof sIFR == "function") {
         sIFR.replaceElement(named({ sSelector: ".menu .selected", sFlashSrc: "/assets/burbank.swf", sColor: "#E1D3A1", sWmode: "transparent", sFlashVars: "textalign=center" }));
         sIFR.replaceElement(named({ sSelector: ".sifr-menu-item", sFlashSrc: "/assets/burbank.swf", sColor: "#FFFFFF", sWmode: "transparent", sFlashVars: "textalign=center" }));
         sIFR.replaceElement(named({ sSelector: ".sifr-submenu-item", sFlashSrc: "/assets/burbank.swf", sColor: "#FFFFFF", sWmode: "transparent", sFlashVars: "" }));
     };
 }

 function renderH2() {
     if (typeof sIFR == "function") {
         sIFR.replaceElement(named({ sSelector: "h2", sFlashSrc: "/assets/burbank.swf", sColor: "#1a2950", sWmode: "transparent", nPaddingTop: 0, nPaddingBottom: 0 }));
     };
 }