function getDocHeight() {
    return Math.max(
	    $(document).height(),
	    $(window).height(),
        /* For opera: */
	    document.documentElement.clientHeight
    );
};

function resizeFlash() {
    var winHeight = $(window).height();
    if (winHeight > 630) {
        var homeFlashHeight = winHeight - 278;
        $('#homeflash').css('height', homeFlashHeight);
    }
    else {
        $('#homeflash').css('height', 352);
    }
}

function resizeContent() {
    var contentHeight = $('#wrapper').outerHeight() + 40;
    var winHeight = $(window).height();
    if (contentHeight < winHeight) {
        $('#footer').css('marginTop', winHeight - contentHeight);
    }
    else {
        $('#footer').css('marginTop', 0);
    }
}

function mailTo(m, cl, e) { if (!e) { e = "ronly.com"; } document.write("<a href=mailto:" + m + String.fromCharCode(64) + e + " class=\"" + cl + "\">" + m + String.fromCharCode(64) + e + "</a>"); }

var overlayHeight = 0;
$(document).ready(function() {
    if (!isHomepage) {
        $(window).bind('load resize scroll', resizeContent);
        resizeContent();
        $('#homelink').show();
    }
    else {
        $(window).bind('load resize scroll', resizeFlash);
    }
    $('.overlay').css({ 'opacity': 0 });
    $('#menu > li > a').css({ 'opacity': 0 })

    $('#menu > li').hover(function() {
        $('#menu span').stop().css({ 'height': '' }).hide();
        $('#menu ul').stop().css({ 'height': '' }).hide();
        overlayHeight = getDocHeight() - 10;
        $('#menu > li > a').css({ 'opacity': 1 });
        $('.overlay').css({ 'height': overlayHeight, 'display': 'block' });
        $('.overlay').stop().css({ 'opacity': 0.60 });
        $(this).find('span').slideDown(75, function() {
            $(this).parent().parent().find('ul').slideDown(250);
        });
    }, function() {
        $('#menu span').stop().css({ 'height': '' }).hide();
        $('#menu ul').stop().css({ 'height': '' }).hide();
        $('.overlay').stop().css({ 'opacity': 0, 'height': 0, 'display': 'none' });
        $('#menu > li > a').css({ 'opacity': 0 });
    });

    $('#menu ul a').hover(function() {
        $(this).parent().addClass('smover')
    }, function() {
        $(this).parent().removeClass('smover')
    });

    $('#homegrid li').hover(function() {
        $(this).find('img').stop().animate({ 'width': '187', 'height': '71px' }, 300);
    }, function() {
        $(this).find('img').stop().animate({ 'width': '180', 'height': '66px' }, 200);
    });

    jfr$('h1.sifr').jfr({
        src: '/swf/interface_bold.swf',
        css: [
            '* { color: #ffffff; text-align: right;   }',
            'a { color: #ffffff; text-decoration: none; }',
            'a:hover { text-decoration: underline; }'
            ]
    });

    jfr$('h2.sifrsub').jfr({
        src: '/swf/interface.swf',
        css: [
            '* { color: #ffffff; text-align: right;   }',
            'a { color: #ffffff; text-decoration: none; }',
            'a:hover { text-decoration: underline; }'
            ]
    });
    $.jfr.render();
});