var operationStatus = new OperationStatus();

/******************     wac class declaration, begin     *******************/

/*
 *  declare ajax action implemention status
 */
function OperationStatus()
{
    this.Succss = "0000";
    this.Error  = "0001";
    this.Processing  = false;
}

/******************     wac class declaration, end     *******************/

/*
 * show loading
 */
function showBlockUILoading(id, msg)
{
    if(msg === undefined){
        var msg = "Chargement";
    }

    if(id === undefined)
    {
        $.blockUI({message: '<h5><img src="/images/ajax-loader.gif" alt="' + msg +'"> ' + msg +'</h5>'});
    }
    else
    {
        $(id).block({message: '<h5><img src="/images/ajax-loader.gif" alt="' + msg +'"> ' + msg +'</h5>'});
    }
}

/*
 * show loading
 */
function showPortletLoading(id, msg)
{
    if(msg === undefined){
        var msg = "...";
    }

    $(id).block({message: '<h3><img src="/images/js_icons/throbber.gif" alt="' + msg +'"> ' + msg +'',
                 css: {border: 'none',  backgroundColor: '#000', opacity: .5}});
}

/*
 * hide blockUI
 */
function hideBlockUI(id)
{
    if(id === undefined)
    {
        $.unblockUI();
    }
    else
    {
        $(id).unblock();
    }
    
}

/*
 * show tips
 */
function showTips(msg, title)
{
    if(title != undefined)
    {
        $("#dynamicZone").append("<div id='wacTipsDialog' title='" + title + "'><p>" + msg +"</p></div>");
    }
    else
    {
        $("#dynamicZone").append("<div id='wacTipsDialog' title='Tips'><p>" + msg +"</p></div>");
    }

    $("#wacTipsDialog").dialog({
        bgiframe: true,
        modal: true,
        width: 550,
        zIndex: 100,
        dialogClass: 'popupTips',
        buttons: {
            Ok: function() {
                $(this).dialog('close');
                $("#wacTipsDialog").remove();
            }
        }
    });
    $(".ui-dialog-titlebar").hide();
}

function isInteger(s)
{
    var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function debugLog(msg)
{
    if (!$.browser.msie) {
        console.log($.browser.version);
        console.log(msg);
    } else {
        alert(msg);
    }
}

function trackConfirmation()
{
    try {
        var pageTracker = _gat._getTracker("UA-445406-10");
        pageTracker._trackPageview('/confirm.html');
    } catch(err) {}
}
