
$.mh = {
    img_h: $("ul.show > li:visible > img").height(),
    img_w: $("ul.show > li:visible > img").width(),
    show_h: $("ul.show").height(),
    show_w: $("ul.show").width()
};

$(document).ready(function(){
    
    update_readout();
    update_vars();
    resize_show();
    
    $(".static.show").cycle( { 
        timeout: 0,
        next: '#next',
        prev: '#prev'        
        } );
        
    $(".auto.show").cycle({
        timeout: 3000
    });
    
    //$("#width").text($(window).width() + " / " + $(window).height() + " : " + $.mh.img_w + " / " + $.mh.img_h);
    
    // $("#nav_show").toggle(
    //     function(){
    //         $("nav ul").slideDown();
    //         $("#nav_show span").text("hide ");
    //     },
    //     function(){
    //         $("nav ul").slideUp();
    //         $("#nav_show span").text("show ");
    //     }
    // );
    
    $("#slide_toggle").click(function(){
        $(".show").cycle('toggle');
    });
    
    
});

$(window).resize(function(){
    
    update_readout();
        
    setTimeout(function(){
        // I think with 100% width CSS values at play, the resize can't happen too soon
        update_vars();
        //$("ul.show").fitToParent();
        resize_show();
        
    },10);
    
    if($(window).width() > 640 && $("nav ul").is(":hidden")){
        $("nav ul").show();
    }
    
});

function update_vars(){
    //currently unused
    //$.mh.ratio = calc_ratio();
    $.mh.img_h = $("ul.show > li:visible > img").height();
    $.mh.img_w = $("ul.show > li:visible > img").width();
    $.mh.show_h = $("ul.show").height();
    $.mh.show_w = $("ul.show").width();
}

function resize_show(){
    $("ul.show > li:visible > img").width( $.mh.show_w - 12 );
    $("ul.show").height( $.mh.show_w * 0.67 );
    //$("ul.show").width( $.mh.show_w );
}

function calc_ratio(){
    return $(window).width() / $(window).height();
}

function update_readout(){
    $("#width").text( $(window).width() + " / " + $(window).height() + " : " + $.mh.show_w + " / " + $.mh.show_h );
    $("#ratio").text( calc_ratio() );
}


