/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */
var tTime = 500;
var tDelay = 500;
var imageArray = new Array();
var imagePath = 'img/images/';
var currentImage = 0;
var firstPage = true;
var scrollDistance = 50;
var slidePosition;
var slideHeight
var textHeight
var maxUp;
var maxDown;
var scrollingDown;
var scrollingUp;
var orgHtmlText;
var orgBodyText;

$(document).ready(function(){documentReady()});

function documentReady() {
	
}

function initSlideshow() {
	checkPage();
	getClassText();
	initSeadragon();
	setupImageArray();
	initGalleryNav();
}

function checkPage() {
	currentURLPage = location.search.substr(1).split("=");
	if(currentURLPage.length == 2) {
		currentImage = Number(currentURLPage[1]);
		firstPage = false;
	}
}

function getClassText() {
	orgHtmlText = $('html').attr('class');
	orgBodyText = $('body').attr('class');
}

function initSeadragon() {
	Seadragon.Config.minZoomImageRatio = 1;
	Seadragon.Config.maxZoomPixelRatio = 1;
	Seadragon.Utils.addEvent(window, "load", seadragonSetup);
}
function seadragonSetup() {
	viewer = new Seadragon.Viewer("seadragon");
	changeSlide();
	if(firstPage) {
		viewer.addEventListener("open", playIntro);
	} else {
		viewer.addEventListener("open", playNormal);
	}
}
function unCrop() {
	cropTimer = setTimeout(function(){
		$('#cropRight').animate({'width':'0px'}, tTime);
		$('#cropLeft').animate({'width':'0px'}, tTime);
		clearTimeout(cropTimer);
	}, tDelay);
}

function initGalleryNav() {
	toggleGalleryNav();
	$('#previous').click(function(){previousSlide()});
	$('#next').click(function(){nextSlide()});
}
function toggleGalleryNav() {
	if(currentImage == 0) {
		$('#previous').hide();
	}
	if(currentImage > 0) {
		$('#previous').show();
	}
	if(currentImage < imageArray.length - 1) {
		$('#next').show();
	}
	if(currentImage == imageArray.length - 1) {
		$('#next').hide();
	}
}
function previousSlide() {
	currentImage--;
	insertParam('image', currentImage);
}
function nextSlide() {
	currentImage++;
	insertParam('image', currentImage);
}
function changeSlide() {
	changeBackground();
	changeImage();
	changeInfo();
	changeCrop();
	toggleGalleryNav();
}
function changeBackground() {
	if(imageArray[currentImage]['background']) {
		modifyClass('html', orgHtmlText);
		modifyClass('body', orgBodyText);
	}
	
	function modifyClass(object, originalText) {
		newHtmlText = originalText.replace(object, object+imageArray[currentImage]['background'])
		$(object).attr('class', newHtmlText);
	}
}
function changeImage() {
	xPoint = 0;
	yPoint = 0;
	zoom = 1;
	
	if(imageArray[currentImage]['xPoint']) xPoint = imageArray[currentImage]['xPoint'];
	if(imageArray[currentImage]['yPoint']) yPoint = imageArray[currentImage]['yPoint'];
	if(imageArray[currentImage]['zoom']) zoom = imageArray[currentImage]['zoom'];
	
	viewer.openDzi(imagePath+imageArray[currentImage]['image']);
	viewer.addEventListener("open", function(){
		viewer.viewport.zoomTo(zoom, true);
		point = new Seadragon.Point(xPoint, yPoint);
		viewer.viewport.panBy(point, true);
	});
}
function changeInfo() {
	$('#slideInfo #location, #slideInfo #project, #slideInfo #artDirector, #slideInfo #artist, #slideInfo #moreInfo').hide();
	
	if(imageArray[currentImage]['location']) {
		$('#slideInfo #location .info').text(imageArray[currentImage]['location']);
		$('#slideInfo #location').show();
	}
	if(imageArray[currentImage]['project']) {
		$('#slideInfo #project .info').text(imageArray[currentImage]['project']);
		$('#slideInfo #project').show();
	}
	if(imageArray[currentImage]['artDirector']) {
		$('#slideInfo #artDirector .info').text(imageArray[currentImage]['artDirector']);
		$('#slideInfo #artDirector').show();
	}
	if(imageArray[currentImage]['artist']) {
		$('#slideInfo #artDirector .info').text(imageArray[currentImage]['artist']);
		$('#slideInfo #artDirector').show();
	}
	if(imageArray[currentImage]['moreInfo']) {
		$('#slideInfo #moreInfo').show();
		$('.slider').load('files/more_info/'+imageArray[currentImage]['moreInfo']);
		initMoreInfo();
	}
}
function changeCrop() {
	if(imageArray[currentImage]['leftCrop']) {
		$('#cropLeft').css({'width':imageArray[currentImage]['leftCrop']+'px'});
	}
	if(imageArray[currentImage]['rightCrop']) {
		$('#cropRight').css({'width':imageArray[currentImage]['rightCrop']+'px'});
	}
}


