jQuery(document).ready(function(){
	
	/*Initialize pretty galery
	 for more settings see http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/documentation/
	 */
	$("a[rel^='prettyPhoto']").prettyPhoto({
		autoplay_slideshow: false,
		theme: 'light_rounded'
	  
	});
	
	
	//Tabs
	jQuery(".cosmo-tabs ul, ").tabs(".cosmo-tabs-container > div", {effect: 'slide'});
	jQuery(".tab_menu ul").tabs(".tab_menu_content > div", {effect: 'slide'});
	
	
	/*toogle*/
	/*Case when by default the toggle is closed */
	jQuery(".open_title").toggle(function(){ 
			jQuery(this).next('div').slideDown();
			jQuery(this).find('a').removeClass('show');
			jQuery(this).find('a').addClass('hide');
			jQuery(this).find('.title_closed').hide();
			jQuery(this).find('.title_open').show();
		}, function () {
		
			jQuery(this).next('div').slideUp();
			jQuery(this).find('a').removeClass('hide');
			jQuery(this).find('a').addClass('show');		 
			jQuery(this).find('.title_open').hide();
			jQuery(this).find('.title_closed').show();
			
	});

	/*Case when by default the toggle is oppened */		
	jQuery(".close_title").toggle(function(){ 
			jQuery(this).next('div').slideUp();
			jQuery(this).find('a').removeClass('hide');
			jQuery(this).find('a').addClass('show');		 
			jQuery(this).find('.title_open').hide();
			jQuery(this).find('.title_closed').show();
		}, function () {
			jQuery(this).next('div').slideDown();
			jQuery(this).find('a').removeClass('show');
			jQuery(this).find('a').addClass('hide');
			jQuery(this).find('.title_closed').hide();
			jQuery(this).find('.title_open').show();
			
	});	
	
	/*Accordion*/
	$('.cosmo-acc-container').hide();
	$('.cosmo-acc-trigger:first').addClass('active').next().show();
	$('.cosmo-acc-trigger').click(function(){
		if( $(this).next().is(':hidden') ) {
			$('.cosmo-acc-trigger').removeClass('active').next().slideUp();
			$(this).toggleClass('active').next().slideDown();
		}
		return false;
	});
	
	
	

	//News Ticker
	jQuery("#newsticker").newsTicker();

	//slider
	
	$('.slideshow').mouseover(function() {
		$('#next_navigation').show();
		$('#prev_navigation').show();
	}).mouseout(function(){
		$('#next_navigation').hide();
		$('#prev_navigation').hide();  
	});
	
	$('.slides_control').mouseover(function() {
		$('#next_navigation').show();
		$('#prev_navigation').show();
	}).mouseout(function(){
		$('#next_navigation').hide();
		$('#prev_navigation').hide();  
	});
	
	$('.navigation').mouseover(function() {
		$('#next_navigation').show();
		$('#prev_navigation').show();
	}).mouseout(function(){
		$('#next_navigation').hide();
		$('#prev_navigation').hide();  
	});
	
	//Scroll to #anchor     
	jQuery(function(){
	  var target = location.hash && $('a[hash='+location.hash+']')[0];
	  if( target )
		  jQuery.scrollTo( target, { speed:400 });
	}); 

	
	//Fade images on hover
	jQuery("img").hover(function(){
		jQuery(this).fadeTo(400, 0.6);
	},function(){
		jQuery(this).fadeTo(400, 1.2);
	});


	//Switch classes
	jQuery("a.switch").toggle(function(){
	  jQuery(this).addClass("swap"); 
	  jQuery("ul.switch").fadeOut("fast", function() {
		  jQuery(this).fadeIn("fast").removeClass("half"); 
		 });
	  }, function () {
	  jQuery(this).removeClass("swap");
	  jQuery("ul.switch").fadeOut("fast", function() {
		  jQuery(this).fadeIn("fast").addClass("half");
		});
	});	
	
	//Superfish menu
	jQuery("ul.sf-menu").supersubs({
				minWidth:    12,
				maxWidth:    27,
				extraWidth:  1
			}).superfish({
				delay: 200,
				speed: 'fast'
			});

	//Tooltip
	jQuery('.tooltip').tipsy({gravity: $.fn.tipsy.autoNS});

	//Lazy Load
	jQuery(".cat_list img, .commentlist img").lazyload({ 
		placeholder: "/wp-content/themes/news24/images/grey.gif", effect: "fadeIn" 
	});

});
