/*
    By Jason Palmer
    http://www.jason-palmer.com/2008/08/jquery-plugin-form-field-default-value/
*/
jQuery.fn.DefaultValue = function(text){

    return this.each(function(){
        //Make sure we're dealing with text-based form fields
        if(this.type != 'text' && this.type != 'password' && this.type != 'textarea') {
            return;
        }
        
        //Store field reference
        var fld_current=this;
        
        //Set value initially if none are specified
        if(this.value === '') {
            this.value=text;
        } else {
            //Other value exists - ignore
            return;
        }
        
        //Remove values on focus
        $(this).focus(function() {
            if(this.value === text || this.value === '' ) {
                this.value='';
            }
        });
        
        //Place values back on blur
        $(this).blur(function() {
            if(this.value === text || this.value === '') {
                this.value=text;
            }
        });
        
        //Capture parent form submission
        //Remove field values that are still default
        $(this).parents("form").each(function() {
            //Bind parent form submit
            $(this).submit(function() {
                if(fld_current.value==text) {
                    fld_current.value='';
                }
            });
        });
    });
};


jQuery(function(){
    
    // Add last class to last menu element
    $("#chromemenu ul>li:last").addClass("last");
    
    // Search field default value
    $("#search-form-s").DefaultValue("Recherche");
    
    
    
    // Fix layout height
    var h1 = $("#main-content").height();
    if (h1 < 600) {
        $("#main-content").height(600);
    }    
    var h2 = $("#egalement").height();
    if (h2 < 100) {
        $("#egalement").height(100);
    }    
    var l_ega = $("#egalement li").length;    
    if (l_ega == 0) {
        $("#egalement h3").hide();
    }
    
    
    $('a[href$=pdf]').addClass("pdf-icon");
    $('a[href$=doc], a[href$=docx]').addClass("doc-icon");
    $('a[href$=ppt]').addClass("ppt-icon");
    $('a[href$=xls]').addClass("xls-icon");
    
    $(document).pngFix(); 
    
    
});


