var Signup = {
	
	registerHooks: function() {
    if($('domain_subdomain')) {
      new Form.Element.Observer('domain_subdomain', 1, this.checkAvailability.bind(this) );        
	    new CountryChoice('shop_country', 'shop_province', true);
    }
	},
  
  checkAvailability: function(element, value) {
    if (value.length >= 4 ) {
      new Ajax.Request('/services/signup/check_availability', {parameters: "domain[subdomain]="+value+"&domain[domain]="+ $F('domain_domain')});
    } 
    else {
      $('available').innerHTML = "<span class='negative'>Subdomain must be at least 4 characters.</span>";
    }
  },
  
  activateTheme: function(theme) {
    $$('.jcarousel-control li').each(function(a) { a.removeClassName('active') });
    $('selected-theme').value = theme;
    $('select-'+theme).addClassName('active');
  }
  
};  

Event.observe(window, 'load', Signup.registerHooks.bind(Signup)); 

Ajax.Responders.register({
 onCreate : function() { $('spinner').show(); },
 onComplete : function() { $('spinner').hide(); }
});
