12 var CountryModel = Class.create();
    13 CountryModel.prototype = {
    14     initialize : 
function()
    17         this.bindSpecificCountryRelation();
    19     bindSpecificCountryRelation : 
function(parentId)
    23             var applyCountryElements = $$(
'#'+parentId+
' .shipping-applicable-country');
    25             var applyCountryElements = $$(
'.shipping-applicable-country');
    27         for(var i=0;i<applyCountryElements.length; i++) {
    28             Event.observe(applyCountryElements[i], 
'change', this.checkSpecificCountry.bind(
this));
    29             this.initSpecificCountry(applyCountryElements[i]);
    33     initSpecificCountry : 
function(element){
    34         var applyCountryElement = element;
    35         if (applyCountryElement && applyCountryElement.id) {
    36             var specifCountryElement  = $(applyCountryElement.id.replace(/sallowspecific/, 
'specificcountry'));
    37             var showMethodElement  = $(applyCountryElement.id.replace(/sallowspecific/, 
'showmethod'));
    39             if (specifCountryElement) {
    40                 if (applyCountryElement.value == 1 && !specifCountryElement.hasAttribute(
'disabled')) {
    42                    specifCountryElement.enable();
    43                    if (showMethodElement) {
    44                        this.showElement(showMethodElement.up(1));
    48                    specifCountryElement.disable();
    49                    if (showMethodElement) {
    50                        this.hideElement(showMethodElement.up(1));
    58     checkSpecificCountry : 
function(event)
    60         var applyCountryElement = Event.element(event);
    61         if (applyCountryElement && applyCountryElement.id) {
    62             var specifCountryElement  = $(applyCountryElement.id.replace(/sallowspecific/, 
'specificcountry'));
    63             var showMethodElement  = $(applyCountryElement.id.replace(/sallowspecific/, 
'showmethod'));
    65             var useDefaultElement = document.getElementById(specifCountryElement.id + 
'_inherit');
    68             if (specifCountryElement) {
    69                 if (applyCountryElement.value == 1) {
    71                    specifCountryElement.disabled = useDefaultElement ? useDefaultElement.checked : 
false;
    72                    if (showMethodElement) {
    73                        this.showElement(showMethodElement.up(1));
    77                     this.unselectSpecificCountry(specifCountryElement);
    78                     specifCountryElement.disable();
    79                     if (showMethodElement) {
    80                         this.hideElement(showMethodElement.up(1));
    88     unselectSpecificCountry : 
function(element)
    90         for (var i=0; i<element.options.length; i++) {
    91             if (element.options[i].selected) {
    92               element.options[i].selected=
false;
    97     showElement : 
function(elm)
   100             if (!elm.down(
'.shipping-skip-show')) {
   106     hideElement : 
function(elm)
   109             if (!elm.down(
'.shipping-skip-hide')) {
   116 countryApply = 
new CountryModel();