//*** SUPERFISH MENU --------------------------------------------------------***//
jQuery(function(){
	jQuery('ul.sf-menu').superfish();
	jQuery('.tagcloud a').prepend('<span></span>');
	jQuery("li[class^='segment-'] a").prepend('<span></span>');
	jQuery('ul.sf-menu li li:last-child').css('border', 'none');
	jQuery(".porthumb, .minithumb, .gallery, .gallery-item, .post-img, .postimg, .imagethumb, .image, .lightbox, .kwicks").preloadify({force_icon:"true", mode:"sequence" });

});

//*** SEARCH ----------------------------------------------------------------***//
function search() {
	$('#search-button').click(function() {
		$('.search-container').fadeToggle();
		return false;
	});
}
//*** LIGHTBOX EVOLUTION ----------------------------------------------------***//
jQuery(document).ready(function($){
    jQuery('.lightbox').lightbox();

});

//*** TOGGLES ---------------------------------------------------------------***//
function sys_toggle() {
	jQuery(".toggle_content").append("<div class='arrow'></div>").hide();

	jQuery("span.toggle").toggle(function(){
		jQuery(this).addClass("active");
		}, function () {
		jQuery(this).removeClass("active");
	});

	jQuery("span.toggle").click(function(){
		jQuery(this).next(".toggle_content").slideToggle();
	});
}

//*** HOVERIMAGE ------------------------------------------------------------***//
function hoverimage() {
		$("a[class^='lightbox']").each(function() {	
			var $image = $(this).contents("img");
				$hoverclass = 'hover_video';
	
		if($(this).attr('href').match(/(jpg|gif|jpeg|png|tif)/)) 
		$hoverclass = 'hover_image';
			
		if ($image.length > 0)
		{	
			var $hoverbg = $("<span class='"+$hoverclass+"'></span>").appendTo($(this));
			
				$(this).bind('mouseenter', function(){
				$height = $image.height();
				$width = $image.width();
				$pos =  $image.position();		
				$hoverbg.css({height:$height, width:$width, top:$pos.top, left:$pos.left});
			});
		}
	
	});	

	$("a[class^='lightbox']").contents("img").hover(function() {
			$(this).stop().animate({"opacity": "0.3"}, 200);
			},function() {
			$(this).stop().animate({"opacity": "1"},200);
	});
}



//*** FUNCTION CALLBACKS ----------------------------------------------------***//

jQuery(function(){
	hoverimage();		
	sys_toggle();
	search();
	jQuery("ul.tabs").tabs(".panes > .tab_content", {tabs:'li',effect: 'fade', fadeOutSpeed: -400});
});

