/*
 * newWindow 1.1 - jQuery plugin for adding new window functionality to links.
 * http://www.alexanderdickson.com/projects/jquery-plugins/newwindow/
 *
 * Copyright (c) 2009 Alex Dickson
 * Licensed under the MIT licenses.
 * See website for more info.
 *
 * Date: 2009-08-22 09:03:00 +1000 (Sunday, 23 Aug 2009)
 */

 (function($){  
  $.fn.newWindow = function(options) {   
    var defaults = {
		titleText: 'Link opens in a new window'
	};	
	var options = $.extend(defaults, options);   
     return this.each(function() {  
	   var obj = $(this);
       if ( ! obj.is('a')) {
           return;
       };
	   if (options.titleText != '') {   
		   if (obj.attr('title')) {
				var newTitle = obj.attr('title') + ' (' + options.titleText + ')';
		   } else {
				var newTitle = options.titleText;   
		   };		   
		   obj.attr('title', newTitle);   
	   };
	   obj.click(function(event) {
	   	  event.preventDefault();  
		  var newBlankWindow = window.open(obj.attr('href'), '_blank');
		  newBlankWindow.focus();
		}); 
	   });
  };  
 })(jQuery); 
