/*
 * Ajax functions for Click2Sell
 *
 */

//$.ajaxSetup({ scriptCharset: "utf-8" ,contentType: "application/x-www-form-urlencoded; charset=UTF-8" });

function ajaxLoadUrlInline(url, target, cache)
{
    $.ajax({
        url: url,
        cache: cache == null ? false : cache,
        success: function(html)
        {
            $(target).empty();
            $(target).append(html);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown)
        {
            $(target).empty();
            $(target).showError(errorThrown);
        }
    });
}

function ajaxSumbitFormInline(form, target, successCallback)
{
    $.ajax({
        url: form.action,
        data : $(form).serialize() + "&ignore_enc_filter=true",
        type : 'POST',
        cache: false,
        success: function(data)
        {
            $(target).empty();
            if(data.length)
            {
                $(target).append(data);
            }
            else
            {
                successCallback(data);
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown)
        {
            $(target).empty();
            $(target).showError(errorThrown);
        }
    });
    $(target).showProgress();
}

function ajaxCallForm(form, target, successCallback, errorCallback)
{
    $.ajax({
        url: form.action,
        data : $(form).serialize() + "&ignore_enc_filter=true",
        type : 'POST',
        cache: false,
        success: successCallback,
        error: errorCallback
    });
    $(target).showProgress();
}

function ajaxCallUrl(url, target, successCallback, errorCallback, cache)
{
    $.ajax({
        url: url,
        type : 'POST',
        cache: cache == null ? false : cache,
        success: successCallback,
        error: errorCallback
    });
    if(target)
    {
        $(target).showProgress();
    }
}




