$(document).ready(function() 
{
	$('a[rel="external"]').live('click', function() {
		window.open( $(this).attr('href') );
        return false;
	});

	// Lightbox
	$('.album_image a').lightBox();
	$('.thumb_photos a').lightBox(); 
	$('.extra_ad').lightBox(); 

	// Jcarousel
	function mycarousel_initCallback(carousel) {
		jQuery('.tl_next').bind('click', function() {
			carousel.next();
			return false;
		});

		jQuery('.tl_prev').bind('click', function() {
			carousel.prev();
			return false;
		});
	};

	jQuery("#timeline").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });


	//VIDEO
	$('.playlist a, .playlist a.active').click(function(){
		$('.playlist a.active').removeClass('active');	
		$(this).addClass('active');
		$('.video').load($('.playlist a.active').attr('href'));
		return false;
	});
	
	$('.video').load($('.playlist a.active').attr('href'));	
	
	
	//SPIN LOGO
	$('.spinlogo a').hover(function()
	{
		$(this).parent('.spinlogo').find('span').slideToggle('slow');
	},function()
	{
		$(this).parent('.spinlogo').find('span').slideToggle();
	});


var first_slide=2;
	//*** HOME BANNER FADEIN FADEOUT
	$('.ps_big_slideshow').cycle({
		fx:'fade',
		timeout: 5000,
		speed:   1500,
		cleartype:true,
		cleartypeNoBg:true,
		prev:'.ps_prev',
		next:'.ps_next',
		before:  onBefore
      });
	function onBefore(curr, next, opts)
	{
		if(opts.nextSlide==1 && first_slide!=1)
		{
			$('#options li').removeClass('active');
			$('#options li:eq(0)').addClass('active');
			first_slide=1;
		}
		else
		{
			$('#options li').removeClass('active');
			$('#options li:eq('+opts.nextSlide+')').addClass('active');
		}
    }; 
	
	$('.row5').cycle({
		fx:'fade',
		timeout: 5000,
		speed:   1000,
		cleartype:true,
		cleartypeNoBg:true
      });
	  
	 $('#options li').click(function()
	 {
		myIndex = $(this).parent('ul').find('li').index(this);
		slide_number=myIndex+1;
		$('.ps_big_slideshow').cycle(myIndex).cycle('pause');
	 });
	
});



