﻿$(document).ready(function () {

    // Login Panel
    $lp_toggled = false;

    $("#loginButton").toggle(
        function () {
            $(".loginPanel").show();
            $(".login-username").focus();
            $(this).css("background", "orange");
            $lp_toggled = true;
        },
        function () {
            $(".loginPanel").hide();
            $(this).css("background", "#717171");
            $lp_toggled = false;
        }
    );

    $("#loginButton").hover(
        function () {
            $(this).css("background", "orange");
        },
        function () {
            if (!$lp_toggled)
                $(this).css("background", "#717171");
        }
    );


    // Left Navigation
    var hidden = true;
    $(".dd_box").click(function () {

        if (hidden) {
            $links = $(this).nextAll("ul");
            $($links).slideDown("fast");
            hidden = false;
        }
        else {
            $links = $(this).nextAll("ul");
            $($links).slideUp("fast");
            hidden = true;
        }
    });

    // Menu Hover
    $a = null;
    $("#menu ul li").mouseover(function () {
        if ($a != null)
            $a.hide();

        $a = $(this).find("ul").show();
    });
});


function cycleBanners(imagePath) {
    var imageCycler = {
        FADE_SPEED: 1500,
        path: imagePath,
        images: ['woman_banner.gif', 'man_banner.gif'],
        counter: 0,
        first: false,

        cycle: function() {
            if ((imageCycler.counter + 1) == imageCycler.images.length) {
                imageCycler.counter = 0;
            }
            else {
                imageCycler.counter++;
            }

            if (!imageCycler.first) {
                $("#banner_img2").attr("src", imageCycler.path + imageCycler.images[imageCycler.counter]);
                $("#banner_img2").fadeIn(imageCycler.FADE_SPEED);
                $("#banner_img1").fadeOut(imageCycler.FADE_SPEED);
            }
            else {
                $("#banner_img1").attr("src", imageCycler.path + imageCycler.images[imageCycler.counter]);
                $("#banner_img1").fadeIn(imageCycler.FADE_SPEED);
                $("#banner_img2").fadeOut(imageCycler.FADE_SPEED);
            }

            imageCycler.first = !imageCycler.first;
        }
    }

    setInterval(imageCycler.cycle, 5000);
}



