function isIPhone(){
    return (
        (navigator.platform.indexOf("iPhone") != -1) ||
        (navigator.platform.indexOf("iPod") != -1)
    );
}

function adjustHeadlineHeight($id, $height){
    $('h1').css({height: ($height-7)+'px'});
}

$(document).ready(function(){

    // Activate flash title replacement
    if (!isIPhone())
    {
        $('h1')
            .css({height:'28px'})
            .bind('load', function(){
                $(this).flash({
                    swf:'assets/flash/title.swf',
                    height: '100%',
                    width: '100%',
                    wmode: 'transparent',
                    id: $(this).attr('id')+'_swf',
                    flashvars: {
                        title:$(this).html(),
                        href:'',
                        id: $(this).attr('id')+'_swf'
                        }
            });
        });
        
        $('h1').trigger('load');
    }

    // Show/hide toplink
    $('#top-link').css('display','none');
    
    if ($(document).height() > $(window).height())
    {
        $('#top-link').css('display','block');
    }

    // Activate img hover
    $('#navigation li:not(.active) img').imghover({suffix: '_mouseover'});

    // Set navigation behaviour
    var BORDER = '3px dotted #FFF';
    var NOBORDER = 'none';
    
    var WIDTH_NORMAL = '200px';
    var WIDTH_ACTIVE = '235px';

    $('#navigation ul li:not(.last,.active, .active li)')
        .mouseover(function(){
            $(this).css({'border-bottom':BORDER, 'width':WIDTH_ACTIVE});
            $(this).next('li').css({'border-top':NOBORDER});
        })
        .mouseout(function(){
            $(this).css({'border-bottom':NOBORDER, 'width':WIDTH_NORMAL});
            $(this).next('li').css('border-top', BORDER);
        });
        
    $('#navigation ul li.last:not(.active)')
        .mouseover(function(){
            $(this).css({'width':WIDTH_ACTIVE});
        })
        .mouseout(function(){
            $(this).css({'width':WIDTH_NORMAL});        
        })

    $('#navigation ul li.active:not(.active li)')
        .bind('click', function(){
            $(this).css({'border-bottom':BORDER, 'width':WIDTH_ACTIVE});
            $(this).next('li').css('border-top', NOBORDER);         
        })
        .trigger('click');
});
