/** Hot News - News Ticker **/
$(document).ready(
				function(){			
					$('ul#portfolio').innerfade({
						speed: 1000,
						timeout: 5000,
						type: 'sequence',
						containerheight: '220px'
					});
					
					$('.fade').innerfade({
						speed: 1000,
						timeout: 6000,
						type: 'random_start',
						containerheight: '1.5em'
					});
					
					$('.adi').innerfade({
						speed: 'slow',
						timeout: 5000,
						type: 'random',
						containerheight: '150px'
					});

			});

/** Slide Show **/
$(function(){
			var article_blocks = $('#article_container .article_new');
			article_blocks.filter(':not(:first)').hide();
			$('#slides').slides({
				preload: true,
				preloadImage: 'image/theme/loading.gif',
				play: 5000,
				pause: 6000,
				hoverPause: true,
				animationComplete: function(i){
					article_blocks.filter(':visible').fadeOut(150,function(){
						var sel=article_blocks.eq(i-1);if(sel[0]){sel.fadeIn(300)}
					});
				},
			});
		});

//tab effects

var TabbedContent = {
	init: function() {	
		$(".tab_item").mouseover(function() {
		
			var background = $(this).parent().find(".moving_bg");
			
			$(background).stop().animate({
				left: $(this).position()['left']
			}, {
				duration: 300
			});
			
			TabbedContent.slideContent($(this));
			
		});
	},
	
	slideContent: function(obj) {
		
		var margin = $(obj).parent().parent().find(".slide_content").width();
		margin = margin * ($(obj).prevAll().size() - 1);
		margin = margin * -1;
		
		$(obj).parent().parent().find(".tabslider").stop().animate({
			marginLeft: margin + "px"
		}, {
			duration: 300
		});
	}
}

$(document).ready(function() {
	TabbedContent.init();
});

/** Caruesel Slider **/
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};



jQuery(document).ready(function($) {
	
	jQuery("a[rel=picture-album]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.9,
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + (currentIndex + 1) + '/' + currentArray.length + (title.length ? ' &nbsp;&nbsp;&nbsp;&nbsp; ' + title : '') + '</span>';
		}
	});  
    jQuery('#mycarousel').jcarousel({
        auto: 2,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
    
    jQuery('#slide_v').jcarousel({
        auto: 3,
        scroll: 1,
        wrap: 'circular',
        animation: 'slow',
        initCallback: function (jc) {
        	jQuery('#slide_v').hover(function () {
        		jc.paused = true; 
        		jc.stopAuto(); 
        	
        	}, function () {
   	        	jc.paused = false; 
	        	jc.startAuto(); 
        	});
        }
    });
    
	var g = $('#lbbtn');
	if(g) {
		g.click(function (e) {
			e.stopPropagation();
			$('#lbform').click(function (e) {
				e.stopPropagation();
			});
			$('html').click(function (e) {
			$('html').unbind('click');
			$('#lbform').hide();
			});
			$('#lbform').show();
		});
	}
	
	var t = $('.welcome-back');
	if(t[0]) {
		t.fadeIn(400, function () { 
			var showWb = function () {
				$(t).fadeOut(800);
				clearInterval(wbpause);
			};
			
			var fdelay  = 3000
			  , wbpause = setInterval(showWb, fdelay);
			  
			
			$('.welcome-back').hover(function () {
				clearInterval(wbpause);
			}, function () {
				wbpause = setInterval(showWb, fdelay/2);
			});
		});
	}
});
