$(function() {
    // Top Search Slider
    $('.topSearchToggler').click(function() {
        var lungime = $('.topSearchInput').width();
        if (lungime == 0) {
            $('.topSearchInput').stop(true, true).animate({ width: 170 + 'px' }, 500);
        } else {
            $('.topSearchInput').stop(true, true).animate({ width: 0 + 'px' }, 500);
        }
    });

    //Hide Search field on blur
    $('input.searcInputField').blur(function() {
        $('.topSearchInput').stop(true, true).animate({ width: 0 + 'px' }, 500);
    });

    //Clear default value of focused input	
    $('input.searcInputField').clearDefault();

});


(function($) {
    // clear form default value jQuery plugin
    $.fn.clearDefault = function() {
        return this.each(function() {
            var default_value = $(this).val();
            $(this).focus(function() {
                if ($(this).val() == default_value) $(this).val("");
            });
            $(this).blur(function() {
                if ($(this).val() == "") $(this).val(default_value);
            });
        });
    }    
})(jQuery);



function showModalDialog(dialogSelector) {
    $(dialogSelector).dialog('open');
}

function closeModalDialog(dialogSelector) {
    $(dialogSelector).dialog('close');
}

/* OK message dialog */
function setModalDialog(headerText, dialogSelector) {
    $(dialogSelector).dialog({
        autoOpen: false,        
        modal: true,
        title: headerText,
        resizable: false,
        buttons: {
            "Ok": function() {
                $(this).dialog('close');
            }
        }
    });
}

/* Keep scroll after postback */
window.scrollTo = function(x, y) {
    return true;
}


