var rnd = Math.random();
//Global XMLHTTP Request object
var XmlHttp;

//Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
function CreateXmlHttp()
{
	//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();
	}
}

function showPopUpOnPage()
{
	var requestUrl = "ajaxServer.aspx?method=showPopUpOnPage&session=" + rnd;
	CreateXmlHttp();
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = showPageContent;
		
		//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);		
	}
}

function setCookies()
{
	var requestUrl = "ajaxServer.aspx?method=setCookies&session=" + rnd;
	CreateXmlHttp();
	if(XmlHttp)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = showPageContent;
		
		//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 showPageContent()
{
	// 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)
		{
			var sValue = XmlHttp.responseText;
			if(sValue == 'YES')
			{
//				window.open('vaultPopUp.aspx','NewWindow','status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,height=310,width=500,left=300,top=175');

				//Change By Dhirendra - New server does not open .htm and .html files
				//window.open('custommadejewelrypopup.htm','NewWindow','status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,height=325,width=500,left=300,top=175');
				window.open('custommadejewelrypopup.aspx','NewWindow','status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,height=325,width=500,left=300,top=175');

			}
		}
	}
}

function hidePage()
{
	// 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

		alert('hi');
		if(XmlHttp.status == 200)
		{
			var sValue = XmlHttp.responseText;
			if(sValue == 'SET')
				obj.close();
		}
	}
}


