	var thumbPath = "video/thumbs/";
	var swfPath = "video/";
	var thumbsOnLine = 4;
	var thumbClass = "vidThumb";
	var thumbHoverClass = "vidThumbOver";
	var lastThumbClass = "last";
	var spacerImg = "img/spacer.gif";

////////////////////////////////////////////////////////////////////////////////////////////////////

$(document).ready(function() {

	if($("#"+activeNav).length > 0){
		$("#"+activeNav).addClass("active");
	}

	// Tweak class, src, background of thumbnail images and add class to parent
	tweakThumbs('portfolioLocal');
	tweakThumbs('portfolioLocal2');
	tweakThumbs('portfolioRemote');
	setTriggers('portfolioLocal');
	setTriggers('portfolioLocal2');
	setTriggers('portfolioRemote');

	addCC();
	$(window).konami(function(){ showCC() },"67,69,67,73,76,73,65");

});

////////////////////////////////////////////////////////////////////////////////////////////////////





// Tweak thumbnails

	function tweakThumbs(pfSection){

		$("#"+pfSection+" .pflItem").each(

		  function(a){
			// Set class of last on last thumb of line
				if(((a+1)%thumbsOnLine) == 0){
					$(this).addClass(lastThumbClass);
				}
				
			// Set background-image to src of thumb and replace src with spacer
				thisImage = $(this).find("img")[0];
				$(thisImage).css({"background-image" : "url("+$(thisImage).attr("src")+")"});
				$(thisImage).attr("src",spacerImg);
				$(thisImage).addClass(thumbClass);
				
			} // End function
														 
		); // End each

	} // End tweakThumbs


////////////////////////////////////////////////////////////////////////////////////////////////////

	function setTriggers(pfSection){

		$("#"+pfSection+" .pflItem")
		.click(
			function(){
				if($(this).find("a").length > 0){
					return;
					//location.href = $(this).find(".link").html();
				}
				else{
					populateTheater($(this));
				}
			} // End function
		); // End click


		$("#"+pfSection+" .pflItem ."+thumbClass)
		.hover(
			function(){ // mouseover
				$(this).addClass(thumbHoverClass);
			},
			function(){ // mouseout
				$(this).removeClass(thumbHoverClass);
			}
		); // End hover

		$("#screen #backLink")
		.click(
			function(){
				$("#screen").hide();
				$("#theater_overlay").hide();
			} // End function
		); // End click


		document.onkeydown = function(e){ 	
			if (e == null) { // ie
				keycode = event.keyCode;
			} else { // mozilla
				keycode = e.which;
			}
			if(keycode == 27){ // close
				$("#screen").hide();
				$("#theater_overlay").hide();
			}	
		};

	} // End setTriggers


////////////////////////////////////////////////////////////////////////////////////////////////////


	function populateTheater(HTMLObj){
		swfWidth = $(HTMLObj).find(".swfWidth").html();
		swfHeight = $(HTMLObj).find(".swfHeight").html();
		swfFileName = $(HTMLObj).find(".swfFileName").html();
		swfDescription = $(HTMLObj).find(".swfDescription").html();

		$("#mainFeature").html(createswfObj(swfWidth,swfHeight,swfFileName));
		$("#synopsis").html(swfDescription);
		$("#theater_overlay").show();
		$("#screen").show();
		theater_position();
	}
	
////////////////////////////////////////////////////////////////////////////////////////////////////

	function theater_position() {
		$("#theater_overlay").show();
		$("#screen").show();

		var movScreenWidth = $("#screen").width();
		var movScreenHeight = $("#screen").height();
		
		$("#screen").css({marginLeft: '-' + parseInt((movScreenWidth / 2),10) + 'px', width: movScreenWidth + 'px'});
		if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
			$("#screen").css({marginTop: '-' + parseInt((movScreenHeight / 2),10) + 'px'});
		}
	}

////////////////////////////////////////////////////////////////////////////////////////////////////

// Create SWF Object
	function createswfObj(swfWidth,swfHeight,swfFileName){

		swfObj = '';
		swfObj += '<object ';
		swfObj += '	classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
		swfObj += '	codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ';
		swfObj += '	width="'+swfWidth+'" ';
		swfObj += '	height="'+swfHeight+'" ';
		swfObj += '	id="video" ';
		swfObj += '	align="middle">';
		swfObj += '	<param name="allowScriptAccess" value="sameDomain" />';
		swfObj += '	<param name="allowFullScreen" value="false" />';
		swfObj += '	<param name="movie" value="'+swfPath+swfFileName+'" />';
		swfObj += '	<param name="quality" value="high" />';
		swfObj += '	<param name="wmode" value="transparent" />';
		swfObj += '	<param name="bgcolor" value="#291e1a" />';
		swfObj += '	<embed ';
		swfObj += '		src="'+swfPath+swfFileName+'"';
		swfObj += '		quality="high"';
		swfObj += '		wmode="transparent"';
		swfObj += '		bgcolor="#291e1a"';
		swfObj += '		width="'+swfWidth+'"';
		swfObj += '		height="'+swfHeight+'"';
		swfObj += '		name="video"';
		swfObj += '		align="middle"';
		swfObj += '		allowScriptAccess="sameDomain"';
		swfObj += '		allowFullScreen="false"';
		swfObj += '		type="application/x-shockwave-flash"';
		swfObj += '		pluginspage="http://www.macromedia.com/go/getflashplayer" ';
		swfObj += '	/>';
		swfObj += '</object>';
		
		return swfObj;
	}





(function($) {

	$.fn.konami = function(callback, code) {
		if(code == undefined) code = "38,38,40,40,37,39,37,39,66,65";
		
		return this.each(function() {
			var kkeys = [];
			$(this).keydown(function(e){
				kkeys.push( e.keyCode );
				if ( kkeys.toString().indexOf( code ) >= 0 ){
					$(this).unbind('keydown', arguments.callee);
					callback(e);
				}
			}, true);
		});
	}

})(jQuery);
function addCC(){
	$("#logo").append("<img id='cecilia' src='img/Ce-nami.png' />");
}
function showCC(){
	$("#cecilia").show("slow").hide("slow");
}
