﻿// JScript File

//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp()
{
    //netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");

	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
}

//AJAX Dynamic Search 
//function dynamicSetOrder(MovedFromId,MovedToId,Value)
function dynamicSetOrder(MovedFromId,UpValue,DownValue,Value)
 {       //alert(UpValue);alert(MovedFromId);alert(DownValue);
	    var requestUrl = "";    	 
         if(Value == 1) //Primary Text
            requestUrl = relativePath()+"ajaxMenu.aspx?FeatureAFromId=" + encodeURIComponent(MovedFromId)+"&FeatureAUpId=" + encodeURIComponent(UpValue) + "&FeatureADownId=" + encodeURIComponent(DownValue);
        else  if(Value == 2) //MIB team Text
            requestUrl = relativePath()+"ajaxMenu.aspx?TeamFromId=" + encodeURIComponent(MovedFromId)+"&TeamUpId=" + encodeURIComponent(UpValue) + "&TeamDownId=" + encodeURIComponent(DownValue);
        else  if(Value == 3) //MIB team Text
            requestUrl = relativePath()+"ajaxMenu.aspx?ColumnistFromId=" + encodeURIComponent(MovedFromId)+"&ColumnistUpId=" + encodeURIComponent(UpValue) + "&ColumnistDownId=" + encodeURIComponent(DownValue);
        else  if(Value == 4) //Facilitator
            requestUrl = relativePath()+"ajaxMenu.aspx?FacilitatorFromId=" + encodeURIComponent(MovedFromId)+"&FacilitatorUpId=" + encodeURIComponent(UpValue) + "&FacilitatorDownId=" + encodeURIComponent(DownValue);
      else  if(Value == 5) //Blog
            requestUrl = relativePath()+"ajaxMenu.aspx?BlogFromId=" + encodeURIComponent(MovedFromId)+"&BlogUpId=" + encodeURIComponent(UpValue) + "&BlogDownId=" + encodeURIComponent(DownValue);
        CreateXmlHttp();
    	
        // If browser supports XMLHTTPRequest object
        if(XmlHttp)
        {  
	        //Setting the event handler for the response
	        XmlHttp.onreadystatechange = HandleResponseSetOrder;
    		 
	        //Initializes the request object with GET (METHOD of posting), 
	        //Request URL and sets the request as asynchronous.
	        XmlHttp.open("GET", requestUrl,  true);
    		
	        //Sends the request to server
	        XmlHttp.send(null);	
        }  
	 
 }
 
 
 
//Called when response comes back from server
function HandleResponseSetOrder()
{ 
	// To make sure receiving response data from server is completed	
	if(XmlHttp.readyState == 4)
	{	 // To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{	  
		    fillOrder(XmlHttp.responseXML.documentElement);
 	    }
		else
		{
			//alert("There was a problem retrieving data from the server." );
		}
	}	
} 

//Returns the node text value 
function GetInnerText (node)
{
    return (node.textContent || node.innerText || node.text) ;	 
}

function fillOrder(text)
{}