var alpha ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,-!:; "
var numeric ="0123456789/"
var phone ="0123456789-()ext.EXT#+/: "
var alphanumeric ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,-!:;#/ "
var usernamepassword ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"
var name ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -."

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,name,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=4) {name=args[i+3]; test=args[i+2]; val=MM_findObj(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+='- '+name+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+name+' 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+='- '+name+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+name+' is required.\n'; }
  } if (errors) alert(errors);
  if (errors == '') document.edit.submit();

}


// check for template matching
function CheckString(as_template, as_string)
{
   var lb_valid = true;
   for (i = 0 ;i < as_string.length;i++)
   {
     ch = as_string.charAt(i);
     for (j = 0; j < as_template.length; j++)
       if (ch == as_template.charAt(j)) break;
     if (j == as_template.length)
     {
       lb_valid = false;
       break;
     }
   }

   if (!lb_valid) return (false);
   return (true);
}


// check if input field is empty (or contains only spaces)
function isblank(str)
{
   var ncheck = str.value;
   var ln_length = ncheck.length;
   var i = 0;
   var all_blank = true;

   if (ln_length < 1)return true;

   while (i < ln_length && all_blank)
   {
     if ((ncheck.charAt(i)!=" ")) all_blank = false;
     i++;
   }

   return all_blank;
}


// check for valid email
function ValidateEmail(obj)
{
   disallowed="$%^*()={}[];#<>,?|\\!\"\' ";
   valid=true;
   if (obj.indexOf('@')<1)
   {
     valid=false;
   }
   if (obj.indexOf('.')==0)
   {
     valid=false;
   }
   for (var i=0;i<disallowed.length;i++)
   {
     if (obj.indexOf(disallowed.substring(i,i+1))!=-1)
     {
        alert("Illegal character: '" +disallowed.substring(i,i+1)+"' found in email address");
        valid=false;
     }
   }
   copy=obj.substring(obj.indexOf('@')+1,obj.length);
   if (copy.indexOf('@')!=-1)
   {
     valid=false;
   }
   if (copy.indexOf(".")<1)
   {
     valid=false;
   }
   if (copy.lastIndexOf(".")+1==copy.length)
   {
     valid=false;
   }
   copy=obj;
   while (copy.indexOf('.')!=-1)
   {
     copy=copy.substring(copy.indexOf('.')+1,copy.length);
     if (copy.indexOf('.')==0)
     {
       valid=false;
     }
   }
   return valid;
}

// check form
function check_email_form(_Form) {

   // check for blank value
   for(index = 0 ;index < _Form.elements.length; index++) {

           if (_Form.elements[index].name == "users_email")
           {

               if (isblank(_Form.elements[index]))
               {
                 if (_Form.elements[index].name =="users_email")
                 {
                   alert("You must enter an Email");
                 };

                 _Form.elements[index].focus();
                 _Form.elements[index].select();
                 return false;
               }
           }
   }

   // check email
   if (!ValidateEmail(_Form.users_email.value))
   {
     alert("I'm sorry. " +_Form.users_email.value +" does not appear to be a valid E-mail address.  Check for errors then re-enter.")
     _Form.users_email.focus();
     _Form.users_email.select();
     return false;
   }

   return true;
}


