
(function($) {

var REG = {
    ondomready: function() {
       REG.links();
       //REG.new_window();
    },
    
    links: function() {
       $("div#content-wrap a").each(function() {
          $a = $(this);
          if (this.href && !/mailto/.test(this.href)) {
             if (! /hbs.edu/.test(this.href)) {$a.addClass("ext");}
             else if (/\.pdf$/.test(this.href)) {$a.addClass("pdf");}
	         else if (/\.ppt$/.test(this.href)) {$a.addClass("ppt");}
	         else if (/\.doc$/.test(this.href)) {$a.addClass("doc");}
             else if (/\.xls$/.test(this.href)) {$a.addClass("xls");}
          }
          if (this.className.indexOf("new_window") > -1 ){
              $(this).click(function(){
                 //prevent doubleclicking
                 if ($(this).hasClass("clicking")) { $(this).removeClass("clicking"); return false; } 
                 $(this).addClass("clicking");
                 REG.new_window(this.href);
                 if ($(this).hasClass("clicking")) { $(this).removeClass("clicking"); }
                 return false;
              });
          }
       });
    },

    new_window: function(link) {
        var url = link.href || link;
        var nw = window.open(url, "newwin", 'width=800,height=550,directories=yes,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
        if (nw) {nw.focus();}
    }
    
}


$(document).ready(REG.ondomready);

})(jQuery);


