﻿// Add to Friend Ajax Utility
// By : Najafian
// Date : 1386/12/05

var A2F_Request;

function A2F_Validate(userSecurityInfo)
{
    var url = "/MView/User/Add2Friend.ashx" + userSecurityInfo;
    //alert(url);
    if (window.XMLHttpRequest)
    {
        A2F_Request = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        A2F_Request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    A2F_ShowLoading("show");
    A2F_Request.open("GET", url, true);
    A2F_Request.onreadystatechange = A2F_Callback;
    A2F_Request.send(null);
}

function A2F_ShowLoading(action)
{
    var divObj = document.getElementById("AjaxLoading");
    if (action == "show")
    {
        divObj.style.display = "block";
        ResizeLoading();
    }
    else if (action == "hide")
        divObj.style.display = "none";    
}

function ResizeLoading()
{
    var divObj = document.getElementById("AjaxLoading");
    divObj.style.top = 5;
    divObj.style.left = 5;
    divObj.style.width = document.body.clientWidth - 10;
    divObj.style.height =  Math.max(window.screen.height - 220, document.body.clientHeight - 5);
}
    
function A2F_Callback()
{
    if (A2F_Request.readyState == 4)
    {
        if (A2F_Request.status == 200)
        {
            A2F_ParseMessage();
        }
    }
}
    
function A2F_ParseMessage()
{
    A2F_ShowLoading("hide");
    alert(A2F_Request.responseText);
}
   
