$(function() {

    var maxUlHeight = 0;
    var navHeight = 40;
    var bottomPadding = 10;
    var scrollTo = navHeight;

    $('#navigation_wrapper ul.level_1_navigation').each(function(){
       var h = $(this).height();
       if(h > maxUlHeight)
            maxUlHeight = h;
        });

    if ($('li.level_1').size()) {
        scrollTo = maxUlHeight+navHeight+bottomPadding;
        }

    $('.level_0_item').click(function(event) {
        $('.level_0_navigation li.level_0').animate({"height": scrollTo}, "slow");
        $('.level_1_navigation').removeClass('dspl_none');
        event.preventDefault();
        });

    $("#image").attr("src", $(".thumb").first().attr("href"));
    $(".thumb").first().children("img").addClass("selected");

    $("a.thumb").click(function(event){
        imgPath = $(this).attr("href")
        $("#image").attr("src", imgPath );
        $(".thumb").children("img").removeClass("selected");
        $(this).children("img").addClass("selected");
        event.preventDefault();
        });

    $("a.href_zoom").fancybox({
        'titleShow' : false
        });

//---------------------------------------------------------------
    if(!$("ul.cultivation a.selected").length)
        {
        $("ul.type a").addClass("zero");
        }

    $("ul.type a.notselected.zero").click(function(event){
        event.preventDefault();
    });

    
//---------------------------------------------------------------
    $('input.show_label').defaultValue();

//---------------------------------------------------------------
    $("div.clickable").click(function(event){
        href = $(this).find("a:first").attr("href")
        if ( href ) {
            window.location = href;
            event.preventDefault();
            }
    });

//---------------------------------------------------------------
    $(".weather_5_day").click(function(event){
        $('.weather_5_day:visible').removeClass('lightblue');
        $(this).toggleClass('lightblue');
        t = $("#detail_"+this.id).html();
        $("#forecast_detail").fadeOut(function(){$(this).html(t).fadeIn()});
    }).ready(function(){
        $('.weather_5_day:first').addClass('lightblue');
        j = $('div[id^="detail_forecast_data_"]:first').html();
        $("#forecast_detail").html(j);
    });

//---------------------------------------------------------------
    $('#forecast_switch a').click(function(event){
        $('#all_forecasts > div:visible').addClass('dspl_none');
        $('#'+this.name).toggleClass('dspl_none');
        $('#'+this.name+' div[id^="forecast_data_"]:first').addClass('lightblue')
        j = $('#'+this.name+' div[id^="detail_forecast_data_"]:first').html();
        $("#forecast_detail").fadeOut(function(){$(this).html(j).fadeIn()});
        event.preventDefault();
    });

//---------------------------------------------------------------
    $("#weather_table tr:even").addClass('even');

//---------------------------------------------------------------
    $('.tbl_event tbody tr:nth-child(4n+1)').addClass('even');
    $('.tbl_event tbody tr:nth-child(4n+2)').addClass('even');
    $('.tbl_event tbody td:nth-child(3)').addClass('txt_bold');

    $('.tbl_head_green tbody tr:nth-child(2n)').addClass('even');
    $('.tbl_head_green tbody td:nth-child(1)').addClass('txt_bold');

    $('.tbl_even_odd tbody tr:nth-child(2n)').addClass('even');
//---------------------------------------------------------------

});

//---------------------------------------------------------------
//---------------------------------------------------------------

