jQuery(document).ready(function(){

	// hide #back-top first
	jQuery("#back-top").css({"opacity":"0"});
	
	// fade in #back-top
	jQuery(function () {
		jQuery(window).scroll(function () {
			if (jQuery(this).scrollTop() > 100) {
				jQuery('#back-top').css({"opacity":"1"});
			} else {
				jQuery('#back-top').css({"opacity":"0"});
			}
		});

		// scroll body to 0px on click
		jQuery('#back-top a').click(function () {
			jQuery('body,html').animate({
				scrollTop: 0
			}, 800);
			return false;
		});
	});



	var ToggleDistance=40;
	var CaptionHide=800;
	// Animate to attract focus
	jQuery('.photomenu-toggle').animate({
		opacity: 1,
		top: '+='+ToggleDistance
		}, 1500, function() {
		// Animation complete.
	  });

	//Sidebar toggle function
	jQuery(".photomenu-toggle-hide").click(
	  function () {
		jQuery(".photomenu-toggle-hide").css({"display":"none"});
		jQuery(".photomenu-toggle-show").css({"display":"block"});
		jQuery(".top-menu-center").slideUp('fast');
		
		jQuery('.photomenu-toggle').animate({
			opacity: 1,
			top: '-='+ToggleDistance
			}, 200, function() {
			// Animation complete.
		  });
		
		jQuery('#slidecaption').stop().animate({left:'-760'},500);
		jQuery('#prevslide').stop().animate({left:'0'},500);
		jQuery('#nextslide').stop().animate({right:'0'},500);
		jQuery('#controls-wrapper').stop().animate({bottom:'-50'},500);
		jQuery('div.jp-audio').stop().animate({opacity:'0'},500);
		jQuery('#thumb-tray').stop().animate({bottom:'-250'},500);
		
	  
	  }
	);

	jQuery(".photomenu-toggle-show").click(
	  function () {
		jQuery(".photomenu-toggle-show").css({"display":"none"});
		jQuery(".photomenu-toggle-hide").css({"display":"block"});

		jQuery(".top-menu-center").slideDown("fast");
		
		jQuery('.photomenu-toggle').animate({
			opacity: 1,
			top: '+='+ToggleDistance
			}, 200, function() {
			// Animation complete.
		  });
		  
		jQuery('#slidecaption').css({opacity:'0.9'});
		jQuery('#slidecaption').stop().animate({left:'80' },500);
		jQuery('#prevslide').stop().animate({left:'34'},500);
		jQuery('#nextslide').stop().animate({right:'34'},500);
		jQuery('#controls-wrapper').stop().animate({bottom:'0'},500);
		jQuery('div.jp-audio').stop().animate({opacity:'1'},500);
		jQuery('#thumb-tray').stop().animate({bottom:'0'},500);
	  }
	);	
	
	jQuery(".photomenu-toggle-show").hover(
	function () {
	  jQuery(".photomenu-tips").css({"display":"block"});
	},
	function () {
	  jQuery(".photomenu-tips").css({"display":"none"});
	});
	
	jQuery(".photomenu-toggle-hide").hover(
	function () {
	  jQuery(".photomenu-tips").css({"display":"block"});
	},
	function () {
	  jQuery(".photomenu-tips").css({"display":"none"});
	});

	jQuery('ul.menu').superfish({
		animation:   {height:'show'},
		speed:         'fast',
		autoArrows:  true,
		dropShadows: true
		});

	jQuery("a[rel^='prettyPhoto']").prettyPhoto({
		theme:'dark_square',
		opacity: 0.9,
		deeplinking: false,
		overlay_gallery: false,
		show_title: false,
		social_tools: false
	});
	
	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	jQuery("h4.trigger").click(function(){
		jQuery(this).toggleClass("active").next().slideToggle("fast");
		return false;
	});
	jQuery('h4.trigger').trigger('click');	
	
	
	jQuery(".postformat-image-lightbox img").hover(
	function () {
	  jQuery(this).stop().fadeTo("fast", 0.6);
	},
	function () {
	  jQuery(this).stop().fadeTo("fast", 1);
	});
	
	jQuery("#main-portfolio-carousel .preload").hover(
	function () {
	  jQuery(this).stop().fadeTo("fast", 0.6);
	},
	function () {
	  jQuery(this).stop().fadeTo("fast", 1);
	});
	
	jQuery(".portfolio-image-holder").hover(
	function () {
	  jQuery(this).stop().fadeTo("fast", 0.6);
	},
	function () {
	  jQuery(this).stop().fadeTo("fast", 1);
	});
	
	jQuery(".thumbnail-image").hover(
	function () {
	  jQuery(this).stop().fadeTo("fast", 0.6);
	},
	function () {
	  jQuery(this).stop().fadeTo("fast", 1);
	});
	
	jQuery(".pictureframe").hover(
	function () {
	  jQuery(this).stop().fadeTo("fast", 0.6);
	},
	function () {
	  jQuery(this).stop().fadeTo("fast", 1);
	});
	
	jQuery(".filter-image-holder").hover(
	function () {
	  jQuery(this).stop().fadeTo("fast", 0.6);
	},
	function () {
	  jQuery(this).stop().fadeTo("fast", 1);
	});
	
	
	jQuery('.qtips').tipsy({gravity: 's'});
    
});

jQuery(function() {
	jQuery("ul.tabs").tabs("div.panes > div");
	jQuery(".accordion-tabs").tabs(".pane", {tabs: 'h5', effect: 'slide'});
	
});
