var pageUri = document.location.href;

function mkSjax(target,url,data) {
    $.ajax({
        url: url,
        type: "POST",
        data: data,
        async:false,
        success: function(msg){
            if (target.is('input')) {
                target.val(jQuery.trim(msg));
            } else {
                target.html(msg);
            }
            
            if($('#ajAlert').size() != 0) {
                alert($('#ajAlert').text());
                $('#ajAlert').remove();
            }
        }
    });
}

$(document).ready(function() {	 
    $(".mui-grid th").click(function ()	{
        var th_url = $(this).children().attr('href');
        if (th_url != undefined) {
            window.location.href = th_url;
        }
        return false;
    });
	
    $(".mui-grid tr").dblclick(function ()	{
        var tr_url = $(this).find(".update").attr('href');
        if (tr_url != undefined) {
            window.location.href = tr_url;
        }
        return false;
    });
    
    $('.show_search_form').click(function() {
        $('.search_form').slideToggle('fast');
        return false;
    });
    

    $("form .inputs").focus(function ()	{
        $(this).removeClass('error');
    });
	
    $(".form_options .advanced").click( function() {
        $(this).hide();
        $('.form_options .pasadvanced').show();
        $(".form_wrapper").find('.optionnal').show();
    });
	
    $(".form_options .pasadvanced").click( function() {
        $(this).hide();
        $('.form_options .advanced').show();
        $(".form_wrapper").find('.optionnal').hide();
    });
	
    /* delete confirmation */
    $(".delete").click(function () {
        if(confirm("Confirm delete ?") == false) {
            return false;
        }
    });
    
    $('#picoreDialogClose').click(function() {
        $('#picoreDialog').hide('normal');
        return false;
    });
});

