var data = {
	rows:
	[{
		title: "NHL Wallpapers & Banners",
		desc: "Various wide-screen desktop wallpaper. Photo credits Getty Images, AP & Lindsay Bell. Click below to view more in this series.",
		imgs:[
			"images/nhlwall01.gif",
			"images/nhlwall02.gif",
			"images/nhlwall03.gif",
			"images/nhlwall04.gif",
			"images/nhlwall05.gif",
			"images/nhlwall06.gif",
			"images/nhlwall07.gif",
			"images/nhlwall08.gif",
			"images/nhlwall09.gif",
			"images/nhlwall10.gif",
			"images/nhlwall11.gif",
			"images/nhlwall12.gif"
		]
	},
	 
	 {
		title: "Las Vegas Vultures",
		desc: "Identity campaign for NHL expansion team inlcluding primary, secondary, and inagural year logos, ticket design and packaging created while at Pratt Institute. Click below to view more in this series.",
		imgs:[
			"images/lvv01.gif",
			"images/lvv02.gif",
			"images/lvv03.gif",
			"images/lvv04.gif",
			"images/lvv05.gif",
			"images/lvv06.gif",
			"images/lvv07.jpg"
		]
	},
	{
		title: "NYC.Buzzgrinder.com",
		desc: "Web work performed for NYC.Buzzgrinder.com including stylized headers and customized CSS. Click below to view more in this series.",
		imgs:[
			"images/buz01.gif",
			"images/buz02.gif",
			"images/buz03.gif"
		]
	},
	{
		title: "'Closer' Series",
		desc: "Series of portraits created using vector based tracings, watercolor, acrylic, and lumocolor pen. Click below to view more in this series.",
		imgs:[
			"images/clos01.gif",
			"images/clos02.gif",
			"images/clos03.gif",
			"images/clos04.gif"
		]
	},
	{
		title: "MisShapes",
		desc: "Website built for New York City based DJ Trio 'The MisShapes' using HTML, CSS, XML, JavaScript, and ASP.NET C#. Click below to view more in this series.",
		imgs:[
			"images/mis01.gif",
			"images/mis02.gif",
			"images/mis03.gif",
			"images/mis04.gif"
		]
	},
	{
		title: "AHL",
		desc: "Primary Logo Re-Design for the American Hockey League (unsolicited). Focus on edge and speed of it's youthful players.",
		imgs:[
			"images/ahl01.gif"
		]
	},
	{
		title: "Print BIG",
		desc: "Large format advertising poster designed for Pratt Institute's Digital Output Center. Click below to view more in this series.",
		imgs:[
			"images/big01.gif",
			"images/big02.gif",
			"images/big03.gif"
		]
	},
	{
		title: "Anti-Savior Clothing",
		desc: "Various print projects for Atheist clothing company including custom logo design, t-shirt designs, stickers, and more. Click below to view more in this series.",
		imgs:[
			"images/as01.gif",
			"images/as02.jpg",
			"images/as03.gif",
			"images/as04.jpg",
			"images/as05.gif"
		]
	},
	{
		title: "Claudia's Cakes",
		desc: "Primary and secondary logo design for New York based bakery",
		imgs:[
			"images/claudia01.gif"
		]
	},
	{
		title: "Lifetime",
		desc: "Logo design for Lifetime Logo Competition - Competition finalist, 1 of final 5 of over 100 designers including Carlos Segura, Pentagram, and Pratt Institute Senior Class of 2006.",
		imgs:[
			"images/life01.gif"
		]
	},
	{
		title: "Enchant Emerson",
		desc: "Logo identity created for New York City based Hip Hop Artist. Click below to view more in this series.",
		imgs:[
			"images/ee01.gif",
			"images/ee02.gif",
			"images/ee03.gif"
		]
	}
	]
};

			
$(function(){
	$('#logo').click(function(){
		var options = {
			direction: 'left', 
			distance: 20, 
			times: 3
		};
		var effect = 'shake';
		var effectTimeInMs = 75;
		$('#logo').effect(effect, options, effectTimeInMs, callback);
	});
	
	function callback(){
		setTimeout(function(){
			$("#logo:hidden").removeAttr('style').hide().fadeIn();
		}, 1000);
	};
	
	$.each(data.rows, function(i, proj){
		$.each(proj.imgs, function(j, img){
			jQuery("<img>").attr("src", img);
		});
	});
	//"container" which adds the line
	var container = $('<div>')
			.addClass('container')
			.append(
				$('<span>')
					.append(
						$('<img>')
							.attr('height', '20')
							.attr('width', '400')
							.attr('src', 'images/greyspan.gif')
							)
					);
					
	$.each(data.rows, function(i, proj){
		//gallery container	
		var gallery = $("<div>")
			.addClass("gallery")
			.addClass("projectTitle");
		
		//title
		var title = $("<div>")
			.addClass("title")
			.text(proj.title);
		
		//add the title to gallery
		gallery.append(title);
		
		//description		
		var desc = $("<div>")
			.addClass("desc")
			.text(proj.desc);
		
		//add the desc to gallery
		gallery.append(desc);
		
		var projImg = $("<div>")
			.addClass("projectImg")
			.attr('id', i)
			.attr('c', '0')
			.attr('t', proj.imgs.length);
		
		$.each(proj.imgs, function(j, img){
			var imgObj = $("<img>")
						.attr("src", img)
						.attr("alt", img);
			if(j > 0) 
				imgObj.hide();
			
			projImg.append(imgObj);
		});
		
		//add the project images to gallery
		gallery.append(projImg);
		
		//create the output
		$('#galleries').append(container.clone());
		$('#galleries').append(gallery);
	});
	
	var isAnimating = false;
	$('.projectImg').click(function(){
		try{
			if(!isAnimating){
				isAnimating = true;
				var id = parseInt($(this).attr('id'));
				var total = parseInt($(this).attr('t'));
				var imgs = $(this).children('IMG');
				var currIndex = parseInt($(this).attr('c'));
				
				var nextIndex = (currIndex + 1 >= total) ? 0 : (currIndex + 1);
				var prevIndex = (currIndex - 1 > 0) ? (currIndex - 1) : (total - 1);
				
				//only switch images if more than one image
				if(total > 1){
					var curImg = $(imgs[currIndex]).hide("slide", {direction:"left"}, 200, function(){
						$(imgs[nextIndex]).show("slide", {direction:"right"}, 200);
					});
					$(this).attr('c', nextIndex);
				}
				isAnimating = false;
			}
		}catch(ex){}
	});
});