﻿	var str_reply;
   var str_affiliateURL;
   
	//Holds XMLHttpRequest or XMLHTTP object depends on the type of the browser
	var pageRequest = null;

    //Branch for native XMLHttpRequest object           
    if (window.XMLHttpRequest)
	{
		try
		{
			//By using XMLHttpRequest object, web clients can retrieve and 
			//submit XML data directly, all in the background. 
			//Creating an instance of the XMLHttpRequest object
			pageRequest = new XMLHttpRequest();
		}
		catch (e)
		{           
			//Set the object to NULL                         
			pageRequest = null;
		}
    }
	else
	{
		//Branch for IE/Windows ActiveX version               
		if (window.ActiveXObject)
		{ 
			try 
			{

				//By using XMLHTTP object, web clients can retrieve and 
				//submit XML data directly, all in the background. 
				//Creating an instance of the Msxml2.XMLHTTP object
				pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
			}
			catch (e) 
			{           
				try
				{
					//Creating an instance of theMicrosoft.XMLHTTP object
					pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
				}
				catch (e)
				{                       
					//Set the object to NULL             
					pageRequest = null;
				}
			}
		}
		else
		{
            //Set the object to NULL
            pageRequest = null;
		}
	}
           
	if(pageRequest != null)
	{
		if (parent != self)
			 {
        		var str_url = "/shared/html/xmldatapass.asp";
        		var str_http_method = "post";                              

        //Postable string which holds the url
        
        //To handle special characters in element content, we can put the text 
		//inside a CDATA section.
		var str_xml="<root><val><![CDATA[" + parent.frames[0].location + "]]></val></root>";     
		
        //Assigns destination URL, method, and other optional 
        //attributes of a pending request
        pageRequest.open(str_http_method, str_url, false);                                   

        //Transmits the request, optionally with postable string or DOM object data
        pageRequest.send(str_xml);                
        
		//String version of data returned from server process
		var strResponse = pageRequest.responseText;  		
	
		var endstr = strResponse.indexOf (",", 0); 
		str_reply =strResponse.substring(0, endstr);
		str_affiliateURL =strResponse.substring(endstr+1, strResponse.length);
		
		if(str_reply == "-1" && str_affiliateURL == "-1")
		{
			//Put some proper error message
			alert("Error");
		}
		}                   
	
	}