iPod = {}
iPod.GalleryCoordinator = {

	synchronizedViewMasters: {},

	trackingNameForSection: function(tracker, name, section) {
		tracker.count++;
		//if (name.match('cs-')) return false;
		if (tracker.count > 2  && !name.match(/cs-/)){ 
			return name;
		}
		return false;
	},

	didShow: function(viewer, outgoing, incoming) {

		// if this is the first section to be shown, no need to sync with anything
		if (!outgoing) {
			return;
		}

		// stop if we don't have a view master corresponding to the incoming section id yet
		var incomingViewMaster = this.synchronizedViewMasters[incoming.id];
		if (!incomingViewMaster) {
			return;
		}

		// otherwise figure out which synchronized viewmaster is leaving
		// and the id of section it was showing
		var outgoingViewMaster = this.synchronizedViewMasters[outgoing.id];
		var outgoingSectionId = outgoingViewMaster.currentSection.id;

		// figure out which section that is in the incoming view master
		// and make sure it's the one that's being shown
		var synchronizedSection = incomingViewMaster.sectionWithId(outgoingSectionId);
		incomingViewMaster.show(synchronizedSection);
	}
}

Event.onDOMReady(function() {
	//Track clicks to view in iTunes
	var colorchange = null;
	if (colorchange = $$('#colorselect a')){
		colorchange.each(function(elem){
			var p3val = AC.Tracking.pageName().split(/\s-\s/g);
			p3val = p3val[0] + ' - ' + p3val[1];
			elem.observe('mousedown', function(evt){
				var properties = {
				prop3: p3val + "- color change", 
				pageName: AC.Tracking.pageName() + ' (US)'
			};
			AC.Tracking.trackClick(properties, this, 'o', properties.prop3);
	 		});
		});
	}
});
