$(document).ready(function() {
	/******************
	* Rounded Corners
	*/
	// Panels
	$(".onePanel").corner("8px");
	$(".leftPanel").corner("8px");
	$(".rightPanel").corner("8px");
	
	// Link bar
	$("#linkbar").corner("8px");
	
	// Tab selection
	//$("div.tabs > div").corner("right 8px");
	$("ul.tabNavigation li a").corner("top 10px");
	
	// Tab content body style
	// If IE browser < 9 then fix border coner curve - NOTE hopefully IE 9 will function correctly like other browsers
	if ($.browser.msie && $.browser.version.substr(0,1)<9) {
		$("div.tabs > div").css('background', '4px solid #666666').corner("tr, br, bl 8px");
		$(".fix").css('padding', '5px');
	} else { 
	// Not IE browser
		$("div.tabs > div").corner("tr, br, bl 8px");
	}
	

	/******************
	* Image effects
	*/
	// Full Caption Sliding (Hidden to Visible)
	$('.boxgrid.captionfull').hover(function(){
		$(".cover", this).stop().animate({top:'287px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'387px'},{queue:false,duration:160});
	});
	
	
	/******************
	* Tab function
	*/
		var tabContainers = $('div.tabs > div');
		tabContainers.hide().filter(':first').show(); // Hide all, Then show first
		

		$('div.tabs ul.tabNavigation a').click(function () {
			tabContainers.hide();
			tabContainers.filter(this.hash).show().slideDown("fast");
			$('div.tabs ul.tabNavigation a').removeClass('selected');
			$(this).addClass('selected');
			return false; // Stop default browers behaviour of going to the anchor
		//}).filter(':first').click(); // Automatically show first tab
		}).filter(window.location.hash ? '[hash=' + window.location.hash + ']' : ':first').click();
		
		// Tab link from text outside of the tabNavigation menu
		$('span.altTab a').click(function () {
			tabContainers.hide();
			tabContainers.filter(this.hash).show();
			$('div.tabs ul.tabNavigation li a').removeClass('selected');
			//alert(this);
			$(this).closest('li').addClass('selected');
			//$(this).addClass('selected');
			
			return false;
		});
	

	/******************
	* Fancybox popup (lightbox)
	*/	

	$(".pdfFancyFrame").fancybox({
		//'padding'			: 0,
		'scrolling' 		: 'no',
		'width'				: '85%',
		'height'			: '85%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

	$(".sendtoafriendFancyFrame").fancybox({
		//'padding'			: 0,
		//'scrolling' 		: 'no',
		'width'				: 650,
		'height'			: 500,
		'autoScale'			: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe'
	});
	
	$(".quizFancyFrame").fancybox({
		//'padding'			: 0,
		//'scrolling' 		: 'no',
		'width'				: 320,
		'height'			: 420,
		'autoScale'			: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe'
	});
	
});
