$(document).ready(function() {

    /* init shadowbox */
    Shadowbox.init({
        overlayColor: '#000',
        overlayOpacity: 0.6,
        resizeDuration: 0.5
    });

    /* add zoom picto to shadowbox links */

});

/* shadowbox */
$('a.sbx').live('click',function() {
    Shadowbox.open({
        player: 'img',
        title: $(this).attr('title'),
        content: $(this).attr('href')
    });
    return false;
});

$(document).ready(function() {

    /* search input */
    $('.wipeOnFocus').focus(function() {
        if($(this).val()==this.defaultValue) $(this).val('');
    }).blur(function() {
        if($(this).val()=='') $(this).val(this.defaultValue);
    });
    
    AutoHeight();
});

$(window).bind("resize",function() {
    AutoHeight();
});

if(jQuery.support.opacity) {
    $('ul#nav > li > a').live('mouseover',function() {
        $('ul#nav > li > a').removeClass('active');
        $(this).addClass('active');
        $('ul#nav > li > a[class!=active]').stop().fadeTo(500,0.5);
    }).live('mouseout',function() {
        $('ul#nav > li > a[class!=active]').stop().fadeTo(500,1);
    });
}
else {
    
}

function AutoHeight() {
    var width = $(window).width();
    var height = $(window).height();

    var img_bloc = $("#fond");
    var img = $("#fond > img");

    // AUTO SIZE
    if((width/height) > (img.width()/img.height())) {
        img.attr("width",width).removeAttr("height");
    } else {
        img.attr("height",height).removeAttr("width");
    }

    // AUTO CENTER HORIZONTAL
    if(img.width() > width) {
        img.css("left","-"+parseInt((img.width()-width)/2)+"px");
    } else {
        img.css("left",0);
    }

    // AUTO CENTER VERTICAL
    if(img.height() > height) {
        img.css("top","-"+parseInt((img.height()-height)/2)+"px");
    } else {
        img.css("top",0);
    }

    // FADE IN
    img.fadeIn(1000);
}
