
//Hide status bar msg II script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use

function hidestatus(){
window.status=''
return true
}

if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

document.onmouseover=hidestatus
document.onmouseout=hidestatus

function ValidateLength(ElementName,DisplayName, MinLength)
{
	var sValue;
	try
	{
		sValue=frmMain.elements(ElementName).value;
	}
	catch (ex)
	{
		alert("Error: " + ElementName );
		sValue = "";
	}

	if (sValue.length < MinLength )
	{
		alert(DisplayName + ' must be longer than ' + MinLength + ' characters.');
		bRetVal=false;
	}
	else
	{
		bRetVal=true;
	}
	
	return bRetVal;
}

function ValidateNonZeroLengthString(ElementName,DisplayName)
{
	sValue=frmMain.elements(ElementName).value;
	
	if (sValue.length==0)
	{
		frmMain.elements(ElementName).focus();
		alert('Input ' + DisplayName + '!');
		bRetVal=false;
	}
	else
	{
		bRetVal=true;
	}
	
	return bRetVal;
}

function ValidateUserid()
{
	bRetVal=true;

	if (ValidateNonZeroLengthString('userid','User ID'))
	{
		if (ValidateLength('userid', 'User ID', 3))
		{
			if (ValidateCharacters(frmMain.elements('userid').value)==true) {
				if (ValidateEmail(frmMain.elements('userid').value)==true) {
					bRetVal=true;
				} else {
					frmMain.elements('userid').focus();
					alert('Wrong email format.');
				}
			} else {
				frmMain.elements('userid').focus();
				alert('Only a-z, 0-9 or \'_\' allowed in userid field..');
				bRetVal=false;
			}
		}
	}
	else
	{
		bRetVal=false;
	}
	
	return bRetVal;
}

function ValidatePassword()
{
	bRetVal=true;

	if (ValidateNonZeroLengthString('passwd','Password'))
	{
		if (ValidateCharacters(frmMain.elements('passwd').value)==false)
		{	
			frmMain.elements('password').focus();
			alert('Only a-z, 0-9 or \'_\' allowed in password field..');		
			bRetVal=false;
		}
	}
	else
	{
		bRetVal=false;
	}

	return bRetVal;
}

function ValidateCharacters(Value)
{
	bRetVal=true;

	for (i=0;i<Value.length;i++) 
	{
		if ('abcdefghijklmnopqrstuvwxyz1234567890_-.@'.lastIndexOf(Value.substr(i,1))==-1)
		{	
			bRetVal=false;
		}
	}
	
	return bRetVal;
}

function ValidateEmail(Value)
{
	bRetVal=false;

	for (i=0;i<Value.length;i++) 
	{
		if ('@.'.lastIndexOf(Value.substr(i,1)) > 0 )
		{	
			bRetVal=true;
		}
	}
	
	return bRetVal;
}

function ValidateNumeric(ElementName,DisplayName,PositiveOnly,IntegerOnly)
{
	bRetVal=false;

	dValue=parseFloat(frmMain.elements(ElementName).value);
	iValue=parseInt(frmMain.elements(ElementName).value);

	if (isNaN(dValue))
	{
		frmMain.elements(ElementName).focus();
		alert(DisplayName + ' must be numeric!');
	}
	else
	{
		if (PositiveOnly && dValue<0)
		{
			frmMain.elements(ElementName).focus();
			alert(DisplayName + ' must be positive!');
		}
		else
		{
			if (IntegerOnly && (parseFloat(iValue)!=dValue))
			{
				frmMain.elements(ElementName).focus();
				alert(DisplayName + ' must be an integer!');
			}
			else
			{
				bRetVal=true;
			}
		}
	}

	return bRetVal;
}

function ValidateDatetype(Value)
{
	bRetVal=true;

	for (i=0;i<Value.length;i++) 
	{
		if ('1234567890/'.lastIndexOf(Value.substr(i,1))==-1)
		{	
			bRetVal=false;
		}
	}
	
	return bRetVal;
}

function getCheckedValue(radioObj) {
	if(!radioObj) {
		return "";
	}
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function getSelectedValue(selectObj) {
	if(!selectObj) {
		return "";
	}
	var selectLength = selectObj.length;
	if(selectLength == undefined)
		if(selectObj.selected)
			return selectObj.value;
		else
			return "";
	for(var i = 0; i < selectLength; i++) {
		if(selectObj[i].selected) {
			return selectObj[i].value;
		}
	}
	return "";
}
