//initialize interface
$(document).ready(function(){
	$(".post").fadeTo("slow", 0.8);
	$(".post-cov").fadeTo("slow", 0.8);
	$(".fader").fadeTo("slow", 0.2);
	$(".excerpt-hide").hide().css({position : 'absolute', top : '94px'});
	$(".post-container").css({height : '120px', float : 'left'});
	$(".paging-nav").css({float : 'left'});
	$("li.content").hide();
});
//contact form display
$(document).ready(function(){
	$("li.contact-show").click(function(event) {
	   $("#contact-cover").removeClass("hidden");
	   $("#contact-cont").animate({left : "5%"}, 200, function(){
			   $("#contact-cover").fadeTo(400,1.0);
			  });
	   });
	$("#contact-cover, a.contact-close").click(function(event) {
	   $("#contact-cover").animate({opacity : 0}, 150, function(){
		   $("#contact-cover").addClass("hidden");
			   $("#contact-cont").animate({
					  left: "-600px"
					  }, 300);
			  });
		});
});

//post meta content user interfacing
$(document).ready(function() {
    metaConfig = {
        sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)
        interval: 200, // number = milliseconds for onMouseOver polling interval
        timeout: 200, // number = milliseconds delay before onMouseOut
        over: function(){
			$(this).parents(".post-container").find(".excerpt-hide").animate({display : 'block', height : 'toggle'}, {duration : 150});
			$(this).removeClass("post");
			$(this).stop().fadeTo("slow", 1.0);
			$("#main-container").find(".post-cov").stop().fadeTo("slow", 0.2);
			$(".post").stop().fadeTo("fast", 0.1);
			}, // function = onMouseOver callback (REQUIRED)
        out: function(){
			$(this).parents(".post-container").find(".excerpt-hide").animate({display : 'none', height : 'toggle'}, {duration : 100});
			$(this).stop().fadeTo("fast", 0.1);
			$(this).addClass("post");
			} // function = onMouseOut callback (REQUIRED)
    }
    exitStrategy = {
        sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)
        timeout: 200, // number = milliseconds delay before onMouseOut
        out: function(){
			$(".post").fadeTo("slow", 0.8);
			$(".post-cov").stop().fadeTo("fast", 0.8);
			}
    }
    $('.post').hoverIntent(metaConfig)
	$('#main-container').hoverIntent(exitStrategy)
});
//excerpt / content switcher
$(document).ready(function() {
   $("a.read-more").click(function(event) {
	   $(".description").animate({opacity: 0},
		   400, 
		   function() {
			   $(".excerpt").hide("slow");
			});
	   $("li.content").show("slow").animate({opacity : 1.0}, 300);
	   $("#single-details").animate({
			width: "480px"
			}, {
				duration: 600
			});
	   });
   $("a.read-less").click(function(event) {
	   $(".description").animate({opacity: 0}, 400);
	   $("li.excerpt").show("slow").animate({opacity : 1.0}, 300);
	   $("#single-details").animate({width: "225px"},
			   400, 
			   function() {
				   $(".content").hide("slow");
				});
	   });
});

//journal / work view toggler
$(document).ready(function() {
	$(".toggle-work").click(toggleWork);
	$(".toggle-journal").click(toggleJournal);
	function toggleWork() {
	 $(".category-work").parent(".post-container").animate({opacity : 'toggle', width: 'toggle'},
		   500, 
		   function() {
			   $(this).toggleClass("hidden");
			});
	$(".work-categories").animate({height: 'toggle'},
		   200, 
		   function() {
			   $(this).toggleClass("hidden");
			   $(".toggle-work").toggleClass('inactive-display');
			});
	}
	function toggleJournal() {
	 $(".category-journal").parent(".post-container").animate({opacity : 'toggle', width: 'toggle'},
		   500, 
		   function() {
			   $(this).toggleClass("hidden");
			});
	$(".journal-categories").animate({height: 'toggle'},
		   200, 
		   function() {
			   $(this).toggleClass("hidden");
			   $(".toggle-journal").toggleClass('inactive-display');
			});
	}
});


