/*******************************************************************************/
var valid = null;
var brow = false;
var debug_l = 0;
    //0 == customer errors only
    //1 == debug errors only
    //2 == debug and customer errors
    //3 == no errors
//window.onload = initi;
/******************intitiation function*******************/
 function initi(f){
    if(f){
        //var valid = new VFF(f);
        valid.SV();
    }
    else{
    brow = (navigator.appName == "Microsoft Internet Explorer")? false:true ;
        if(typeof(window['defs']) != "undefined"){
        var start_point;
          if(start_point = document.getElementById(defs[0][0])){
          var f0rm = Find_Parent_Form(start_point.parentNode);
              if(f0rm.tagName == "form" || f0rm.tagName == "FORM"){
                  valid = new VFF(f0rm);
                  valid.FP = f0rm;
                  valid.C_geo();
              }
          }
        }
        else{
            if(debug_l == 1 || debug_l == 2)
                alert("There are no definitions to this form. Please check vdefinitions.js and verify it is filled out and matches the form on this page.");
            if(debug_l == 0)
                alert("Your request cannot be processed at this time, please try again later.");

            }
    }
  }

  function Find_Parent_Form(SP){
  //SP == starting point
  var PF;
    if(SP.tagName.toUpperCase() != "FORM"){
     while(SP.tagName.toUpperCase() != "FORM"){
       SP = SP.parentNode;
     }
    }
    return SP;
  }

/***************************************************************/



