function validateForm()
{
	if (document.form1.orgName.value == '')
	{
		alert('Please enter your Organizatioin Name');
		document.form1.orgName.focus();
		return false;
	}
	
	if (document.form1.addr1.value == '')
	{
		alert('Please enter your Address');
		document.form1.addr1.focus();
		return false;
	}

	if (document.form1.city.value == '')
	{
		alert('Please enter your City');
		document.form1.city.focus();
		return false;
	}

	if (document.form1.state.value == '')
	{
		alert('Please enter your State');
		document.form1.state.focus();
		return false;
	}

	if (document.form1.zip.value == '')
	{
		alert('Please enter your Zip Code');
		document.form1.zip.focus();
		return false;
	}

	return true;
}
function validateRegForm_x()
{
	// Registrant email
	//
	var emailID=document.regForm.email;
	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("Please enter a valid email address");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false)
	{
		alert("Please enter a valid email address");
		emailID.focus();
		return false;
	}
	//
	// Password
	//
	var pswd=document.regForm.pwd;
	var pstr = pswd.value;
	if (pswd.value == '' || (pstr.length < 5) || (pstr.length > 12))
	{	alert('Please choose a password between 5 and 12 characters');
		pswd.focus();
		return false;
	}
	return true;
}
function validateRegForm()
{
	// Registrant email
	//
	var emailID=document.regForm.email;
	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("Please enter a valid email address");
		emailID.focus();
		return false;
	}

	//
	// Password
	//
	var pswd=document.regForm.pwd;
	var pstr = pswd.value;
	if (pswd.value == '' || (pstr.length < 5) || (pstr.length > 12))
	{	alert('Please choose a password between 5 and 12 characters');
		pswd.focus();
		return false;
	}
	//
	// Org
	//
	var val_orgID = getElementValue(document.forms['regForm'].elements['sel_org']);
	if (val_orgID == 0)
	{	alert("Please select an Organization.");
		return false;
	}
	//
	// City
	//
	var city=document.regForm.city;
	if ((city.value==null)||(city.value==""))
	{
		alert("Please enter your city");
		city.focus();
		return false;
	}
	//
	// State
	//
	var state=document.regForm.state;
	if ((state.value==null)||(state.value==""))
	{
		alert("Please enter your state");
		state.focus();
		return false;
	}
	return true;
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false;
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    return false;
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false;
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    return false;
		 }
		 if (str.indexOf(" ")!=-1){
		    return false;
		 }
 		 return true;					
}

function getElementValue(formElement)
{
	if(formElement.length != null) var type = formElement[0].type;
	if((typeof(type) == 'undefined') || (type == 0)) var type = formElement.type;

	switch(type)
	{
		case 'undefined': return;

		case 'radio':
			for(var x=0; x < formElement.length; x++) 
				if(formElement[x].checked == true)
			return formElement[x].value;

		case 'select-multiple':
			var myArray = new Array();
			for(var x=0; x < formElement.length; x++) 
				if(formElement[x].selected == true)
					myArray[myArray.length] = formElement[x].value;
			return myArray;

		case 'checkbox': return formElement.checked;
	
		default: return formElement.value;
	}
}
