
 
  function resetAlerts(oarrInput){
    for (i=0; i < oarrInput.length; i++){
      errorNameToReset = oarrInput[i] + '_error';
      if (document.getElementById(errorNameToReset)) {
        document.getElementById(errorNameToReset).style.visibility = 'hidden';
      } else {
        alert("! Tamar Debug\r\r" + "Check document errors for: " + errorNameToReset)
      }
    }
    
   }
   
  function resetMessageAlerts(oarrInput){
    for (i=0; i < oarrInput.length; i++){
      errorNameToReset = oarrInput[i] + '_err_mess';
      if (document.getElementById(errorNameToReset)) {
        YAHOO.util.Dom.addClass(errorNameToReset,'hidden');
      } else {
        alert("! Tamar Debug\r\r" + "Check document errors for: " + errorNameToReset)
      }
    }
    
   }
 
  function checkMail(oStringToCheck){
    var mailError = 0;
    var charError = 0;
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.@";
    //alert('checkIllegalChars')
    for (n = 0; n < oStringToCheck.length; n++){
      //alert("checking: " + checkOK.indexOf(oStringToCheck.charAt(n)) + ", val: " + oStringToCheck.charAt(n));
      if (checkOK.indexOf(oStringToCheck.charAt(n)) == -1){
        charError++;
      }
    }

    if (charError > 0){
      return true;
    } 

    var atSymbol = oStringToCheck.indexOf('@');
    var period = oStringToCheck.lastIndexOf('.')
    if (atSymbol == -1 || period == -1 || period==oStringToCheck.length){
      mailError++;
    }
    if (mailError > 0) {
      return true;
    } else {
      return false;
    }
  }
 
 
 function checkRadio(oRadioToCheck){
    var radioError = 1
    for (r=0; r < oRadioToCheck.length; r++){
      if (oRadioToCheck[r].checked){
        radioError = 0;
        return;
      }
    }
    if (radioError) return true;
  }
  
  function checkNumber(oStringToCheck){
    var myNumber = Number(oStringToCheck.replace(/(,|\.|k)/g, ""));
    if (isNaN(myNumber)) return true;
  }
 
  function checkDay(oStringToCheck){
    var myNumber = Number(oStringToCheck)
    if (isNaN(myNumber) || myNumber <= 0 || myNumber > 31) return true;
  }
  
  function checkMonth(oStringToCheck){
    var myNumber = Number(oStringToCheck)
    if (isNaN(myNumber) || myNumber < 0 || myNumber > 12) return true;
  }
  
  function checkYear(oStringToCheck){
    var myNumber = Number(oStringToCheck)
    if (isNaN(myNumber) || myNumber < 00 || myNumber > 99) return true;
  }
  
  function checkFullYear(oStringToCheck){
    var myNumber = Number(oStringToCheck)
    if (isNaN(myNumber) || myNumber < 1900 || myNumber > 2010) return true;
  }

  function checkFullHouseYear(oStringToCheck){
    var myNumber = Number(oStringToCheck)
    if (isNaN(myNumber) || myNumber < 1500 || myNumber > 2010) return true;
  }

  function checkWeek(oStringToCheck){
    var myNumber = Number(oStringToCheck)
    if (isNaN(myNumber) || myNumber < 0 || myNumber > 52) return true;
  }
  

  function checkCreditCardNumber(oStringToCheck){
    var myNumber = Number(oStringToCheck.replace(/(\s)/g, ""));
    if (isNaN(myNumber)) return true;
  }

  function checkTotalNumber(string1, string2, string3){
    var myNumber1 = Number(string1.replace(/(,|\.)/g, ""));
    var myNumber2 = Number(string2.replace(/(,|\.)/g, ""));
    var myNumber3 = Number(string3.replace(/(,|\.)/g, ""));
    var total = myNumber1 + myNumber2 + myNumber3;
    if (total < 1) return true;
  }

  
  function checkFutureDate(day,month,year) {
    var today = new Date();
    var strToday = today.getDate();
    var strMonth = today.getMonth() + 1;
    var strYear = today.getYear();
    if (strYear < 1000) {
      strYear = strYear + 1900;
    }

    if (year < strYear) {
      return true;
    } else if (strYear == year) {
      if (month < strMonth) {
        return true;
      } else if (strMonth == month) {
        if (day < strToday) {
          return true;
        }
      }
    }

    return false;
  }

  function checkPastDate(day,month,year) {
    var today = new Date();
    var strToday = today.getDate();
    var strMonth = today.getMonth() + 1;
    var strYear = today.getYear();
    if (strYear < 1000) {
      strYear = strYear + 1900;
    }

    if (year > strYear) {
      return true;
    } else if (strYear == year) {
      if (month > strMonth) {
        return true;
      } else if (strMonth == month) {
        if (day > strToday) {
          return true;
        }
      }
    }

    return false;
  }


  function checkBirthDate(day,month,year) {
    var today = new Date();
    var strToday = today.getDate();
    var strMonth = today.getMonth() + 1;
    var strYear = today.getYear();
    if (strYear < 1000) {
      strYear = strYear + 1900;
    }

    if (year > strYear) {
      return true;
    } else if (strYear == year) {
      if (month > strMonth) {
        return true;
      } else if (strMonth == month) {
        if (day > strToday) {
          return true;
        }
      }
    }

    return false;
  }

  function checkOver21(day,month,year) {
    var today = new Date();
    var strToday = today.getDate();
    var strMonth = today.getMonth() + 1;
    var strYear = today.getYear();
    if (strYear < 1000) {
      strYear = strYear + 1900;
    }

    strYear = strYear - 21;
    if (year > strYear) {
      return true;
    } else if (strYear == year ) {
      if (month > strMonth) {
        return true;
      } else if (strMonth == month) {
        if (day > strToday) {
          return true;
        }
      }
    }

    return false;
  }


  function checkValidDate(strToday,strMonth,strYear) {

    if (strMonth > 12 || strMonth < 1) {
      return true;
    }
    if ((strMonth == 1 || strMonth == 3 || strMonth == 5 
         || strMonth == 7 || strMonth == 8 || strMonth == 10 
         || strMonth == 12) && (strToday > 31 || strToday < 1)) {
      return true;
    }
    if ((strMonth == 4 || strMonth == 6 || strMonth == 9 
         || strMonth == 11) && (strToday > 30 || strToday < 1)) {
      return true;
    }
    if (strMonth == 2) {
      if (strToday < 1) {
         return true;
      }
      if (LeapYear(strYear) == true) {
        if (strToday > 29) {
          return true;
        }
      } else {
        if (strToday > 28) {
          return true;
        }
      }
    }
    return false;
  }


  function LeapYear(intYear) {
    if (intYear % 100 == 0) {
      if (intYear % 400 == 0) { return true; }
    } else {
      if ((intYear % 4) == 0) { return true; }
    }
    return false;
  } 


  function checkPastYear(year) {
    var today = new Date();
    var strYear = today.getYear();
    if (strYear < 1000) {
      strYear = strYear + 1900;
    }

    if (year > strYear) {
      return true;
    } else {
      return false;
    }
  }

  function checkFutureYear(year) {
    var today = new Date();
    var strYear = today.getYear();
    if (strYear < 1000) {
      strYear = strYear + 1900;
    }

    if (year <= strYear) {
      return true;
    } else {
      return false;
    }
  }


  function checkCreditCardExpiry(month, year) {
    // convert to int and add 2000
    year1 = Number(year);
    year1 = year1 + 2000;

    month1 = Number(month);

    var today = new Date();
    var todayMonth = Number(today.getMonth() + 1);
    var todayYear  = Number(today.getYear());

    if (todayYear < 1000) {
      todayYear = todayYear + 1900;
    }

    if (year1 > todayYear) {
      return false;
    } else if (todayYear == year1) {
      if (month1 > todayMonth) {
        return false;
      }
    }

    return true;
  }


  function checkEmpty(oStringToCheck){
    var charError = 0;
    if (oStringToCheck == ''){
      charError++;
    }
    if (charError > 0){
      return true;
    }else{
      return false;
    }
  }
  
  function checkIllegalChars(oStringToCheck){
    var charError = 0;
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'-";
    //alert('checkIllegalChars')
      for (n = 0; n < oStringToCheck.length; n++){
        if (checkOK.indexOf(oStringToCheck.charAt(n)) == -1){
          charError++;
        }
      }
    if (charError > 0){
      return true;
    }else{
      return false;
    }
  }
  
  function checkNumberError(oStringToCheck){
    var charError = 0;
    var checkOK = "0123456789";
      for (n = 0; n < oStringToCheck.length; n++){
        if (checkOK.indexOf(oStringToCheck.charAt(n)) == -1 || oStringToCheck.length < 10 || oStringToCheck.length > 12){
          charError++;
        }
      }
    if (charError > 0){
      return true;
    }else{
      return false;
    }
  }

  function checkPhoneNumber(oStringToCheck){
    var charError = 0;
    var checkOK = "0123456789";
    var myNumber = oStringToCheck.replace(/(,|\-|\(|\)|\+|\s)/g, "");
//    alert("Phone Numer : " + oStringToCheck + " : " + myNumber);
    for (n = 0; n < myNumber.length; n++){
      if (checkOK.indexOf(myNumber.charAt(n)) == -1 || myNumber.length < 10 || myNumber.length > 20){
        charError++;
      }
    }
    if (charError > 0){
      return true;
    }else{
      return false;
    }
  }

  function checkPastMonthYear(month, year) {
    var today = new Date();
    var strMonth = today.getMonth() + 1;
    var strYear = today.getYear();
    if (strYear < 1000) {
      strYear = strYear + 1900;
    }

    if (year > strYear) {
      return true;
    } else if (strYear == year) {
      if (month > strMonth) {
        return true;
      }
    }

    return false;
  }


  function checkPostcodeError(oStringToCheck){
    var postcodeError = 0;

    // strip spaces & convert to upper case
    oStringToCheck = oStringToCheck.replace(/ /g, ""); 
    oStringToCheck = oStringToCheck.toUpperCase();

    size = oStringToCheck.length;

    // incode is the last 3 chars
    var incode  = oStringToCheck.substr(size-3, 3);
 
    // outcode is everything except the last 3 chars
    var outcode = oStringToCheck.substr(0, size-3);

    // incode must equal 9AA format
    if (incode.match(/[0-9][A-Z][A-Z]/)) { 
        //alert("incode success");
    } 
    else {
        //alert("incode failure");
        postcodeError++;
    }

    // incode must equal A9, A99, AA9, AA99, AA9A, A9A or AAA format
    if (outcode.match(/^[A-Z][0-9]$/)           ||
        outcode.match(/^[A-Z][0-9][0-9]$/)      ||
        outcode.match(/^[A-Z][A-Z][0-9]$/)      ||
        outcode.match(/^[A-Z][A-Z][0-9][0-9]$/) ||
        outcode.match(/^[A-Z][A-Z][0-9][A-Z]$/) ||
        outcode.match(/^[A-Z][0-9][A-Z]$/)      ||
        outcode.match(/^[A-Z][A-Z][A-Z]$/) ) {

        //alert("outcode success");
    }  
    else {
        //alert("outcode failure");
        postcodeError++;
    }

    if (postcodeError > 0){
      return true;
    } else{
      return false;
    }
  }

  function checkPostcodeErrorOld(oStringToCheck){
    var postcodeError = 0;
    if (oStringToCheck.length < 2 || oStringToCheck.length > 8){
      postcodeError++;
    }
    if (postcodeError > 0){
      return true;
    } else{
      return false;
    }
  }
  
  
