
//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 = document.getElementById(ElementName).value;
	}
	catch (ex)
	{
		alert("Error: " + ElementName + ": " + ex );
		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=document.getElementById(ElementName).value;
	
	if (sValue.length==0)
	{
		document.getElementById(ElementName).focus();
		alert('Input ' + DisplayName + '!');
		bRetVal=false;
	}
	else
	{
		bRetVal=true;
	}
	
	return bRetVal;
}

function ValidateUserid()
{
	bRetVal=true;

	if (ValidateNonZeroLengthString('join_id','User ID'))
	{
		if (ValidateLength('join_id', 'User ID', 3))
		{
			if (ValidateCharacters(document.getElementById('join_id').value)==true) {
				if (ValidateEmail(document.getElementById('join_id').value)==true) {
					bRetVal=true;
				} else {
					document.getElementById('join_id').focus();
					alert('Wrong email format.');
				}
			} else {
				document.getElementById('join_id').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(document.getElementById('passwd').value)==false)
		{	
			document.getElementById('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(document.getElementById(ElementName).value);
	iValue=parseInt(document.getElementById(ElementName).value);

	if (isNaN(dValue))
	{
		document.getElementById(ElementName).focus();
		alert(DisplayName + ' must be numeric!');
	}
	else
	{
		if (PositiveOnly && dValue<0)
		{
			document.getElementById(ElementName).focus();
			alert(DisplayName + ' must be positive!');
		}
		else
		{
			if (IntegerOnly && (parseFloat(iValue)!=dValue))
			{
				document.getElementById(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 "";
}
