
    // Validator Object
    var valid = new Object();

    // REGEX Elements

        // matches zip codes
        //valid.zipCode = /\d{5}(-\d{4})?/;
        valid.zipCode = /^\d{5}-\d{4}|\d{5}|[A-Za-z]\d[A-Za-z] ?\d[A-Za-z]\d$/;

        // matches $17.23 or $14,281,545.45 or ...
        valid.Currency = /\$\d{1,3}(,\d{3})*\.\d{2}/;

        // matches 5:04 or 12:34 but not 75:83
        valid.Time = /^([1-9]|1[0-2]):[0-5]\d$/;

        //matches email
        valid.emailAddress = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/ 
        ///^[a-zA-Z0-9_\-\.]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
        
        //matches emails
        valid.emailAddresses = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}(\s*,\s*[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})*$/;
        
        //matches login
        valid.login = /^[a-zA-Z0-9\-\.@]{3,}$/;        

        // matches phone ###-###-####
        valid.phoneNumber = /^\(?\d{3}\)?\s|-\d{3}-\d{4}$/;

        // International Phone Number
        valid.phoneNumberInternational = /^\d(\d|-){7,20}/;

        // IP Address
        valid.ipAddress = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;

        // Date xx/xx/xxxx
        valid.Date = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;

        // State Abbreviation
        valid.StateCanada = /^(AB|NF|PE|BC|NT|PQ|MB|NS|SK|NB|ON|YT)$/i;
        valid.State = /^(AK|AL|AR|AZ|CA|CO|CT|DC|DE|FL|GA|HI|IA|ID|IL|IN|KS|KY|LA|MA|MD|ME|MI|MN|MO|MS|MT|NE|NC|ND|NH|NJ|NM|NV|NY|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VA|VT|WA|WI|WV|WY)$/i;

        // Social Security Number
        valid.SSN = /^\d{3}\-\d{2}\-\d{4}$/;
        
        //Credit Card Number
        valid.CredtCardNumber = /^[\d\s]{15,}$/;
        
        //Credit Card Security Code
        valid.CCardSecurityCode = /^\d{3,4}$/;

///////////////////////////////////////////////////

function alertField(field,msg) {
	if (!field.readOnly && field.focus) field.focus();
	if (field.select!=null && !field.readOnly) field.select();
	alert(msg);
	if (field.readOnly && field.focus) field.focus();
	
	return false;
}

// checks if any element of list has 'checked' attribute equal to 'true'
function listCheckedIndex(l)
{
  var i;
  for (i = 0; i < l.length; i ++)
    if (l[i].checked)
      return i;
  return -1;
}

// return array index of the given element (or -1 if not found)
function inArray(arr, el)
{
  if (!arr.length)
      return false;
  for (i = 0; i <= arr.length; i ++)
      if (arr[i] == el)
          return i;
  return -1;
}

// return numeric postfix
function numPostfix(num)
{
  if (1 == num)
      return 'st';
  else if (2 == num)
      return 'nd';
  else if (3 == num)
      return 'rd';
  else
      return 'th';
}

// clears list
function clearCheckedList(el)
{
    var i;
    for (i = 0; i < el.length; i ++)
        el[i].checked = false;
}

// select elements (which value equal to given) of list
function checkListElements(el, val)
{
    var i;
    if(el)
    for (i = 0; i < el.length; i ++)
        if (el[i].value == val)
            el[i].checked = true;
}

////////////////////////////////////////////////////////////////////////////

function info(url, wname,width){
    if(!width)width=520;
   	window.open(url, wname, "menubar=0,titelbar=0,scrollbars=1,status=0, width="+width+",height=550").focus();;
}



