var globals ={	i: 0,	agent: navigator.userAgent.toLowerCase(),	count: 0}var util ={	remove:function(str, tok)	{		/*		 *  Remove all occurrences of a token in a string		 *    str  string to be processed		 *    tok  token to be removed		 *  returns new string		 */		i = str.indexOf(tok);		removed = '';		if (i == -1) return str;		removed += str.substring(0,i) + util.remove(str.substring(i + tok.length), tok);		return removed;	}}//	The [load] event on [window] fires after all page images are loadedEvent.observe(window, 'load', function(){	var target = '';	var cpath = window.location;	if (cpath.pathname.include('/work/') && !cpath.pathname.endsWith('/work/')) target = util.remove(cpath.pathname, '/work/').sub('/','');//	if (cpath.hash == '#all') target = 'morework';	if (!target.empty()) {	//	new Effect.ScrollTo($(target), { delay:.5 });	}});//	The [dom:loaded] event fires immediately after the HTML document is fully loaded, but before images on the page are fully loadeddocument.observe("dom:loaded", function(){	if (!document.getElementsByTagName) return;	// Prepare the current path variable for usage	var cpath = window.location;	// Add external relation to outside links in news, projects & twitter	$$('.details a').each(function(el) {		if (!el.readAttribute('href').include('/work/') && !el.readAttribute('href').include('#'))			el.writeAttribute({'rel':'external'});	});	$$('#news li a').each(function(el) {		if (!el.readAttribute('href').include('/work/'))			el.writeAttribute({'rel':'external'});	});	$$('#twitter li a + a').each(function(el) {		el.writeAttribute({'rel':'external'});	});	$$('a[rel~=external]').each(function(anchor) {		if (anchor.getAttribute('href')) anchor.target = '_blank';	}.bind(this));	// Hide all of the details containers	$$('.details').each(function(el) {		el.hide();	});		// If we AREN'T viewing a permalink:	//	hide the "morework" button	// If we ARE viewing a permalink:	//	set the number of projects to show (using showCount)	//	show the detail container for the first project	if (!cpath.pathname.include('/work/') || cpath.pathname.endsWith('/work/'))	{		$('morework').hide();	}	else	{		// How many projects to show on a permalink pages		globals.count = 1;		globals.i = 0;		$$('.project').each(function(el) {			globals.i++;			if (globals.i > globals.count) el.hide();			else { if (el.down('.details')) el.down('.details').show(); }		});		// Watch for click event on morework button to unhide projects		$$('#morework a').each(function(el) {			Event.observe(el, 'click', function(event) {				Event.stop(event);				new Effect.SlideUp(el.up(0), { duration:.5 });				globals.i = 0;				$$('.project').each(function(e) {					globals.i++;					if (globals.i > globals.count) {						new Effect.Parallel([							new Effect.BlindDown(e),							new Effect.Appear(e)						], { queue:'end' });					}				});			});		});	}	// Watch for click event on project-info button to expand/contract description	$$('.project-info').each(function(el) {		Event.observe(el, 'click', function(event) {			Event.stop(event);			if (el.up('.transwrapper').next(0).visible()) { new Effect.BlindUp(el.up('.transwrapper').next(0), { duration:.5 }); }			else {				var blinddowndelay = 0				$$('.details').each(function(e) {					if (e.visible()) {						blinddowndelay = .5						new Effect.BlindUp(e, { duration:.5 })					}				});				new Effect.BlindDown(el.up('.transwrapper').next(0), { delay:blinddowndelay, duration:.5 });			}		});	});	/* Lightview */	$$('a.lightview[title]').each(function(element) { element.title = 'Zoom'; });});