/***** Add Register Validation - starts here *****/
/***** Create the XMLHttp object depends on the browser *****/
var argumentSeparator = "&";
var queryStringSeparator = "?";
 function createAJAX() 
 {
	try{ 
		return new XMLHttpRequest();
	}
	catch(e){
		  try{ 
			return new ActiveXObject("MSXML3.XMLHTTP") 
		}catch(e){}
		try{ 
			return new ActiveXObject("MSXML2.XMLHttp.5.0") 
		}catch(e){}
		try{ 
			  return new ActiveXObject("MSXML2.XMLHttp.4.0") 
		}catch(e){}
		try{ 
			  return new ActiveXObject("MSXML2.XMLHTTP.3.0") 
		}catch(e){}
		try{ 
			  return new ActiveXObject("Msxml2.XMLHTTP") 
		}catch(e){}
		try{ 
			  return new ActiveXObject("Microsoft.XMLHTTP") }
		catch(e){
			  	alert("AJAX is not supported. Could not find an XMLHttpRequest alternative.");
		}
    }
}

/***** Set the URL parameters using this function *****/	
/***** Create the URL with all the parameters using this function *****/
function createAJAXURLString(arrayobject)
{
	URLString="";
	arrayobject["rndval"] = Array(new Date().getTime(), false);
	urlstringtemp = new Array();
	for (key in arrayobject) 
	{ 
		urlstringtemp[urlstringtemp.length] = key + "=" + arrayobject[key][0];
	}
		
	URLString += urlstringtemp.join(argumentSeparator);
	return URLString;
}
/***** If the browser doesn't support AJAX *****/

function AJAXCODE(custid,clientid,priomotionid)
{
	var variable = new Object();	
	
	xmlhttp3 =  createAJAX();
	
	variable["custid"] = Array(escape(custid), false);
	variable["client_id"] = Array(escape(clientid), false);
	variable["priomotionid"] = Array(escape(priomotionid), false);
	
	requestFile = "embed_code_action.php";
	URLString1 = "";
	URLString1 =createAJAXURLString(variable);
	if (xmlhttp3)
	{
		totalurlstring = requestFile + queryStringSeparator + URLString1;	
		xmlhttp3.open("POST", totalurlstring, true);
		//Send the proper header information along with the request
		xmlhttp3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp3.onreadystatechange = showMessage3;
		xmlhttp3.send(URLString1);
	}
		
	return false;
}
function showMessage3()
{
	if(xmlhttp3.readyState==4) 
	{
		if (xmlhttp3.status==200)
		{
			var response3 = xmlhttp3.responseText; 	
			//SetBlankofManageGroupsControls();
			AjaxMessage=response3; // New code	
			if(AjaxMessage=="Session-Expired")
			{
				window.location.reload();
			}
			else
			{
				if(AjaxMessage=="1")
				{
					document.getElementById('main_tab').style.display = "none";
				}
				else
				{
					if(document.getElementById('code_td')!=null)
					{
						document.getElementById('code_td').innerHTML=AjaxMessage;
					}
				}				
			}
		}
		else // Show Errors - Accordingly Error Status Code
		{		
			ShowStatusError(xmlhttp3.status)
		}
	}
}
/*****Manage Group Validation - ends here *****/
