 $(document).ready( function(){	
		var buttons = { previous:$('#lofslidecontent45 .lof-previous') ,
						next:$('#lofslidecontent45 .lof-next') };
						
		$obj = $('#lofslidecontent45').lofJSidernews( { interval : 4000,
												direction		: 'opacitys',	
											 	easing			: 'easeInOutExpo',
												duration		: 1200,
												auto		 	: false,
												maxItemDisplay  : 5,
												navPosition     : 'horizontal', // horizontal
												navigatorHeight : 117,
												navigatorWidth  : 174,
												mainWidth:980,
												buttons			: buttons} );	
		


		var imgArr 		= [];
		function setGallery()
		{
			$("#pikame li").each(function(i)
			{
				var img 	= $(this).find('a').attr('href');
				var title 	= $(this).find('img').attr('alt');
				imgArr[i] 	= 	{
									'href' 	: img,
									'title'	: title
								}
				$(this).find('a').attr("href", "javascript:;");
				$(this).find('img').attr("title", i);
			});
			//console.log(imgArr);
		}
		setGallery();
		
		function showGallery(num)
		{
			$.fancybox(imgArr,
			{
				'index'		: num,
				'titlePosition'	: 'inside',
				'type'		: 'image'
			});
		}
		
		function updateImage(self)
		{
			var num	= self.active.attr("title");
			//console.log(num, imgArray);
			//self.caption.find("a").click(function(){showGallery(num)}); // Uncomment to activate popup on any links in caption
			self.anchor.click(function(){showGallery(num)});
		}
		
		$("#pikame").PikaChoose({autoPlay:true, animationFinished:updateImage});
		
		$("a[rel=group]").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'inside',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span>' + title + '</span>';
			}
		});
		$('a[rel*=external]').click( function() {
			window.open(this.href);
			return false;
		});
  
});
