
$(document).ready(function(){

$("#loading").bind("ajaxSend", function(){
   $('#loading').show()
 }).bind("ajaxComplete", function(){
   $('#loading').hide()
 });
});

/*
This function is used to show any DOM element as a dialog with animation during showing/hiding
e.g. We have <div id="dialog">Hello Word</div>
We can invoke: showDialog('dialog') to show the dialog
and showDialog('dialog', false) to hide it
*/
function showDialog(name,show, conf){
    if(show ==  undefined)
        show=true
    if (conf== undefined)
        conf = { modal: true, resizable: flase }
    if(show){
        $('#'+name).dialog(conf);
        $('#'+name).dialog().fadeIn('slow');
    }
    else{
        $('#'+name).dialog().fadeOut('normal', function(){$('#'+name).dialog('destroy'); });
    }
}

/*
scrollWin is used to scroll the window top to a certain DOM element.
*/
function scrollWin(node){
    $('html, body').animate({
        scrollTop: $("#"+node).offset().top
    }, 2000);
}

/*
Used internally by flex
*/
function getBaseUrl(){
    return document.location.host;
}