//paging nav
function linkFader(linkO) {
   $(linkO).hover(function(event) {
		 $(this).stop().fadeTo("slow", 1.0);
		 }, function(event) {
			 $(this).stop().fadeTo("fast", 0.2);
	 });
}
$(document).ready(function() {
	linkFader(".fader");
});
//tooltips
$(document).ready(function() {
	$("a, img").tooltip({ 
		track: true, 
		delay: 2000, 
		showURL: false, 
		showBody: " - ", 
		fade: 300,
		top: 5
	});
});
//navigation / content integration base
function referenceContent(conCat, navClass) {
	$(navClass).hover(function(event) {
			$(".post-cov").stop().fadeTo("fast", 0.2);
			$(conCat).removeClass("post");
			$(conCat).stop().fadeTo("slow", 1.0);
			$(".post").stop().fadeTo("fast", 0.1);
	 }, function(event) {
			$(conCat).stop().fadeTo("fast", 0.1);
			$(conCat).addClass("post");
	 });
    navExit = {
        sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)
        interval: 0, // number = milliseconds for onMouseOver polling interval
        timeout: 300, // number = milliseconds delay before onMouseOut
        out: function(){
			$(".post").fadeTo("slow", 1.0);
			$(".post-cov").stop().fadeTo("fast", 0.8);
			}
    }
    $('#main-nav').hoverIntent(navExit)
}

/*currently not working
function(conCat, navClass) {
    refCon = {
        sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)
        interval: 200, // number = milliseconds for onMouseOver polling interval
        timeout: 200, // number = milliseconds delay before onMouseOut
        over: function(){
			$(conCat).removeClass("post");
			$(conCat).stop().fadeTo("slow", 1.0);
			$(".post").stop().fadeTo("fast", 0.1);
			}, // function = onMouseOver callback (REQUIRED)
        out: function(){
			$(conCat).stop().fadeTo("fast", 0.1);
			$(conCat).addClass("post");
			} // function = onMouseOut callback (REQUIRED)
    }
    navExit = {
        sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)
        interval: 0, // number = milliseconds for onMouseOver polling interval
        timeout: 300, // number = milliseconds delay before onMouseOut
        out: function(){
			$(".post").fadeTo("slow", 1.0);
			}
    }
	$(navClass).hoverIntent(refCon);
    $('#main-nav').hoverIntent(navExit);
}
*/

//main img cycler
$(document).ready(function() {     
      $('#single-images').cycle({ 
          fx:     'fade', 
          speed:  'fast', 
          timeout: 0, 
          next: '#next',
          prev: '#prev',
		  pager: '#image-pager' 
        });
	  $('#next, #prev, #image-pager a').click(function(event) {
		   $('#single-content').animate({top : "8px", left : "220px"}, {duration : 300});
		   });
});

//hash line scrolling
$(document).ready(function(event) {
	$().mousemove(function(e){
		$('#y-axis').stop().animate({
		 top: e.pageY
		 }, {
			 duration: 200
		 });
      $('#y-status').html(e.pageY);
	}); 
});

//navArrow scrolling
var TabbedContent = {
	init: function(navItem) {	
		var background = $(navItem).parent().find(".moving-bg");
		var container = $(navItem).parent();
		$(background).stop().animate({
			top: $(".current-cat").position()['top']+3
		}, {
			duration: 400
		});
		$(navItem).hover(function(event) {
			$(background).stop().animate({
				top: $(this).position()['top']+3
			}, {
				duration: 400
			});
		});
		$(container).mouseleave(function(event) {
			$(background).stop().animate({
				top: $(".current-cat").position()['top']+3
			}, {
				duration: 400
			});
		});
	}
}
$(document).ready(function() {
	TabbedContent.init("#main-nav li");
});

//Anchor Slider by Cedric Dugas http://www.position-absolute.com
$(document).ready(function() {
	$("a.anchorLink").anchorAnimate()
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 400
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}
//comment toggler
$(document).ready(function(){
	 $(".comment-content").hide();
	 $("a.comment-toggle").click(function(event){
	 $(this).parents(".commentlist").find(".comment-content").toggle("fast");
	 return false;
	});
}); 
