﻿function validateEmail(elementValue){      
   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
   return emailPattern.test(elementValue);

}
 
 function checkPasswordLength(source, args) {
     args.IsValid = args.Value.length >= 5;
 }
 function validatePasswords(password, confirmPassword, source, args) {

     if (password.length == 0) {
         args.IsValid = false;
         source.innerHTML = "Please enter a password"
     } else if (password.length > 0) {
         args.IsValid = false;

         if (password.length < 5) {
             args.IsValid = false;
             source.innerHTML = 'The password must be at least 5 characters long.';
         } else {
         if (confirmPassword.length > 0) {

             if (password != confirmPassword) {
                     args.IsValid = false;
                     source.innerHTML = 'The passwords do not match.';
                 }
                 else {
                     args.IsValid = true;
                 }
             }
             else {
                 args.IsValid = true;
                 
                 //source.style.visibility = 'hidden';
             }
         }
     }
     if (args.IsValid)
         source.style.display = 'hidden';
     else
        source.style.display = 'none';
 }

 //**** Checks that a checbox is selected  *******
 //To Call:  write a method on the page, passing the checkbox itself, and the CustomValidator args object
 function validateCheckBox(checkbox, args) {
     args.IsValid = checkbox.checked;
 }

 //**** Validates a FCK editor has text in it *****
 //To Call: pass the id of the FckEditor, and the CustomValidator args object
 function validateFck(fckID, args) {
     var oEditor = FCKeditorAPI.GetInstance(fckID);
     var text = oEditor.GetXHTML(true);

     if (text != null && text.length > 0) {
         args.IsValid = true;
     }
     else {
         args.IsValid = false;
     }
 }
 
 function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

function showWait() {
    document.getElementById('spinnerDiv').className = "ProgressVisible";
}

