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');
    }
    if (obj.get('href') && (obj.get('type') == 'popup')){
      obj.addEvent("click", function(event){
        popObj(this.get('href'));
        return false;
      });
    }
  });

  /* 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');
    	});
    });
  }

  /* drop downs */
  if (Browser.Engine.trident || Browser.Engine.webkit){
    var nav = $$('#nav ul li');
    nav.each(function(navs, i) {
      navs.addEvent("mouseenter", function(event) {
        this.addClass('hover');
      });
    	navs.addEvent("mouseleave", function(event) {
        this.removeClass('hover');
      });
    });
  }

  /* prev events */
  var objs = $$('#prev-events div h3 a');
  objs.each(function(obj, i) {
    obj.addEvent("click", function(event) {
      if (!$(this.parentNode.parentNode).hasClass('active')){
        $$('#prev-events div').removeClass('active');
        $(this.parentNode.parentNode).addClass('active');
      }
      return false;
    });
  });

});

function popObj(arg){
  var b = $$('base').get('href');
  newwindow=window.open(""+arg,"name","height=640, width=480, resizable=no, scrollbars=no, status=yes");
  if(window.focus){
    newwindow.focus();
  }
  return false
}