function initMoreInfo() {
	$('#arrows #up').css({'opacity':'.25','cursor':'default'});
	$('#moreInfo').click(function(){
		moreInfoClick();
	});
}
function moreInfoClick() {
	$('#moreInfoBox').fadeIn('fast', function() {
		initScroll();
		$('#close').click(function(){
			$('#moreInfoBox').fadeOut('fast');
		});
	});
}
function initScroll() {
	slideHeight = $('.slider').height();
	textHeight = $('.text').height();
	maxUp = (slideHeight-textHeight)* -1;
	maxDown = 0;
	slidePosition = 0;

	bindUp();
	bindDown();
}
function startScrolling(obj, param) {
    checkSlidePosition();
    obj.animate({"top": param}, "fast", function() {
        if (scrolling) {
                startScrolling(obj, param);
        }
    });
}
function checkSlidePosition() {
	slidePosition = $('.slider').css('top');
	slidePosition = slidePosition.replace("px", "");
	slidePosition = Number(slidePosition);
	
	$('#arrows #down').css({'opacity':'1', 'cursor':'pointer'});
	$('#arrows #up').css({'opacity':'1', 'cursor':'pointer'});
	
	if(slidePosition <= maxUp && scrollingUp) {
		scrolling= false;
		$(".slider").css({'top':String(maxUp)+'px'});
		$('#arrows #down').css({'opacity':'.25','cursor':'default'});
	}
	if(slidePosition >= maxDown && scrollingDown) {
		scrolling= false;
		$(".slider").css({'top':String(maxDown)+'px'});
		$('#arrows #up').css({'opacity':'.25','cursor':'default'});
	}
}
function bindUp() {
	$("#arrows #up").mousedown(function() {
 		scrollingDown = true;
        scrolling = true;
        startScrolling($(".slider"), "+=20px");
    }).mouseup(function(){
        scrolling = false;
        scrollingDown = false;
    });
}
function bindDown() {
	$("#arrows #down").mousedown(function(){
     	scrollingUp = true;
        scrolling = true;
        startScrolling($(".slider"), "-=20px");
    }).mouseup(function(){
        scrolling = false;
        scrollingUp = false;
    });
}
function unbindUp() {
	$("#arrows #up").unbind('mousedown');
	$("#arrows #up").unbind('mouseup');
}
function unbindDown() {
	$("#arrows #down").unbind('mousedown');
	$("#arrows #down").unbind('mouseup');
}


