
YAHOO.util.Event.onDOMReady(
    function(){
        var contrib_locale = new locale( 
            {
                get_region_row: get_region_row, 
                get_postal_row: get_postal_row 
            }
        );

        LOCALE_COUNTRY_LISTENER = new YAHOO.util.CustomEvent('blue_country_event');
        LOCALE_COUNTRY_LISTENER.subscribe( function(){ contrib_locale.load(true); }, contrib_locale);
        
        YAHOO.util.Event.addListener(contrib_locale.get_country(),"change",
            function(e,contrib_locale){ contrib_locale.load(); }, contrib_locale, true);
        

            // add a listener to deal with region level postal exceptions
        if(contrib_locale.region_postal_exceptions.length > 0){
            YAHOO.util.Event.addListener('state_cd','change',contrib_locale.handle_postal_exceptions,contrib_locale);
        }
        
        
        // locale for the contrib employer address form
        var contrib_employer_locale = new locale( 
            {
                get_region_row: get_region_row, 
                get_postal_row: get_postal_row,
                country_el: 'employer_country',
                region_el: 'employer_state_cd',
                postal_el: 'employer_zip'
            }
        );
        
        YAHOO.util.Event.addListener(contrib_employer_locale.get_country(),"change",
            function(e,contrib_employer_locale){ contrib_employer_locale.load(); }, contrib_employer_locale, true);
        

            // add a listener to deal with region level postal exceptions
        if(contrib_employer_locale.region_postal_exceptions.length > 0){
            YAHOO.util.Event.addListener('employer_state_cd','change',contrib_employer_locale.handle_postal_exceptions,contrib_employer_locale);
        }
    }
);


function get_region_row(){
    var region = YAHOO.util.Dom.get(this.region_el);
    return (region) ? region.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode : null;
}

function get_postal_row(){
    var zip = YAHOO.util.Dom.get(this.postal_el);
    return (zip) ? zip.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode : null;
}
