
///////////////////////////////////////////////////////////////////////////

var url;
var xmlHttp = createXmlHttpRequestObject();
//global declarations

function checkLogin(_params)
{
   //alert (_params);
   url = 'http://www.clickastro.com/common/avlogincheck4article.php?'+_params;
   process(); 
}

///////////////////////////////////////////////////////////////////////////
// retrieves the XMLHttpRequest object

function createXmlHttpRequestObject()
{
var reqHttp;
if(window.ActiveXObject)
{
	try
	{
		reqHttp = new ActiveXObject("Microsoft.XMLHTTP");
		
	}
	catch (e)
	{
		reqHttp = false;
	}
}
// if running Mozilla or other browsers
else
{
	try
	{
		reqHttp = new XMLHttpRequest();
		
	}
	catch (e)
	{
		reqHttp = false;
	}
}
if (!reqHttp)
	alert("Error creating the XMLHttpRequest object.");
else
	return reqHttp;
}
//////////////////////////////////////////////////////////////////////

function process()
{
// proceed only if the xmlHttp object isn't busy

	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange = handleServerResponse;
		xmlHttp.send(null);
	
	}
	else
	{
// if the connection is busy, try again after one second
 		t = setTimeout('process()', 1000);
	}
}
// executed automatically when a message is received from the server
function handleServerResponse()
{
	if (xmlHttp.readyState == 4)
	{
// status of 200 indicates the transaction completed successfully
		if (xmlHttp.status == 200)
		{
		
			_data=xmlHttp.responseText;
			//alert('xx'+_data+'yy');
		if ( xmlHttp.responseText =='LOGINOK')
			{
		    showhide('d1');
			showhide('uiTabsParent');
			 document.getElementById('regloginout').innerHTML = "<a href=\"#\"><img src=\"http://www.clickastro.com/image/btn-logout.gif\" width=\"138\" height=\"29\" border=\"0\" alt=\"Logout\" onclick=\"logout('http://www.clickastro.com/');\"></a>";
			}
		 else
			{
		   document.getElementById('loginerror').innerHTML=_data;
		  // alert(document.getElementById('regloginout').innerHTML);
		   document.getElementById('reguname').innerHTML = '';
		   document.getElementById('regupwd').innerHTML = '';	  	   
		  
			}
		   
		   
		 
		}
// a HTTP status different than 200 signals an error
	}
	else
	{
		//t = setTimeout('handleServerResponse()', 1000);
		// alert("There was a problem accessing the server: " + xmlHttp.statusText);
	}
}

////////////////////////////////////////////////////


