$(document).ready(function(){
	


	$("#items").wrap('<div id="load"></div>');


	setTimeout(function()
		{
		$('#items').animate({ opacity: '1'}, 1000);
		$("#items").cycle(
			{ 
    		fx:			"scrollHorz", 
    		speed:  	"2500", 
    		timeout:	0, 
    		next:		".next", 
    		prev:		".prev",
			before:		onBefore,
	    	after:		onAfter
 			}
		);
		}, 1000);	

	setTimeout(function()
		{
		$('#scroller-navigation').show();
		}, 2000);	



	$('.content-txt-hide').hide();
	$('#relatedWork li a span').css({opacity: '0.5'});

	

	function onBefore(curr, next, opts, fwd)
		{
		$('.content-txt-hide').fadeOut(150);
		}

	function onAfter(curr, next, opts, fwd)
		{ 
		var x = opts.currSlide+1;
		var y = opts.slideCount;
    	$('#nav-index').html(x + ' / ' + y); 
	
	    var client = this.alt;
		$('div.'+client).fadeIn();
		}







	$("#section-title").click(function()
		{
		$('#nav-index').animate({opacity: 'toggle'}, 'fast');
		}
	);




///////////////////////////////////////////////////////////////////////////////////////////


	$('.thumbnails span.caption').css({ opacity: '0.5' });

	$('.thumbnails a').ajaxify(
		{
		event:				'mouseenter',
        target:				'#thumbnail-output+',
		method:				'POST',
		loading_target:		'#loading',
        loading_img:		'/images/spinner.gif',
		onComplete:			function(options)
								{
								$('#thumbnail-output').css({ display: 'block' });
								$('#thumbnail-output').css({ opacity: '1' });
								if ($.browser.msie && $.browser.version.substr(0,1)<8)  // check for ie lower than 8
									{
									$('#thumbnail-output img').show();			// simply show the content
									} else {
									$('#thumbnail-output img').fadeIn(500);	// nicely fade in the content
									}
								}
		}
	);
	
	
	//$('.thumbnail-item a').append('<span class="viewed"><span>');


	$('.thumbnails a').hover(function()
			{
			$(this).children('img').css({ opacity: '1' });
			$(this).children('span.caption').animate({ opacity: '1'}, 150);
			}, function()
			{
			$(this).children('span.caption').animate({ opacity: '0.5'}, 150);	
			$(this).children('img').css({ opacity: '0.5' });
			//$(this).children('span').filter('.viewed').addClass('viewed-true');
			}
		).click(function(event)
			{
			event.preventDefault();
			}
	);


	$('.thumbnails').mouseleave(function()
		{
		$('#thumbnail-output').fadeOut(500);
		setTimeout(function(){ $('#thumbnail-output').empty(); }, 500);	// empty the div
		}
	);


	$('#thumbnail-output').mouseenter(function()
		{
		$(this).fadeOut(500);
		}
	);


///////////////////////////////////////////////////////////////////////////////////////////





});