// @author Yonas Hassen

$j(document).ready(function() {
    // Home page controls
    $j(".rkLiveButton").click(function() {
        $j(".rkLive").slideToggle("slow");
        $j(".rkLiveOuter").slideToggle("slow");
        if ($j(".tab").attr("src") == "/Images/buttons/RKLive_off.png") {
            $j(".tab").attr("src", "/Images/buttons/RKLive_on.png");
        } else if ($j(".tab").attr("src") == "/Images/buttons/RKLive_on.png") {
            $j(".tab").attr("src", "/Images/buttons/RKLive_off.png");
        } else if ($j(".tab").attr("src") == "Linked/Images/buttons/RKLive_off.png") {
            $j(".tab").attr("src", "Linked/Images/buttons/RKLive_on.png");
        } else if ($j(".tab").attr("src") == "Linked/Images/buttons/RKLive_on.png") {
            $j(".tab").attr("src", "Linked/Images/buttons/RKLive_off.png");
        } else if ($j(".tab").attr("src") == "/Linked/Images/buttons/RKLive_off.png") {
            $j(".tab").attr("src", "/Linked/Images/buttons/RKLive_on.png");
        } else if ($j(".tab").attr("src") == "/Linked/Images/buttons/RKLive_on.png") {
            $j(".tab").attr("src", "/Linked/Images/buttons/RKLive_off.png");
        } else if ($j(".tab").attr("src") == "../Linked/Images/buttons/RKLive_off.png") {
            $j(".tab").attr("src", "../Linked/Images/buttons/RKLive_on.png");
        } else if ($j(".tab").attr("src") == "../Linked/Images/buttons/RKLive_on.png") {
            $j(".tab").attr("src", "../Linked/Images/buttons/RKLive_off.png");
        } else if ($j(".tab").attr("src") == "../../Linked/Images/buttons/RKLive_off.png") {
            $j(".tab").attr("src", "../../Linked/Images/buttons/RKLive_on.png");
        } else if ($j(".tab").attr("src") == "../../Linked/Images/buttons/RKLive_on.png") {
            $j(".tab").attr("src", "../../Linked/Images/buttons/RKLive_off.png");
        }
    })
    $j("#myController").jFlow({
        slides: "#slides",
        controller: ".jFlowControl", // must be class, use . sign
        slideWrapper: "#jFlowSlide", // must be id, use # sign
        selectedWrapper: "jFlowSelected",  // just pure text, no sign
        auto: true, 	//auto change slide, default true
        width: "660px",
        height: "296px",
        duration: 400,
        prev: ".jFlowPrev", // must be class, use . sign
        next: ".jFlowNext" // must be class, use . sign
    });

    $j(".newsletterEmail").click(function() {
        var inputValue = $j(".newsletterEmail").val();
        if (inputValue == "enter email here") $j(this).attr({ value: '' });
    })

    $j(".featured .featuredImg").hover(function() {
        $j(this).fadeTo(100, 0.33);
        $j(this).fadeTo(500, 1);
    });

    // The Work page controls
    $j(".clientList a").click(function() {
        $j(".clientList li").removeClass("clientListActive");
        $j(this).parent().addClass("clientListActive");
        $j(".theWorkRight h3").html($j(this).html() + ":");
        $j(".theWorkRight .theWorkGrid div").hide("slow");
    })

    $j(".slideControls .slidePrev").hover(function() {
        $j(this).attr({ src: '../Linked/Images/buttons/slidePrevHover.gif' });
    }, function() {
        $j(this).attr({ src: '../Linked/Images/buttons/slidePrev.gif' });
    });
    $j(".slideControls .slideNext").hover(function() {
        $j(this).attr({ src: '../Linked/Images/buttons/slideNextHover.gif' });
    }, function() {
        $j(this).attr({ src: '../Linked/Images/buttons/slideNext.gif' });
    });
    $j(".thumbAnimate").hover(function() {
        $j(this).css({ 'border': '2px solid rgb(81,79,38)' });
    }, function() {
        $j(this).css({ 'border': 'none' });
    });

    //Careers page controls
    $j(".fillOutApp").click(function() {
        //$j(".shady").show("slow");
        $j(".careersApplication").show("slow");
        return false;
    })
    $j(".exOutApp").click(function() {
        $j(".careersApplication").hide("slow");
        // $j(".shady").hide("slow"); 
        return false;
    })

    //Insights page controls
    $j(".insightsLeft .archiveList li a").click(function() {
        if ($j(this).hasClass("openItem")) {
            $j(this).removeClass("openItem");
            $j(this).addClass("closedItem");
            $j(this).parent().children(".innerUL").hide("slow");
        } else {
            $j(this).removeClass("closedItem");
            $j(this).addClass("openItem");
            $j(this).parent().children(".innerUL").show("slow");
        }
        return false;
    })
});