// check form
function check_form(_Form) {

   // check for blank value
   for(index = 0 ;index < _Form.elements.length; index++) {


           if (_Form.elements[index].name == "f_first_name" ||
               _Form.elements[index].name == "f_last_name" ||
               _Form.elements[index].name == "f_email_address" ||
               _Form.elements[index].name == "f_password" ||
               _Form.elements[index].name == "f_password2" ||
               _Form.elements[index].name == "f_address_1" ||
               _Form.elements[index].name == "f_phone" ||
               _Form.elements[index].name == "f_address_1" ||
               _Form.elements[index].name == "f_hosting"
               )
           {

               if (isblank(_Form.elements[index]))
               {
                 if (_Form.elements[index].name =="f_first_name")
                 {
                   alert("You must enter a value for your First Name");
                 }
                 else if (_Form.elements[index].name =="f_last_name")
                 {
                   alert("You must enter a value for your Last Name");
                 }
                 else if (_Form.elements[index].name =="f_email_address")
                 {
                   alert("You must enter a value for your E-mail");
                 }
                 else if (_Form.elements[index].name =="f_password")
                 {
                   alert("You must enter a value for your Password");
                 }
                 else if (_Form.elements[index].name =="f_password2")
                 {
                   alert("You must retype your Password to verify accuracy");
                 }
                 else if (_Form.elements[index].name =="f_address_1")
                 {
                   alert("You must enter a value for your Address");
                 }
                 else if (_Form.elements[index].name =="f_phone")
                 {
                   alert("You must enter a value for your Phone");
                 }
                 else if (_Form.elements[index].name =="f_hosting")
                 {
                   alert("You must enter a value for Company");
                 }



                 _Form.elements[index].focus();
                 _Form.elements[index].select();
                 return false;
               }
           }
   }

   // check email
   if (!ValidateEmail(_Form.f_email_address.value))
   {
     alert("I'm sorry. " +_Form.f_email_address.value +" does not appear to be a valid E-mail address.  Check for errors then re-enter.")
     _Form.f_email_address.focus();
     _Form.f_email_address.select();
     return false;
   }

   // check for identical Passwords
   if (_Form.f_password.value !=_Form.f_password2.value)
   {
     alert("The two passwords entered must be the same to verify accuracy.")
     _Form.f_password.focus();
     _Form.f_password.select();
     return false;
   }

   // check for valid home phone
   if (!CheckString(phone, _Form.f_phone.value)) {
         alert("Invalid Phone. Please try again.")
         _Form.f_phone.focus();
         _Form.f_phone.select();
         return false;
      }

   // check for valid first name
   if (!CheckString(name, _Form.f_first_name.value)) {
         alert("Invalid First Name. Please try again.")
         _Form.f_first_name.focus();
         _Form.f_first_name.select();
         return false;
   }

   // check for valid last name
   if (!CheckString(name, _Form.f_last_name.value)) {
         alert("Invalid Last Name. Please try again.")
         _Form.f_last_name.focus();
         _Form.f_last_name.select();
         return false;
   }

   // check for valid password
   if (!CheckString(usernamepassword, _Form.f_password.value)) {
         alert("Invalid Password. Please try again.")
         _Form.f_password.focus();
         _Form.f_password.select();
         return false;
   }

   return true;
}