function setupImageArray() {
	i=0;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "deyoung/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "DE YOUNG MUSEUM";
	imageArray[i]['project'] = "MURALISMO SPECIAL EVENT";
	imageArray[i]['moreInfo'] = "de_young.html";
	imageArray[i]['background'] = "DeYoung";
	imageArray[i]['leftCrop'] = "315";
	imageArray[i]['rightCrop'] = "235";
	imageArray[i]['xPoint'] = -.015;
	imageArray[i]['yPoint'] = .0285;
	imageArray[i]['zoom'] = 3.05;
	
	i=1;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "deyoung/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "DE YOUNG MUSEUM";
	imageArray[i]['project'] = "MURALISMO SPECIAL EVENT";
	imageArray[i]['moreInfo'] = "de_young.html";
	imageArray[i]['background'] = "DeYoung";
	imageArray[i]['zoom'] = 1.02;
	
	i=2;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "craneway_pavilion/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "CRANEWAY PAVILION";
	imageArray[i]['project'] = "ART DIRECTORS EVENT";
	imageArray[i]['moreInfo'] = "craneway_pavilion.html";
	imageArray[i]['background'] = "Craneway";
	imageArray[i]['xPoint'] = -.02;
	imageArray[i]['yPoint'] = -.01;
	imageArray[i]['zoom'] = 1.32;
	
	i=3;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "throckmorton_theatre/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "142 THROCKMORTON THEATRE";
	imageArray[i]['project'] = "ANNIE JUNIOR PRODUCTION";
	imageArray[i]['artDirector'] = "LUCY MERCER";
	imageArray[i]['moreInfo'] = "throckmorton.html";
	imageArray[i]['background'] = "AnnieJr";
	imageArray[i]['xPoint'] = -.058;
	imageArray[i]['yPoint'] = 0;
	imageArray[i]['zoom'] = 1.69;
	
	i=4;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "man_of_la_mancha/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "MT. TAMALPAIS AMPHITHEATRE";
	imageArray[i]['project'] = "THE MAN OF LA MANCHA";
	imageArray[i]['artDirector'] = "SARA PEARSON";
	imageArray[i]['moreInfo'] = "man_of_la_mancha.html";
	imageArray[i]['background'] = "ManOfLa";
	imageArray[i]['xPoint'] = 0.206;
	imageArray[i]['yPoint'] = 0.03;
	imageArray[i]['zoom'] = 2.41;
	
	i=5;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "the_blush_ice/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "WILDCAT HOLLOW POND";
	imageArray[i]['project'] = "FINE ART INSTALLATION";
	imageArray[i]['moreInfo'] = "blush_ice.html";
	imageArray[i]['background'] = "BlushIce";
	imageArray[i]['xPoint'] = -.009;
	imageArray[i]['yPoint'] = -.06;
	imageArray[i]['zoom'] = 2.21;
	
	i=6;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "language_of_the_birds/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "BROADWAY AND COLUMBUS, SF";
	imageArray[i]['project'] = "PUBLIC ART / LANGUAGE OF THE BIRDS";
	imageArray[i]['artist'] = "BRIAN GOGGIN";
	imageArray[i]['moreInfo'] = "language_of_the_birds.html";
	imageArray[i]['background'] = "Language";
	imageArray[i]['xPoint'] = -.025;
	imageArray[i]['yPoint'] = -.007;
	imageArray[i]['zoom'] = 1.64;
	
	i=7;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "de_young_interior/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "DE YOUNG MUSEUM";
	imageArray[i]['project'] = "MURALISMO SPECIAL EVENT";
	imageArray[i]['moreInfo'] = "de_young_interior.html";
	imageArray[i]['background'] = "DeYoungInterior";
	imageArray[i]['xPoint'] = 0.01;
	imageArray[i]['yPoint'] = 0.011;
	imageArray[i]['zoom'] = 2.315;
	
	i=8;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "heavenly_body/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "THE CONCOURSE";
	imageArray[i]['project'] = "SEA OF DREAMS";
	imageArray[i]['artDirector'] = "MARK PETRAKIS";
	imageArray[i]['moreInfo'] = "sea_of_dreams.html";
	imageArray[i]['background'] = "SeaOfDreams";
	imageArray[i]['xPoint'] = 0.003;
	imageArray[i]['yPoint'] = 0.028;
	imageArray[i]['zoom'] = 2.8;
	
	i=9;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "serpent_mother/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "TREASURE ISLAND";
	imageArray[i]['project'] = "SERPENT MOTHER INSTALLATION";
	imageArray[i]['artist'] = "THE FLAMING LOTUS GIRLS";
	imageArray[i]['moreInfo'] = "serpent_mother.html";
	imageArray[i]['background'] = "SerpentMother";
	imageArray[i]['xPoint'] = 0;
	imageArray[i]['yPoint'] = .013;
	imageArray[i]['zoom'] = 5;
	
	i=10;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "obama_inauguration/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "142 THROCKMORTON THEATRE";
	imageArray[i]['project'] = "OBAMA INAUGURATION";
	imageArray[i]['artDirector'] = "LUCY MERCER";
	imageArray[i]['moreInfo'] = "barack_obama_inauguration.html";
	imageArray[i]['background'] = "ObamaInauguration";
	imageArray[i]['xPoint'] = .093;
	imageArray[i]['yPoint'] = -.05;
	imageArray[i]['zoom'] = 5.8;
	
	i=11;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "obama_ball/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "142 THROCKMORTON THEATRE";
	imageArray[i]['project'] = "OBAMA INAUGURATION BALL";
	imageArray[i]['artDirector'] = "LUCY MERCER";
	imageArray[i]['moreInfo'] = "obama_inauguration_ball.html";
	imageArray[i]['background'] = "ObamaBall";
	imageArray[i]['xPoint'] = 0.0535;
	imageArray[i]['yPoint'] = 0.086;
	imageArray[i]['zoom'] = 1.9;
	
	i=12;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "musica_lisa/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "SEBASTOPOL ANTIQUES EMPORIUM";
	imageArray[i]['project'] = "SUNDAY JAM";
	imageArray[i]['moreInfo'] = "still_melody.html";
	imageArray[i]['background'] = "StillMelody";
	imageArray[i]['xPoint'] = -.07;
	imageArray[i]['yPoint'] = 0;
	imageArray[i]['zoom'] = 1.9;
	
	i=13;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "mark_pita_and_friends/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "142 THROCKMORTON THEATRE";
	imageArray[i]['project'] = "MARK PITTA AND FRIENDS COMEDY";
	imageArray[i]['artDirector'] = "LUCY MERCER";
	imageArray[i]['moreInfo'] = "mark_pitta.html";
	imageArray[i]['background'] = "MarkPitta";
	imageArray[i]['xPoint'] = -.073;
	imageArray[i]['yPoint'] = 0.015;
	imageArray[i]['zoom'] = 3;
	
	i=14;
	imageArray[i] = new Array();
	imageArray[i]['image'] = "the_housatonic/GeneratedImages/dzc_output.xml";
	imageArray[i]['location'] = "INDIAN CROSSING";
	imageArray[i]['project'] = "THE HOUSATONIC AT SALIBURY";
	imageArray[i]['moreInfo'] = "housatonic.html";
	imageArray[i]['background'] = "Housatonic";
	imageArray[i]['xPoint'] = -.095;
	imageArray[i]['yPoint'] = 0.008;
	imageArray[i]['zoom'] = 2.7;
}
function hideBeforeIntro() {
	$('#slideInfo').hide();
}
function playIntro() {
	hideBeforeIntro();
	
	setTimeout ( function() {
		setTimeout ( function() {$('#photography').fadeIn(tTime+500,function(){});}, 1000 );
		$('#expanding').fadeIn(tTime+2000,function(){
				setTimeout ( function() {
					//spring = true;
					spring = Seadragon.Point(1000000);
					viewer.viewport.zoomTo(1.02, spring);
					point = new Seadragon.Point(.015, -.032);
					viewer.viewport.panBy(point, spring);
					$('#cropLeft, #cropRight').animate({'width':'0px'}, {'duration':2000, 'easing':'easeInOutQuart', 'complete':function() {
						$('#photography').fadeOut(tTime);
						$('#expanding').fadeOut(tTime,function(){
							setTimeout ( function() {
								$('#instructions').fadeIn(tTime+500,function(){
									blinkNav();
									$('#seadragon').mouseover(function(){
											$('#instructions').fadeOut(tTime);
										$('#slideInfo').fadeIn(tTime);
									});
								});
							}, 1000 );
						});
					}});
				}, 500 );
		});
	}, 1500 );
	currentImage = 1;
}
function blinkNav() {
	i = 0;
	nextOver = false; 
	setTimeout ( function() {
		$('#galleryNav #next').mouseover(function(){
			nextOver =true;
		});	
		fadeOnNav();
		function fadeOnNav() {
			$('#galleryNav #next').animate({'opacity':'0'}, tTime, function() {
				fadeOffNav();
			});
		}
		function fadeOffNav() {
			i++;
			if(nextOver) {
				$('#galleryNav #next').animate({'opacity':'1'}, tTime);
			}else {
				$('#galleryNav #next').animate({'opacity':'1'}, tTime, function() {
					fadeOnNav();
				});
			}
		}
	}, 3000 );
}

