function validateFormOnSubmit() {
var reason = "";
var doc = document.forms[0];
  reason += validateUsername(doc.WClogin1_txtUsername);
  reason += validatePassword(doc.WClogin1_txtPassword);
  //reason += validateEmail(theForm.email);'
  //reason += validatePhone(theForm.phone);
  //reason += validateEmpty(theForm.from);
      
  if (reason != "") {
    alert("Please check the information below:\n" + reason);
    return false;
  }

  //alert("All fields are filled correctly");
 // return false;
}

function validateEmpty(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'LightBlue'; 
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}
function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = 'Red'; 
        error = "Email Address missing.\n";
   // } else if (illegalChars.test(fld.value)) {
   //     fld.style.background = 'Red'; 
   //     error = "The Username contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "") {
        fld.style.background = 'Red';
        error = "Password missing.\n";
    } else if ((fld.value.length < 1) || (fld.value.length > 30)) {
        error = "The Password is the wrong length. \n";
        fld.style.background = 'Red';
    } else if (illegalChars.test(fld.value)) {
        error = "The Password contains illegal characters.\n";
        fld.style.background = 'Red';
   // } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) {
   //     error = "The password must contain at least one numeral.\n";
   //     fld.style.background = 'Red';
    } 
    
    else {
        fld.style.background = 'White';
    }
   return error;
}  
function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}
function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Yellow';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

   if (fld.value == "") {
        error = "You didn't enter a phone number.\n";
        fld.style.background = 'Yellow';
    } else if (isNaN(parseInt(stripped))) {
        error = "The phone number contains illegal characters.\n";
        fld.style.background = 'Yellow';
    } else if (!(stripped.length == 10)) {
        error = "The phone number is the wrong length. Make sure you included an area code.\n";
        fld.style.background = 'Yellow';
    }
    return error;
}

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=yes,status=no,menubar=yes,toolbar=yes,resizable=yes';
win=window.open(mypage,myname,settings);}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);

else 
countfield.value = maxlimit - field.value.length;
}



function CenterPopup(location, window_name, toolbar, locationbar, directoriesbar, statusbar, menubar, scrollbars, resizable, iwidth, iheight) 
{ 
if (document.all) 
{ 
var xMax = screen.width, yMax = screen.height 
} 
else if (document.layers) 
{ 
var xMax = window.outerWidth, yMax = window.outerHeight 
} 
else 
{ 
var xMax = 640, yMax=480; 
} 
if (xMax < iwidth) 
{ 
iwidth = xMax, iheight = yMax 
} 
var xOffset = (xMax - iwidth)/2, yOffset = (yMax - iheight - 75)/2; 
var options = '' 
if (toolbar == 'True') 
{ 
var options = 'toolbar=yes' 
} 
else 
{ 
options = 'toolbar=no' 
} 
if (locationbar == 'True') 
{ 
options = options+', location=yes' 
} 
else 
{ 
options = options+', location=yes' 
} 
if (directoriesbar == 'True') 
{ 
options = options+', directories=yes' 
} 
else 
{ 
options = options+', directories=no' 
} 
if (statusbar == 'True') 
{ 
options = options+', status=yes' 
} 
else 
{ 
options = options+', status=no' 
} 
if (menubar == 'True') 
{ 
options = options+', menubar=yes' 
} 
else 
{ 
options = options+', menubar=yes' 
} 
if (scrollbars == 'True') 
{ 
options = options+', scrollbars=yes' 
} 
else 
{ 
options = options+', scrollbars=yes' 
} 
if (resizable == 'True') 
{ 
options = options+', resizable=yes' 
} 
else 
{ 
var options = options+', resizable=yes' 
} 
window.open(location, window_name, options+', width='+iwidth+', height='+iheight+', screenX='+xOffset+', screenY='+yOffset+', top='+yOffset+', left='+xOffset+''); 
} 

<!-- // load htmlarea
_editor_url = "/LA/htmlarea/";                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
  document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
  document.write(' language="Javascript1.2"></scr' + 'ipt>');  
} else { document.write('<script>function editor_generate() { return false; }</script>'); 
}
// -->