/********************begin validation object********************/
function VFF(F){
    //0 == check for value
    //1 == email
    //2 == telephone
    //3 == zip
    //4 == username
    //5 == password
    //6 == confirm password
    //7 == state
    //8 == country




var SA = new Array();//SA = states array
SA[0] = '';
SA[1] = 'Alabama';
SA[2] = 'Alaska';
SA[3] = '';
SA[4] = 'Arizona';
SA[5] = 'Arkansas';
SA[6] = 'California';
SA[7] = '';
SA[8] = 'Colorado';
SA[9] = 'Connecticut';
SA[10] = 'Delaware';
SA[11] = 'District of Columbia';
SA[12] = 'Florida';
SA[13] = 'Georgia';
SA[14] = '';
SA[15] = 'Hawaii';
SA[16] = 'Idaho';
SA[17] = 'Illinois';
SA[18] = 'Indiana';
SA[19] = 'Iowa';
SA[20] = 'Kansas';
SA[21] = 'Kentucky';
SA[22] = 'Louisana';
SA[23] = 'Maine';
SA[24] = 'Maryland';
SA[25] = 'Massachusetts';
SA[26] = 'Michigan';
SA[27] = 'Minnesota';
SA[28] = 'Mississippi';
SA[29] = 'Missouri';
SA[30] = 'Montana';
SA[31] = 'Nebraska';
SA[32] = 'Nevada';
SA[33] = 'New Hampshire';
SA[34] = 'New Jersey';
SA[35] = 'New Mexico';
SA[36] = 'New York';
SA[37] = 'North Carolina';
SA[38] = 'North Dakota';
SA[39] = 'Ohio';
SA[40] = 'Oklahoma';
SA[41] = 'Oregon';
SA[42] = 'Pennsylvania';
SA[43] = '';
SA[44] = 'Rhode Island';
SA[45] = 'South Carolina';
SA[46] = 'South Dakota';
SA[47] = 'Tennessee';
SA[48] = 'Texas';
SA[49] = 'Utah';
SA[50] = 'Vermont';
SA[51] = 'Virgina';
SA[52] = '';
SA[53] = 'Washington';
SA[54] = 'West Virgina';
SA[55] = 'Wisconsin';
SA[56] = 'Wyoming';
SA[57] = 'Puerto Rico';



var country = new Array();
country[0] = new Array("00","Select");
country[1] = new Array("AU","Australia");
country[2] = new Array("NZ","New Zealand");
country[3] = new Array("US","United States");
country[4] = new Array("GB","United Kingdom");
country[5] = new Array("JP","Japan");
country[6] = new Array("AF","Afghanistan");
country[7] = new Array("AG","Antigua and Barbuda");
country[8] = new Array("AI","Anguilla");
country[9] = new Array("AL","Albania");
country[10] = new Array("AM","Armenia");
country[11] = new Array("DZ","Algeria");
country[12] = new Array("AD","Andorra");
country[13] = new Array("AO","Angola");
country[14] = new Array("AR","Argentina");
country[15] = new Array("AW","Aruba");
country[16] = new Array("AT","Austria");
country[17] = new Array("BS","Bahamas");
country[18] = new Array("BH","Bahrain");
country[19] = new Array("BD","BBangladesh");
country[20] = new Array("BB","Barbados");
country[21] = new Array("BE","Belgium");
country[22] = new Array("BZ","Belize");
country[23] = new Array("BM","Bermuda");
country[24] = new Array("BT","Bhutan");
country[25] = new Array("BO","Bolivia");
country[26] = new Array("BW","Botswana");
country[27] = new Array("BR","Brazil");
country[28] = new Array("BN","Brunei");
country[29] = new Array("BG","Bulgaria");
country[30] = new Array("BI","Burundi");
country[31] = new Array("KH","Cambodia");
country[32] = new Array("CA","Canada");
country[33] = new Array("CV","Cape Verde");
country[34] = new Array("KY","Cayman Islands");
country[35] = new Array("CF","Central African Republic");
country[36] = new Array("CL","Chile");
country[37] = new Array("CN","China");
country[38] = new Array("CO","Colombia");
country[39] = new Array("KM","Comoros");
country[40] = new Array("CR","Costa Rica");
country[41] = new Array("HR","Croatia");
country[42] = new Array("CU","Cuba");
country[43] = new Array("CY","Cyprus");
country[44] = new Array("CZ","Czech Republic");
country[45] = new Array("DK","Denmark");
country[46] = new Array("DJ","Djibouti");
country[47] = new Array("DO","Dominican Republic");
country[48] = new Array("NL","Netherlands");
country[49] = new Array("EC","Ecuador");
country[50] = new Array("EG","Egypt");
country[51] = new Array("SV","El Salvador");
country[52] = new Array("EE","Estonia");
country[53] = new Array("ET","Ethiopia");
country[54] = new Array("FK","Falkland Islands");
country[55] = new Array("FJ","Fiji");
country[56] = new Array("FI","Finland");
country[57] = new Array("FR","France");
country[58] = new Array("GM","Gambia");
country[59] = new Array("DE","Germany");
country[60] = new Array("GH","Ghana");
country[61] = new Array("GI","Gibraltar");
country[62] = new Array("GR","Greece");
country[63] = new Array("GT","Guatemala");
country[64] = new Array("GN","Guinea");
country[65] = new Array("GY","Guyana");
country[66] = new Array("HT","Haiti");
country[67] = new Array("HN","Honduras");
country[68] = new Array("HK","Hong Kong");
country[69] = new Array("HU","Hungary");
country[70] = new Array("IS","Iceland");
country[71] = new Array("IN","India");
country[72] = new Array("ID","Indonesia");
country[73] = new Array("IR","Iran");
country[74] = new Array("IQ","Iraq");
country[75] = new Array("IE","Ireland");
country[76] = new Array("IL","Israel");
country[77] = new Array("IT","Italy");
country[78] = new Array("JM","Jamaica");
country[79] = new Array("JO","Jordan");
country[80] = new Array("KZ","Kazakhstan");
country[81] = new Array("KE","Kenya");
country[82] = new Array("KW","Kuwait");
country[83] = new Array("LA","Laos");
country[84] = new Array("LV","Latvia");
country[85] = new Array("LB","Lebanon");
country[86] = new Array("LS","Lesotho");
country[87] = new Array("LR","Liberia");
country[88] = new Array("LY","Libya");
country[89] = new Array("LT","Lithuania");
country[90] = new Array("LU","Luxembourg");
country[91] = new Array("MO","Macao");
country[92] = new Array("MG","Madagascar");
country[93] = new Array("MW","Malawi");
country[94] = new Array("MY","Malaysia");
country[95] = new Array("MV","Maldives");
country[96] = new Array("MT","Malta");
country[97] = new Array("MR","Mauritania");
country[98] = new Array("MU","Mauritius");
country[99] = new Array("MX","Mexico");
country[100] = new Array("MN","Mongolia");
country[101] = new Array("MA","Morocco");
country[102] = new Array("MZ","Mozambique");
country[103] = new Array("MM","Myanmar");
country[104] = new Array("AN","Netherlands Antilles");
country[105] = new Array("NA","Namibia");
country[106] = new Array("NP","Nepal");
country[107] = new Array("NI","Nicaragua");
country[108] = new Array("NG","Nigeria");
country[109] = new Array("KP","North Korea");
country[110] = new Array("NO","Norway");
country[111] = new Array("OM","Oman");
country[112] = new Array("PK","Pakistan");
country[113] = new Array("PA","Panama");
country[114] = new Array("PG","Papua New Guinea");
country[115] = new Array("PY","Paraguay");
country[116] = new Array("PE","Peru");
country[117] = new Array("PH","Philippines");
country[118] = new Array("PL","Poland");
country[119] = new Array("PT","Portugal");
country[120] = new Array("QA","Qatar");
country[121] = new Array("RO","Romania");
country[122] = new Array("RU","Russia");
country[123] = new Array("WS","Samoa");
country[124] = new Array("ST","Sao Tome/Principe");
country[125] = new Array("SA","Saudi Arabia");
country[126] = new Array("SC","Seychelles");
country[127] = new Array("SL","Sierra Leone");
country[128] = new Array("SG","Singapore");
country[129] = new Array("SK","Slovakia");
country[130] = new Array("SI","Slovenia");
country[131] = new Array("SB","Solomon Islands");
country[132] = new Array("SO","Somalia");
country[133] = new Array("ZA","South Africa");
country[134] = new Array("KR","South Korea");
country[135] = new Array("ES","Spain");
country[136] = new Array("LK","Sri Lanka");
country[137] = new Array("SH","Saint Helena");
country[138] = new Array("SD","Sudan");
country[139] = new Array("SR","Suriname");
country[140] = new Array("SZ","Swaziland");
country[141] = new Array("SE","Sweden");
country[142] = new Array("CH","Switzerland");
country[143] = new Array("SY","Syria");
country[144] = new Array("TW","Taiwan");
country[145] = new Array("TZ","Tanzania");
country[146] = new Array("TH","Thailand");
country[147] = new Array("TO","Tonga");
country[148] = new Array("TT","Trinidad/Tobago");
country[149] = new Array("TN","Tunisia");
country[150] = new Array("TR","Turkey");
country[151] = new Array("UG","Uganda");
country[152] = new Array("UA","Ukraine");
country[153] = new Array("UY","Uruguay");
country[154] = new Array("AE","United Arab Emirates");
country[155] = new Array("VU","Vanuatu");
country[156] = new Array("VE","Venezuela");
country[157] = new Array("VN","Vietnam");
country[158] = new Array("ZM","Zambia");
country[159] = new Array("ZW","Zimbabwe");
    var error_list = '';
    var dyna_err = '';
    var pp = '';
    var sta_p = null;
    var sta_puf = null;
    var errors = new Array();
    errors[0] = "We're sorry your request cannot be processed at this time. Please contact the web administrator, or try again later. Thank you.- 1";
    errors[1] = "We're sorry your request cannot be processed at this time. Please contact the web administrator, or try again later. Thank you. --- 2";
    errors[2] = "Test Error";
    /*********function defs***********/
    this.constru = constru;
    this.Getfields = Getfields;
    /***validation**/
    this.VNN = VNN;
    this.Vemail = Vemail;
    this.Vtelephone = Vtelephone;
    this.Vzip = Vzip;
    this.Vusername = Vusername;
    this.Vpassword = Vpassword;
    this.Vstate = Vstate;
    this.Vcountry = Vcountry;
    this.Vvccformat = Vvccformat;
    this.Vccformat = Vccformat;
    this.Vcompanyname = Vcompanyname;
    this.Vdomainname = Vdomainname;
    this.Vaddress = Vaddress;
    this.Vcity = Vcity;
    this.Vhistorydate = Vhistorydate;
    this.Vfuturedate = Vfuturedate;
    this.Vdropdown = Vdropdown;
    this.Vmdropdown = Vmdropdown;
    /****validation***/
    this.Compare_Value = Compare_Value;
    this.Mark_Fields_Fail = Mark_Fields_Fail;
    this.Mark_Field_Pass = Mark_Field_Pass;
    this.Dynamic_Errs = Dynamic_Errs;
    this.Finish_Err = Finish_Err;
    this.Show_Errs = Show_Errs;
    this.Clear_Errs = Clear_Errs;
    this.Ajax_Check = Ajax_Check;
    this.SV = SV;
    this.Ale = Ale;
    this.Distribute = Distribute;
    this.C_geo = C_geo;
    this.US_status = US_status;
    this.State_status = State_status;
    this.Get_field = Get_field;
    this.Get_Def = Get_Def;
    this.Get_Blind_fields = Get_Blind_fields;
    this.Strip_Chars = Strip_Chars;
    this.Check_Invalid = Check_Invalid;
    this.Find_value = Find_value;
    this.Get_By_Def = Get_By_Def;
    /*********function defs***********/
    this.FP = F;
    this.complist = new Array();
    this.defs = false;
    this.len = false;
    this.error_list = '';

    this.predef = false;
    this.constru();
    var valid_numbers = new Array('0','1','2','3','4','5','6','7','8','9','-');
    //,'-','.','@','_'
    var valid_letters = new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','-','.','@','_');
    var invalid_text = new Array('~','`','!','@','#','$','%','^','&','*','_','=','{','}','[',']','|',':',';','/','<','>','?');
     var_defs = new Array();
     var_defs[0] = this.VNN;
     var_defs[1] = this.Vemail;
     var_defs[2] = this.Vtelephone;
     var_defs[3] = this.Vzip;
     var_defs[4] = this.Vusername;
     var_defs[5] = this.Vpassword;
     var_defs[6] = this.Vpassword;
     var_defs[7] = this.Vstate;
     var_defs[8] = this.Vcountry;
     var_defs[9] = this.Vstate;
     var_defs[10] = this.Vcountry;
     var_defs[11] = this.Vvccformat;
     var_defs[12] = this.Vccformat;
     var_defs[13] = this.Vcompanyname;
     var_defs[14] = this.Vdomainname;
     var_defs[15] = this.Vaddress;
     var_defs[16] = this.Vcity;
     var_defs[17] = this.Vhistorydate;
     var_defs[18] = this.Vfuturedate;
     var_defs[19] = this.Vhistorydate;
     var_defs[20] = this.Vfuturedate;
     var_defs[21] = this.Vdropdown;
     var_defs[22] = this.Vmdropdown;


function Ale(m,o){
 if(o == 0)
  alert(errors[m]);
 if(o == 1)
   alert(m);
}

function SV(){
    this.defs = GetDefs(this);
    //defs == predefined definitions -- defs[][0] == fieldname, defs[][1] == preset validation code
    if(this.defs){
        this.len = Getfields(this);
        //alert(this.len)
        //len == form array -- len[][0] == field name, len[][1] == field as object
        if(this.len){
           Compare_Value(this);//alert(this.len.length+"!!!!!!");
        }
        else{
           Ale(1,0);
        }
    }
    else
        Ale(0,0);
}

function Distribute(f){

}

function C_geo(){

   var sta = '';
   var cou = '';

   this.defs = GetDefs(this);
   if(this.defs){
   //alert("defs");
    for(x=0;x<this.defs.length;x++){
        //alert(this.defs[x][1]+"--"+x+this.defs.length)
        if(this.defs[x][1] == 7){
           var conb = document.getElementById(this.defs[x][0]);
           var con_alt = document.createElement("input");
          con_alt.type="hidden";
          con_alt.value = "none";
          con_alt.id=this.defs[x][0]+"2";
          con_alt.name=this.defs[x][0]+"2";
          sta_p = conb;
          sta_puf = con_alt;
          //conb.parentNode.appendChild(con_alt);
        }
        if(this.defs[x][1] == 9){
          //alert(this.defs[x][0]);
          sta = this.defs[x][0];
          var conb = document.getElementById(this.defs[x][0]);
          var conp = document.createElement("select");
          var con_alt = document.createElement("input");
          con_alt.type="hidden";
          con_alt.value = "none";
          con_alt.id=this.defs[x][0]+"2";
          con_alt.name=this.defs[x][0]+"2";
          conp.name = this.defs[x][0];
          conp.id = this.defs[x][0];
          sta_p = conb;
          sta_puf = con_alt;
          conb.parentNode.appendChild(con_alt);
          conp.style.color = "#000000";
          conp.style.backgroundColor = "#FFFFFF";
          conb.parentNode.replaceChild(conp,conb);
          //conp.onchange = function(){State_status(this)};
          var inc = 1;
          var newpt = new Option("Select",0);
          conp.options[0] = newpt;
          for(v=1;v<SA.length;v++){
             if(SA[v] != "" && v != 0){
                newpt = new Option(SA[v],v);
                newpt.style.color = "#000000";
                conp.options[inc] = newpt;
                inc++;
                }
          }
        }
        if(this.defs[x][1] == 10){
          var conb = document.getElementById(this.defs[x][0]);
          var conp = document.createElement("select");
          conp.name = this.defs[x][0];
          conp.id = this.defs[x][0];
          conp.style.color = "#000000";
          conp.style.backgroundColor = "#FFFFFF";
          sta_p = conb;
          sta_puf = con_alt;
          conb.parentNode.replaceChild(conp,conb);
          if(sta = Find_value(9,this.defs)){
          //alert(Get_field((sta+"2")).name+'--'+sta);
          conp.onchange = function(){US_status(this,Get_field(sta))};
          }
          //var newpt = new Option("Select","00");
          //conp.options[0] = newpt;
          var inc = 0;
          var v_x;
          for(v_x in country){
             if(country[v_x][1] != "")
                var newpt = new Option(country[v_x][1],country[v_x][0]);
                newpt.style.color = "#000000";
                conp.options[v_x] = newpt;
          }
        }
        if(this.defs[x][1] == 8){
        var fieldname = Get_By_Def(7);
            if(fieldname){
              var field = Get_field(fieldname+"2");
              if(field)
                field.disabled = true;
            }
        //alert(834)
        }
    }

   }
}

function US_status(c,s){
   if(c.value == "US" || c.value == "United States"){
       s.disabled = false;
       State_status(s.id,false)
   }
   else{
      s.disabled = true;
      State_status(s.id,true)
   }
}

function State_status(s,c){
var c_item = document.getElementById((s+"2"));
   if(c){
      if(c_item){

       c_item.disabled = false;
      }
      else
         sta_p.parentNode.appendChild(sta_puf);
   }
   else{
     if(c_item){
      c_item.disabled = true;
      c_item.parentNode.removeChild(c_item);
     }
   }
}

function Get_field(id){
var ret = false;
this.len = Getfields(valid);
  if(this.len != ""){
    for(x=0;x<this.len.length;x++){
       if(this.len[x][0] == id)
        ret = this.len[x][1];
    }
  }
  return ret;
}

function Get_Def(id){
   var ret = false;
  if(this.defs != ""){
    for(x=0;x<this.defs.length;x++){
       if(this.defs[x][0] == id)
        ret = this.defs[x][1];
    }
  }
  return ret;
}

function Get_By_Def(did){
  var ret = false;
  if(this.defs != ""){
    for(x=0;x<this.defs.length;x++){
       if(this.defs[x][1] == did)
        ret = this.defs[x][0];
    }
  }
  return ret;
}

function Find_value(v2,str){
   var ret = false;
  if(str != ""){
    for(x2=0;x2<str.length;x2++){
       if(str[x2][1] == v2)
        ret = str[x2][0];
    }
  }
  return ret;
}

function constru(){
   this.FP = F;
    this.complist = new Array();
    this.defs = false;
    this.len = false;
    this.error_list = '';
    this.pp = '';
}

/*************make debug or customer errors******************/




var shit = 0;
function Dynamic_Errs(er,s,out,ty){
//er == error message
//s == show == 1, or alert == 0
//out == supress == 0, send to ale == 1
//ty == type of error, 0 == for user, 1 == debug
   if(typeof(dyna_err) != "undefined"){
    if(debug_l == 0  && ty == 0){
       dyna_err += ("<br />"+er);
       error_list += ("\n"+er);
       Finish_Err(s,out)
    }

    if(debug_l == 2){
       dyna_err += ("<br />"+er);
       error_list += ("\n"+er);
       Finish_Err(s,out)
    }

    if(debug_l == 1 && ty == 1){
       dyna_err += ("<br />"+er);
       error_list += ("\n"+er);
       Finish_Err(s,out)
    }
   }
}

function Finish_Err(s,out){
   if(out == 1){
        if(s == 0)
         Ale(error_list,out);
        if(s == 1)
         Show_Errs("err");
       }
}

function Show_Errs(o){
var obj;
   if(obj = document.getElementById(o))
     obj.innerHTML = dyna_err;
}

function Clear_Errs(){
   dyna_err = '';
   error_list = '';
}

/*************make debug or customer errors******************/

/********special fields***********************************/




function VNN(v,n){
   if(v.value == ""){
      Dynamic_Errs("Please enter a value for "+v.name+ ".",0,0,0);
      this.rog = false;
   }
   else
    this.rog = true;
  return this.rog;
}

function Vemail(v,n){
var IV = 0;
v = v.value;
    if(v != ""){
      if(v.indexOf("@") != v.lastIndexOf("@") || v.length < 7){
          Dynamic_Errs('There are invalid characters in your email address, or it is not long enough, please verify it and try again.',0,0,0);
          IV++;
      }
      v = v.toLowerCase();
      for(z=0;z<v.length;z++){

      var atz = v.charAt(z);
      var VL = valid_letters.toString();
      var VN = valid_numbers.toString();
      atz = atz.toLowerCase();
      //alert(atz);
      //alert(VL.indexOf(atz));
         if(VN.indexOf(atz) < 0 && VL.indexOf(atz) < 0){
            Dynamic_Errs('There are invalid characters in your email address, please verify it and try again.-'+v.charAt(z),0,0,0);
             IV++;
         }
      }
    }
    else{
       Dynamic_Errs("Please enter an email address.",0,0,0);
       IV++;
       }

    if(IV < 1)
        this.rog = true;
    else
        this.rog = false;
return this.rog;
}

function Vtelephone(v,n){
v = v.value.toString();

    if(v != ""){

       while(v.indexOf("-") >= 0){
          v = v.replace("-","");
       }

       while(v.indexOf(".") >= 0){
          v = v.replace(".","");
       }
       while(v.indexOf("(") >= 0){
          v = v.replace("(","");
       }
       while(v.indexOf(")") >= 0){
          v = v.replace(")","");
       }

       if(v.length >= 10){
         if(!isNaN(v)){
            this.rog = true;
         }
         else{
          Dynamic_Errs("There appear to be characters in your telephone number that are not valid. Please remove non-numeric characters and try again.",0,0,0);
          this.rog = false;
        }
      }
      else{
         Dynamic_Errs("Your telephone number appears to be too short. Please verify you have included the area code, and try again.",0,0,0);
          this.rog = false;
      }
    }
    else{
      Dynamic_Errs("Please enter a valid telephone number.",0,0,0);
      this.rog = false;
    }
return false;
}

function Vzip(v,n){
   var IV = 0;
   var v_v = v.value;
  v = v_v.toString();
  var vout = v.replace("-","");
     if(vout.length < 5){
        Dynamic_Errs("Your zip code is too short.",0,0,0);
        IV++;
        }
      else if(vout.length > 9){
        Dynamic_Errs("Your zip code is too long.",0,0,0);
        IV++;
        }
     else{
         var VN = valid_numbers.toString();
         for(z=0;z<v.length;z++){
            if(VN.indexOf(v.charAt(z)) < 0){
                Dynamic_Errs('There are invalid characters in your zip code. Please use a dash for the extended zip code extension.-'+v.charAt(z),0,0,0);
                IV++;
            }
        }
        if(IV < 1)
            this.rog = true;
        else
            this.rog = false;
     }
     return false;
}

function Vusername(v,n){
this.rog = true;
var IT = invalid_text.toString();
v_v = v.value;
    if(v_v != ""){
      for(x=0;x<v_v.length;x++){
        for(x2=0;x2<invalid_text.length;x2++){
           if(IT.indexOf(v_v.charAt(x)) >= 0){
             this.rog = false;
             Dynamic_Errs("You have invalid characters in the "+v.name+" field - "+v_v.charAt(x)+" . Please check it and try again.",0,0,0);
             break;
           }
        }
      }
    }
    else{
       this.rog = false;
       Dynamic_Errs("The username field is blank. Please check it and try again.",0,0,0);
       }
return false;
}

function Vpassword(v,n){
v = v.value;
    if(n == 5){
      if(v != ""){
        pp = v;
        this.rog = true;
      }
      else{
        this.rog = false;
        Dynamic_Errs("The password field is blank. Please check it and try again.",0,0,0);
      }
    }
    if(n == 6){
       if(v != ""){
          if(v == pp){
             this.rog = true;

          }
          else{
             this.rog = false;
             Dynamic_Errs("Your passwords do not match. Please check them and try again.",0,0,0);
          }
       }
       else{
         this.rog = false;
         Dynamic_Errs("The confirm password field is blank. Please check it and try again.",0,0,0);
       }
    }

return false;
}

function Vstate(v,n){
this.rog = false;
var fdefs = GetDefs(valid);
var flen = Getfields(valid);
var sta = '';
       if(fdefs){
         for(x=0;x<fdefs.length;x++){
            if(fdefs[x][1] == 10 || fdefs[x][1] == 9){
                sta = fdefs[x][0];
            }
         }
       }
    if(n == 9){

       if(flen != "" && sta != ""){
          for(y=0;y<flen.length;y++){
             if(flen[y][0] == sta){
                if(flen[y][1].value == "US" || flen[y][1].value == "United States"){
                   if(v.value == "0"){
                      this.rog = false;
                      Dynamic_Errs("Please specify a State",0,0,0);
                   }
                   else{
                      this.rog = true;
                   }
                }

                else{
                  if(flen[y][1].value == "00"){
                    this.rog = false;
                    Dynamic_Errs("Please specify a state.",0,0,0);
                  }
                  else
                    this.rog = true;
                }

             }
          }

       }
    }
    else{

       if((v.value == "0" || v.value == "") && sta==""){
          var fieldname = Get_By_Def(8);
          var cuntry = Get_field(fieldname);
          if(cuntry.value == "US" || cuntry.value == "United States"){
            this.rog = false;
            Dynamic_Errs("Please specify a state.",0,0,0);
         }
         else
            this.rog = true;
       }
       else{
           if(sta != "" && v.value != ""){
          if(Check_Invalid(v.value,valid_numbers) && Check_Invalid(v.value,invalid_text))
            this.rog = true;
          else{
            Dynamic_Errs("You have invalid characters in your state. Please check the spelling and try again.",0,0,0);
            this.rog = true;
          }
         }

         else{
         /*
            for(y=0;y<flen.length;y++){
             if(flen[y][0] == sta){
                if(flen[y][1].value == "US" || flen[y][1].value == "United States"){

                }
             }
            }
            */
            this.rog = true;
         }

       }
    }
//this.rog = false;
return false;
}

function Vcountry(v,n){
    if(n == 10){

       if(v.value == "00"){
         this.rog = false;
         Dynamic_Errs("Please select a Country.",0,0,0);
       }
       else{
        //if(v == "US")
          this.rog = true;
       }
    }
    else{
       if(v.value == ""){
          this.rog = false;
         Dynamic_Errs("Please specify a Country.",0,0,0);
       }
       else{
          if(Check_Invalid(v.value,valid_numbers) && Check_Invalid(v.value,invalid_text))
            this.rog = true;
          else{
            Dynamic_Errs("You have invalid characters in your country. Please check the spelling and try again.",0,0,0);
            this.rog = true;
          }
       }
    }

return false;
}

function Vvccformat(v,n){
v = v.value;
    if(v != ""){
      if(v.length == 3){
         if(!isNaN(v))
          this.rog = true;
         else{
          Dynamic_Errs("Please verify you are only using numbers in your CVV.",0,0,0);
          this.rog = false;
         }
      }
      else{
          Dynamic_Errs("Please verify that the CVV is only three numbers long.",0,0,0);
          this.rog = false;
      }
    }
    else{
      Dynamic_Errs("Please verify that the CVV is three numbers long.",0,0,0);
      this.rog = false;
    }

return false;
}

function Vccformat(v,n){
v = v.value;
    if(v != ""){
      while(v.indexOf("-") >= 0){
          v = v.replace("-","");
       }
      if(v.length == 16){
         if(!isNaN(v))
          this.rog = true;
         else{
          Dynamic_Errs("Please verify you are only using numbers for your credit card.",0,0,0);
          this.rog = false;
         }
      }
      else{
          Dynamic_Errs("Please verify that the credit card number is 16 numbers long.",0,0,0);
          this.rog = false;
      }
    }
    else{
      Dynamic_Errs("Please enter a credit card number.",0,0,0);
      this.rog = false;
    }

return false;
}

function Vcompanyname(v,n){
    v = v.value;
    if(v != ""){
       if(Check_Invalid(v,'~`!@#$%^*_={}[]|:;/\<>?')){
          this.rog = true;
       }
       else{
        Dynamic_Errs("You have invalid characters in your domain name. Please check the spelling and try again.",0,0,0);
        this.rog = false;
       }
    }
    else{
       Dynamic_Errs("Please enter a company name.",0,0,0);
       this.rog = false;
    }
    return false;
}

function Vdomainname(v,n){
    v = v.value;
    v = v.replace("http://","");
    if(v != ""){
       if(Check_Invalid(v,invalid_text)){
          this.rog = true;
       }
       else{
        Dynamic_Errs("You have invalid characters in your domain name. Please check the spelling and try again.",0,0,0);
        this.rog = false;
       }
    }
    else{
       Dynamic_Errs("Please enter a domain name.",0,0,0);
       this.rog = false;
    }
    return false;
}

function Vaddress(v,n){
    v = v.value;
    if(v != ""){
       if(Check_Invalid(v,'~`!@$%^*_={}[]|:;/\<>?')){
          this.rog = true;
       }
       else{
        Dynamic_Errs("You have invalid characters in your domain name. Please check the spelling and try again.",0,0,0);
        this.rog = false;
       }
    }
    else{
       Dynamic_Errs("Please enter an address.",0,0,0);
       this.rog = false;
    }
    return false;
}

function Vcity(v,n){
    v = v.value;
    if(v != ""){
       if(Check_Invalid(v,valid_numbers) && Check_Invalid(v,invalid_text))
         this.rog = true;
       else{
         Dynamic_Errs("There are invalid characters in your city. Please check it and try again.",0,0,0);
         this.rog = false;
       }
    }
    else{
       Dynamic_Errs("Please enter a city.",0,0,0);
       this.rog = false;
    }
    return false;
}

function Vhistorydate(v,n){
   v = v.value;
   if(n == 19){
      if(v != 0){

      }
      else{
         Dynamic_Errs("Please select a date.",0,0,0);
         this.rog = false;
      }
   }
   else{
      if(v != ""){
      var pv = Strip_Chars(v,"-/\,");
         if(isNaN(pv)){
            var td = Split_Date(v,",");

         }

      }
      else{
         Dynamic_Errs("Please enter a date.",0,0,0);
         this.rog = false;
      }
   }
    return false;
}

function Vfuturedate(v,n){
    v = v.value;
    if(n == 20){
      if(v != 0){

      }
      else{
         Dynamic_Errs("Please select a date.",0,0,0);
         this.rog = false;
      }
   }
   else{
      if(v != ""){

      }
      else{
         Dynamic_Errs("Please enter a date.",0,0,0);
         this.rog = false;
      }
   }
    return false;
}

function Vdropdown(v,n){
   v_v = v.value;
   if(v_v != 0 && v.innerHTML.toLowerCase() != "select"){
     this.rog = true;
   }
   else{
      Dynamic_Errs("Please select a value for the "+v.name+" field.",0,0,0);
      this.rog = false;
   }
}

function Vmdropdown(v,n){
var sells = '';
   v_v = v.value;     
   if(v_v != 0 && v.innerHTML.toLowerCase() != "select"){
     for(c0=0;c0<v.length;c0++){
        if(v[c0].selected == true)
            sells += v[c0].value+",";
     }
     var newm = document.createElement('input');
     newm.type = "hidden";
     newm.name = v.id;
     newm.id = v.id;
     newm.value = sells;
     document.getElementById(v.id).parentNode.appendChild(newm);
     this.rog = true;
   }
   else{
      Dynamic_Errs("Please select a value for the "+v.name+" field.",0,0,0);
      this.rog = false;
   }
}



/*************string manipulation***/
function Split_Date(d,del){
   if(d != "" && del != ""){
      d = d.split(del);
   }
   return d;
}

function Check_Invalid(s,c){
c = c.toString();
   if(s != "" && c != ""){
      for(c1=0;c1<s.length;c1++){
        if(c.indexOf(s.charAt(c1)) >= 0)
            return false;
      }
   }
   else
    s = false;
return s;
}

/*************string manipulation***/

/********special fields***********************************/

/*******************read fields**********************/

function Getfields(t){
//FP = form passed in
var inc = 0;
if(t.defs){
  var ret = new Array();
  if(typeof(F) != "undefined"){
    for(x=0;x<F.length;x++){
      for(z1=0;z1<t.defs.length;z1++){
         if(F[x].type != "button" && F[x].name == t.defs[z1][0]){
          ret[inc] = new Array(F[x].name,F[x]);
          inc++;
          }
      }
    }
  }
  else{
     if(typeof(t) == "object"){
     this.FP = Get_Blind_fields;
        for(x=0;x<this.FP.length;x++){
          for(z1=0;z1<t.defs.length;z1++){
            if(this.FP[x].type != "button" && this.FP[x].name == t.defs[z1][0]){
            ret[inc] = new Array(this.FP[x].name,this.FP[x]);
            inc++;
            }
          }
        }
     }
  }

    if(ret.length < 1)
        ret = false;
}
        //return field array
    return ret;
}

function Get_Blind_fields(){
ret = false;
  if(typeof(window['defs']) != "undefined"){
    var start_point;
    if(start_point = document.getElementById(defs[0][0]))
      //this.FP = start_point.parentNode;
      ret = start_point.parentNode;
  }
return ret;
}

/*******************read fields**********************/

/************* Fail red/Pass green fields*********************/

function Mark_Field_Pass(t){
   //t.style.color = "#006633";
   t.style.backgroundColor = "#AAFFD5";
   return true;
}

function Mark_Fields_Fail(t){
   //t.style.color = "#6F0000";
   t.style.backgroundColor = "#FF9595";
   return true;
}

/************* Fail red/Pass green fields*********************/

function GetDefs(t){
  if(typeof(window['defs']) != "undefined")
    return defs;
  else
    return false;
}

function Strip_Chars(s,c){
//s == string, c == chars to remove( in string format)
var bc = '';
  if(s != "" && c != ""){
    for(v_=0;v_<s.length;v_++){
      if(c.indexOf(s.charAt(v_)) >= 0){
      bc = c.indexOf(s.charAt(v_))
        while(s.indexOf(bc) >= 0){
           s = s.replace(bc,"");
        }
      }
    }
  }
  return s;
}

function Compare_Value(t){
//alert(t.len.length+"--"+t.defs.length);
   for(x_=0;x_<t.defs.length;x_++){
     for(z_=0;z_<t.len.length;z_++){
      //alert(t.defs[x_][0]+t.defs[x_][1]+"defs"+"---"+t.defs+"--"+x_);
      //alert(t.len[z_][0]+t.len[z_][1]+"defs"+"---"+t.len+"--"+z_);
      if(t.len[z_] && t.len[z_][0] == t.defs[x_][0]){
        var nobj = t.len[z_][1];
        //alert(t.defs[x_][0]+t.defs[x_][1]+"defs"+"---"+t.defs+"--"+x_);
        var vvv = new var_defs[t.defs[x_][1]](nobj,t.defs[x_][1]);
        if(vvv.rog && nobj){
            Mark_Field_Pass(nobj);
         }
        else{
             Mark_Fields_Fail(nobj);
            }
       }
       //else
        //Dynamic_Errs(t.len[z][0]+" error in compare value "+ t.defs[x_][0],1,0,1);
     }
   }
     if(dyna_err == ''){
        F.submit();
     }
     if(dyna_err != '' && debug_l != 3){
        Show_Errs("err");
        Clear_Errs();
     }

}



function Ajax_Check(ss,d){
//ss == send string , d == direction
var ret = true;

return ret;
}



return this;
}