function playNormal() {
	$('#slideInfo').show();
	unCrop();
}
function playSkills() {
	$('#swfVideo').fadeIn(tTime,function(){
		setTimeout ( function() {
			$('#skillstext').fadeIn(tTime);
		}, 3000 );
	});
}
function playAbout() {
	tTime = 200;
	$('#aboutLogo, #about p').hide();
	$('#aboutLogo').fadeIn(tTime,function(){
		$('.p1').fadeIn(tTime,function(){
			$('.p2').fadeIn(tTime,function(){
				$('.p3').fadeIn(tTime,function(){
					$('.p4').fadeIn(tTime,function(){
						$('.p5').fadeIn(tTime,function(){
							$('.p6').fadeIn(tTime);
						});
					});
				});
			});
		});
	});
}
function playKudos() {
	$('#bgBand, #block1, #block2, #block3').hide();
	$('#bgBand').fadeIn(tTime,function(){
		$('#block1').fadeIn(tTime,function(){
			$('#block2').fadeIn(tTime,function(){
				$('#block3').fadeIn(tTime);
			});
		});
	});
}
function playCollectors() {
	$('img, .strip, .text').hide();
	
	$('img').fadeIn(tTime,function(){
		$('.strip').fadeIn(tTime,function(){
		$('.strip').css('filter', 'alpha(opacity=40)');
			$('.text').fadeIn(tTime);
		});
	});
}
function playContact() {
	$('#inauguration, #branding, #text').hide();
	
	$('#inauguration').fadeIn(tTime,function(){
		$('#branding, #text').fadeIn(tTime);
	});
}
function insertParam(key, value) {
    key = escape(key); value = escape(value);
    var kvp = document.location.search.substr(1).split('&');
    var i=kvp.length; var x; while(i--) {
        x = kvp[i].split('=');
        if (x[0]==key) {
                x[1] = value;
                kvp[i] = x.join('=');
                break;
        }
    }
    if(i<0) {kvp[kvp.length] = [key,value].join('=');}
    //this will reload the page, it's likely better to store this until finished
    document.location.search = kvp.join('?'); 
}
