/* FILE ARCHIVED ON 18:48:44 Mar 3, 2010 AND RETRIEVED FROM THE AN OPENWAYBACK INSTANCE ON 16:04:51 Oct 4, 2024. JAVASCRIPT APPENDED BY OPENWAYBACK, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). */ function Gallery(title,photos,defaultPhotoId){var self=this;this.photo;this.current_index;this.changingPhotos=false;function getIdFromHash(id){var photomatch=document.location.toString().match(/^.*#(.*)$/);return photomatch?parseInt(photomatch[1]):id;} function getPhotoIndex(id){var index=false;$.each(photos,function(i,photo){if(photo.id==id){index=i;return false;};});return index;} function getShareText(){var siteName=AASSite.twitter_name||AASSite.display_name;var shareName=$('.selected-photo .photo-caption').text();if(!shareName){shareName=$('#gallery-title').text();} return siteName+' Photo Gallery : '+shareName;} this.buyme=function(evnt){function urlifyParams(params){var pairs=[];for(var key in params){if(params.hasOwnProperty(key)){pairs.push(encodeURIComponent(key)+'='+encodeURIComponent(params[key]));}} return pairs.join('&');};var siteName=AASSite.display_name||AASSite.twitter_name;var url='https://webarchive.library.unt.edu/web/20100303184844/http://statesman.mycapture.com/mycapture/remoteimage.asp?'+urlifyParams({backtext:'Back to '+siteName+': '+title+' Gallery',backurl:document.location,pricingsheetid:528,retrievehighres:'yes',thumbpath:self.photo.thumbnail,previewpath:self.photo.fullsize});window.open(url,'_blank');return false;};this.facebook=function(evnt){var shareLink=photos[self.current_index]['sharelink'];var shareText=getShareText();var url='https://webarchive.library.unt.edu/web/20100303184844/http://www.facebook.com/sharer.php?u='+encodeURIComponent(shareLink)+'&t='+encodeURIComponent(shareText);window.open(url,'status','toolbar=0,status=0,width=626,height=436');return false;};this.twitter=function(evnt){var url='https://webarchive.library.unt.edu/web/20100303184844/http://twitter.com/home?status=' var shareLink=photos[self.current_index]['sharelink'];var maxLength=140-shareLink.length-1;if(maxLength>10){var shareText=getShareText();if(shareText.length>maxLength){shareText=shareText.substring(0,maxLength-1)+'\u2026';} url+=encodeURIComponent(shareText+' '+shareLink);}else{url+=encodeURIComponent(shareLink);} window.open(url,'tweet','toolbar=0,status=0,width=800,height=600');return false;};this.photoErrorHandlerFactory=function(){var reloadCount=0;var handler=function(){reloadCount++;var img=this;if(reloadCount>3){$(this).hide();var $errorMsg=$(this).closest('.photo-wrapper').find('.photo-error') $errorMsg.show();$errorMsg.find('a').one('click',function(){reloadCount=0;$errorMsg.hide();$(img).show();handler.apply(img);return false;});return;} var src=$(this).attr('src');if(src.indexOf('?')!=-1){src+='&r';}else{src+='?r';} var id=/photo-(\d+)/.exec($(this).parent().attr('id'))[1];var index=getPhotoIndex(parseInt(id));if(index){photos[index].fullsize=src;} setTimeout(function(){if(index==self.current_index){self.setPhoto(photos[index]);}},2000)};return handler;};this.setPhoto=function(photo){self.photo=photo;var $photoWrapper=$('#photo-'+self.photo.id);var $photoImg=$photoWrapper.find('.photo-img');$('#photo-index').text(self.current_index+1);$('.photo-wrapper').removeClass('selected-photo');$photoWrapper.addClass('selected-photo');$photoImg.attr('alt','loading image...');$photoImg.attr('src',self.photo.fullsize);self.updatePhotoWrapper.apply($photoImg.get(0));var nextPhoto=photos[self._calcIndex(+1)];var prevPhoto=photos[self._calcIndex(-1)];$('#photo-'+nextPhoto.id+' .photo-img').attr('src',nextPhoto.fullsize);$('#photo-'+prevPhoto.id+' .photo-img').attr('src',prevPhoto.fullsize);};this.updatePhotoWrapper=function(){var $photoImg=$(this);var $photoWrapper=$photoImg.closest('.photo-wrapper');if(!$photoWrapper.hasClass('selected-photo')){return;} var $content=$('#content');$('#rail-border').css({marginTop:$content.css('marginTop'),top:$content.position().top,left:$content.position().left+$content.outerWidth(),height:$photoImg.position().top+$photoImg.height()});$photoImg.attr('alt','');var canPurchase=$photoWrapper.hasClass('photo-can-purchase');$('#buy-photo').toggle(canPurchase);$photoImg.click(canPurchase?self.buyme:function(){});};this._photoChange=function(index){if(index==self.current_index){return;} self.changingPhotos=photos[index].id;self.current_index=index;self.setPhoto(photos[index]);var photoURL=document.location.toString().replace(/^([^#]*)(#\d+)?/,'$1#'+self.photo.id);if(document.location!=photoURL){document.location=photoURL;} parent.rail_ad.location.replace(document.getElementById('rail-ad').src);s_coxnews.t();if(self.changingPhotos==photos[index].id){self.changingPhotos=false;}};this._calcIndex=function(delta){var index=self.current_index+delta if(index>photos.length-1){index=0} else if(index<0){index=photos.length-1;} return index;};this.showPreviousPhoto=function(){self._photoChange(self._calcIndex(-1));return false;};this.showNextPhoto=function(){self._photoChange(self._calcIndex(+1));return false;};$(document).ready(function(){var $content=$('#content');$content.css({borderStyle:'none',marginRight:'1px'});$('#rail-border').css({top:$content.position().top,left:$content.position().left+$content.outerWidth()});$('#content').css({borderStyle:'none',marginRight:'1px'});self.current_index=getPhotoIndex(getIdFromHash(defaultPhotoId));if(self.current_index===false){self.current_index=0;} self.setPhoto(photos[self.current_index]);$('#buy-photo-link').click(self.buyme);$('#share-photo #facebook').click(self.facebook);$('#share-photo #twitter').click(self.twitter);$('.photo-img').load(self.updatePhotoWrapper);$('.photo-img').each(function(){$(this).error(self.photoErrorHandlerFactory());});$('.page-prev').click(self.showPreviousPhoto);$('.page-next').click(self.showNextPhoto);$(document).keydown(function(evnt){switch(evnt.which||evnt.keyCode){case 37:return self.showPreviousPhoto();case 39:return self.showNextPhoto();}});$('#see-also-tabs a').click(function(){var $tab=$(this).closest('li');if($tab.hasClass('selected')){return false;} $('#see-also-tabs li').removeClass('selected');$tab.addClass('selected');$('#see-also .galleries-list').removeClass('hide');var kind=/^([^-]+)/.exec($tab.attr('id'))[1];$('#see-also .galleries-list').not('[id^='+kind+']').addClass('hide');return false;});if($('#related-galleries li.no-galleries').length&&!$('#latest-galleries li.no-galleries').length){$('#latest-tab a').click();} setInterval(function(){if(self.changingPhotos){return;} var id=getIdFromHash(defaultPhotoId);if(id!=self.photo.id){self.current_index=getPhotoIndex(id);self.setPhoto(photos[self.current_index]);}},500);});};