// check form
function check_form2(_Form) {

   // check for blank value
   for(index = 0 ;index < _Form.elements.length; index++) {


           if (_Form.elements[index].name == "f_first_name" ||
               _Form.elements[index].name == "f_last_name" ||
               _Form.elements[index].name == "f_email_address" ||
               _Form.elements[index].name == "f_address_1" ||
               _Form.elements[index].name == "f_phone" ||
               _Form.elements[index].name == "f_address_1" ||
               _Form.elements[index].name == "f_hosting" ||
               _Form.elements[index].name == "f_state" ||
               _Form.elements[index].name == "f_zip_code" ||
               _Form.elements[index].name == "f_city"
               )
           {

               if (isblank(_Form.elements[index]))
               {
                 if (_Form.elements[index].name =="f_first_name")
                 {
                   alert("You must enter a value for your First Name");
                 }
                 else if (_Form.elements[index].name =="f_last_name")
                 {
                   alert("You must enter a value for your Last Name");
                 }
                 else if (_Form.elements[index].name =="f_email_address")
                 {
                   alert("You must enter a value for your E-mail");
                 }
                 else if (_Form.elements[index].name =="f_address_1")
                 {
                   alert("You must enter a value for your Address");
                 }
                 else if (_Form.elements[index].name =="f_phone")
                 {
                   alert("You must enter a value for your Phone");
                 }
                 else if (_Form.elements[index].name =="f_company")
                 {
                   alert("You must enter a value for Company");
                 }
                 else if (_Form.elements[index].name =="f_city")
                 {
                   alert("You must enter a value for City");
                 }
                 else if (_Form.elements[index].name =="f_zip_code")
                 {
                   alert("You must enter a value for Zip Code");
                 }
                 else if (_Form.elements[index].name =="f_state")
                 {
                   alert("You must enter a value for State");
                 }



                 _Form.elements[index].focus();
                 _Form.elements[index].select();
                 return false;
               }
           }
   }

   // check email
   if (!ValidateEmail(_Form.f_email_address.value))
   {
     alert("I'm sorry. " +_Form.f_email_address.value +" does not appear to be a valid E-mail address.  Check for errors then re-enter.")
     _Form.f_email_address.focus();
     _Form.f_email_address.select();
     return false;
   }


   // check for valid home phone
   if (!CheckString(phone, _Form.f_phone.value)) {
         alert("Invalid Phone. Please try again.")
         _Form.f_phone.focus();
         _Form.f_phone.select();
         return false;
      }


   // check for valid first name
   if (!CheckString(name, _Form.f_first_name.value)) {
         alert("Invalid First Name. Please try again.")
         _Form.f_first_name.focus();
         _Form.f_first_name.select();
         return false;
   }

   // check for valid last name
   if (!CheckString(name, _Form.f_last_name.value)) {
         alert("Invalid Last Name. Please try again.")
         _Form.f_last_name.focus();
         _Form.f_last_name.select();
         return false;
   }

   return true;
}

   function check_character() {
  var znach;
  var ost;
  var rem;
  znach = document.company_info.f_description.value;
  ost = document.company_info.f_description.value;
  if (znach.length>430) ost = znach.substr(0, 430);
  rem = 430 - znach.length;
  document.company_info.f_description.value = ost;
  if (rem<0) rem=0;
  document.getElementById('remain_str').innerHTML = "(" + rem.toString() + " remaining)";
  }

  function check_updates_form_new2() {
    var name = "";
       /*
       for(index = 0 ;index < document.keywords.elements.length; index++) {
           name = document.keywords.elements[index].name;
           if (name.substr(0, 15)=="select_keywords") {
                     for (index2 = 0; index2<document.keywords.elements[index].length; index2++) {
                          document.keywords.elements[index][index2].selected = "true";
                     };
           };
       };*/

       /*
       for(index = 0 ;index < document.keywords.elements.length; index++) {
           name = document.keywords.elements[index].name;
           if (name.substr(0, 15)=="select_pre_list") {
                     document.keywords.elements[index].innerHTML = "";
           };
       };
      */
       document.keywords.submit();
 }

 function check_purchase_form(service_level) {
    var i=0;

    for(index = 0 ;index < document.category_selection.elements.length; index++) {
           if (document.category_selection.elements[index].type=="checkbox") {
               if (document.category_selection.elements[index].checked)
                   i++;
           };
       };

    if (i==0) {
        alert ("Please select at least one category!");
        return false;
    };

    i=0;
    if (service_level==1) {
       for(index = 0 ;index < document.category_selection.elements.length; index++) {
           if (document.category_selection.elements[index].type=="checkbox") {
               if (document.category_selection.elements[index].checked)
                   i++;
           };
       };
       if (i>1) {
          alert("You can select only one category!");
          return false;
       };
   };

    document.category_selection.submit();
 }





function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


/*
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }



}
window.onload=startList;
 */

 activateMenu = function(nav) {

    /* currentStyle restricts the Javascript to IE only */
        if (document.all && document.getElementById(nav).currentStyle) {
        var navroot = document.getElementById(nav);

        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("LI");
        for (i=0; i<lis.length; i++) {

           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){

                /* assign the function to the LI */
                     lis[i].onmouseover=function() {

                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {
                   this.lastChild.style.display="none";
                }
            }
        }
    }
}
window.onload= function(){
    /* pass the function the id of the top level UL */
    /* remove one, when only using one menu */
    activateMenu('nav');
   // activateMenu('vertnav');
}
