$(function(){
	$('.breadcrumbs .post-page').closest('.breadcrumbs').find('em:last').hide();
	// tabs init
	$(".thumbs-list").jtabs();
	
	var galleries = $('.ad-gallery').adGallery();
	
	$('.quick-news-area').mouseenter(function(){
			$(this).data('mouseover',1);
	}).mouseleave(function(){
			$(this).data('mouseover',0);
	});

	$(".quick-news-list a").bind('select',function(){
				var $this = $(this),
						$tab = $($this.attr('data-tab-selector'));
				
				// show active tab
				$('.desc-box-holder .tab').hide();
				$tab.fadeIn(500);
				
				// set active link
				$(".quick-news-list a.active").removeClass('active');
				$(this).addClass('active');
				
				// set top link
				$(".main-news a").html($('span', $this).html() ).attr('href', $this.attr('href') );
			})
		.mouseenter(function(){ // attach custom event 'select' to mouseover
			$(this).trigger('select');
			return !1;
		});
		//$(".quick-news-list a.active").trigger('select'); // set first active
		
		$.turnNextSlide = function(){
									if($('.quick-news-area').data('mouseover')==true) return;
									var $current = $(".quick-news-list li:has(a.active)"),
											n = $(".quick-news-list a").size(),
											next_i = $(".quick-news-list li").index($current)+2;
											if(next_i > n) next_i = 1;
											$(".quick-news-list li:nth-child("+next_i+") a").trigger('select');
								};
		
		setInterval('$.turnNextSlide()', 8000);
		
	
	// jticker init
/*	$("#ticker").ticker({
 		cursorList: " ",
 		rate: 10,
 		delay: 6000
	}).trigger("play");
	*/
	
	$.typer = {
		t: '',
		captionLength: 0,
		caption: $("#ticker a").text(),
		type:	function(){
				  	$('#ticker a').html($.typer.t.substr(0, $.typer.captionLength++));
					  if($.typer.captionLength < $.typer.t.length+1){
					    setTimeout("$.typer.type()", 50);
					  }else{
					    $.typer.captionLength = 0;
					    $.typer.t = $.typer.caption;
					    setTimeout("$.typer.type()", 2000);
					  }
				}
	};
	$.typer.type();	
 	
	
	
});



