$(document).ready(function() {
    // Home banner
    var bannerDuration = 3000;
    var bannerIndex = 0;
    var bannerFadeIn = function() {
        bannerIndex = (bannerIndex < $("#banner a").size()) ? bannerIndex : 0;
        $("#banner a").eq(bannerIndex).fadeIn(bannerDuration, bannerFadeOut);
    }
    var bannerFadeOut = function() {
        $("#banner a").eq(bannerIndex).fadeOut(bannerDuration, function(){
            bannerIndex += 1;
            bannerFadeIn();
        });
    }
    if ($("#banner a").size() > 1) {
        $("#banner a").css("display", "none");
        bannerFadeIn();
    }
    
    // Top menu
    $("#nav ul li").hover(function() {
        $(this).addClass("hover");
    }, function() {
        $(this).removeClass("hover");
    });

//    $('#banner').cycle({
//        fx: 'fade',
//        pause: 1
//    });
    /*
    // top menu
    $("#nav").each(function(){
    var current = $("ul li[class=active]", this);
    var timer = null;
    $("ul li", this).hover(function(){  
    $("li", $(this).parent()).removeClass("active");
    $(this).addClass("active");     
    if (timer) {
    window.clearTimeout(timer);
    }
    },function(){
    var t = this;        
    timer = window.setTimeout(function(){
    $("li", $(t).parent()).removeClass("active");
    if (current) {
    current.addClass("active");
    }
    },3000);
    });
    });
    // left menu
    $(".menu .left").each(function(){
    $("> li > ul > li", this).each(function(){
    $("> .bullet", this).click(function(){
    $("> ul", $(this).parent()).slideToggle("slow");
    });
    });
    });
    // search
    $(".search-box").each(function(){
    var t = this;
    var submit = function(){
    var jkw = $(".kw input[name='kw']", t);            
    if (jkw.val() != "") {
    var url = $("input[name='search_url']", t).val() + escape(jkw.val());
    window.location.href = url;
    } else {
    jkw.focus();
    }
    }
    $(".btn", this).click(submit);
    $(".kw", this).keypress(function(e){
    if (e.which == 13) {
    submit();
    }
    });
    });
    */
});


