function fancyRefresh()
{
	$("a[rel=photo]").fancybox({
		'titlePosition'  : 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});		
}
$(function() {
	if ($('#indexSlide').length) 
	{
		var totalWidth = 0;
		var marginLi = 29;
		var selectPos = 0;
		$.each($('#indexSlide .ins ul li'), function(index, value) {
			totalWidth += $(this).width() + marginLi;
			if ($(this).hasClass('currIt'))
				selectPos = totalWidth;
		});
		$('#indexSlide .ins ul').css('width', totalWidth + 'px');
	
		var listBoxWidth = $('#indexSlide .listBox').width() - marginLi;
		var maxLeft = totalWidth -listBoxWidth ;
		selectPos = -(selectPos  - listBoxWidth);
		if (selectPos < 0 && selectPos < maxLeft)
		{
			$('#indexSlide .listBox ul').css({
				'margin-left': selectPos + 'px'
			});
		}

		$('#indexSlide .ins .navPrev, #indexSlide .ins .navNext').click(function(){

			var left = $('#indexSlide .listBox ul').css('margin-left').replace('px', '');
			left = ~~left;
			
			if ($(this).hasClass('navPrev'))
			{
				if (left < 0)
					left += 150;
			}
			else
			{
				if (left > -maxLeft)
					left -= 150;
			}
			$('#indexSlide .listBox ul').animate({
				'margin-left': left + 'px'
			}, 200);
		});
	}
	
}); 

$(function() {
	if ($('#logoSlider').length)
	{
		var totalWidth = 0;
		var marginLi = 29;
			
		var totalWidth = $('#logoSlider ul').width(); 

		var listBoxWidth = $('#logoSlider .listBox').width() - marginLi;
		var maxLeft = totalWidth - listBoxWidth;
		
		
		$('#logoSlider .navPrev, #logoSlider .navNext').click(function(){
	
			var left = $('#logoSlider .listBox ul').css('margin-left').replace('px', '');
			left = ~~left;
			
			if ($(this).hasClass('navPrev'))
			{
				if (left < 0)
					left += 150;
			}
			else
			{
				if (left > -maxLeft)
					left -= 150;
			}
			
			$('#logoSlider .listBox ul').animate({
				'margin-left': left + 'px'
			}, 200);
		});	
	}

}); 

$(function() {	
	if ($('#subSlide').length) 
	{
		var totalWidth = 0;
		var marginLi = 29;
		var selectPos = 0;
		$.each($('#subSlide .ins ul:first > li'), function(index, value) {
			totalWidth += $(this).width() + marginLi;
			if ($(this).find('a').length == 0)
				selectPos = totalWidth;
		});
		$('#subSlide .ins > ul').css('width', totalWidth + 'px');
	
		var listBoxWidth = $('#subSlide .listBox').width() - marginLi;
		if (listBoxWidth < totalWidth)
		{
			var maxLeft = totalWidth -listBoxWidth ;
			selectPos = -(selectPos - listBoxWidth);
			if (selectPos < 0 && selectPos < maxLeft)
			{
				$('#subSlide .listBox > ul').css({
					'margin-left': selectPos + 'px'
				});
			}
	
			$('#subSlide .ins .navPrev, #subSlide .ins .navNext').click(function(){
		
				var left = $('#subSlide .listBox > ul').css('margin-left').replace('px', '');
				left = ~~left;
				
				if ($(this).hasClass('navPrev'))
				{
					if (left < 0)
						left += 150;
				}
				else
				{
					if (left > -maxLeft)
						left -= 150;
				}
				$('#subSlide .listBox > ul').animate({
					'margin-left': left + 'px'
				}, 200);
			});
		}
		else
		{
			$('#subSlide .ins .navPrev, #subSlide .ins .navNext').remove();
		}
	}
}); $(function() {
	if (window.photos !== undefined)
	{
		var indexTimerInterval = 10000;
		var indexTimerSlider = setTimeout( function() { $('#mainLogoNext').click(); } , indexTimerInterval);
		
		var minSliderPos = 1;
		var maxSliderPos = photos.length;
		var sliderPos = minSliderPos;
		var pwidth = $('#sliderPanel').width() / maxSliderPos;
	
		$('#sliderPanel').css('width', pwidth * maxSliderPos + 'px');
		function refreshSlider()
		{
			$('#sliderPanel').animate({
				'margin-left': -(pwidth * (sliderPos - 1)) + 'px'
			});
			$('.sliderInfoHd').text(photos[sliderPos - 1][1]);
		}
	
		$('#mainLogoPrev').click(function(){
			if (indexTimerSlider !== null)
				clearTimeout(indexTimerSlider);
			indexTimerSlider = setTimeout( function() {$('#mainLogoPrev').click(); } , indexTimerInterval);

			if (sliderPos > minSliderPos)
			{
				sliderPos--;
			}
			else
			{
				sliderPos = maxSliderPos;
			}
			refreshSlider();
		});
	
		$('#mainLogoNext').click(function(){
			if (indexTimerSlider !== null)
				clearTimeout(indexTimerSlider);
			indexTimerSlider = setTimeout( function() {$('#mainLogoNext').click(); } , indexTimerInterval);

			if (sliderPos < maxSliderPos)
			{
				sliderPos++;
			}
			else
			{
				sliderPos = minSliderPos;
			}
			refreshSlider();
		});
	}
	
}); $(function() {
	if ($('#coda-slider-1').length)
	{
		var width = $('#coda-slider-1 .panel').width();
		$('#coda-slider-1 .panel-container').css('width', width * 3 + 'px');
	
		$('#coda-nav-1 ul li a').click(function (){
			$(this).blur();
			$('#coda-nav-1 ul li a').removeClass('current');
			$('#coda-nav-1 ul li').removeClass('liPrev');
			var a = $(this);
			a.addClass('current');
			var rel = a.attr('rel');
			a.parent('li').prev('li').addClass('liPrev');
			
			$('#coda-slider-1 .panel-container').animate({
				'margin-left': -(width * (rel - 1)) + 'px'
			});
		});
	}
	
	fancyRefresh();
});
