﻿// JScript File
var stateDropDown = jQuery(".NormalDropDownState");
var filteredDropDown = jQuery(".NormalDropDownStore");
var fullDropDown = jQuery(".NormalDropDownFullStore");
var selectedState = "";

stateDropDown.change(function () { 
    jQuery("option:selected", stateDropDown).each(function (i) { 
        selectedState = jQuery(this).text(); 
    }); 
    
    filteredDropDown.empty();
    
    //Now add in stores relevant to the state
    filteredDropDown.append("<option value='' selected='true'>(please select an option)</option");
    jQuery(".NormalDropDownFullStore option").each(function() {
        if (jQuery(this).val().indexOf(selectedState + ";") == 0)
            filteredDropDown.append(jQuery(this).clone());
        
    });
    
    //Now strip out unwanted State
    jQuery(".NormalDropDownStore option").each(function() {
        var optionValue = jQuery(this).val();
        jQuery(this).val(optionValue.substr(optionValue.indexOf(";") + 1));
    });
    
});


