<!--


/**********************************************************************
   Country / State
 *********************************************************************/

function initCountryState(countrySelect) {
   
   // populate state select
   populateState(countrySelect.options[countrySelect.selectedIndex].value);
   
   // add onchange event handler to country select to populate state select
   countrySelect.onchange = function() { populateState(this.options[this.selectedIndex].value); };

   // add onreset event handler to form to re-init state / country
   countrySelect.form.onreset = showCountryMessage;
}

function showCountryMessage() {
   
   // show message to select a country
   document.getElementById('state-select-country-message').style.display = 'block';
   
   // show state required label
   document.getElementById('state-required-label').style.display = 'block';
   document.getElementById('state-not-required-label').style.display = 'none';
   
   // hide and disable text input
   var stateInput = document.getElementById('state-input');
   stateInput.style.display = 'none';
   stateInput.disabled = true;
   
   // hide and enable select
   var stateSelect = document.getElementById('ctl00_LeftColumnContentPlaceholder_ddlState');
   stateSelect.style.display = 'none';
   stateSelect.disabled = false;
}


function populateState(country) {
   if (country == 'USA') {
      var stateArray =  new Array("('Select State','Select State',true,true)",
         "('Alabama','AL')",
         "('Alaska','AK')",
         "('Arizona','AZ')",
         "('Arkansas','AR')",
         "('California','CA')",
         "('Colorado','CO')",
         "('Connecticut','CT')",
         "('Delaware','DE')",
         "('District of Columbia','DC')",
         "('Florida','FM')",
         "('Georgia','GA')",
         "('Hawaii','HI')",
         "('Idaho','ID')",
         "('Illinois','IL')",
         "('Indiana','IN')",
         "('Iowa','IA')",
         "('Kansas','KS')",
         "('Kentucky','KY')",
         "('Louisiana','LA')",
         "('Maine','ME')",
         "('Maryland','MD')",
         "('Massachusetts','MA')",
         "('Michigan','MI')",
         "('Minnesota','MN')",
         "('Mississippi','MS')",
         "('Missouri','MO')",
         "('Montana','MT')",
         "('Nebraska','NE')",
         "('Nevada','NV')",
         "('New Hampshire','NH')",
         "('New Jersey','NJ')",
         "('New Mexico','NM')",
         "('New York','NY')",
         "('North Carolina','NC')",
         "('North Dakota','ND')",
         "('Ohio','OH')",
         "('Oklahoma','OK')",
         "('Oregon','OR')",
         "('Pennsylvania','PA')",
         "('Rhode Island','RI')",
         "('South Carolina','SC')",
         "('South Dakota','SD')",
         "('Tennessee','TN')",
         "('Texas','TX')",
         "('Utah','UT')",
         "('Vermont','VT')",
         "('Virginia','VA')",
         "('Washington','WA')",
         "('West Virginia','WV')",
         "('Wisconsin','WI')",
         "('Wyoming','WY')"
      );
   }
   else if (country == 'Canada') {
      var stateArray =  new Array("('Select Province','Select State',true,true)",
         "('Alberta','Alberta')",
         "('British Columbia','British Columbia')",
         "('Manitoba','Manitoba')",
         "('New Brunswick','New Brunswick')",
         "('Newfoundland','Newfoundland')",
         "('Northwest Territories','Northwest Territories')",
         "('Nova Scotia','Nova Scotia')",
         "('Nunavut','Nunavut')",
         "('Ontario','Ontario')",
         "('Prince Edward Island','Prince Edward Island')",
         "('Quebec','Quebec')",
         "('Saskatchewan','Saskatchewan')",
         "('Yukon Territory','Yukon Territory')"
      );
   }

   // for non-empty selection
   if (country != 'Select Country') {      
      
      // hide message to select a country
      document.getElementById('state-select-country-message').style.display = 'none';
     
      // countries that require a state / province selection
      if (country == 'USA' || country == 'Canada') {
         
         // show state required label
         document.getElementById('state-required-label').style.display = 'block';
         document.getElementById('state-not-required-label').style.display = 'none';

         // hide and disable text input
     
         var stateInput = document.getElementById('state-input');
         if (stateInput != null)
         {
             stateInput.style.display = 'none';
             stateInput.disabled = true;
         }
              

         // show and enable select
         var stateSelect = document.getElementById('ctl00_LeftColumnContentPlaceholder_ddlState');
         stateSelect.style.display = 'block';
         stateSelect.disabled = false;
       
         
         // populate state select
         eval("document.getElementById('ctl00_LeftColumnContentPlaceholder_ddlState').options.length = stateArray.length");
         for (var optionIndex = 0; optionIndex < stateArray.length; optionIndex++) {
            eval("document.getElementById('ctl00_LeftColumnContentPlaceholder_ddlState').options[optionIndex]=" + "new Option" + stateArray[optionIndex]);
         }
            
            var hiddenStateValue = document.getElementById('ctl00_LeftColumnContentPlaceholder_txtHiddenStateSelection');
           
            if(hiddenStateValue != null )
            {            
                
                var hiddenState = hiddenStateValue.value; 
                
                     for(var i=0; i < stateSelect.length; i++)
                     {                
                        if(stateSelect.options[i].value == hiddenState)
                        {   
                            stateSelect.options.selectedIndex = i;                                           
                        }    

                     }                 
            }
         
      }
      
      // for other selections 
      else {
         
         // show state not required label
         document.getElementById('state-required-label').style.display = 'none';
         document.getElementById('state-not-required-label').style.display = 'block';
     
         // show and enable text input
         var stateInput = document.getElementById('state-input');
         stateInput.style.display = 'block';
         stateInput.disabled = false;
           
         // hide and disable select
         var stateSelect = document.getElementById('ctl00_LeftColumnContentPlaceholder_ddlState');
         stateSelect.style.display = 'none';
         stateSelect.disabled = true;
         
         var hiddenStateInput = document.getElementById('ctl00_LeftColumnContentPlaceholder_txtHiddenStateInput');
            if(hiddenStateInput != null)
            {            
                var hiddenInput = hiddenStateInput.value; 
               
                 if(hiddenInput != '')
                 {
                    if(hiddenInput != null)
                    {
                       stateInput.value = hiddenInput;
                        
                    }
                 }
            }
      }
   }
   
   // for an empty selection
   else {
      showCountryMessage();
   }
  
   validationZipcode();
   validateState()
}

