$(document).ready(function(){
	
	$("ul.navigation-top-ul").superfish();
	$("ul.navigation-top-ul ul li:first-child a").addClass("no-top-border");
	$("ul.navigation-top-ul ul li:last-child a").addClass("no-bottom-border");
	
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	// Portfolio Hover Sliders
	$("#featured").hover(function(){
		$(this).find(".top-slide").animate({top:"0"},{queue:false,duration:350,easing:'easeOutExpo'});
		$(this).find(".bottom-slide").animate({bottom:"0"},{queue:false,duration:350,easing:'easeOutExpo'});
		$(this).find(".arrow-left").animate({left:"0"},{queue:false,duration:350,easing:'easeOutExpo'});
		$(this).find(".arrow-right").animate({right:"0"},{queue:false,duration:350,easing:'easeOutExpo'});
	}, function(){
		$(this).find(".top-slide").animate({top:"-70px"},{queue:false,duration:350,easing:'easeOutExpo'});
		$(this).find(".bottom-slide").animate({bottom:"-66px"},{queue:false,duration:350,easing:'easeOutExpo'});
		$(this).find(".arrow-left").animate({left:"-50px"},{queue:false,duration:350,easing:'easeOutExpo'});
		$(this).find(".arrow-right").animate({right:"-50px"},{queue:false,duration:350,easing:'easeOutExpo'});
	});
	
	// Portfolio Page Arrows
	var currentFeatureSlide = 1;
	var currentFeatureLocation = 0;
	$("a.arrow-left").fadeTo(0,0.2);
	
	var totalFeatureSlides = Math.ceil( ($(".featured-entry > div").size()) );
	var animationOn = false;
	
	$("a.arrow-right").click(function(event){
									 
		if (currentFeatureSlide != totalFeatureSlides) {
				
			if (currentFeatureSlide == 1) { $("a.arrow-left").fadeTo(300,0.75); }
			newFeatureLocation = (currentFeatureLocation + 920);
			
			$(".featured-entry").animate({left:"-"+newFeatureLocation},{queue:false,duration:450,easing:'easeInOutExpo'});
			currentFeatureSlide++;
			if (currentFeatureSlide == totalFeatureSlides) {
				$("a.arrow-right").fadeTo(300,0.2); }
			currentFeatureLocation = newFeatureLocation;
			$(".slide-page").removeClass("active");
			$("#slide-page_"+currentFeatureSlide).addClass("active");
				
		}
		
	});
	
	$("a.arrow-left").click(function(event){
								   
		if (currentFeatureSlide != 1) {
			
			if (currentFeatureSlide == totalFeatureSlides) {
				$("a.arrow-right").fadeTo(300,0.75); }
				
			newFeatureLocation = (currentFeatureLocation - 920);
			
			if (currentFeatureSlide > 2) {
				newFeatureLocationNum = "-"+newFeatureLocation; } else {
				newFeatureLocationNum = newFeatureLocation; }
			$(".featured-entry").animate({left:newFeatureLocationNum},{queue:false,duration:450,easing:'easeInOutExpo'});
			currentFeatureSlide--;
			if (currentFeatureSlide == 1) {
				$("a.arrow-left").fadeTo(300,0.2); }
			currentFeatureLocation = newFeatureLocation;
			$(".slide-page").removeClass("active");
			$("#slide-page_"+currentFeatureSlide).addClass("active");
				
		}
		
	});
	
	$("a.slide-page").hoverIntent(function(){
		$(this).find("span").show();
		$(this).find("span").animate({opacity:1,top:"-69px"},120);
	}, function() { 
		$(this).find("span").animate({opacity:0,top:"-64px"},0);
		$(this).find("span").hide();
	});
	
	$("a.slide-page").click(function(event){
	
		gotoPage = this.id;
		gotoPage = gotoPage.split("_");
		actualPage = gotoPage[1] - 1;
		currentFeatureLocation = actualPage * 920;
		
		$(".featured-entry").animate({left:"-"+currentFeatureLocation},{queue:false,duration:450,easing:'easeInOutExpo'});
		currentFeatureSlide = gotoPage[1];
		
		if (currentFeatureSlide == totalFeatureSlides) { $("a.arrow-right").fadeTo(300,0.2); }
		if (currentFeatureSlide < totalFeatureSlides) { $("a.arrow-right").fadeTo(300,0.65); }
		
		if (currentFeatureSlide == 1) { $("a.arrow-left").fadeTo(300,0.2); }
		if (currentFeatureSlide > 1) { $("a.arrow-left").fadeTo(300,0.65); }
		
		$(".slide-page").removeClass("active");
		$("#slide-page_"+currentFeatureSlide).addClass("active");
	
	});
	
	
	/* Options on Hover (Gallery Links) */
	$(".gallery-thumb").hoverIntent(function(){
	
		$(this).find(".optionsOnHover").fadeIn("fast");
	
	}, function() {
		
		$(this).find(".optionsOnHover").fadeOut("fast");
		
	});
	
});
