// Handle search engine friendly uris such as /index.php/whoweare
var uri = window.location.toString();

// BEGIN: remove this section when deploying mod_rewrite
// if uri does not match #section:sometext
if (!uri.match(/\#section\:[^\/]+$/)) {
  // see if it matches index.php/sometext
  var searchLocation = uri.match(/\/[^\/\.]+$/);
  if (searchLocation) {
    // if so, change the location, replacing /sometext with #section:sometext
    window.location = uri.replace(/\/[^\/\.]+$/, "#section:" + searchLocation.toString().substr(1));
  }
}
// END: remove this section when deploying mod_rewrite

// initialize ourselves when the page is finished loading
/** Our function that initializes when the page is finished loading. */
window.onload = function() {
  // Start preloading site elements.  Run this asynchronously so we don't stall other startup items.
  setTimeout(function() {
    PageLoader.initialize([
  'home_snippet.php',
    'images/metadesign_logo.gif',
  'ourwork_carousel.php',
  'whatwedo_snippet.php',
    'what_intro_snippet.php',
    'what_identity_snippet.php',
    'what_interaction_snippet.php',
    'what_strategic_snippet.php',
  'ourwork_snippet.php',
    'work_intro_snippet.php',
'work_adobe_snippet.php',
'images/work_adobe_1.jpg',
'images/work_adobe_2.jpg',
'images/work_adobe_3.jpg',
'images/work_adobe_4.jpg',
'images/work_adobe_5.jpg',
'images/work_adobe_s.jpg',
'work_autodesk_snippet.php',
'images/work_autodesk_1.jpg',
'images/work_autodesk_2.jpg',
'images/work_autodesk_3.jpg',
'images/work_autodesk_4.jpg',
'images/work_autodesk_s.jpg',
'work_cpp_snippet.php',
'images/work_cpp_1.jpg',
'images/work_cpp_2.jpg',
'images/work_cpp_3.jpg',
'images/work_cpp_s.jpg',
'work_kohler_snippet.php',
'images/work_kohler_1.jpg',
'images/work_kohler_2.jpg',
'images/work_kohler_3.jpg',
'images/work_kohler_4.jpg',
'images/work_kohler_s.jpg',
'work_shangrila_snippet.php',
'images/work_shangrila_1.jpg',
'images/work_shangrila_2.jpg',
'images/work_shangrila_3.jpg',
'images/work_shangrila_s.jpg',
'work_sfcm_snippet.php',
'images/work_sfcm_1.jpg',
'images/work_sfcm_2.jpg',
'images/work_sfcm_3.jpg',
'images/work_sfcm_s.gif',
'work_inkling_snippet.php',
'images/work_inkling_1.gif',
'images/work_inkling_2.jpg',
'images/work_inkling_s.gif',
'work_pcworld_snippet.php',
'images/work_pcworld_1.jpg',
'images/work_pcworld_s.jpg',
'work_sfballet_snippet.php',
'images/work_sfballet_1.jpg',
'images/work_sfballet_2.jpg',
'images/work_sfballet_3.jpg',
'images/work_sfballet_4.jpg',
'images/work_sfballet_5.jpg',
'images/work_sfballet_s.jpg',
'work_onetouch_snippet.php',
'images/work_onetouch_1.jpg',
'images/work_onetouch_2.jpg',
'images/work_onetouch_s.jpg',
'work_23andme_snippet.php',
'images/work_23andme_1.gif',
'images/work_23andme_2.gif',
'images/work_23andme_3.jpg',
'images/work_23andme_s.gif',
'work_gateway_snippet.php',
'images/work_gateway_1.jpg',
'images/work_gateway_2.jpg',
'images/work_gateway_3.jpg',
'images/work_gateway_4.jpg',
'images/work_gateway_5.jpg',
'images/work_gateway_s.jpg',
'work_sonyvaio_snippet.php',
'images/work_sonyvaio_1.jpg',
'images/work_sonyvaio_2.jpg',
'images/work_sonyvaio_s.jpg',
'work_mcafee_snippet.php',
'images/work_mcafee_1.jpg',
'images/work_mcafee_2.jpg',
'images/work_mcafee_3.jpg',
'images/work_mcafee_4.gif',
'images/work_mcafee_s.gif',
'work_current_snippet.php',
'images/work_current_1.jpg',
'images/work_current_2.jpg',
'images/work_current_s.jpg',
'work_fourseasons_snippet.php',
'images/work_fourseasons_1.jpg',
'images/work_fourseasons_s.jpg',
'work_dai_snippet.php',
'images/work_dai_1.gif',
'images/work_dai_2.jpg',
'images/work_dai_3.jpg',
'images/work_dai_4.jpg',
'images/work_dai_s.gif',
'work_condenast_snippet.php',
'images/work_condenast_1.jpg',
'images/work_condenast_2.jpg',
'images/work_condenast_s.jpg',
'work_bloomenergy_snippet.php',
'images/work_bloomenergy_1.gif',
'images/work_bloomenergy_2.jpg',
'images/work_bloomenergy_3.jpg',
'images/work_bloomenergy_s.gif',
'work_symantec_snippet.php',
'images/work_symantec_1.jpg',
'images/work_symantec_2.gif',
'images/work_symantec_3.gif',
'images/work_symantec_s.jpg',
'work_hoteljen_snippet.php',
'images/work_hoteljen_1.gif',
'images/work_hoteljen_2.jpg',
'images/work_hoteljen_s.jpg',
'work_sandisk_snippet.php',
'images/work_sandisk_1.gif',
'images/work_sandisk_2.jpg',
'images/work_sandisk_3.jpg',
'images/work_sandisk_s.gif',
'work_denverart_snippet.php',
'images/work_denverart_1.gif',
'images/work_denverart_2.jpg',
'images/work_denverart_3.gif',
'images/work_denverart_s.gif',
'work_yahoo_snippet.php',
'images/work_yahoo_1.jpg',
'images/work_yahoo_s.jpg',
'work_move_snippet.php',
'images/work_move_1.jpg',
'images/work_move_s.jpg',
'work_sonycorp_snippet.php',
'images/work_sonycorp_1.jpg',
'images/work_sonycorp_s.jpg',
'work_viacom_snippet.php',
'images/work_viacom_1.jpg',
'images/work_viacom_s.jpg',
'work_polo_snippet.php',
'images/work_polo_1.jpg',
'images/work_polo_2.jpg',
'images/work_polo_s.jpg',
'work_epinions_snippet.php',
'images/work_epinions_1.jpg',
'images/work_epinions_s.jpg',
'work_nokia_snippet.php',
'images/work_nokia_1.jpg',
'images/work_nokia_s.jpg',
'work_etrade_snippet.php',
'images/work_etrade_1.jpg',
'images/work_etrade_s.jpg',
'work_danger_snippet.php',
'images/work_danger_1.jpg',
'images/work_danger_s.jpg',
'work_cnet_snippet.php',
'images/work_cnet_1.jpg',
'images/work_cnet_s.jpg',
'work_philm_snippet.php',
'images/work_philm_1.jpg',
'images/work_philm_s.jpg',
'work_palm_snippet.php',
'images/work_palm_1.jpg',
'images/work_palm_s.jpg',
'work_ripple_snippet.php',
'images/work_ripple_1.gif',
'images/work_ripple_2.jpg',
'images/work_ripple_3.gif',
'images/work_ripple_s.jpg',
  'ourclients_snippet.php',
  	'clients_intro_snippet.php',
  	'clients_industry_snippet.php',
  	'clients_capability_snippet.php',
  	'clients_adobe_snippet.php',
  	'clients_autodesk_snippet.php',
  	'clients_cpp_snippet.php',
  	'clients_kohler_snippet.php',
  	'clients_inkling_snippet.php',
  	'clients_shangrila_snippet.php',
  	'clients_sfcm_snippet.php',
  	'clients_pcworld_snippet.php',
  	'clients_polo_snippet.php',
  	'clients_sfballet_snippet.php',
  	'clients_23andme_snippet.php',
  	'clients_sonyvaio_snippet.php',
  	'clients_mcafee_snippet.php',
  	'clients_current_snippet.php',
  	'clients_fourseasons_snippet.php',
  	'clients_dai_snippet.php',
  	'clients_bloomenergy_snippet.php',
  	'clients_hoteljen_snippet.php',
  	'clients_sandisk_snippet.php',
  	'clients_move_snippet.php',
  	'clients_viacom_snippet.php',
  	'clients_ripple_snippet.php',
  'whoweare_snippet.php',
    'bio_intro_snippet.php',
    'bio_bill_snippet.php',
    'bio_alex_snippet.php',
    'bio_jane_snippet.php',
    'bio_vince_snippet.php',
    'bio_mark_snippet.php',
    'bio_sean_snippet.php',
  'contactus_snippet.php',
    'images/map.gif',
  'news_snippet.php',
  '404_snippet.php'
]);
    //add logo hover behavior
    new LogoFader();
  }, 1);

  // No javascript version preloads the content with php.
  // Remove the content so that we can show our transition on load.
  Element.update('content', "");
  // apply link behavior
  applyPageLinks("logo");
  applyPageLinks("menu");
  //Element.update('footer', "");
  // Javascript-less version preloads with faded logo.
  // Remove fade so that we can fade on load
  //Element.removeClassName("home", "logoFade");
  // initialize the DHTML History framework
  dhtmlHistory.initialize();
  // add ourselves as a DHTML History listener
  dhtmlHistory.addListener(handleHistoryChange);
  // determine what our initial location is by retrieving it from the browser's
  // location after the hash
  // Make sure we don't call this again if a history event has already fired
  // For example, on a page reload

  if (!contentPage) {
    handleHistoryChange(dhtmlHistory.getCurrentLocation(), null);
  }
}

/** Handles history change events. */
function handleHistoryChange(modifiedLocation, historyData) {
  var newLocation = modifiedLocation.replace(/section\:/, "");
  // update the browser to respond to this DHTML history change
  displayLocation(newLocation);
  // test for selected work section

/*
  if (newLocation.substr(0,5) == 'work_') {
    var str = $(newLocation).parentNode.parentNode.parentNode.id;
    var ourWork = parseInt(str.charAt(str.length-1));
    if (ourWork > 1) {
      // need to reposition carousel
alert(typeof(carousel));
      while (typeof(carousel) == 'undefined') {
        document.getElementById("debug").innerHTML = '~~~~~';
        document.getElementById("debug").innerHTML = typeof(carousel);
      }
      alert ('pause to advance carousel');
alert(typeof(carousel));
      //alert (typeof(carousel));
      YAHOO.extension.Carousel.prototype._scrollNextInc(carousel, ourWork-1, false);
    }
  }
*/
}

/** Respond to mouse clicks. */
function handlePageClick(evt) {
  var target = (evt.srcElement || evt.target);

  // Get new location from id
  // User might click on logo
  // If so, get the id from the parent href
  var newLocation = (target.id || target.parentNode.id);
	// in order to handle second link to same destination on same page (would normally require redundant id)
	// we use [page name]_ for second link
	// detect trailing "_" and remove
	if (newLocation.substr(newLocation.length-1)=='_') {
		newLocation = newLocation.substr(0,newLocation.length-1);
	}
  // Register a history event so this action gets recorded in the browser; Internet
  // Explorer has a bug that prevents us from setting a location value if there
  // are ANY HTML elements in the document that have the same ID already. For example,
  // if we tell dhtmlHistory to add the location 'inbox' to our browser's history, and there
  // is an element in the document with the ID 'inbox', then Internet Explorer will 
  // misbehave. We must accomodate this problem in IE by changing the location so it does
  // not match a pre-existing HTML id
  var modifiedLocation = "section:" + newLocation;
  /* replace above with this when deploying mod_rewrite
  var modifiedLocation = newLocation;
  */
  // clean up 'caption' locations (submenu_grid)
  modifiedLocation = modifiedLocation.replace(/_caption/, "");
  if (modifiedLocation != dhtmlHistory.getCurrentLocation()) {
    var historyData = {
      location:  newLocation,
      message:  "<p>The following location was loaded from our DHTML history: " + modifiedLocation + "</p>"
    }
    dhtmlHistory.add(modifiedLocation, historyData);
  
    // display this location in this container
    displayLocation(newLocation);
  }
  
  // Return false to abort any links
  return false;
}

/** Displays the given page. */
function displayLocation(newLocation) {
  // if the location is invalid then display the default, 
  // which is the home page, and load the home page content
  if (!content[newLocation]) {
    newLocation = "home";
  }
  // call swapPage for effects
  swapPage(newLocation);
}

// swapPage: change page content
// - fade out current content
// - get new content
// - fade in new content
function swapPage(newLocation) {
  var dur = 0.50; // fade/appear duration
  var reload = 0;
  if (contentPage == '') {
    // this is a page reload
    reload = 1;
  }
  // must hack opacity setting for Safari
  // 0.99999 works in Safari and breaks IE6/7
  // 1.0 works in IE6/7 and breaks Safari
  var endOpacity = (/Konqueror|Safari|KHTML/.test(navigator.userAgent) ? 0.99999 : 1.0);
  
  var newContentPage = content[newLocation][0];
  var newSubPage = content[newLocation][1];
//  alert('newContentPage: ' + newContentPage + '\n' + 'newSubPage: ' + newSubPage + '\n' + 'contentPage: ' + contentPage);

  if (newContentPage == contentPage) {
    // Make sure we have a sub page to change
    if (newSubPage) {
      highlightMenu("submenu", newSubPage);

      var subPageURL = newSubPage + '_snippet.php';

		/* BEGIN AdP changes 6/4/08 */
      // IE6/7 #02050a transparency bug fix:
      // if we're transitioning to/from a portfolio subpage
      // add a white veil and change its opacity, rather than the opacity of the image itself
      if (newContentPage.indexOf('ourwork') == 0) {
      	if (typeof $('work_veil') == 'undefined') {
	      	var testBg = document.createElement('div');
	      	testBg.id = 'work_veil';
	      	$('content').appendChild(testBg);
	      }
	      new Effect.Appear('work_veil', {duration: dur,
	        to: endOpacity,
	        afterFinish: function() {
	          setTimeout(function() {
	            Element.update("content_left", PageLoader.get(subPageURL));
	  			    new Effect.Fade('work_veil', {duration: dur});
							applyPageLinks("contentarea");
	          }, 10);
	        }
	      });
	    } else { // non-portfolio subpage, proceed as normal
	      new Effect.Fade('content_left', {duration: dur,
	        afterFinish: function() {
	          setTimeout(function() {
	            Element.update("content_left", PageLoader.get(subPageURL));
	            new Effect.Appear('content_left', {duration: dur});
							applyPageLinks("contentarea");
	          }, 10);
	        }
	      });
	    }
      /* END AdP changes 6/4/08 */
    }
  } else {
    highlightMenu("menu", newContentPage);

    var contentPageURL = newContentPage + '_snippet.php';
    var subPageURL = newSubPage + '_snippet.php';
    
    if (reload) {
      // this is a page reload (omit fade/appear)
      Element.update('content', PageLoader.get(contentPageURL));
      if (newSubPage) {
        Element.update("content_left", PageLoader.get(subPageURL));
        highlightMenu("submenu", newSubPage);
        applyPageLinks("submenu");
				applyPageLinks("contentarea");
      }
      new Effect.Appear('content', {duration: dur});
/*
      // logo handling
      // handle non-home pages (for home, do nothing)
      if (newContentPage != 'home') {
        // fade in logo
        new Effect.Opacity('home', {
          duration: .25,
          from:  0.25,
          to:    endOpacity
        })
      }
*/

    } else {
      // this is not a page reload
  		/* BEGIN AdP changes 10/5/09: added conditional so carousel doesn't fade going from home to our_work or vice versa */
  		var _subpageIsWork = newSubPage ? (newSubPage.indexOf('work_') == 0) : false;
  		var _home_ourwork = ((contentPage == 'home' && newContentPage == 'ourwork') || (contentPage == 'ourwork' && newContentPage == 'home'));
  		var noCarouselFade = (_home_ourwork && _subpageIsWork);
  		if (!noCarouselFade) {
		    new Effect.Fade('content', {duration: dur,
		      afterFinish: function() {
		    		setTimeout(function() {
		          Element.update('content', PageLoader.get(contentPageURL));
		          if (newSubPage) {
		            Element.update("content_left", PageLoader.get(subPageURL));
		            highlightMenu("submenu", newSubPage);
		            applyPageLinks("submenu");
		            applyPageLinks("contentarea");
		          }
		          new Effect.Appear('content', {duration: dur});
		        }, 10);
		      }
		    });
  		} else {
        if (newSubPage) {
			    new Effect.Fade('content_left', {duration: dur,
			      afterFinish: function() {
			    		setTimeout(function() {
			            Element.update("content_left", PageLoader.get(subPageURL));
			            highlightMenu("submenu", newSubPage);
			            applyPageLinks("submenu");
			            applyPageLinks("contentarea");
			          new Effect.Appear('content_left', {duration: dur});
			        }, 10);
			      }
			    });
        }
  		}
  		/* END AdP changes 10/5/09 */
/*
      // logo handling
      if (newContentPage == 'home') {
        // going to home from another page
        // fade out logo
        new Effect.Opacity('home', {
          duration: .25,
          from:  1.0,
          to:    0.25
        })
      } else if (contentPage == 'home') {
        // going to another page from home
        // fade in logo
        new Effect.Opacity('home', {
          duration: .25,
          from:  0.25,
          to:    endOpacity
        })
      }
*/
    }

    contentPage = newContentPage;
    subPage = newSubPage;
  }
  // google analytics
  // clicking in carousel produces work_ripple_caption instead of work_ripple,
  // but for tracking purposes it's the same request, so strip it out here
//  alert(newLocation.replace('_caption',''));
  if (typeof pageTracker != 'undefined') pageTracker._trackPageview(newLocation.replace('_caption',''));
}

function highlightMenu(menu, selected) {
  // clear out the old selected menu item
  var links = document.getElementsByClassName("pageLink", menu);
  for (var i = 0; i < links.length; i++) {
    Element.removeClassName(links[i], "selected");
  }
//alert(links);
  // cause the new selected menu item to appear differently in the UI
  Element.addClassName(selected, "selected");
}

function applyPageLinks(menu) {
  var links = document.getElementsByClassName('pageLink', menu);
  for (var i = 0; i < links.length; i++) {
    links[i].onclick = handlePageClick.bindAsEventListener(this);
  }
}

var PageLoader = {
  pages: new Array(),

  initialize: function(preloadPages) {
    for (var i = 0; i < preloadPages.length; i++) {
      this.load(preloadPages[i]);
    }
  },
  
  load: function(page) {
//    window.status = "loading " + page;
    new Ajax.Request(page, {
      method: 'get',
      asynchronous: true,
      onComplete: this.onComplete.bind(this,page)
    });
  },
  
  loadNow: function(page) {
//    window.status = "loading " + page;
    var request = new Ajax.Request(page, {
      method: 'get',
      asynchronous: false
    });
    this.pages[page] = request.transport.responseText;
  },
    
  onComplete: function(page,request) {
    this.pages[page] = request.responseText;
//    alert (page + " = " + this.pages[page]);
  },
  
  get: function(page) {
    if (!this.pages[page]) {
      this.loadNow(page);
    }
    return this.pages[page];
  }
}

var LogoFader = function() {
	this.dom = YAHOO.util.Dom;
	this.anim = YAHOO.util.Anim;
	this.ease = YAHOO.util.Easing.easeOutStrong;

	this.logo = $('home');
	this.opFadeUp = /Konqueror|Safari|KHTML/.test(navigator.userAgent) ? 0.99999 : 1.0;
	this.opFadeDown = 0.25;
	this.dur = 0.25; // fade/appear duration
	
	//this.init(); //disable for transition site
};

LogoFader.prototype = {
	init: function() {
		this.logo.onmouseover = this.handleMouseOver.bindAsEventListener(this);
		this.logo.onmouseout  = this.handleMouseOut.bindAsEventListener(this);
	},
	handleMouseOver: function(evt) {
		new Effect.Opacity('home', {
			duration: this.dur,
			to: this.opFadeDown
		});
	},
	handleMouseOut: function(evt) {
		new Effect.Opacity('home', {
			duration: this.dur,
			to: this.opFadeUp
		});
	}
};

var WorkSlideshow = function() {
	this.dom = YAHOO.util.Dom;
	this.anim = YAHOO.util.Anim;
	this.ease = YAHOO.util.Easing.easeOutStrong;

	this.imgs = $$('div#client-work img');
	this.imgLinks = $$('div#work-nav-imgs a') || null;
	if (this.imgLinks) {
		this.prev = $('work-nav-img-prev');
		this.next = $('work-nav-img-next');
	}
	this.viewImg = $('view-img-link') || null;
	this.readStoryId = 'read-story-link';
	this.readStory = $(this.readStoryId) || null;
	this.storyContId = 'story-cont';
	this.storyCont = $(this.storyContId);
	this.veil = 'work_veil';
	
	// must hack opacity setting for Safari
	// 0.99999 works in Safari and breaks IE6/7
	// 1.0 works in IE6/7 and breaks Safari
	this.endOpacity = /Konqueror|Safari|KHTML/.test(navigator.userAgent) ? 0.99999 : 1.0;
	this.dur = 0.50; // fade/appear duration
	
	this.currImg = 0;
	this.storyLoaded = false;
	
	this.init();
};

WorkSlideshow.prototype = {
	init: function() {
		this.imgs[this.currImg].setStyle({display:'block'});
		if (this.imgLinks.length) {
			for (var i = 0; i < this.imgLinks.length; i++) {
				this.imgLinks[i].onclick = this.handleImgNavClick.bindAsEventListener(this);
			}
			$('work-nav-img-prev').onclick = this.loadPrevImg.bindAsEventListener(this);
			$('work-nav-img-next').onclick = this.loadNextImg.bindAsEventListener(this);
		}
		if (this.viewImg) this.viewImg.onclick = this.handleImgNavClick.bindAsEventListener(this);
		if (this.readStory) this.readStory.onclick = this.loadStory.bindAsEventListener(this);
	},
	addVeil: function() {
		if (typeof $(this.veil) == 'undefined') {
			var testBg = document.createElement('div');
			testBg.id = this.veil;
			$('client-work').appendChild(testBg);
		}
	},
	loadImg: function(imgNo) {
		this.addVeil();
		new Effect.Appear(this.veil, {duration: this.dur,
			to: this.endOpacity,
			afterFinish: function() {
				setTimeout(function() {
					this.swapImg(imgNo);
					new Effect.Fade(this.veil, {duration: this.dur});
				}.bind(this), 10);
			}.bind(this)
		});
	},
	loadStory: function(evt) {
		if (this.storyCont.getStyle('display') == 'block') return false;
		var target = (evt.srcElement || evt.target);
		var requestedPg = target.getAttribute('rel');

		this.addVeil();
		new Effect.Appear(this.veil, {duration: this.dur,
			to: this.endOpacity,
			afterFinish: function() {
				setTimeout(function() {
					this.imgs[this.currImg].setStyle({display:'none'});
					if (!this.storyLoaded) {
			            Element.update(this.storyContId, PageLoader.get(requestedPg + '_snippet.php'));
			            this.storyLoaded = true;
					}
		            this.storyCont.setStyle({display:'block'});
		            //change some link styles
		            if (this.viewImg) this.viewImg.removeClassName('sel');
		            if (this.readStory) this.readStory.addClassName('sel');
					new Effect.Fade(this.veil, {duration: this.dur});
				}.bind(this), 10);
			}.bind(this)
		});
		// google analytics
		// we want to track requests to read a client story
		if (typeof pageTracker != 'undefined') pageTracker._trackPageview(requestedPg);
		
		return false;
	},
	swapImg: function(newImgNo) {
		//is an image showing, or the story?
		var showing = (this.storyCont.getStyle('display') == 'block') ? this.storyCont : this.imgs[this.currImg];
		//swap images
		showing.setStyle({display:'none'});
		this.imgs[newImgNo].setStyle({display:'block'});
		//update image link display
		if (this.imgLinks.length) {
			this.imgLinks[this.currImg].removeClassName('sel');
			this.imgLinks[newImgNo].addClassName('sel');
		}
        if (this.viewImg) this.viewImg.addClassName('sel');
        if (this.readStory) this.readStory.removeClassName('sel');
		//update current image
		this.currImg = newImgNo;
	},
	handleImgNavClick: function(evt) {
		var target = (evt.srcElement || evt.target);
		var requestedImg = target.getAttribute('rel');
		if ((requestedImg == this.currImg) && (this.storyCont.getStyle('display') != 'block')) return false;
		this.loadImg(requestedImg);
		return false;
	},
	loadPrevImg: function() {
		if (this.currImg == 0) return false;
		this.loadImg(this.currImg - 1);
		return false;
	},
	loadNextImg: function() {
		if (this.currImg == (this.imgs.length - 1)) return false;
		this.loadImg(this.currImg + 1);
		return false;
	}
};

var contentPage = "";
var subPage = "";

var firstCarouselItem = 'work_shangrila';
var content = {
  'home':              ['home',    'work_intro'],
  'whatwedo':            ['whatwedo',  'what_intro'],
  'what_identity':          ['whatwedo',  'what_identity'],
  'what_interaction':        ['whatwedo',  'what_interaction'],
  'what_strategic':        ['whatwedo',  'what_strategic'],
  'ourwork':            ['ourwork',    firstCarouselItem],
  'work_adobe':     ['ourwork',  'work_adobe'],
  'work_adobe_caption':   ['ourwork',  'work_adobe'],
  'work_autodesk':     ['ourwork',  'work_autodesk'],
  'work_autodesk_caption':   ['ourwork',  'work_autodesk'],
  'work_cpp':     ['ourwork',  'work_cpp'],
  'work_cpp_caption':   ['ourwork',  'work_cpp'],
  'work_kohler':     ['ourwork',  'work_kohler'],
  'work_kohler_caption':   ['ourwork',  'work_kohler'],
  'work_inkling':     ['ourwork',  'work_inkling'],
  'work_inkling_caption':   ['ourwork',  'work_inkling'],
  'work_shangrila':     ['ourwork',  'work_shangrila'],
  'work_shangrila_caption':   ['ourwork',  'work_shangrila'],
  'work_sfcm':     ['ourwork',  'work_sfcm'],
  'work_sfcm_caption':   ['ourwork',  'work_sfcm'],
  'work_pcworld':     ['ourwork',  'work_pcworld'],
  'work_pcworld_caption':   ['ourwork',  'work_pcworld'],
  'work_sfballet':     ['ourwork',  'work_sfballet'],
  'work_sfballet_caption':   ['ourwork',  'work_sfballet'],
  'work_onetouch':     ['ourwork',  'work_onetouch'],
  'work_onetouch_caption':   ['ourwork',  'work_onetouch'],
  'work_23andme':     ['ourwork',  'work_23andme'],
  'work_23andme_caption':   ['ourwork',  'work_23andme'],
  'work_gateway':     ['ourwork',  'work_gateway'],
  'work_gateway_caption':   ['ourwork',  'work_gateway'],
  'work_sonyvaio':     ['ourwork',  'work_sonyvaio'],
  'work_sonyvaio_caption':   ['ourwork',  'work_sonyvaio'],
  'work_mcafee':     ['ourwork',  'work_mcafee'],
  'work_mcafee_caption':   ['ourwork',  'work_mcafee'],
  'work_current':     ['ourwork',  'work_current'],
  'work_current_caption':   ['ourwork',  'work_current'],
  'work_fourseasons':     ['ourwork',  'work_fourseasons'],
  'work_fourseasons_caption':   ['ourwork',  'work_fourseasons'],
  'work_dai':     ['ourwork',  'work_dai'],
  'work_dai_caption':   ['ourwork',  'work_dai'],
  'work_condenast':     ['ourwork',  'work_condenast'],
  'work_condenast_caption':   ['ourwork',  'work_condenast'],
  'work_bloomenergy':     ['ourwork',  'work_bloomenergy'],
  'work_bloomenergy_caption':   ['ourwork',  'work_bloomenergy'],
  'work_symantec':     ['ourwork',  'work_symantec'],
  'work_symantec_caption':   ['ourwork',  'work_symantec'],
  'work_hoteljen':     ['ourwork',  'work_hoteljen'],
  'work_hoteljen_caption':   ['ourwork',  'work_hoteljen'],
  'work_sandisk':     ['ourwork',  'work_sandisk'],
  'work_sandisk_caption':   ['ourwork',  'work_sandisk'],
  'work_denverart':     ['ourwork',  'work_denverart'],
  'work_denverart_caption':   ['ourwork',  'work_denverart'],
  'work_yahoo':     ['ourwork',  'work_yahoo'],
  'work_yahoo_caption':   ['ourwork',  'work_yahoo'],
  'work_move':     ['ourwork',  'work_move'],
  'work_move_caption':   ['ourwork',  'work_move'],
  'work_sonycorp':     ['ourwork',  'work_sonycorp'],
  'work_sonycorp_caption':   ['ourwork',  'work_sonycorp'],
  'work_viacom':     ['ourwork',  'work_viacom'],
  'work_viacom_caption':   ['ourwork',  'work_viacom'],
  'work_polo':     ['ourwork',  'work_polo'],
  'work_polo_caption':   ['ourwork',  'work_polo'],
  'work_epinions':     ['ourwork',  'work_epinions'],
  'work_epinions_caption':   ['ourwork',  'work_epinions'],
  'work_nokia':     ['ourwork',  'work_nokia'],
  'work_nokia_caption':   ['ourwork',  'work_nokia'],
  'work_etrade':     ['ourwork',  'work_etrade'],
  'work_etrade_caption':   ['ourwork',  'work_etrade'],
  'work_danger':     ['ourwork',  'work_danger'],
  'work_danger_caption':   ['ourwork',  'work_danger'],
  'work_cnet':     ['ourwork',  'work_cnet'],
  'work_cnet_caption':   ['ourwork',  'work_cnet'],
  'work_philm':     ['ourwork',  'work_philm'],
  'work_philm_caption':   ['ourwork',  'work_philm'],
  'work_palm':     ['ourwork',  'work_palm'],
  'work_palm_caption':   ['ourwork',  'work_palm'],
  'work_ripple':     ['ourwork',  'work_ripple'],
  'work_ripple_caption':   ['ourwork',  'work_ripple'],
  'ourclients':          ['ourclients',  'clients_intro'],
  'clients_industry':          ['ourclients',  'clients_industry'],
  'clients_capability':          ['ourclients',  'clients_capability'],
  'clients_adobe':          ['ourwork',  'clients_adobe'],
  'clients_autodesk':          ['ourwork',  'clients_autodesk'],
  'clients_cpp':          ['ourwork',  'clients_cpp'],
  'clients_kohler':          ['ourwork',  'clients_kohler'],
  'clients_inkling':          ['ourwork',  'clients_inkling'],
  'clients_shangrila':          ['ourwork',  'clients_shangrila'],
  'clients_sfcm':          ['ourwork',  'clients_sfcm'],
  'clients_pcworld':          ['ourwork',  'clients_pcworld'],
  'clients_polo':          ['ourwork',  'clients_polo'],
  'clients_sfballet':          ['ourwork',  'clients_sfballet'],
  'clients_23andme':          ['ourwork',  'clients_23andme'],
  'clients_sonyvaio':          ['ourwork',  'clients_sonyvaio'],
  'clients_mcafee':          ['ourwork',  'clients_mcafee'],
  'clients_current':          ['ourwork',  'clients_current'],
  'clients_fourseasons':          ['ourwork',  'clients_fourseasons'],
  'clients_dai':          ['ourwork',  'clients_dai'],
  'clients_bloomenergy':          ['ourwork',  'clients_bloomenergy'],
  'clients_hoteljen':          ['ourwork',  'clients_hoteljen'],
  'clients_sandisk':          ['ourwork',  'clients_sandisk'],
  'clients_move':          ['ourwork',  'clients_move'],
  'clients_viacom':          ['ourwork',  'clients_viacom'],
  'clients_ripple':          ['ourwork',  'clients_ripple'],
  'whoweare':            ['whoweare',    'bio_intro'],
  'bio_bill':            ['whoweare',    'bio_bill'],
  'bio_alex':            ['whoweare',    'bio_alex'],
  'bio_vince':           ['whoweare',    'bio_vince'],
  'bio_jane':            ['whoweare',    'bio_jane'],
  'bio_mark':            ['whoweare',    'bio_mark'],
  'bio_sean':            ['whoweare',    'bio_sean'],
  'contactus':          ['contactus',  ''],
  'news':          ['news',  ''],
  '404':              ['404',      '']
}