$(document).ready(function()
{
	var serviceList = {
	// format - <id of link> : {<id of div to show>: true, ...}
  	branding: {
		titleClass: "work_branding",
		caption: "What you say, how you say it, and how it looks determine whether your brand will resonate with your customers. We make sure your brand delivers on all measures.",
		projects: {
			latintelligence: true,
			isobel: true,
			mediahog: true,
			yourtake: true,
			tregoe: true,
			lightsout: true,
			mysteryball: true,
			rhg: true
	      	}
  	},
  	experience: {	//user experience research
		titleClass: "work_experience",
		caption: "Our research methodologies help you understand how users perceive your site. We give you the tools and information to create a successful user experience.",
		projects: {
			cfr: true,
			napster: true,
			yourtake: true,
			poetry: true
	      	}
  	},
  	ui: {		//user interface design
		titleClass: "work_ui",
		caption: "We bring together visual design and technology&mdash;along with a keen understanding of how users think and behave&mdash;to create intuitive and robust interfaces.",
		projects: {
			cfr: true,
			napster: true,
			yourtake: true,
			cwtvpr: true,
			high5: true,
			tregoe: true,
			vov: true,
			mysteryball: true,
			poetry: true
		}
  	},
  	visual: {		//visual design
		titleClass: "work_visual",
		caption: "Successful visual design can capture and engage audiences. We work with you to develop the right look and feel to reach your users and support your content.",
		projects: {
			cfr: true,
			latintelligence: true,
			mediahog: true,
			isobel: true,
			napster: true,
			yourtake: true,
			cwtvpr: true,
			high5: true,
			tregoe: true,
			vov: true,
			lightsout: true,
			mysteryball: true,
			poetry: true,
			newyorker: true,
			theparisreview: true,
			nfln: true,
			rhg: true,
			cbspress: true,
			cwingo: true
		}
  	},
  	ia: {		//information architecture
		titleClass: "work_ia",
		caption: "We love to map it out. We organize content so the information on your site is easy to navigate, easy to read and simple to update.",
		projects: {
			cfr: true,
			napster: true,
			yourtake: true,
			cwtv: true,
			cwtvpr: true,
			high5: true,
			tregoe: true,
			vov: true,
			poetry: true,
			thirteen: true,
			nfln: true,
			newyorker: true,
			theparisreview: true,
			wb: true
		}
  	},
  	strategy: {		//strategy
		titleClass: "work_strategy",
		caption: "We begin by listening to your needs and getting to know your goals. Then we pinpoint the right opportunities to go after and design a plan to achieve them.",
		projects: {
			cfr: true,
			cwtv: true,
			mediahog: true,
			napster: true,
			kidswb: true,
			yourtake: true,
			thirteen: true,
			theparisreview: true,
			wb: true
		}
  	},
  	webdev: {		//web development
		titleClass: "work_webdev",
		caption: "The code that brings your site to life is as important as the design itself. Our process ensures that your site is accessible, flexible, and search-engine friendly.",
		projects: {
			latintelligence: true,
			cwtv: true,
			isobel: true,
			poetry: true,
			yourtake: true,
			cwtvpr: true,
			high5: true,
			tregoe: true,
			vov: true,
			lightsout: true,
			thirteen: true,
			knightforce: true,
			lightsout: true,
			mysteryball: true,
			wb: true,
			theparisreview: true,
			nfln: true,
			rhg: true,
			cbspress: true,
			cwingo: true
		}
  	},
  	webapp: {		//web app integration
		titleClass: "work_webapp",
		caption: "Web technologies are constantly evolving. We find partners and customize community apps that create loyal relationships between your site and your users.",
		projects: {
			cwtv: true,
			yourtake: true,
			lightsout: true,
			mysteryball: true,
			wb: true			
		}
  	},
  	cms: {		//content management
		titleClass: "work_cms",
		caption: "We give you a customized and turnkey platform with a user-friendly interface for publishing all your content video, text, photos and other digital assets.",
		projects: {
			cwtv: true,
			kidswb: true,
			cwtvpr: true,
			thirteen: true,
			poetry: true,
			nfln: true,
			theparisreview: true,
			wb: true,
			rhg: true,
			cbspress: true,
			cwingo: true
		}
  	},
  	softdev: {		//software development
		titleClass: "work_softdev",
		caption: "We harness the latest technology and open source software tools to develop customized applications for web and mobile services.",
		projects: {
			cfr: true,
			cwtv: true,
			kidswb: true,
			poetry: true,
			yourtake: true,
			thirteen: true,
			knightforce: true,
			wb: true			
		}
  	},
  	mobile: {		//mobile apps
		titleClass: "work_mobile",
		caption: "We design and develop mobile applications that can be updated and adapted as the devices, operating systems, and consumer desires change.",
		projects: {
			cwtv: true,
			napster: true,
			newyorker: true,
			poetry: true,
			cwingo: true
		}
  	},
  	all: {
		titleClass: "work",
		caption: "We love what we do. From strategy to technology to design, we're always seeking new challenges. Here are a few examples of what we've done:",
		projects: {
			cfr: true,
			cwtv: true,
			mediahog: true,
			napster: true,
			kidswb: true,
			yourtake: true,
			cwtvpr: true,
			high5: true,
			tregoe: true,
			vov: true,
			lightsout: true,
			thirteen: true,
			knightforce: true,
			poetry: true,
			latintelligence: true,
			mysteryball: true,
			nfln: true,
			theparisreview: true,
			wb: true
		}
  	}
};

$("a.proj_links").click(function() {
	var service = serviceList[this.id];
	$("#project_title").removeClass();
	$("#project_title").addClass(service.titleClass);
	$("p#project_caption").html(service.caption);
    
	var currentService = this;
	$("a.proj_links").each(function() {
		if (this == currentService)
			$(this).addClass("selectedService");
		else
			$(this).removeClass("selectedService");
	});
    
	$("div.project").each(function() {
		if (service.projects[this.id])
			$(this).fadeTo("slow", 2)
		else
			$(this).fadeTo("slow", 0.20)
 		});
	});
  
	// check if there is a group to show from the query string
	if (document.location.search) {
		var pairs = document.location.search.substring(1).split(/[;&]/);
		for (var i = 0; i < pairs.length; i++ ) {
			var keyVal = pairs[i].split('=');

			if (!keyVal || keyVal.length != 2 ) continue;
			var key = unescape(keyVal[0]);

			if (key == "grp") {
				var val = unescape(keyVal[1]);
				val = val.replace(/\+/g, ' ');
				var service = serviceList[val];

				if (service) {
					$("#project_title").removeClass();
					$("#project_title").addClass(service.titleClass);
					$("p#project_caption").html(service.caption);
					$("a#" + val).addClass("selectedService");

					if (service.projects) {
						$("div.project").each(function() {
							if (!service.projects[this.id])
								$(this).fadeTo("slow", 0.2)
						});
					}
				}
				break;
			}
		}
	}
});
