
/* Congradulations! */

$(function() {
    var konami = "38,38,40,40,37,39,37,39,66,65".split(','); // konami keys sequence
    var keyIndex = 0;

    /* hook event function that captures keypresses made by user */
    $(document).keydown(function(ev) {
        // increase keyindex if current index matches current position in konami sequence
        (konami[keyIndex] == ev.keyCode) ? keyIndex++ : keyIndex = 0;
        if (keyIndex == konami.length) {
            window.location = "/konami.php";
            keyIndex = 0;
        }
    });
});


// Homepage Start

$(document).ready(function()
{
	// hides all DIVs with the CLASS container
	// and displays the one with the ID 'home' only
	$(".container").css("display","none");
	$("#press-a").css("display","block");
	
	// makes the navigation work after all containers have bee hidden 
	showViaLink($("#start-site a"));
	
	// listens for any navigation keypress activity
	$(document).keypress(function(e)
	{
		switch(e.which)
		{
			case 97:	showViaKeypress("#welcome");
			break;
		}
	});
});

// shows a given element and hides all others
function showViaKeypress(element_id)
{
	$(".container").css("display","none");
	// if multiple keys are pressed rapidly this will hide all but the last pressed key's div
	$(".container").hide(1);
	$(element_id).slideDown("slow");
}

// shows proper DIV depending on link 'href'
function showViaLink(array)
{
	array.each(function(i)
	{	
		$(this).click(function()
		{
			var target = $(this).attr("href");
			$(".container").css("display","none");
			$(target).slideDown("slow");
		});
	});
}


// Portfolio caption animation
	$(document).ready(function(){
		$('.portfolio-box.portfolio-caption-full').hover(function(){
			$(".cover", this).stop().animate({top:'75px'},{queue:false,duration:256});
		}, function() {
			$(".cover", this).stop().animate({top:'100px'},{queue:false,duration:256});
		});
	});

// Image zoom function
(function($){
	var initLayout = function() {
		$('a.portfolio-image').zoomimage({
			border: 20,
			centered: true,
			hideSource: true
		});
	};
	
	EYE.register(initLayout, 'init');
  
})(jQuery);
