



	var imageList;

$(function() {
	// establish connection between thumbnails and imageList array
	if (typeof(imageList) == 'object') {
		var thumbs = $('.galleryListing li a img');
		for (var thumbIndex = thumbs.length - 1; thumbIndex >= 0; thumbIndex--) {
			thumbs[thumbIndex].imageInfo = imageList[thumbIndex];
		}
	}
	
	// show the terms and conditions div on first click of the download button
	$('.photosDownload').click(function(){
		return doPhotoDownload(this.href);
	});
	
	// set terms cookie and download from terms window
	$('.termsAgree').click(function(){
		if ($('input[type=checkbox]', this.form)[0].checked) {
			$.cookie(COOKIE_NAMES.PHOTO_TERMS_ACCEPTED, true, { expiries: getCookieExpiresDate() });
			setImage($('.galleryListing li.current'));
			doPhotoDownload($('.photosDownload')[0].href);
		}
	});
																			
	$('.galleryListing a').mouseover(function(){
		$('.galleryListing li').removeClass('active');
		$(this).parent().addClass('active');
		return false; 
	});
	
	$('.galleryListing a').mouseout(function(){
		$('.galleryListing li').removeClass('active');
		return false; 
	});

	$('.galleryListing:not(.videoListing) a').click(function(){
		var activeItem = $(this).parent();
		setImage(activeItem);
		if ($('#photoScrollHref')) {
			window.location.href = "#photoScrollHref";
		}
		return false; 
	})

	// photo gallery, previous photo 
	$('.photosMouseOverLeft').click(function(){ 
		setImageClick('left'); 
		return false; 
	});

	// photo gallery, next photo 
	$('.photosMouseOverRight').click(function(){ 
		setImageClick('right'); 
		return false; 
	});
	
	// photo gallery, "More Information"
	$('a.photosSeeMore').click(function(){ 
		$('.moreInfosPhotos').toggleClass('hidden');
		$('a.photosSeeMore').toggleClass('minus');
		return false; 
	});
	
	$('.moreInfosPhotos').addClass('hidden');
	//var imgActive = $('.mainPhotoGallery .tabItem li.active img');
	//var longdesc = "";
	//longdesc = imgActive.attr('longdesc'); 
	//$('.moreInfosPhotos').html(longdesc);
	var activeItem = $('.galleryListing li.current');
	if (activeItem.length == 0) {
		activeItem = $('.galleryListing li:first');
		activeItem.addClass('current');
	}
  setImage(activeItem);
});

function setImage(chosenli){
	if (chosenli.length==0)
		return;
	var chosenImageInfo = $('img', chosenli)[0].imageInfo;
	if (chosenImageInfo) {
		var largeImage = $('#photoGalleryImg');
		largeImage.attr('src', chosenImageInfo.url);
		largeImage.attr('alt', chosenImageInfo.title);
		$('.photosTitle').html(chosenImageInfo.title ? chosenImageInfo.title : '&nbsp;');
		
		if (chosenImageInfo.body) {
			$('.photosSeeMore').css('display', 'inline');
		} else {
			$('.photosSeeMore').css('display', 'none');
		}
		$('.moreInfosPhotos').html(chosenImageInfo.body);
		
		if (chosenImageInfo.highResUrl) {
			$('.photosDownload')[0].href = chosenImageInfo.highResUrl;
			$('.photosDownload').css('display', 'inline');
		}
		else {
			$('.photosDownload').css('display', 'none');
		}
	}
	
	/*
	var chosenAInfo = $('a', chosenli);
	var chosenImageInfo = $('img', chosenli);
	var largeImage = $('#photoGalleryImg');
	if (chosenAInfo.attr('title').length>0) {var Imgalt = chosenAInfo.attr('title');} else {var Imgalt = chosenImageInfo.attr('alt');}
	if (chosenAInfo.attr('href').length>0 && chosenAInfo.attr('href')!="#") {var Imgsrc = chosenAInfo.attr('href');} else {var Imgsrc = chosenImageInfo.attr('src').replace("_small", "");}
	var Imgdesc = "";
	Imgdesc = chosenImageInfo.attr('longdesc');
	largeImage.attr('alt', Imgalt);
	largeImage.attr('src', Imgsrc);
	largeImage.attr('longdesc', Imgdesc);
	$('.moreInfosPhotos').html(Imgdesc);
	*/
	
	$('.galleryListing li').removeClass('current');
	$(chosenli).addClass('current');
	
	// centering now done using css
	//setTimeout("centerit('photoGalleryImg');",100);

	// Google Anaylitics tracking
	if (typeof(pageTracker) == 'object' && typeof(pageTracker._trackEvent) != 'undefined') {
		pageTracker._trackPageview('Photogallery', 'View', (chosenImageInfo.title ? chosenImageInfo.title : $('a', chosenli).title));
	}
}

function setImageClick(way){
	var currentItem = $('.galleryListing li.current');
	var currentul = $(currentItem).parent();
	var listItemEnd1 = (way == 'left') ? 'li:first' : 'li:last';
	var listItemEnd2 = (way == 'left') ? 'li:last' : 'li:first';
	if($(currentItem).html() == $(currentul).find(listItemEnd1).html()) {
		currentItem = $(currentul).find(listItemEnd2);
	}else{
		currentItem = (way == 'left') ? $(currentItem).prev() : $(currentItem).next();
	}
	
	setImage(currentItem);
}

/*
function setImageClick(way){
	var activeItem = $('.mainPhotoGallery .tabItem li.active');
	var activeul = $(activeItem).parent();
	var activetabItem = $(activeItem).parents('.tabItem');
	var activetabSlider = $(activetabItem).parents('.tabSlider');
	var slideway = '';
	var listItemEnd1 = (way == 'left') ? 'li:first' : 'li:last';
	var listItemEnd2 = (way == 'left') ? 'li:last' : 'li:first';
	var listEnd = (way == 'left') ? 'ul:first' : 'ul:last';

	if ($(activeItem).html() == $(activetabSlider).find(listItemEnd1).html() && $(activeul).html() == $(activetabSlider).find(listEnd).html()) {
		activeItem = $(activetabSlider).find(listItemEnd2);
		slideway = way;
	} else if ($(activeItem).html() == $(activetabItem).find(listItemEnd1).html()) {
		activetabItem = (way == 'left') ? $(activetabItem).prev() : $(activetabItem).next();
		activeItem = $(activetabItem).find(listItemEnd2);
		slideway = way;
	}else{ 
		activeItem = (way == 'left') ? $(activeItem).prev() : $(activeItem).next();
	}

	if(slideway!='') {slideTabContent(slideway);}		
	setImage(activeItem);
}
*/

/*function centerit(imgId) {
	if (document.getElementById(imgId)) {
		heightImg = 0;
		if (document.getElementById(imgId).complete){
			heightImg=document.images[imgId].height;
			document.getElementById(imgId).style.marginTop = Math.floor( (document.getElementById(imgId).parentNode.offsetHeight - heightImg) / 2 ) + 'px';
		}
		else{ setTimeout('centerit(' + imgId + ')', 50); }
	}
}*/

function doPhotoDownload(imageUrl) {
	if ($.cookie(COOKIE_NAMES.PHOTO_TERMS_ACCEPTED) == 'true') {
		$('.vo_tc').hide();
		window.location.href = imageUrl;
	}
	else {
		$('.vo_tc').show();
	}
	return false;
}
	




<!--generated: Tue Nov 03 15:37:10 PST 2009, host: '42', release: v.3.0.14 r.9747 id:79404 -->