  var fm;
  var state_fd;
  var country_fd;
  var bStateInit = false;
  var formname_ele; 
  var campaignid_ele;

  arNotApply = Array( new Option("Not Required", ''));
  
  arCanada = Array( new Option("Select One", '')
            , new Option("Alberta", "AB")
            , new Option("British Columbia", "BC")
            , new Option("Manitoba", "MB")
            , new Option("New Brunswick", "NB")
            , new Option("Newfoundland", "NL")
            , new Option("Northwest Territories", "NT")
            , new Option("Nova Scotia", "NS")
            , new Option("Nunavut", "NU")
            , new Option("Ontario", "ON")
            , new Option("Prince Edward Island", "PE")
            , new Option("Quebec", "QC")
            , new Option("Saskatchewan", "SK")
            , new Option("Yukon", "YT")
  );
  
  arUSA = Array(    new Option("Select One", '')
            , new Option("Alabama", "AL")
            , new Option("Alaska", "AK")
            , new Option("Arizona", "AZ")
            , new Option("Arkansas", "AR")
            , new Option("California", "CA")
            , new Option("Colorado", "CO")
            , new Option("Connecticut", "CT")
            , new Option("Delaware", "DE")
            , new Option("District of Columbia", "DC")
            , new Option("Florida", "FL")
            , new Option("Georgia", "GA")
            , new Option("Hawaii", "HI")
            , new Option("Idaho", "ID")
            , new Option("Illinois", "IL")
            , new Option("Indiana", "IN")
            , new Option("Iowa", "IA")
            , new Option("Kansas", "KS")
            , new Option("Kentucky", "KY")
            , new Option("Louisiana", "LA")
            , new Option("Maine", "ME")
            , new Option("Maryland", "MD")
            , new Option("Massachusetts", "MA")
            , new Option("Michigan", "MI")
            , new Option("Minnesota", "MN")
            , new Option("Mississippi", "MS")
            , new Option("Missouri", "MO")
            , new Option("Montana", "MT")
            , new Option("Nebraska", "NE")
            , new Option("Nevada", "NV")
            , new Option("New Hampshire", "NH")
            , new Option("New Jersey", "NJ")
            , new Option("New Mexico", "NM")
            , new Option("New York", "NY")
            , new Option("North Carolina", "NC")
            , new Option("North Dakota", "ND")
            , new Option("Ohio", "OH")
            , new Option("Oklahoma", "OK")
            , new Option("Oregon", "OR")
            , new Option("Pennsylvania", "PA")
            , new Option("Rhode Island", "RI")
            , new Option("South Carolina", "SC")
            , new Option("South Dakota", "SD")
            , new Option("Tennessee", "TN")
            , new Option("Texas", "TX")
            , new Option("Utah", "UT")
            , new Option("Vermont", "VT")
            , new Option("Virginia", "VA")
            , new Option("Washington", "WA")
            , new Option("West Virginia", "WV")
            , new Option("Wisconsin", "WI")
            , new Option("Wyoming", "WY")
  );
  
  function SVInitStateOpts(){ 
    state_fd = document.getElementById('idCompanyState');
    country_fd = document.getElementById('idCompanyCountry');
    mapCountries = {"CA":arCanada, "US":arUSA};
    bStateInit = true;
  }

    function SVSwapCountryStates(arCountry){
      state_fd = document.getElementById('idCompanyState');
      country_fd = document.getElementById('idCompanyCountry');
      new_ubound = arCountry.length;
      old_ubound = state_fd.options.length;
      z_ubound = old_ubound;
      if(new_ubound > old_ubound){z_ubound=new_ubound;}
      for(oi=0; oi < new_ubound; oi++){state_fd.options[oi] = arCountry[oi];}
      for(zi = state_fd.options.length-1;zi>=oi;zi--){state_fd.options[zi]= null;}
    }

    function SVCheckStates(c){
      if(!bStateInit){SVInitStateOpts();}
      if(c == ''){
        arCountry = arNotApply;
      }else{
        arCountry = mapCountries[c];
        if(typeof(arCountry) == 'undefined'){arCountry = arNotApply;}
        if(arCountry){SVSwapCountryStates(arCountry);}
        var st_span = document.getElementById('state_req_span');
        if ((c == 'US')||(c == 'CA')) {
          st_span.style.display = "none";
          document.getElementById('idCompanyState').style.display = "block";
        }
        else {
          st_span.style.display = "block";
          document.getElementById('idCompanyState').style.display = "none";
        }
      }
    }

  function SVIsValidPhoneNumber(num, requiredDigits) {
      var digits = 0;
      if (num == null) return false;
      for( i=0; i<num.length; i++ ){
          var c = num.charCodeAt(i);  
          if( (c>=48) && (c<=57) ) digits++;
      }    
      return (digits >= requiredDigits);
  }
  function SVIsValidEmail(emailad) {
     var exclude=/[^@\-\.\w\']|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
     var check=/@[\w\-]+\./;
     var checkend=/\.[a-zA-Z]{2,4}$/;
     return (((emailad.length > 80) || (emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1))?false:true;
  }
  function SVSFDCSignUpValidate() {
      var blnReturn = false;
      var ArErrMsg= new Array();
      var err_msg = new String();
      if((document.getElementById('idUserFirstName')) && (document.getElementById('idUserFirstName').value.length < 1)){
        err_msg += "Enter your First Name \n";
      }
      
      if((document.getElementById('idUserLastName')) && (document.getElementById('idUserLastName').value.length < 1)){
        err_msg += "Enter your Last Name \n";
      }
      
      if((document.getElementById('idUserTitle')) && (document.getElementById('idUserTitle').value.length < 1)){
        err_msg += "Enter your Last Title \n";
      }
      
      if((document.getElementById('idCompanyName')) && (document.getElementById('idCompanyName').value.length < 1)){
        err_msg += "Enter your Company Name \n";
      }
     
      if (!SVIsValidPhoneNumber(document.getElementById('idUserPhone').value, 10)) { 
          err_msg += "Enter a Valid Phone Number \n";
      }
      if (!SVIsValidEmail(document.getElementById('idUserEmail').value)) {
          err_msg += "Enter a Valid Email Address \n";
      }

      if(document.getElementById('idCompanyCountry').selectedIndex < 1){
          err_msg += "Choose a Valid Country \n";
      }else{  
        c_ele = document.getElementById('idCompanyCountry');
        var c_val = c_ele[c_ele.selectedIndex].value;
        if((c_val == 'CA') || (c_val == 'US')){if(document.getElementById('idCompanyState').selectedIndex < 1) {
          err_msg += "Enter your State/Province \n";
        }}
    }             
      if(document.getElementById('idCompanyEmployees').selectedIndex < 1) {
        err_msg += "Select the Number of Employees \n";
      }
    
      if ((document.getElementById('idprocess_form').value != false) && (document.getElementById('idSubscriptionAgreement').checked != true)){
        err_msg += "Please read and agree to the Master Subscription Agreement \n";    
      }

      if (err_msg.length > 0) {
        alert(err_msg);
        blnReturn = false;
      }
  
      if (err_msg.length > 0) {
        blnReturn = false;
      }
      else {
        blnReturn = true;
      }   
      return blnReturn;
    }
    
    function fncSVSignupSubmit() {
      var blnReturn = false;
      var blnValid = SVSFDCSignUpValidate();
      if (blnValid) {
        var strActionURL = document.getElementById('idSVFormAction').value;
        blnReturn = fncSVFormSubmit('idSignupFormContainer', 'post', strActionURL);
      }
      
      return blnReturn;
    }