function showErrors(myErrorArray){
  for (t=0;t<myErrorArray.length; t++){
    myErrorName = myErrorArray[t];
    if (document.getElementById){
      // elem = document.getElementById(myErrorName);

      if (myErrorName.match('err_mess')) {
        YAHOO.util.Dom.removeClass(myErrorName,'hidden');
      } else {
        document.getElementById(myErrorName).style.visibility = 'visible';
      }
    }
  }
}

  function showError(errorName){
      myErrorName = errorName + '_error';
      if (document.getElementById){
       document.getElementById(myErrorName).style.visibility = 'visible';
      }
  }


//  function startHelp() {
//    showHelp('Default',1); //show a div on page load (and init with a fresh value of 1)
    
//  }

//  function showHelp(id,fresh) {
//  if (fresh==1) {
//    prevId = 'Default';
//  }
//  if (typeof(prevId) != "undefined") {
//    if (prevId){
//      document.getElementById('lyr_'+prevId).style.visibility = 'hidden';
//    }
//    document.getElementById('lyr_'+id).style.visibility = 'visible';
//    prevId = id;
//    }
//  }
  
/* Removes 'noscript' class from the class attribute of an element, leaving all other classes intact */
function noscript(choice,elem) { 
	
    //alert("choice = " + choice + " elem = " + elem);
    // Identify the Help messages
    if (elem.indexOf('help')!=-1) { var help = true; } 
	
    // Find the element.
    // If it's not an element, try to use it as an ID
    if (!elem.nodeType || !elem.nodeType == 1) elem = document.getElementById(elem); 
    
    if (!elem) return true; // Error - can't find element
	
    // Add/Remove noscript class
    // Does element already have a noscript class?
    var isNoscript  = elem.className.match(/(\s|^)noscript(\s|$)/); 
	
    // toggle Help messages on and off
    if (help) { 
        if (isNoscript) { 
            var helpOn = 'no'; 
        }
        else if(!isNoscript) { 
            // if Help message is displayed, turn it off
            var helpOn = 'yes';
            choice = 'add';
        }
    }

    if (isNoscript && choice == 'remove'){ 
        // If it does have noscript class and we need to remove it then:
        // Get a new classname that doesn't include noscript
    	var newName = elem.className.replace(/\snoscript|noscript\s|noscript/,''); 
    	elem.className = newName; // Replace classname with new classname
        if((help) && (helpOn == 'no')) {
            helpOn == 'yes';
        }
    } 
    else if(!isNoscript&&choice == 'add') {
        // Else if it doesn't and we need to add one then add one.
        elem.className += ' noscript'; 
        if((help) && (helpOn == 'yes')) {
            helpOn == 'no';
        }
    }
    return false; // Return with no error.
}
   
  
  
 
