window.addEvent('load',function(){
    if( $('InputCountry') ){
        /*/////////////////////////////////////////////////////////////////////////////////////////////
        // Dynamic Country / Province Toggling
        /*/////////////////////////////////////////////////////////////////////////////////////////////
        $('InputCountry').addEvent('change',function(){
            var pars = $('InputCountry').name+'='+$('InputCountry').options[$('InputCountry').selectedIndex].value;
            if ($('InputCountry').options[$('InputCountry').selectedIndex].value != ""){
                new Ajax( '/ajax/select_province.php', {
                    method: 'post',
                    postBody: pars,
                    update: $('InputProvinceDiv')
                } ).request();
            }
        });
    }

    if( $('Country') ){
        /*/////////////////////////////////////////////////////////////////////////////////////////////
        // Dynamic Country / Province Toggling
        /*/////////////////////////////////////////////////////////////////////////////////////////////
        $('Country').addEvent('change',function(){
            var pars = $('Country').name+'='+$('Country').options[$('Country').selectedIndex].value;
            if ($('Country').options[$('Country').selectedIndex].value != ""){
                new Ajax( '/ajax/select_province.php', {
                    method: 'post',
                    postBody: pars,
                    update: $('InputProvinceDiv')
                } ).request();
            }
        });
    }

    if( $('shipping_Country') ){
        /*/////////////////////////////////////////////////////////////////////////////////////////////
        // Dynamic Country / Province Toggling
        /*/////////////////////////////////////////////////////////////////////////////////////////////
        $('shipping_Country').addEvent('change',function(){
            var pars = 'country_code='+$('shipping_Country').options[$('shipping_Country').selectedIndex].value+'&field_id=shipping_InputProvince&field_name=shipping_province_code';
            if ($('shipping_Country').options[$('shipping_Country').selectedIndex].value != ""){
                new Ajax( '/ajax/select_province.php', {
                    method: 'post',
                    postBody: pars,
                    update: $('shipping_InputProvinceDiv')
                } ).request();
            }
        });
    }

    if ($('InputSubsType')&&$('SubscribeFldsDiv')){
        $$('input[name=subs_type]').each(function(radio){
        //$$('#InputSubsType div').each(function(radio){
            radio.addEvent('click',hideSubsFlds.pass([radio.value]));
            if (radio.checked) hideSubsFlds(radio.value);
        });
    }

    function hideSubsFlds(val){
       $('SubscribeFldsDiv').setStyle('display',(val=='u')?'none':'');
    }
});

function UpdateProvince(src, dest){
    src.addEvent('change', function(){ dest.value = src.value;});
}
