// This helps to make sure that jQuery doesn't conflict with the $ object of other libraries.

jQuery(document).ready(function($){
//jQuery.noConflict()(function($){

	/* CMTBC - prevent content showing above header submenu items in IE6 */
	$('#nav ul li ul').bgiframe();

	/* Functionality for the Top Stories on the homepage, news and sports home */
	$('ul.categories').parent().tabs();
	//$('ul.categories').tabs({ fx: { opacity: 'toggle', duration: 100 } });//.tabs('rotate', 8000, false);
	/* tab rotation
	$('ul.categories').parent().hover(
		function(){
			$(this).find('ul.categories').tabs('rotate', 0);
		},
		function(){
			$(this).find('ul.categories').tabs('rotate', 8000, false);
		}
	);
	*/

	/* MouseOver Functionality for story image swap */
	$('.stories li').hover(
		function(){
			// Highlight the selected news item
			$(this).parent().find('li a').removeClass('selected');
			$(this).find('a').addClass('selected');

			// Swap the main image with the image for this story
			var imagePath = $(this).find('div.story-image img').attr('src');
			$(this).parent().parent().find('p.section-photo img').attr('src', imagePath);
		},
		function(){}
	);

	/*** tooltip.js is no longer included in the master header by default ***/
	/* Tool Tip for the Product Sign Up */
	try{
		$('#tooltip-wrap').hide();
		$('#password-tip img').hover(
			function () {
				$('#tooltip-wrap').slideDown('slow');
			},
			function () {
				$('#tooltip-wrap').slideUp('slow');
			}
		);
	} catch(e){}

	/*** tooltip.js is no longer included in the master header by default ***/
	/* Tooltips for product descriptions - simply add the class tooltip to any link you want.
	   The tooltip content is determined like so: title="<tooltip title> - <tooltip content>" */
	try{
		$(".tooltip").tooltip({
			track: true,
			showBody: " - ",
			showURL: false
		});
	} catch(e){}

	/* MouseOver Functionality for header menu */
	$('#nav li').hover(
		function(){
			$(this).find('ul').show();
		},
		function(){
			$(this).find('ul').hide();
		}
	);

	/* Calendar */
	$('.header-date').attr('title', 'Click for calendar :)');
	$('.header-date').click(function(){
		window.open('http://siteassets.eircom.net/calendar', '_blank')
	});
});