//Cufon.replace("h2")("h3");
	
//Cufon.replace('#nav a', {
//	hover: {
//		color: '#228286'
//	}
//});

var mside = false; // initialise mouse-inside 

// when the DOM is ready...
$(document).ready(function() {

	// content slider
	$("#nav a").click(function(e){
		e.preventDefault();

		// re-set vertical position
		$("#pages").animate({top: 0});
	
		// horizontal slide
		var xpos = ("-" + $(this).parent().index() * 960).toString();
		$("#pages").animate({left : xpos});

		// toggle the portfolio pager
		($(this).parent().index() > 0 ? $("#paging li").fadeOut() : $("#paging li").fadeIn());
		
		// re-set active paging tab
		$("#paging li").removeClass("active").filter(":first-child").addClass("active");
	});
	
	// portfolio paging
	$("#paging a").click(function() {
		// toggle active tab
		$(this).parent().addClass("active").siblings().removeClass("active");

		// re-position page vertically
		var ypos = "-" + $(this).parent().index() * $("#content").height() + "px";
		$("#pages").animate({"top" : ypos});
		
		return false;
	});

	// portfolio interaction
	$("#portfolio").find(".block").mouseenter(function() {
		//$(this).siblings("div").stop().animate({"opacity": "0.5"}).end().find("dl").animate({"bottom" : "0"})
		$(this).find("dl").animate({"bottom" : "0"})
	}).mouseleave(function() {
		//$(this).siblings().stop().animate({"opacity": "1"}).end().find("dl").animate({"bottom" : "-60px"});
		$(this).find("dl").animate({"bottom" : "-75px"});
	});
	
	// set _blank targets here to avoid invalidating xhtml
	$(".external").attr("target", "_blank");

	
	// MODAL WINDOW
	// inject modal window
	$("<div id=\"result-wrapper\"/>").wrapInner("<div id=\"result\"/>").prependTo("body");

	// open modal window
	$(".confirm").click(function() {
		var hrf = $(this).attr("href");
		$("#result").load(hrf + ' .content').parent().fadeIn();
		$("#result .external").attr("target", "_blank");
		
		return false;
	});

	// check mouse position in modal window
        $('#result').hover(function(){
                    mside = true;
        }, function(){
            mside = false;
        });
	
	// only close modal if cursor is outside of content area
	$("#result-wrapper").click(function(){
		if(!mside) $("#result-wrapper").fadeOut();
	});

        $("#mailTo").click(function(){
            var x = "alan", y = "functionfirst.co.uk";
            window.location.href = "mailto:"+x+"@"+y;
        })
});
