$(document).ready(function () {
    
    // OVERLAY
    $("img[rel]").overlay({
        top: 0,
        onLoad: function () {
            //set focus on the search input AFTER the overlay has loaded
            $('#search_input').focus();
        }
    })

    // INPUT FIELDS
    //init
    $('input[type="text"]').addClass("idle");
    //when the field recieves a focus
    $('input[type="text"]').focus(function () {
        $(this).removeClass("idle").addClass("focus");
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    //when the field looses its focus
    $('input[type="text"]').blur(function () {
        $(this).removeClass("focus").addClass("idle");
        if ($.trim(this.value == '')) {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

}); 


