/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
On Load Function
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*/
jQuery(function(){
	jQuery('.tagcloud a').prepend('<span></span>');
	jQuery("li[class^='segment-'] a").prepend('<span></span>');
	jQuery(".porthumb, .minithumb, .gallery, .gallery-item, .sys_mini_gallery, .post-img, postimg,  .imagethumb, .image, .accordion li, .lightbox,").preloadify({force_icon:"true", mode:"sequence" });
	jQuery(".image-grid").find("img").hover(function() {
		$(this).find(".image_desc").slideUp("slow");
	});
	/* TOGGLE BUTTON  */
	$("#trigger").toggle(function(){
		$(this).addClass("active");
		}, function () {
		$(this).removeClass("active");
	});
	$("#trigger").click(function(){
		$(this).next("#sticky").slideToggle({ duration: 1000, easing: 'easeOutQuart'});
	});
});

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Toggle Slider
http://www.aivah.com/
Thanks to fem
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*/

$(document).ready(function(){
	//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
	//Vertical Sliding
	$('.plan_box').hover(function(){
		$(".plan_info", this).fadeOut(500, function() { });
		}, function() {
		$(".plan_info", this).fadeIn(500, function() { });
	});
});

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Christian 'Kriesi' Budschedl
http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*/
function k_menu() {
	// k_menu controlls the dropdown menus and improves them with javascript
	
	jQuery(".nav a").removeAttr('title');
	jQuery(" .nav ul ").css({display: "none"}); // Opera Fix
	
	//smooth drop downs
	jQuery(".nav li").each(function()
	{	
		
		var $sublist = jQuery(this).find('ul:first');
		
		jQuery(this).hover(function()
		{	
			$sublist.stop().css({overflow:"hidden", height:"auto", display:"none"}).slideDown(400, function()
			{
				jQuery(this).css({overflow:"visible", height:"auto"});
			});	
		},
		function()
		{	
			$sublist.stop().slideUp(400, function()
			{	
				jQuery(this).css({overflow:"hidden", display:"none"});
			});
		});	
	});

	//  Menu mouse hovered background
}

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
LIGHTBOX EVOLUTION
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*/

jQuery(document).ready(function(){
    jQuery('.lightbox').lightbox();

});

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
TOGGLES
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*/

function atp_sociables() {
	jQuery(".atpsocials ul li").hover(function(){
		jQuery(this).find("img").animate({top:"-5px"}, "fast")
		},function(){
		jQuery(this).find("img").animate({top:"0"}, "fast")
	});
}

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
TOGGLES
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*/

function sys_toggle() {
	jQuery(".toggle").toggle(function(){
		jQuery(this).addClass("active");
		}, function () {
		jQuery(this).removeClass("active");
	});

	jQuery(".toggle").click(function(){
		jQuery(this).next(".toggle_content").slideToggle("slow");
	});
}

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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.9"}, 200);
			},function() {
			$(this).stop().animate({"opacity": "1"},200);
	});

	$('.hover_type').animate({"opacity": "0"}, "fast");
		$(".port_img, .sort_img").hover(function() {
			$(this).find('.hover_type').css('display','block').animate({"opacity": "1"}, "fast");
			$(this).stop().animate({"opacity": "0.9"}, 200);
		},function() {
			$(this).find('.hover_type').css('display','none').animate({"opacity": "0"}, "fast");
			$(this).stop().animate({"opacity": "1"}, 200);
		}
	);
}

/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
FUNCTION CALLBACKS
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*/
jQuery(function(){
	k_menu();
	sys_toggle();
	hoverimage();
	atp_sociables();
	//comparePlans();
	jQuery("ul.tabs").tabs(".panes > .tab_content", {tabs:'li',effect: 'fade', fadeOutSpeed: -400});
});
