﻿// Code for Creating the XMLHTTP Obj
var xmlReq = new Array(); // ARRAY OF XML-HTTP REQUESTS
var xmlIndex = new Array(0); // ARRAY OF XML-HTTP REQUEST INDEXES
xmlIndex[0] = 1; // FIRST INDEX SET TO 1 MAKING IT AVAILABLE


function xhrRequest(type) 
{
    if (!type) 
    {
        type = 'html';
    }
    // xhrsend IS THE xmlIndex POSITION THAT GETS PASSED BACK
    // INITIALIZED TO THE LENGTH OF THE ARRAY(LAST POSITION + 1)
    var xhrsend = xmlIndex.length;

    // GO THROUGH AVAILABLE xi VALUES
    for (var i=0; i<xmlIndex.length; i++) 
    {
        // IF IT'S 1 (AVAILABLE), ALLOCATE IT FOR USE AND BREAK
        if (xmlIndex[i] == 1) 
        {
            xmlIndex[i] = 0;
            xhrsend = i;
            break;
        }
    }
    // SET TO 0 SINCE IT'S NOW ALLOCATED FOR USE
    xmlIndex[xhrsend] = 0;


    // SET UP THE REQUEST
    if (window.ActiveXObject) 
    {
        try 
        {
            xmlReq[xhrsend] = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                xmlReq[xhrsend] = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) 
            {
                
            }
        }
    } 
    else if (window.XMLHttpRequest) 
    {
        xmlReq[xhrsend] = new XMLHttpRequest();
        if (xmlReq[xhrsend].overrideMimeType) 
        {
            xmlReq[xhrsend].overrideMimeType('text/' + type);
        }
    }
    return (xhrsend);
}

function LoadMyPageData()
{ 
   
   
    LoadMyPageRequest('ajax/MyPageCode.aspx?id=VO&filter=Video');
   
}

function LoadMyPageRequest(url, reqType) 
{
//alert(url);
   // debugger;
    var xhri = xhrRequest('html'); 
    xmlReq[xhri].open('GET', url, true);    
    xmlReq[xhri].onreadystatechange = function() 
    {             
        if (xmlReq[xhri].readyState == 4 && xmlReq[xhri].status == 200) 
        {  
                      
            if(url == "ajax/MyPageCode.aspx?id=VO&filter=Video")
            {
            //alert('hi');
                var arResponce;
                var arOutput = xmlReq[xhri].responseText;               
                if(arOutput != '')
                {                
                    document.getElementById("spnVideo").innerHTML = arOutput;  
                }
            }
            
        }
    } 
    xmlReq[xhri].send(null);  
} 


