// JavaScript Document
$(document).ready (function(){
	$("#tabContent1").show();
	$("#portfolio h3").one("mouseover", function(){
		var portfolioTitle = $(this).children("strong").html();
		$(this).children("span.clone").append(portfolioTitle);								  
	});
	$("#portfolio h3").click(function(){
		var slidingDiv = $(this).next("div");
		if (slidingDiv.is(":hidden")) {
		$("div.inside").slideUp();
		$("#portfolio h3").removeClass("active");
		/*var thisPosition = ($(this).position().top);
        $(slidingDiv).slideDown("default", function(){window.scrollTo(0, thisPosition);});*/
		$(slidingDiv).slideDown();
      	} else {
        $(slidingDiv).slideUp();
      	}
		$(this).toggleClass("active");
	});
	$("span.pagination").click(function(){
		$(this).addClass("active").siblings("span.pagination").removeClass("active");
		if ($(this).attr("page") == "one") {
			$(this).siblings(".imageDiv").children("img").animate({marginLeft:"0px"}, 300);
		}else if ($(this).attr("page") == "two") {
			$(this).siblings(".imageDiv").children("img").animate({marginLeft:"-600px"}, 300);
		}else if ($(this).attr("page") == "three") {
			$(this).siblings(".imageDiv").children("img").animate({marginLeft:"-1200px"}, 300);
		}
	});
	$("a.tab").each(function(){
		var idStr = $(this).attr("id"); 
		var tabNum = String(idStr.charAt(idStr.length-1));
		$(this).click(function(){
			$(".cssProject").hide();
			$(".tabNav li").removeClass("active");
			$("div#tabContent" + tabNum).show();
			$(this).parent().addClass("active");
			return false;
		});
	});
	var slideUp;
	var slideDown;
	var arrowBlue;
	var arrowGray;
	$("#contact").hover(function(){
		clearTimeout(slideDown);
		clearTimeout(arrowBlue);
		slideUp = setTimeout("$('#contact').animate({top:'-9em'}, 600)", 400);
		arrowGray = setTimeout("grayArrow()", 1200);
		$(this).toggleClass("up");
		}, function(){
			clearTimeout(slideUp);
			clearTimeout(arrowGray);
			slideDown = setTimeout("$('#contact').animate({top:'0'}, 600)", 600);
			arrowBlue = setTimeout("blueArrow()", 1400);
			$(this).toggleClass("up");
	});
	var maskOn = 0;
	$(".imageDiv").attr("title", "Click to expose");
	$(".imageDiv").click(function(){
		var docHeight = $(document).height();
		$("#mask").height(docHeight);
		if(!maskOn) {
			$("#mask").show();
			maskOn = 1;
			$(this).attr("title", "Click to unexpose");
		}else {
			$("#mask").hide();
			maskOn = 0;
			$(".imageDiv").attr("title", "Click to expose");
		}
	});
});
function blueArrow(){
	$('#contact h6').removeClass('up')
	$('#contact h6').addClass('down')	;	
}
function grayArrow(){
	$('#contact h6').removeClass('down')
	$('#contact h6').addClass('up')	;	
}