var http = createRequestObject();
var objectId = 'ajaxOutput';


function createRequestObject(htmlObjectId)
{
    var obj;
    var browser = navigator.appName;
    
    objectId = htmlObjectId;
    
    if(browser == "Microsoft Internet Explorer")
	{
        obj = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
	{
        obj = new XMLHttpRequest();
    }
    return obj;    
}

function sendReq(serverFileName, variableNames, variableValues) 
{
	var paramString = '';
	
	variableNames = variableNames.split(',');
	variableValues = variableValues.split(',');
	
	for(i=0; i<variableNames.length; i++) 
	{
		paramString += variableNames[i]+'='+variableValues[i]+'&';
	}
	paramString = paramString.substring(0, (paramString.length-1));
	
			
	if (paramString.length == 0) 
	{
	   	http.open('get', serverFileName);
	}
	else 
	{
		http.open('get', serverFileName+'?'+paramString);
	}
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function sendReq(serverFileName) 
{	
	//alert(serverFileName);
	http.open('get', serverFileName);
	http.onreadystatechange = handleResponse;
    http.send(null);
}
function handleResponse() 
{
	//alert(clubobj);
	if(http.readyState != 4) responseText = "<h3>Loading....</h3>";
				returnval=0;
	if(http.readyState == 4)
	{
		
		//alert(http.responseText);
		if(http.responseText==1)
		{	
			document.getElementById("clubURLinner").innerHTML='<TABLE cellspacing=0 cellpadding=0 width="100%" border=0 ><TBODY><TR><TD style="COLOR:#ff0000; "  align="center"><STRONG>Sorry! Club URL already exists.</STRONG></TD></TR></TBODY></TABLE>';
		}
		else
		{
			document.getElementById("clubURLinner").innerHTML='<TABLE cellspacing=0 cellpadding=0 width="100%" border=0 ><TBODY><TR><TD style="COLOR:#009900; " align="center"><STRONG>Congratulation! You can register with this club URL.</STRONG></TD></TR></TBODY></TABLE>';
		}
		/*if(responseText == '<TABLE cellspacing=0 cellpadding=0 width="100%" border=0 ><TBODY><TR><TD style="COLOR:#ff0000; " align=left><STRONG>Congratulation! You can register with this club URL.</STRONG></TD></TR></TBODY></TABLE>' )
		{
			document.getElementById("isExist").value =1 ;
			alert("aaaa");
		}
		else
		{
			isExist =0;
		}*/
		/*document.getElementById("clubURLinner").innerHTML= responseText;*/
		///document.getElementById("clubURLinner").innerHTML='<TABLE cellspacing=0 cellpadding=0 width="100%" border=0 ><TBODY><TR><TD style="COLOR:#ff0000; " align=left><STRONG>Congratulation! You can register with this club URL.</STRONG></TD></TR></TBODY></TABLE>';
    }

}
function sendReqBut(serverFileName) 
{	
	http.open('get', serverFileName);
	http.onreadystatechange = handleResponseBut;
    http.send(null);
}
function handleResponseBut() 
{
	//alert(clubobj);
	if(http.readyState != 4) responseText = "<h3>Loading....</h3>";
	if(http.readyState == 4)
	{
		
		if(http.responseText==1)
		{	
			alert("Club URL already exits.");
			document.getElementById('cluburl').focus();
			document.getElementById("clubURLinner").innerHTML='<TABLE cellspacing=0 cellpadding=0 width="100%" border=0 ><TBODY><TR><TD style="COLOR:#ff0000; " align=left><STRONG>Sorry! Club URL already exists.</STRONG></TD></TR></TBODY></TABLE>';
			return false;
		}
		else
		{
				document.addclub.submit();
				return true;
		}
    }

}