var data = {
	rows:
	[{
		title: "NHL/NFL Desktop Wallpaper",
		desc: "Various wide-screen desktop wallpaper. Photo credits Getty Images, AP & Lindsay Bell. Click below to view more in this series.",
		imgs:[
			"images/wall01.gif",
			"images/wall02.gif",
			"images/wall03.gif",
			"images/wall04.gif",
			"images/wall05.gif",
			"images/wall06.gif",
			"images/wall07.gif",
			"images/wall08.gif",
			"images/wall09.gif"
		]
	},
	{
		title: "Steam Tonic Studios",
		desc: "Identity/logo design for Brooklyn-based creative agency.",
		imgs:[
			"images/tonic01.gif"
		]
	},
	{
		title: "Tattle Taxi NYC",
		desc: "Conceptual identity/logo and website design for reporting unruly and illegal taxi cab practice in NYC. Click below to view more in this series.",
		imgs:[
			"images/taxi01.gif",
			"images/taxi02.gif",
			"images/taxi03.gif"
		]
	},
	{
		title: "Affinity Solutions, Inc.",
		desc: "Conceptual design for iPhone application providing users with access to regional rewards program information. Click below to view more in this series.",
		imgs:[
			"images/afs01.gif",
			"images/afs02.gif",
			"images/afs03.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: "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/mis04.gif",
			"images/mis02.gif",
			"images/mis03.gif",
			"images/mis01.gif"
		]
	},
	{
		title: "Seven Layer Snowboarding",
		desc: "Conceptual identity/logo and magazine ad for start-up Snowboarding company.",
		imgs:[
			"images/seven01.gif",
			"images/seven02.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: "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){}
	});
});
