function Inactive()
{
	alert("Login in failed.\r\nYour registration is pending.");
}

function WrongPassword()
{
	alert("Please double check your trader id and password.");
}

function LoginAlert()
{
	alert("This is a trade only section.\r\n Please log on to enter this section.");
}

function Login()
{
	id = frmLogin.userid.value;
	pw = frmLogin.passwd.value;
	if( id.length > 2 ) {
		if( pw.length >2 ) {
			frmLogin.action = "code_login.php";
			frmLogin.submit();
		} else {
			alert("Password must be longer than 3 characters!");
			frmLogin.passwd.focus();
		}
	}else {
		alert("User id must be longer than 3 characters!");
		frmLogin.userid.focus();
	}    
}

function Register()
{
	location.href = "register_form.php";
}

function Logout()
{
	location.href = "logout.php";
}

function ShowMenuProduct()
{
	w_menu.style.display = 'none';
	p_menu.style.display = 'inline';
}

function ShowMenuNew()
{
	p_menu.style.display = 'none';
	w_menu.style.display = 'inline';
}
function HideMenu()
{
	p_menu.style.display = 'none';
	w_menu.style.display = 'none';
}

function Support()
{
	frmMain.submit();
}

function SupportReset()
{
	frmMain.reset();
}

function ValidateLength(ElementName,DisplayName, MinLength)
{
	sValue=frmMain.elements(ElementName).value;
	
	if (sValue.length < MinLength )
	{
		alert(DisplayName + ' must be longer than ' + MinLength + ' characters.');
		bRetVal=false;
	}
	else
	{
		bRetVal=true;
	}
	
	return bRetVal;
}

function ValidatePassword()
{
	bRetVal=true;

	if (ValidateNonZeroLengthString('password','Password'))
	{
		if (ValidateCharacters(frmMain.elements('password').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 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 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 show_main(src)
{
	html = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width=617 height=240>";
    html = html + "<param name='movie' value='flash/" + src + ".swf' />";
	html = html + "<param name='quality' value='high' />";
	html = html + "<embed src='flash/" + src + ".swf' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=617 height=240></embed></object>";
	document.write(html);
}

function print_my_account()
{
	w_name = "my_account";
	url = "my_account_print.php";
	Width = 700;
	Height = 800;
	window_string = "toolbar=no,menubar=no,resizable=yes,scrollbars=yes, width=" + Width + ",height=" + Height;
	window.open(url,w_name,window_string);	
}