/*
    Document   : main
    Created on : Nov 23, 2010, 1:26:43 PM
    Author     : Zoljargal Altantsatsral <cosmos0monster@gmail.com>
    Description:
        EnergyResources LLC Slideshow Javascript.
*/

/*
   Jquery http://www.jquery.com
*/
$(document).ready(function(){
    $('#healthimg').hide("");
    $('#scholarshipimg').hide("");
    $('#managmentimg').hide("");

    $("li#protection").hover(function() {
        $('#managmentimg').hide("");
        $('#healthimg').hide("");
        $('#scholarshipimg').hide("");
        $('#protection a').css("color","#fefefe");
        $('#protectionimg').animate({"opacity": "show"});
        $("#protectionimg").clearQueue();
    });
    $("li#protection").mouseleave(function() {
        $('#protection a').css("color","#4d4d4d");
    });
    $("li#managment").hover(function() {
        $('#protectionimg').hide("");
        $('#healthimg').hide("");
        $('#managment a').css("color","#fefefe");
        $('#scholarshipimg').hide("");
        $('#managmentimg').animate({"opacity": "show"});
        $("#managmentimg").clearQueue();
    });
    $("li#managment").mouseleave(function() {
        $('#managment a').css("color","#4d4d4d");
    });
    $("li#health").hover(function() {
        $('#managmentimg').hide("");
        $('#protectionimg').hide("");
        $('#scholarshipimg').hide("");
        $('#health a').css("color","#fefefe");
        $('#healthimg').animate({"opacity": "show"});
        $("#healthimg").clearQueue();
    });
    $("li#health").mouseleave(function() {
        $('#health a').css("color","#4d4d4d");
    });
    $("li#scholarship").hover(function() {
        $('#managmentimg').hide("");
        $('#healthimg').hide("");
        $('#scholarship a').css("color","#fefefe");
        $('#protectionimg').hide("");
        $('#scholarshipimg').animate({"opacity": "show"});
        $("#scholarshipimg").clearQueue();
    });
    $("li#scholarship").mouseleave(function() {
        $('#scholarship a').css("color","#4d4d4d");
    });
});

function slideSwitch() {
    var $active = $('#scholarship-student IMG.active');

    if ( $active.length == 0 ) $active = $('#scholarship-student IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#scholarship-student IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 3000 );
});
