/*
 * Script Name: ExternalLink
 * Description: Easily open external links in a new window using jQuery
 * Version: 1.0
 * Author: Darrin Boutote
 * Author URI: http://www.martinish.com/about/
 */
/*  
 * Copyright 2009  Darrin Boutote  (contact : http://www.martinish.com/contact/)
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
// init a variable for the jQuery noConflict function 
var $Q = jQuery.noConflict();

$Q(document).ready(function() {
	// find all links that begin with "http://"
    $Q('a.external[href^="http://"]').filter(function(){ 
	
		// filter out links that have the same domain name as the current page
		return this.hostname && this.hostname !== location.hostname; 
	})
        
		// add a CSS class of "external" to each external link (for styling)
		//.addClass("external")
		
		// inform visitor that link will open in new window
        .attr( 'title', 'Link will open in new window')
		
		// open link in new window once clicked
		.click( function() {
				window.open(this.href);
				return false;
		});
});