
 hidehim = new String(" , "); 

function checkForm()
{document.forms[0].HideMe.value = hidehim; 
var Email = document.forms[0].Email.value;
var password = document.forms[0].password.value;
if ((!isEMailAddress(Email))   ) { 
  window.alert('Please Enter a Valid Value for E-mail Address in this format: you@somewhere.com');
  document.forms[0].Email.focus();
  return false; }
 else {  
if ((password == '')   ) { 
window.alert('Please Enter a Value for Password');
document.forms[0].password.focus();
return false; }
else {   
return true;}
}
} 

function isPhoneNumber(input) { 
var areaCode = input.substring(0,3); 
var dash1 = input.substring(3,4); 
var exchange = input.substring(4,7); 
var dash = input.substring(7,8); 
var line = input.substring(8,12); 
var plen = input.length; 
if ((isNaN(areaCode)) || (plen < 12) || (dash1 != "-") ||  ( dash != "-") || isNaN(line))
 { return false;  }
 else { return true;}
 } 

function isZipCode(input) { 
var ziplen = input.length;
if ((ziplen < 5) || ((ziplen > 5) && (ziplen < 10 )) ||(input.indexOf(".") > 1 ) || (input.indexOf(" ") > 1 ) || ((ziplen > 5) && (input.indexOf("-") < 1 )) ||(isNaN(input.replace("-","0"))))
{ return false;  }
 else { return true;}
 } 


function isEMailAddress(input) {
var emailLen = input.length;
if ((emailLen < 7) || (input.indexOf("@") < 1 ) ||(input.indexOf(".") < 1 ) || (input.indexOf(",") > 1 ) || (input.indexOf("'") > 1 ) || (input.indexOf('"') > 1 ) || (input.indexOf(";") > 1 ) || (input.indexOf(":") > 1 ) || (input.indexOf("*") > 1 ) || (input.indexOf("%") > 1 ) || (input.indexOf("+") > 1 ) || (input.indexOf(" ") > 1 ))
{ return false;  }
 else { return true;}
 } 

function checkName(input, response)
{
if (response != '')
{
   if (response != '1^') {
	message   = document.getElementById('nameCheckFailed');
	var activityCheckElements = response.split("^");
	var i = 0;
	while(activityCheckElements[i] != null) 
	{						
				var activityControlType = activityCheckElements[i];
				var activityFormElementName = activityCheckElements[i+1];
				var activityDisplayOrder = activityCheckElements[i+2];
				var activityValue = activityCheckElements[i+3];
				var activityText = activityCheckElements[i+4];
				i += 5;
				var posBracket = activityText.indexOf("<");
				if (posBracket > 0) 
				{
					activityText = activityText.substring(0,posBracket);
				}
				if((activityControlType == 2) || (activityControlType == 5))
				{
					var myControl = eval('document.getElementById("' + activityFormElementName + activityDisplayOrder + '")');
					if (myControl.checked == true)
					{
						alert("Sorry the capacity for "+ activityText +" has been exhausted. Kindly change your selection.");
						myControl.checked = false;
						myControl.focus();
					}
				}
				else if(activityControlType == 3) 
				{						
					var myControl = eval('document.forms[0].' + activityFormElementName  + '.options[document.forms[0].' + activityFormElementName  + '.selectedIndex].value');
					if(myControl == activityValue)
					{
						alert("Sorry the capacity for "+ activityText +" has been exhausted. Kindly change your selection.");
						var selectThis = eval('document.forms[0].'+ activityFormElementName);
						selectThis.selectedIndex = 0;
					} 
					}
			}
	}
}
else
{
	url  = 'PreSubmitcheck.aspx?site=rbs.ecommunique.com&q=' + input;
	loadXMLDoc(url);
}
}// end checkname
function processReqChange() 
{
if (req.readyState == 4)
{
	if (req.status == 200)
	{
		//alert("OK");
		//alert(req.responseText);
		var mystring = req.responseText;
		var listElements = mystring.split("|");
		var result = listElements[0];
		if(result != '') {
		checkName('',result);}
	} 
	else
	{
		alert("There was a problem retrieving the XML data:" + req.statusText);
	}
}
}// process request change
function handleResponse(mystring)
{
		var listElements = mystring.split("|");
		var result = listElements[0];
		if(result != '') {
		checkName('',result);}
}// handle response
var req;
function loadXMLDoc(url) 
{
	if (window.XMLHttpRequest) 
 { 
 req = new XMLHttpRequest();
	req.onreadystatechange = processReqChange;
	req.open("GET", url, true);
	req.send(null);
	}
	else if (window.ActiveXObject) 
 {
	req = new ActiveXObject("Microsoft.XMLHTTP");
	if (req) 
 {
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send("a");
	}
}
 else 
 { 
 document.getElementById("RSIFrame").src = "IFrameCheck.aspx?q=271";}
}

