﻿NG = {}
NG.Portal = {}
NG.Portal.Mix = {}
NG.Portal.Mix.Web = {}
NG.Portal.Mix.Web.CommonMethods = function() {
};

var initCaller = new Array();
var ajaxCaller = new Number();
var Markets = null;
var UrlBase = "http://" + window.location.hostname;
var AjaxServiceUrl = UrlBase + '/WebServices/AJAXService.asmx';

NG.Portal.Mix.Web.CommonMethods.SendEmail = function(onSuccess, onFail, email) {

    $.ajax({
        type: "POST",
        url: AjaxServiceUrl + "/SendEmail",
        contentType: "application/json",
        data: JSON.stringify(email),
        dataType: "json",
        success: onSuccess,
        fail: onFail
    });
};

NG.Portal.Mix.Web.CommonMethods.IsNumeric = function(form_value) {
    if (form_value.match(/^\d+$/) == null)
        return false;
    else
        return true;
};

NG.Portal.Mix.Web.CommonMethods.ShowAjax = function(functionName) {
    if (ajaxCaller[functionName] == null) {
        ajaxCaller[functionName] = new Date();
        $("div.ajaxLoading").show();
        return true;
    }
    return false;
};

NG.Portal.Mix.Web.CommonMethods.HideAjax = function(functionName) {
    if (ajaxCaller[functionName] != null) {
        ajaxCaller[functionName] = null;
    }

    for (var obj in ajaxCaller) {
        if (ajaxCaller[obj] != null) {
            return;
        }
    }
    
    $("div.ajaxLoading").hide();
   
};


Array.prototype.contains = function(element) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == element) {
            return true;
        }
    }
    return false;
}



