var form;
var http;
var on_event;
function checkCustomAliasExist(frm, objId, act)
{
	if(Trim(objId) != 0)
	{
		on_event = act;
		var PostParam = "";
		form = frm;
		PostParam = "objId="+objId;
		var url = site_url+"ajax_custom_alias_check.php?";
		var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
		url = url+PostParam;
		//alert(url);
		document.getElementById('loading_img_id').style.display = "";
		if (window.XMLHttpRequest) 
		{
			http = new XMLHttpRequest();
			http.onreadystatechange = handleHttpResponse_status;
			http.open("GET", url, true);
			http.setRequestHeader("Content-Type", contentType);
			http.send(null);
			status = true;
			// ActiveX XMLHttpRequest object
		} 
		else if (window.ActiveXObject) 
		{
			http = new ActiveXObject("Microsoft.XMLHTTP");
			if (http) 
			{
				http.onreadystatechange = handleHttpResponse_status;
				http.open("GET", url, true);
				http.setRequestHeader("Content-Type", contentType);
				http.send(null);
				status = true;
			}
		}
		return false;
	}
	else
	{
		if(act == "submit")
			frm.submit();
	}
}
function handleHttpResponse_status() 
{
	if (http.readyState == 4) 
	{	
      	//isWorking = false;
		//alert(http.responseText);
    	if (http.responseText.indexOf('invalid') == -1) 
		{
    		var xmlDocument = http.responseXML; 
			//alert(http.responseText);
			// alert(xmlDocument.getElementsByTagName('exist'));
			var objIdvar = xmlDocument.getElementsByTagName('exist').item(0).firstChild.data;

			//alert(objIdvar);
			document.getElementById('loading_img_id').style.display = "none";
			if(objIdvar != 0)
			{
				document.getElementById('alisa_inuse').style.display = "";
				//alert("Alias in Use! To use a randomly generated alias, simply leave the field blank");
				document.frmimage.vAlias.value = "";
				//document.frmimage.vAlias.focus();
				return false;
			}
			else
			{
				document.getElementById('alisa_inuse').style.display = "none";
				if(on_event == "submit")
					form.submit();
			}
		}
	}	
}