var $j = jQuery.noConflict();

$j(function(){
			
	$j('li.headlink').hoverIntent(
		function() { $j('ul', this).fadeIn("slow"); },
		function() { $j('ul', this).fadeOut("slow"); }
	);
			
	$j("img.prev").hover(
		function() { this.src = this.src.replace("_off","_on"); },
		function() { this.src = this.src.replace("_on","_off"); }
	);
	
	$j("img.next").hover(
		function() { this.src = this.src.replace("_off","_on"); },
		function() { this.src = this.src.replace("_on","_off"); }
	);
			
	//Assign the ColorBox event to elements
	$j(".lightboxWindow").colorbox({width:"760px", height:"470px"});
	$j(".calcWindow").colorbox({iframe:true, innerWidth:325, innerHeight:350});
	$j(".contactWindow").colorbox({iframe:true, innerWidth:720, innerHeight:420});
	
	$j('.storyLink').hover(function(){
		$j('h1.caption').html(
		   $j(this).attr('title')
		);
	},
	function(){ 
		$j('h1.caption').html('');
	});

	//open external links in a new window by adding rel="external"
	$j('a[rel="external"]').click( function() {
		window.open( $j(this).attr('href') );
		return false;
	});	
	
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($j("a.jqbookmark").attr("rel") != ""){
			$j("a.jqbookmark").attr("rel","sidebar");
		} 
	}

	$j("a.jqbookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.title;
		
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing
		} else { 
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}
	
	});
	
});