function initCaps(str) {
// converts passed in string to initial capitalization
	str = str.toLowerCase();	
	
	// use Regular Expression to convert to capitalization
	var reInitCaps = /\b\w/g;
	str = str.replace(reInitCaps, function (s1) { return s1.toUpperCase(); })
	
	return str;
}

function validateState(){

    var selectedCountry = document.getElementById("ctl00_LeftColumnContentPlaceholder_country_select").value;
    if(selectedCountry != null)
    {          
        var customStateValidator = document.getElementById("ctl00_LeftColumnContentPlaceholder_cstState"); 
        var stateSpanTag = document.getElementById("lblstateSpan");
        stateSpanTag.Visible = false;
         if(customStateValidator != null)
        {        
            if(selectedCountry == 'USA' || selectedCountry == 'Canada')
            {
                customStateValidator.enabled = true;
                stateSpanTag.Visible = true; 
            }
            else
            {
                customStateValidator.enabled = true;
            }             
        }   
    }

}

 
function validationZipcode(){
   
   var selectedCountry = document.getElementById("ctl00_LeftColumnContentPlaceholder_country_select").value;
   var zipUSValidator = document.getElementById("ctl00_LeftColumnContentPlaceholder_regUSZipcode");
   var zipCanadaValidator = document.getElementById("ctl00_LeftColumnContentPlaceholder_regCanadaZipcode");
   var zipFranceValidator =  document.getElementById("ctl00_LeftColumnContentPlaceholder_regFranceZipcode");
   var zipGermanyValidator = document.getElementById("ctl00_LeftColumnContentPlaceholder_regGermanyZipcode");
   var zipItalyValidator = document.getElementById("ctl00_LeftColumnContentPlaceholder_regItalyZipcode");
   var zipJapanValidator = document.getElementById("ctl00_LeftColumnContentPlaceholder_regJapanZipcode");
   var zipRussiaValidator = document.getElementById("ctl00_LeftColumnContentPlaceholder_regRussiaZipcode");
   var zipUKValidator = document.getElementById("ctl00_LeftColumnContentPlaceholder_regUKZipcode");
   var reqZipcode= document.getElementById("ctl00_LeftColumnContentPlaceholder_reqZipCode");
   
   if(zipUSValidator != null)
   {
        
        zipUSValidator.enabled = false;
        
       
       
        zipCanadaValidator.enabled = false;        
        zipFranceValidator.enabled = false;
        zipGermanyValidator.enabled = false;
        zipItalyValidator.enabled = false;
        zipJapanValidator.enabled = false;
        zipRussiaValidator.enabled = false;
        zipUKValidator.enabled = false;
        reqZipcode.enabled = false;
       
       
        
       switch(selectedCountry)
       {
           
            case "USA":  
                zipUSValidator.enabled = true;
                reqZipcode.enabled = true;
                break;
            
             case "Canada":            
                zipCanadaValidator.enabled = true;
                reqZipcode.enabled = true;
                break;
                
             case "France":
                zipFranceValidator.enabled = true;
                reqZipcode.enabled = true;
                break;
                
             case "Germany":
                zipGermanyValidator.enabled = true;
                reqZipcode.enabled = true;
                break;
                
             case "Italy":
                zipItalyValidator.enabled = true;
                reqZipcode.enabled = true;
                break;
                
             case "Japan":
                zipJapanValidator.enabled = true;
                reqZipcode.enabled = true;
                break;
            
             case "Russian_Federation":
                zipRussiaValidator.enabled = true;
                reqZipcode.enabled = true;
                break;
                
             case "UK":
                zipUKValidator.enabled = true;
                reqZipcode.enabled = true;
                break;
        }
    }
   
}
    

//-->