/*
Form validation, how to implement it with the Adobe's error checking scripts.

function MM_validateForm() {
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } 
	

	errors += checkVerifyPassword (document.ownerForm.password.value, document.ownerForm.password2.value)
	errors += checkPassword (document.ownerForm.password.value)
	errors += checkUsername (document.ownerForm.username.value)
	
	if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }


*/


function checkVerifyPassword (strng1, strng2) {
var error = "";

	//check password matching
	if (strng1 != strng2) {
		error = '- your passwords do not match.\n'
	}
	

return error;
}


// password - between 5-25 chars

function checkPassword (strng) {
var error = "";

    var illegalChars = /[\W_]/; // allow only letters and numbers
    
    if ((strng.length < 4) || (strng.length > 25)) {
       error = "- the password is the wrong length (4-25 characters).\n";
    }
    else if (illegalChars.test(strng)) {
      error = "- the password contains illegal characters.\n";
    } 
  //  else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
  //     error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";
  //  }  
return error;    
}    


// username - 4-10 chars, uc, lc, and underscore only.

function checkUsername (strng) {
var error = "";

    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 25)) {
       error = "- the username is the wrong length (4-25 characters).\n";
    }
    else if (illegalChars.test(strng)) {
    error = "- the username contains illegal characters.\n";
    } 
return error;
}       


//various utility functions, thanks w3schools!
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "False";
}