///////////////////////////
//Custom jQuery methods.
///////////////////////////

/////////////////////////////
//When the DOM is ready,
//initialize scripts.
///////////////////////////
jQuery(function($){
    ///////////////////////////

    ///////////////////////////
    //Code display dialogue.
    ///////////////////////////
    $("#dialog_code_a").dialog({
        autoOpen: false,
        width: 800,
        height: 600,
        position: ['center','center'],
        show: 'puff',
        modal: true
    });
    $("#dialog_code_b").dialog({
        autoOpen: false,
        width: 800,
        height: 600,
        position: ['center','center'],
        show: 'puff',
        modal: true
    });
    // Dialog Link
    $('#dialog_link_a').click(function(){
        $('#dialog_code_a').dialog('open');
        return false;
    });
    $('#dialog_link_b').click(function(){
        $('#dialog_code_b').dialog('open');
        return false;
    });
    ///////////////////////////

    ///////////////////////////
    //Hover on header.
    ///////////////////////////
    $(".portfolio_image").live('mouseenter', function () {
        $(this).fadeTo("slow", 1, function() {});
    });
    $(".portfolio_image").live('mouseleave',function () {
        $(this).fadeTo("slow", 0.6, function() {});
    });
    ///////////////////////////

    ///////////////////////////
    //Dynamic viewport dimensions.
    ///////////////////////////
    $(window).resize(function() {
        $('span#dimensiondisplay').text($(window).width()+ ' x ' + $(window).height()).css({
            'display' : 'block',
            'color' : '#cccccc',
            'float' : 'right',
            'margin-right': '1.5em',
            'margin-top': '0.5em',
            'padding' : '1em',
            'clear' : 'both'
        });
    });
    ///////////////////////////

    var footerHeight = 0, footerTop = 0, $footer = $("#footer");
    positionFooter();
    function positionFooter() {
        footerHeight = $footer.height();
        footerTop = ($(window).scrollTop()+$(window).height()-footerHeight)+"px";

        if ( ($(document.body).height()+footerHeight) < $(window).height()) {
            $footer.css({
                position: "absolute"
            }).animate({
                top: footerTop
            });
        } else {
            $footer.css({
                position: "static"
            });
        }
    }
    $(window).scroll(positionFooter).resize(positionFooter);

});
///////////////////////////
