//variables used to create object for keyboard entry validation
var keybYN = new keybEdit('yn','Valid values are \'Y\' or \'N\'.');
var keybNumeric = new keybEdit('01234567890','Numeric input only.');
var keybAlpha = new keybEdit('abcdefghijklmnopqurstuvwxyz ','Alpha input only.');
var keybAlphaNumeric = new keybEdit('abcdefghijklmnopqurstuvwxyz01234567890 ','Alpha-numeric input only.');
var keybDecimal = new keybEdit('01234567890.','Decimal input only.');
var keybDate =  new keybEdit('01234567890/','Date input only');
var keybSQL = new keybEdit('abcdefghijklmnopqurstuvwxyz01234567890!@#$^-_`~+\\[]{}:<>,./ ','Invalid Character Input');;
var keybYNNM = new keybEdit('yn');
var keybNumericNM = new keybEdit('01234567890');
var keybAlphaNM = new keybEdit('abcdefghijklmnopqurstuvwxyz ');
var keybAlphaNumericNM = new keybEdit('abcdefghijklmnopqurstuvwxyz 01234567890');
var keybDecimalNM = new keybEdit('01234567890.');
var keybDateNM = new keybEdit('01234567890/');
var keybSQLNM = new keybEdit('abcdefghijklmnopqurstuvwxyz01234567890!@#$^-_`~+\\[]{}:<>,./ ');;

function keybEdit(strValid, strMsg) {
    var reWork = new RegExp('[a-z]','gi');		//	Regular expression\

    if(reWork.test(strValid))
        this.valid = strValid.toLowerCase() + strValid.toUpperCase();
    else
        this.valid = strValid;

    if((strMsg == null) || (typeof(strMsg) == 'undefined'))
        this.message = '';
    else
        this.message = strMsg;

    this.getValid = keybEditGetValid;
    this.getMessage = keybEditGetMessage;
    
    function keybEditGetValid() {
        return this.valid.toString();
    }
    
    function keybEditGetMessage() {
        return this.message;
    }
}

//this function uses the above opjects and variables for keyboard entry validation
// call with onkeypress='editKeyBoard(this,keybSQL)' event.
void function editKeyBoard(objForm, objKeyb) {
    strWork = objKeyb.getValid();
    strMsg = '';							// Error message
    blnValidChar = false;					// Valid character flag

    // Part 1: Validate input
    if(!blnValidChar)
        for(i=0;i < strWork.length;i++)
            if(window.event.keyCode == strWork.charCodeAt(i)) {
                blnValidChar = true;

                break;
            }

    // Part 2: Build error message
    if(!blnValidChar) {
        if(objKeyb.getMessage().toString().length != 0)
            alert('Error: ' + objKeyb.getMessage());

        window.event.returnValue = false;		// Clear invalid character
        objForm.focus();						// Set focus
    }
}

void function HOSIGNUP(where)
{
	if(document.getElementById("signup_name").value == "")
	{
		alert("Signup Name is a required Field.");
		document.getElementById("signup_name").focus();
	}
	else if(document.getElementById("signup_email").value == "")
	{
		alert("Signup Email is a required Field.");
		document.getElementById("signup_email").focus();
	}
	else
	{
		document.getElementById("perform").value = "signup";
		document.atlatldemo.target = "atlatldemo";
	    document.atlatldemo.action = "http://demo.consumerarts.com/HoDemoLink.jsp";
		document.atlatldemo.submit();
		document.atlatldemo.target = "_self";
	}
}

void function HOLOGIN()
{
	if(document.getElementById("login_name").value == "")
	{
		alert("Login Name is a required Field.");
		document.getElementById("login_name").focus();
	}
	else if(document.getElementById("login_password").value == "")
	{
		alert("Login password is a required Field.");
		document.getElementById("login_password").focus();
	}
	else
	{
		document.getElementById("perform").value = "login";
		document.atlatldemo.target = "atlatldemo";
	    document.atlatldemo.action = "http://demo.consumerarts.com/HoDemoLink.jsp";
		document.atlatldemo.submit();
		document.atlatldemo.target = "_self";
	}
}
void function AUTOSIGNUP(where)
{
	if(document.getElementById("signup_name").value == "")
	{
		alert("Signup Name is a required Field.");
		document.getElementById("signup_name").focus();
	}
	else if(document.getElementById("signup_email").value == "")
	{
		alert("Signup Email is a required Field.");
		document.getElementById("signup_email").focus();
	}
	else
	{
		document.getElementById("perform").value = "signup";
		document.atlatldemo.target = "atlatldemo";
	    document.atlatldemo.action = "http://demo.consumerarts.com/autodemo/AutoDemoLink.jsp";
		document.atlatldemo.submit();
		document.atlatldemo.target = "_self";
	}
}

void function AUTOLOGIN()
{
	if(document.getElementById("login_name").value == "")
	{
		alert("Login Name is a required Field.");
		document.getElementById("login_name").focus();
	}
	else if(document.getElementById("login_password").value == "")
	{
		alert("Login password is a required Field.");
		document.getElementById("login_password").focus();
	}
	else
	{
		document.getElementById("perform").value = "login";
		document.atlatldemo.target = "atlatldemo";
	    document.atlatldemo.action = "http://demo.consumerarts.com/autodemo/AutoDemoLink.jsp";
		document.atlatldemo.submit();
		document.atlatldemo.target = "_self";
	}
}
void function GOPAGE(where)
{
	if(where == "http://4.18.167.242/forms/Home.jsp?UserName=auser1&Password=auser1" ||
	   where == "http://demo.consumerarts.com/MainMenuServlet.jrun?username=demo&password=demo" ||
	   where == "http://www.consumerarts.com/AtlatlForms/workerscomp/demo/WorkersComp.jsp")
	{
		document.atlatldemo.method = "POST";
		document.atlatldemo.target = "NEW";
	}
	else
	{
		document.atlatldemo.method = "GET";
		document.atlatldemo.target = "_self";
	}
	document.atlatldemo.action = where;
	document.atlatldemo.submit();
	document.atlatldemo.method = "POST";
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
function openWin(URL) {
	aWindow=window.open("","toolbar=no,width=300,height=375,status=no,menubar=no,scrollbars=yes,resizable=no");
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
