window.addEvent('domready', function() {

  /* external links */
  var objs = $$('a');
  objs.each(function(obj, i) {
    if (obj.get('href') && (obj.get('rel') == 'external')){
      obj.set('target', '_blank');
    }
  });

  /* IE hovers */
  if (Browser.Engine.trident){
    var objs = $$('button');
    objs.each(function(obj, i) {
      obj.addEvent("mouseover", function(event) {
        this.addClass('hover');
      });
    	obj.addEvent("mouseout", function(event) {
        this.removeClass('hover');
      });
    });
    var objs = $$('input').extend($$('textarea'));
    objs.each(function(obj, i) {
      obj.addEvent("focus", function(event) {
        this.addClass('focus');
    	});
    	obj.addEvent("blur", function(event) {
        this.removeClass('focus');
    	});
    });
  }

  var objs = $$('#quicklink1 a');
  objs.each(function(obj, i) {
    obj.addEvent('mouseover', function(event){
      $$('#quicklink1 a').addClass('hover');
    });
    obj.addEvent('mouseout', function(event){
      $$('#quicklink1 a').removeClass('hover');
    });
  });

  $$('.email').each(function(el) {
    var anchor = new Element('a', {
      href: 'mailto:' + el.get('rel').replace('|','@'),
      'class': el.get('class'),
      'text': el.get('text')
    }).replaces(el);
  });

  if ($chk($('distlist'))) {

    var objs = $$('h3');
    objs.each(function(obj, i) {
      obj.addEvent("mouseover", function(event) {
        this.addClass('hover');
      });
    	obj.addEvent("mouseout", function(event) {
        this.removeClass('hover');
      });
    });

    var url = ''+window.location;
    var arg = url.split('#')[1];
    var display = -1;
    switch(arg){
      case 'aus':
        display = 0;
      break;
      case 'nz':
        display = 1;
      break;
      case 'hk':
        display = 2;
      break;
      case 'singapore':
        display = 3;
      break;
    }
    var myAccordion = new Accordion($('distlist'), 'h3', 'div.element', {
  	  alwaysHide: true,
  	  display: display,
  		opacity: true,
  		onActive: function(toggler, element){
  		  toggler.addClass('active');
  		  element.setStyle('padding-bottom', '1px');
  		},
  		onBackground: function(toggler, element){
  		  toggler.removeClass('active');
  		  element.setStyle('padding-bottom', '0');
  		}
  	});
	}

});

Cufon.replace('h2', {
  fontFamily: 'Arial'
});