function doHref(myObj)
{

        var myHref = myObj.href;
	if (document.forms['mwjreg'].TestMode.value == "1")
	{
		if (myHref.indexOf("?",0) == -1) 
		{
			myObj.href = myHref + "?t=1";
		}
		else
		{
			myObj.href = myHref + "&t=1";
		}
	}
}

function formCheck(mode)
{
	if (mode == "reg")
	{
		if (document.forms['mwjreg'].EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
	        	document.forms['mwjreg'].EMAIL_ADDRESS.focus();
			return false;
		}
                if (!validEmail(document.forms['mwjreg'].EMAIL_ADDRESS.value))
		{
			alert("You have entered an invalid email address. Please re-enter it.");
			document.forms['mwjreg'].EMAIL_ADDRESS.focus();
			return false;
		}

		if (document.forms['mwjreg'].FNAME.value == "")
		{
			alert("Please specify your First Name.");
	        	document.forms['mwjreg'].FNAME.focus();
			return false;
		}
		if (document.forms['mwjreg'].LNAME.value == "")
		{
			alert("Please specify your Last Name.");
	        	document.forms['mwjreg'].LNAME.focus();
			return false;
		}

		//if (!CheckboxChecked('mwjreg','WEB_PRODUCTS'))
		//{
		//	alert("Please check products.");
		//	return false;
		//}

	}

	if (mode == "login")
	{
		if (document.forms['mwjreg'].EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
	        	document.forms['mwjreg'].EMAIL_ADDRESS.focus();
			return false;
		}
                if ((document.forms['mwjreg'].EMAIL_ADDRESS.value != "") && (!validEmail(document.forms['mwjreg'].EMAIL_ADDRESS.value)))
		{
			alert("You have entered an invalid email address. Please re-enter it.");
			document.forms['mwjreg'].EMAIL_ADDRESS.focus();
			return false;
		}

		if (document.forms['mwjreg'].PASSWORD.value == "")
		{
			alert("Please specify your Password.");
	        	document.forms['mwjreg'].PASSWORD.focus();
			return false;
		}
	}

	if (mode == "password")
	{
		if (document.forms['mwjreg'].EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
	        	document.forms['mwjreg'].EMAIL_ADDRESS.focus();
			return false;
		}
                if ((document.forms['mwjreg'].EMAIL_ADDRESS.value != "") && (!validEmail(document.forms['mwjreg'].EMAIL_ADDRESS.value)))
		{
			alert("You have entered an invalid email address. Please re-enter it.");
			document.forms['mwjreg'].EMAIL_ADDRESS.focus();
			return false;
		} 
	}

	if (mode == "editprofile")
	{
		if (document.forms['mwjreg'].NEW_EMAIL_ADDRESS.value == "")
		{
			alert("Please specify your E-mail Address.");
	        	document.forms['mwjreg'].NEW_EMAIL_ADDRESS.focus();
			return false;
		}
                if ((document.forms['mwjreg'].NEW_EMAIL_ADDRESS.value != "") && (!validEmail(document.forms['mwjreg'].NEW_EMAIL_ADDRESS.value)))
		{
			alert("You have entered an invalid email address. Please re-enter it.");
			document.forms['mwjreg'].NEW_EMAIL_ADDRESS.focus();
			return false;
		}
	}

	if (mode == "chngpwd")
	{
		if (document.forms['mwjreg'].PASSWORD.value == "")
		{
			alert("Please enter your password.");
	        	document.forms['mwjreg'].PASSWORD.focus();
			return false;
		}

		if (document.forms['mwjreg'].PASSWORD1.value == "")
		{
			alert("Please re-enter your password.");
	        	document.forms['mwjreg'].PASSWORD1.focus();
			return false;
		}

		if (document.forms['mwjreg'].PASSWORD.value != document.forms['mwjreg'].PASSWORD1.value)
		{
			alert("Please repeat your input.");
	        	document.forms['mwjreg'].PASSWORD.focus();
			return false;
		}

	}

	if (mode == "activate")
	{
	}

	return true;
}

function checkDropdown(selectBox)
{
	if (selectBox.selectedIndex == "0")
	{
		return false;
	}
	else
	{
		return true;
	}
}

function CheckUnselects(radioItem)
{
	for (i=0;i<radioItem.length;i++)
	{
		if (radioItem[i].checked)
		{
			return true;
		}//end if
	}//end for
	return false;
}
function CheckedRadioValue(radioItem)
{
	for (i=0;i<radioItem.length;i++)
	{
		if (radioItem[i].checked)
		{
			return radioItem[i].value;
		}//end if
	}//end for
	return false;
}

function CheckboxChecked(formindex, CheckBoxName)
{
var ChLength = CheckBoxName.length + 1;
var vName = CheckBoxName + "-";

var CBindex = 0;
	for ( i=0; i < document.forms[formindex].elements.length; i++)
	{
		if (document.forms[formindex].elements[i].type == "checkbox")
		{
			if (document.forms[formindex].elements[i].name.substring(0,ChLength)==vName)
			{
				if (CBindex==0) {CBindex = i;}
				if (document.forms[formindex].elements[i].checked)
				{
					return true;
					break;
				}
			}
		}

	}
	document.forms[formindex].elements[CBindex].focus();
	return false;
}
function validEmail(email)
{
	invalidchars = " /:;"

	if(email == "")
	{			//checks to see if blank field
		return false;
	}
			
	for(i=0;i<invalidchars.length;i++)
	{ //checks for invalid chars
			
		badchars = invalidchars.charAt(i);
			
		if(email.indexOf(badchars,0)!= -1)
		{
			return false;
		}
	}
	
	atPos = email.indexOf("@",1)  //holds position of "@"
			
	if(atPos == -1) 
	{	//checks to see if "@" present
		return false;
	}
							
	if(email.indexOf("@",atPos+1) != -1) 
	{ //checks for second "@"
		return false;
	}
							
	periodPos = email.indexOf(".",atPos) //holds position of "."
			
	if(periodPos == -1)
	{ //checks for presence of "."
		return false;
	}
	if(periodPos+3 > email.length)
	{//makes sure at least two chars after the period
		return false;
	}
	return true;
}
