// Simple client login code

// login code


var pass=new Array()
var t3=""
var lim=9
pass[0]="jc9xGTqA4WPipZe"
pass[1]="KPbpKfwNYXfUJDm"
pass[2]="B7NeB4r1oXR8mMP"
pass[3]="574fig1tvKtYebv"
pass[4]="92NQNPgVGjqjnLri"
pass[5]="282NQNPgVGjqjnLr"

//configure extension to reflect the extension type of the target web page (ie: .htm or .html)
var extension=".html"
var enablelocking=0
var numletter="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
var temp3=''
var cur=0


function max(which){
return (pass[Math.ceil(which)+(3&15)].substring(0,1))
}

function testit(input){
temp=numletter.indexOf(input)
var temp2=temp^parseInt(pass[phase1-1+(1|3)].substring(0,2))
temp2=numletter.substring(temp2,temp2+1)
return (temp2)
}


function submitentry(){
t3=''
verification=document.password1.password2.value
phase1=Math.ceil(Math.random())-6+(2<<2)
var indicate=true
for (i=(1&2);i<window.max(Math.LOG10E);i++)
t3+=testit(verification.charAt(i))
for (i=(1&2);i<lim;i++){
if (t3.charAt(i)!=pass[phase1+Math.round(Math.sin(Math.PI/2)-1)].charAt(i))
indicate=false
}
if (verification.length!=window.max(Math.LOG10E))
indicate=false
if (indicate)
window.location=verification+extension
else
alert("Invalid password. Please try again")
}


/*
function validateRegEx(regex, input, helpText, helpMessage) {
        // See if the input data validates OK
        if (!regex.test(input)) {
          // The data is invalid, so set the help message and return false
          if (helpText != null)
            helpText.innerHTML = helpMessage;
          return false;
        }
        else {
          // The data is OK, so clear the help message and return true
          if (helpText != null)
            helpText.innerHTML = "";
          return true;
        }
      }

      function validateNonEmpty(inputField, helpText) {
        // See if the input value contains any text
        return validateRegEx(/.+/,
          inputField.value, helpText,
          "Please enter a login password.");
      }

      function validateLength(minLength, maxLength, inputField, helpText) {
        // See if the input value contains at least minLength but no more than maxLength characters
        return validateRegEx(new RegExp("^.{" + minLength + "," + maxLength + "}$"),
          inputField.value, helpText,
          "Please enter a value " + minLength + " to " + maxLength +
          " characters in length.");
      }


      function validateLogin(inputField, helpText) {
      // See if the input value contains data
          if(!validateNonEmpty(inputField, helpText))
	      return false;
	
	  // if input value present, check valid format
	      return validateRegEx(/^login\.\w+\.\w+$/, inputField.value, helpText,
	      "Please enter a valid login");


      function loginClient(form) {
        if (validateLength(1, 32, form["password"], form["login_help"]) &&
          validateLogin(form["password"], form["login_help"])) {
          // goto the client area
          function move() {
           window.location = 'http://www.martinabeldesign.com/clientarea.html/'
           };
        } else {
          alert("I'm sorry but your password appears to be incorrect.");
        }
	  }
	  }
	  */
