
SM.namespace('navigation');(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.util.Lang;PageNav=function(el,attr){attr=attr||{};if(arguments.length===1&&!Lang.isString(el)&&!el.nodeName){attr=el;el=attr.element;}
if(!el&&!attr.element){el=_createPageNavElement.call(this,attr);}
if(Event.isIE){Dom.setStyle(el,'z-index','999');}
PageNav.superclass.constructor.call(this,el,attr);_initEvents.call(this);_createNavigation.call(this);};YAHOO.extend(PageNav,YAHOO.util.Element);var proto=PageNav.prototype;proto._picker=null;proto.PAGENAV_CLASSNAME='pageNav';proto.NAV_CLASSNAME='nav';proto.FIRSTLINK_CLASSNAME=proto.NAV_CLASSNAME+' first';proto.PREVLINK_CLASSNAME=proto.NAV_CLASSNAME+' prev';proto.NEXTLINK_CLASSNAME=proto.NAV_CLASSNAME+' next';proto.LASTLINK_CLASSNAME=proto.NAV_CLASSNAME+' last';proto.CURRENTPAGE_CLASSNAME='pageOn title';proto.TOTALPAGES_CLASSNAME='totalPages title';proto.toString=function(){var el=this.get('element');var id=el.id||el.tagName;return"PageNav "+id;};proto.initAttributes=function(attr){attr=attr||{};PageNav.superclass.initAttributes.call(this,attr);this.setAttributeConfig('currentPage',{value:attr.currentPage||0,method:function(value){if(this.get('currentPage')==value){return;}
if(this._picker){this._picker.set('currentPage',value);}},validator:Lang.isNumber});this.setAttributeConfig('totalPages',{value:attr.totalPages||0,method:function(value){if(this.get('totalPages')==value){return;}
if(this._picker){this._picker.set('totalPages',value);}},validator:Lang.isNumber});this.setAttributeConfig('photosPerPage',{value:attr.photosPerPage||0,method:function(value){if(this.get('photosPerPage')==value){return;}
if(this._picker){this._picker.set('photosPerPage',value);}},validator:Lang.isNumber});this.setAttributeConfig('pagePicker',{value:this._picker,readOnly:true});};var _initEvents=function(){this.addListener('currentPageChange',function(e){if(e.newValue!=e.prevValue){_updateNav.call(this);}},this,true);this.addListener('totalPagesChange',function(e){if(e.newValue!=e.prevValue){_updateNav.call(this);}},this,true);this.addListener('photosPerPageChange',function(e){if(e.newValue!=e.prevValue){_updateNav.call(this);}},this,true);};var _createPageNavElement=function(attr){var pn=document.createElement("div");Dom.addClass(pn,this.PAGENAV_CLASSNAME);if(attr.id){pn.id=attr.id;}
return(pn);};var _createNavigation=function(){var nav=SM.navigation;var navFrag=document.createDocumentFragment();var currentPage=this.get('currentPage');var photosPerPage=this.get('photosPerPage');var totalPages=this.get('totalPages');var first=document.createElement('a');first.className=this.FIRSTLINK_CLASSNAME;first.href=SM.navigation.getAjaxPageLink(1,photosPerPage);first.appendChild(document.createTextNode('<<'));var prev=document.createElement('a');prev.className=this.PREVLINK_CLASSNAME;prev.href=SM.navigation.getAjaxPageLink(currentPage-1,photosPerPage);prev.appendChild(document.createTextNode('< Prev'));if(currentPage==1){Dom.setStyle([first,prev],'visibility','hidden');}
var next=document.createElement('a');next.className=this.NEXTLINK_CLASSNAME;next.href=SM.navigation.getAjaxPageLink(currentPage+1,photosPerPage);next.appendChild(document.createTextNode('Next >'));var last=document.createElement('a');last.className=this.LASTLINK_CLASSNAME;last.href=SM.navigation.getAjaxPageLink(totalPages,photosPerPage);last.appendChild(document.createTextNode('>>'));if(currentPage==totalPages){Dom.setStyle([next,last],'visibility','hidden');}
if(totalPages<3){var page=document.createElement('span');Dom.addClass(page,this.CURRENTPAGE_CLASSNAME);page.appendChild(document.createTextNode(currentPage));}else{var page=document.createElement('a');Dom.addClass(page,this.CURRENTPAGE_CLASSNAME);page.innerHTML=currentPage+'&nbsp;<img src="/img/spacer.gif" />';this._picker=new SM.navigation.PagePicker({'id':YD.generateId(null,'pp'),'currentPage':currentPage,'totalPages':totalPages,'photosPerPage':photosPerPage,'visible':false});this._picker.appendTo(page);var oThis=this;Event.addListener(page,'mouseover',function(e,picker){if(picker.get('visible')){return;}
var target=YE.getTarget(e);var relatedTarget=YE.getRelatedTarget(e);if(!YD.isAncestor(target,relatedTarget)){_setPickerPosition.call(oThis);picker.open();}},this._picker,false);Event.addListener(page,'mouseout',function(e,picker){if(!picker.get('visible')){return;}
var target=YE.getTarget(e);var relatedTarget=YE.getRelatedTarget(e);if(relatedTarget!=this&&!YD.isAncestor(this,relatedTarget)){picker.close();}},this._picker,false);}
navFrag.appendChild(first);navFrag.appendChild(prev);navFrag.appendChild(document.createTextNode('Page'));navFrag.appendChild(page);navFrag.appendChild(document.createTextNode('of '+totalPages));navFrag.appendChild(next);navFrag.appendChild(last);this.appendChild(navFrag);if(this._picker){_setPickerPosition.call(this);}};var _setPickerPosition=function(){var me=this._picker.get('element');var parent=me.parentNode;this._picker.setStyle('top',parent.offsetTop+parent.offsetHeight+'px');this._picker.setStyle('left',parent.offsetLeft-(me.offsetWidth/2)+(parent.offsetWidth/2)+'px');};var _updateNav=function(){var firstLink=this.getElementsByClassName(this.FIRSTLINK_CLASSNAME,'a')[0];var prevLink=this.getElementsByClassName(this.PREVLINK_CLASSNAME,'a')[0];var nextLink=this.getElementsByClassName(this.NEXTLINK_CLASSNAME,'a')[0];var lastLink=this.getElementsByClassName(this.LASTLINK_CLASSNAME,'a')[0];var currentLink=this.getElementsByClassName(this.CURRENTPAGE_CLASSNAME,'')[0];var currentPage=this.get('currentPage');var photosPerPage=this.get('photosPerPage');var totalPages=this.get('totalPages');firstLink.href=SM.navigation.getAjaxPageLink(1,photosPerPage);prevLink.href=SM.navigation.getAjaxPageLink(currentPage-1,photosPerPage);nextLink.href=SM.navigation.getAjaxPageLink(currentPage+1,photosPerPage);lastLink.href=SM.navigation.getAjaxPageLink(totalPages,photosPerPage);currentLink.replaceChild(document.createTextNode(currentPage+'\u00a0'),currentLink.firstChild);this.get('element').replaceChild(document.createTextNode('of '+totalPages),currentLink.nextSibling);if(currentPage<=1){Dom.setStyle([firstLink,prevLink],'visibility','hidden');}else{Dom.setStyle([firstLink,prevLink],'visibility','visible');}
if(currentPage>=totalPages){Dom.setStyle([nextLink,lastLink],'visibility','hidden');}else{Dom.setStyle([nextLink,lastLink],'visibility','visible');}};SM.navigation.PageNav=PageNav;})();(function(){SM.navigation.PagePicker=function(attr){attr=attr||{};var el=_createPagePickerElement.call(this,attr);SM.navigation.PagePicker.superclass.constructor.call(this,el,attr);this.set('visible',attr.visible);_initEvents.call(this);_initContent.call(this);};YAHOO.extend(SM.navigation.PagePicker,YAHOO.util.Element);var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.util.Lang,proto=SM.navigation.PagePicker.prototype;proto._hasScrollBars=false;proto._initialized=false;proto.PICKER_CLASSNAME='pickerBox';proto.BACKGROUND_CLASSNAME='pickerBg';proto.CONTROLS_CLASSNAME='pickerControls';proto.CONTENT_CLASSNAME='pickerContent';proto.CONTENT_MAXHEIGHT=102;proto.CURRENTPAGE_CLASSNAME='pageOn';proto.PAGE_CLASSNAME='page nav';proto.MAXPAGES=60;proto.toString=function(){var el=this.get('element');var id=el.id||el.tagName;return"PagePicker "+id;};proto.initAttributes=function(attr){SM.navigation.PagePicker.superclass.initAttributes.call(this,attr);this._status='closed';this._scrollPageStart=0;this._scrollPageEnd=0;this.setAttributeConfig('totalPages',{value:attr.totalPages,validator:Lang.isNumber});this.setAttributeConfig('currentPage',{value:attr.currentPage,validator:Lang.isNumber});this.setAttributeConfig('photosPerPage',{value:attr.photosPerPage,validator:Lang.isNumber});this.setAttributeConfig('visible',{value:attr.visible,method:function(value){if(value===true){this.setStyle('visibility','visible');}else{this.setStyle('visibility','hidden');}},validator:Lang.isBoolean});};proto.open=function(){var contentEl=_getContentEl.call(this);var animDuration,contentHeight;this._status='opening';if(this._hasScrollBars){contentHeight=this.CONTENT_MAXHEIGHT;animDuration=.1;}else{contentHeight=contentEl.scrollHeight;animDuration=.05;}
this.set('visible',true,false);var anim=new YA(_getBackgroundEl.call(this).childNodes[1],{height:{to:contentHeight}},animDuration,YAHOO.util.Easing.backOut);anim.onComplete.subscribe(function(e){if(this._status=='opening'){_setContentVisibility.call(this,true);if(this._hasScrollBars){_setScrollbarStatus.call(this);}
this._status='open';}},this,true);anim.animate();};proto.close=function(){this._status='closing';var animDuration=(this._hasScrollBars)?.1:.05;var anim=new YA(_getBackgroundEl.call(this).childNodes[1],{height:{to:-1}},animDuration,YAHOO.util.Easing.backIn);anim.onComplete.subscribe(function(e){if(this._status=='closing'){this.set('visible',false,false);this._status='closed';}},this,true);_setContentVisibility.call(this,false);anim.animate();};var _initEvents=function(){this.addListener('click',function(e){var target=Event.getTarget(e);if(Dom.hasClass(target,'pageOn')){Event.stopEvent(e);}});this.addListener('currentPageChange',function(e){if(e.prevValue!=e.newValue){_updateCurrentPage.call(this);}},this,true);this.addListener('totalPagesChange',function(e){if(e.prevValue!=e.newValue){this._scrollPageStart=this.get('currentPage');this._scrollPageEnd=this.get('currentPage');_writePages.call(this);}},this,true);this.addListener('photosPerPageChange',function(e){if(e.prevValue!=e.newValue){_updatePageLinks.call(this);}},this,true);};var _createPagePickerElement=function(){var pickerBox=document.createElement('div');Dom.addClass(pickerBox,this.PICKER_CLASSNAME);Dom.setStyle(pickerBox,'zIndex',999);var pickerBg=document.createElement('div');Dom.addClass(pickerBg,this.BACKGROUND_CLASSNAME);pickerBox.appendChild(pickerBg);var pickerBgFirst=document.createElement('div');Dom.addClass(pickerBgFirst,'first');pickerBg.appendChild(pickerBgFirst);var pickerBgMain=document.createElement('div');pickerBg.appendChild(pickerBgMain);var pickerBgLast=document.createElement('div');Dom.addClass(pickerBgLast,'last');pickerBg.appendChild(pickerBgLast);var pickerContent=document.createElement('div');Dom.addClass(pickerContent,this.CONTENT_CLASSNAME);pickerBox.appendChild(pickerContent);return pickerBox;};var _initContent=function(){if(!this.get('element').parentNode||!this.get('element').parentNode.tagName){this.appendTo(document.body);}
var contentEl=_getContentEl.call(this);this._scrollPageStart=this.get('currentPage');this._scrollPageEnd=(this._scrollPageStart==1)?0:this._scrollPageStart;_writePages.call(this);};var _writePages=function(direction){var fillForward=function(){var aTag;while(contentEl.offsetHeight<=this.CONTENT_MAXHEIGHT&&this._scrollPageEnd<=totalPages){this._scrollPageEnd++;aTag=document.createElement('a');aTag.href=SM.navigation.getAjaxPageLink(this._scrollPageEnd,photosPerPage);if(this._scrollPageEnd==currentPage){aTag.className='page nav pageOn';}else{aTag.className='page nav';}
aTag.appendChild(document.createTextNode(this._scrollPageEnd));contentEl.appendChild(aTag);}
contentEl.removeChild(contentEl.lastChild);this._scrollPageEnd--;this._scrollPageStart=this._scrollPageEnd-contentEl.childNodes.length+1;};var fillBackward=function(){var aTag;while(contentEl.offsetHeight<=this.CONTENT_MAXHEIGHT&&this._scrollPageStart>=1){this._scrollPageStart--;aTag=document.createElement('a');aTag.href=SM.navigation.getAjaxPageLink(this._scrollPageStart,photosPerPage);if(this._scrollPageStart==currentPage){aTag.className='page nav pageOn';}else{aTag.className='page nav';}
aTag.appendChild(document.createTextNode(this._scrollPageStart));contentEl.insertBefore(aTag,contentEl.firstChild);}
contentEl.removeChild(contentEl.firstChild);this._scrollPageStart++;this._scrollPageEnd=this._scrollPageStart+contentEl.childNodes.length-1;};var contentEl=_getContentEl.call(this);var totalPages=this.get('totalPages');var photosPerPage=this.get('photosPerPage');var currentPage=this.get('currentPage');while(contentEl.hasChildNodes()){contentEl.removeChild(contentEl.childNodes[0]);}
if(direction=='backward'){fillBackward.call(this);fillForward.call(this);}else{fillForward.call(this);fillBackward.call(this);}
if(totalPages>this.MAXPAGES){_createPagePickerScrollbar.call(this);this._hasScrollBars=true;}else{_removePagePickerScrollbar.call(this);this._hasScrollBars=false;}};var _createPagePickerScrollbar=function(){var pickerBgMain=_getBackgroundEl.call(this).childNodes[1];Dom.addClass(pickerBgMain,'controls');var spacer=document.createElement('img');spacer.src='/img/spacer.gif';var pickerControls=document.createElement('div');pickerControls.className=this.CONTROLS_CLASSNAME;pickerControls.style.visibility='hidden';var upControls=document.createElement('div');var pageFirst=document.createElement('a');pageFirst.className='control first';Event.addListener(pageFirst,'click',function(){_scroll.call(this,'first');},this,true);pageFirst.appendChild(spacer.cloneNode(false));var pagePrev=document.createElement('a');pagePrev.className='control prev';Event.addListener(pagePrev,'click',function(){_scroll.call(this,'prev');},this,true);pagePrev.appendChild(spacer.cloneNode(false));upControls.appendChild(pageFirst);upControls.appendChild(pagePrev);var downControls=document.createElement('div');var pageNext=document.createElement('a');pageNext.className='control next';Event.addListener(pageNext,'click',function(){_scroll.call(this,'next');},this,true);pageNext.appendChild(spacer.cloneNode(false));var pageLast=document.createElement('a');pageLast.className='control last';Event.addListener(pageLast,'click',function(){_scroll.call(this,'last');},this,true);pageLast.appendChild(spacer.cloneNode(false));downControls.appendChild(pageNext);downControls.appendChild(pageLast);pickerControls.appendChild(upControls);pickerControls.appendChild(downControls);this.appendChild(pickerControls);};var _removePagePickerScrollbar=function(){var pickerBgMain=_getBackgroundEl.call(this).childNodes[1];Dom.removeClass(pickerBgMain,'controls');var controlsEl=_getControlsEl.call(this);if(controlsEl){controlsEl.parentNode.removeChild(controlsEl);}};var _getBackgroundEl=function(){return this.getElementsByClassName(this.BACKGROUND_CLASSNAME)[0];};var _getContentEl=function(){return this.getElementsByClassName(this.CONTENT_CLASSNAME)[0];};var _getControlsEl=function(){return this.getElementsByClassName(this.CONTROLS_CLASSNAME)[0];};var _contentVisible=function(){var strVisible=_getContentEl.call(this).style.visibility;if(strVisible=='visible'){return true;}else{return false;}};var _setContentVisibility=function(visible){var strVisible=(visible)?'visible':'hidden';Dom.setStyle(_getContentEl.call(this),'visibility',strVisible);if(this._hasScrollBars){Dom.setStyle(_getControlsEl.call(this),'visibility',strVisible);}};var _getVisible=function(){return this.getStyle('visibility')=='visible'?true:false;};var _updateCurrentPage=function(){var contentEl=_getContentEl.call(this);Dom.removeClass(Dom.getElementsByClassName(this.CURRENTPAGE_CLASSNAME,'a',contentEl),this.CURRENTPAGE_CLASSNAME);var pageOn=(this.get('currentPage')==1)?0:this.get('currentPage')-this._scrollPageStart;var pages=Dom.getElementsByClassName(this.PAGE_CLASSNAME,'a',contentEl);Dom.addClass(pages[pageOn],this.CURRENTPAGE_CLASSNAME);};var _updatePageLinks=function(){var contentEl=_getContentEl.call(this);var pages=Dom.getElementsByClassName(this.PAGE_CLASSNAME,'a',contentEl);var page=this._scrollPageStart;for(i=0;i<pages.length;i++){pages[i].href=SM.navigation.getAjaxPageLink(page,this.get('photosPerPage'));page++;}};var _scroll=function(scrollTo){var contentEl=_getContentEl.call(this);var direction='forward';switch(scrollTo){case'prev':this._scrollPageEnd=this._scrollPageStart-1;direction='backward';break;case'next':this._scrollPageStart=this._scrollPageEnd+1;direction='forward';break;case'first':this._scrollPageStart=1;this._scrollPageEnd=0;direction='forward';break;case'last':this._scrollPageStart=this.get('currentPage');this._scrollPageEnd=this.get('totalPages');direction='forward';break;}
_writePages.call(this,direction);if(_contentVisible.call(this)){_setScrollbarStatus.call(this);}};var _setScrollbarStatus=function(){var contentEl=_getContentEl.call(this);var controls=_getControlsEl.call(this);var upControls=controls.childNodes[0];var downControls=controls.childNodes[1];if(this._scrollPageStart==1){Dom.addClass(upControls,'disabled');Dom.removeClass(downControls,'disabled');}else if(this._scrollPageEnd==this.get('totalPages')){Dom.addClass(downControls,'disabled');Dom.removeClass(upControls,'disabled');}else{Dom.removeClass(upControls,'disabled');Dom.removeClass(downControls,'disabled');}};})();SM.navigation.getAjaxPageLink=function(page,photosPerPage){return('#P-'+page+'-'+photosPerPage);};
SM.namespace('photo','photo.data');SM.photo.ORIENTATION_SQUARE=0;SM.photo.ORIENTATION_PORTRAIT=1;SM.photo.ORIENTATION_LANDSCAPE=2;SM.photo.getOrientation=function(el){var w=parseInt(YAHOO.util.Dom.getStyle(el,'width'),10);var h=parseInt(YAHOO.util.Dom.getStyle(el,'height'),10);if(w<h){return SM.photo.ORIENTATION_PORTRAIT;}else if(w>h){return SM.photo.ORIENTATION_LANDSCAPE;}else{return SM.photo.ORIENTATION_SQUARE;}};SM.photo.getAspect=function(el){var w=parseInt(YAHOO.util.Dom.getStyle(el,'width'),10);var h=parseInt(YAHOO.util.Dom.getStyle(el,'height'),10);return SM.util.reduceFraction(w,h);};(function(){var ExifBox=function(attr){attr=attr||{};var el=_createExifBoxElement.call(this,attr);superC.constructor.call(this,el,attr);Dom.setXY(el,_calculatePosition.call(this));};YAHOO.extend(ExifBox,YAHOO.util.Element);var proto=ExifBox.prototype,superC=ExifBox.superclass,Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.util.Lang;proto.CLASSNAME='exifBox';proto.BACKGROUND_CLASSNAME='background';proto.CONTENT_CLASSNAME='content';proto.EXIFLINK_CLASSNAME='exifLink';proto.toString=function(){var el=this.get('element');var id=el.id||el.tagName;return"ExifBox "+id;};proto.initAttributes=function(attr){superC.initAttributes.call(this,attr);if(!attr.appendTo){attr.appendTo=document.body;}
if(!attr.visible){attr.visible=false;}
if(!attr.autoPosition){attr.autoPosition=false;}
if(!attr.positionAnchor){attr.positionAnchor=document.body;}
if(!attr.draggable){attr.draggable=false;}
this._exifInfo=new SM.util.SimpleAjaxCache('/rpc/image.mg');this._exifInfo.subscribe('load',_updateExifContent,this,true);this._backgroundElement=this.getElementsByClassName(this.BACKGROUND_CLASSNAME)[0];this._contentParent=this.getElementsByClassName(this.CONTENT_CLASSNAME)[0];_setContentVisibility.call(this,false);this._ddObj=null;this.register('appendTo',{value:attr.appendTo,method:function(el){this.appendTo(Dom.get(el));},writeOnce:true,validator:function(el){return Dom.inDocument(el);}});this.register('imageId_Key',{value:attr.imageId_Key,validator:function(value){return value!==this.get('imageId_Key');}});this.register('autoPosition',{value:attr.autoPosition,method:function(value){if(value===true){Event.addListener(window,'resize',_setPosition,this,true);}else{Event.removeListener(window,'resize',_setPosition);}},validator:Lang.isBoolean});this.register('positionAnchor',{value:attr.positionAnchor,validator:function(el){return Dom.inDocument(el);}});this.register('draggable',{value:attr.draggable,method:function(value){_setDraggable.call(this,value);},validator:Lang.isBoolean});this.register('dragDropObject',{value:this._ddObj,readOnly:true});this.register('tabViewObject',{value:_createTabViewObject.call(this),readOnly:true});this.register('visible',{value:attr.visible,method:function(value){this.setStyle('visibility',value?'visible':'hidden');},validator:Lang.isBoolean});this.initEvents();};proto.initEvents=function(){this.addListener('imageId_KeyChange',function(e){if(e.newValue!==e.prevValue){if(this.get('visible')){_updateExifLink.call(this);_getExifInfo.call(this);}}},this,true);var tvObj=this.get('tabViewObject');tvObj.addListener('beforeActiveTabChange',function(e){if(e.prevValue===e.newValue){return false;}
Dom.setStyle(tvObj._contentParent,'visibility','hidden');},this,true);tvObj.addListener('activeTabChange',_handleActiveTabChange,this,true);tvObj.beforeActiveContentChange=new YAHOO.util.CustomEvent('beforeActiveContentChange',this.get('tabViewObject'),false,YAHOO.util.CustomEvent.FLAT);tvObj.beforeActiveContentChange.subscribe(function(e){Dom.setStyle(tvObj._contentParent,'visibility','hidden');},this,true);tvObj.activeContentChange=new YAHOO.util.CustomEvent('activeContentChange',this.get('tabViewObject'),false,YAHOO.util.CustomEvent.FLAT);tvObj.activeContentChange.subscribe(_handleActiveContentChange,this,true);this.addListener('click',function(e){var target=Event.getTarget(e);var thisEl=this.get('element');while(target!==thisEl&&target.tagName!=='A'){target=target.parentNode;}
if(target===thisEl){return;}
if(Dom.hasClass(target,'closeButton')){Event.stopEvent(e);this.close();}},this,true);};proto.open=function(){_updateExifLink.call(this);_getExifInfo.call(this);};proto.close=function(){var bgContentEl=this._backgroundElement.childNodes[1];var tvObj=this.get('tabViewObject');_setContentVisibility.call(this,false);var anim=new YAHOO.util.Anim(bgContentEl,{height:{to:-1}},.25,YAHOO.util.Easing.backIn);anim.onComplete.subscribe(function(){this.set('visible',false);},this,true);anim.animate();};var _handleActiveContentChange=function(e){_resizeToContent.call(this,this._contentParent.offsetHeight);};var _handleActiveTabChange=function(e){_resizeToContent.call(this,this._contentParent.offsetHeight);e.newValue.set('title','');SM.util.setCookie('exifTab',e.newValue.get('label').toLowerCase(),365);};var _resizeToContent=function(newHeight){var bgContentEl=this._backgroundElement.childNodes[1];var tabViewObj=this.get('tabViewObject');newHeight-=parseInt(Dom.getStyle(this._contentParent,'padding-top'),10);newHeight-=parseInt(Dom.getStyle(this._contentParent,'padding-bottom'),10);var bgContentHeight=bgContentEl.offsetHeight;if(!this.get('visible')){this.set('visible',true);}
if(bgContentHeight!==newHeight){Dom.setStyle(tabViewObj._contentParent,'visibility','hidden');var anim=new YAHOO.util.Anim(bgContentEl,{height:{to:newHeight}},.25,(bgContentHeight>newHeight)?YAHOO.util.Easing.backIn:YAHOO.util.Easing.backOut);anim.onComplete.subscribe(function(){_setContentVisibility.call(this,true);Dom.setStyle(this.get('tabViewObject')._contentParent,'visibility','');},this,true);anim.animate();}else{Dom.setStyle(tabViewObj._contentParent,'visibility','');}
_setPosition.call(this);};var _setContentVisibility=function(visible){var strVisible=(visible)?'visible':'hidden';Dom.setStyle(this._contentParent,'visibility',strVisible);this._contentVisible=visible;};var _setDraggable=function(draggable){if(!this._ddObj&&draggable){var myObj=this;this._ddObj=new YAHOO.util.DD(this.get('element'));this._ddObj.endDrag2=new YAHOO.util.CustomEvent('endDrag2',this._ddObj);this._ddObj.endDrag=function(e){var exifXY=YD.getXY(myObj.get('element'));var anchorXY=YD.getXY(myObj.get('positionAnchor'));SM.util.setCookie(galleryStyle+'ExifPos',[exifXY[0]-anchorXY[0],exifXY[1]-anchorXY[1]],365);};this.setStyle('cursor','move');}else if(this._ddObj&&!draggable){this._ddObj.unreg();this._ddObj=null;this.setStyle('cursor','auto');}};var _updateExifLink=function(){var exifLink=this.getElementsByClassName(this.EXIFLINK_CLASSNAME)[0];var imageId=this.get('imageId_Key').split('_')[0];var imageKey=this.get('imageId_Key').split('_')[1];if(exifLink&&exifLink.tagName.toLowerCase()==='a'){exifLink.href='/photos/newexif.mg?ImageID='+imageId+'&ImageKey='+imageKey;}};var _getExifInfo=function(){var imageId=this.get('imageId_Key').split('_')[0];var imageKey=this.get('imageId_Key').split('_')[1];this._exifInfo.load({'method':'getExif','imageId':imageId,'imageKey':imageKey});};var buildTabContent=function(category,property){var i,str='';for(i in property){str+='<tr id="'+property[i].name+'"><th>'+property[i].friendlyName+'</th><td>'+property[i].friendlyValue+'</td></tr>';}
if(str===''){str='<h4 class="noExif">No '+category.toLowerCase()+' information available</h4>';}else{str='<table class="photoInfo">'+str+'</table>';}
return str;};var _updateExifContent=function(responseText){var tvObj=this.get('tabViewObject'),tabs=tvObj.get('tabs'),activeTab=SM.util.getCookie('exifTab')||'basic',cats,tab,label,oldContent,newContent,i;try{cats=this._exifInfo.data;}catch(e){cats={};}
for(i=0;i<tabs.length;i++){tab=tvObj.getTab(i);label=tab.get('label').toLowerCase();oldContent=tab.get('content');if(typeof cats==='object'){newContent=buildTabContent(label,cats[label]);}else{newContent=buildTabContent(label,{});}
if(tab.get('active')){tvObj.beforeActiveContentChange.fire({'prevValue':oldContent,'newValue':newContent});}
tab.set('content',newContent);if(tab.get('active')){tvObj.activeContentChange.fire({'prevValue':oldContent,'newValue':newContent});}
if(activeTab===label&&!tab.get('active')){tvObj.set('activeIndex',i);}}
if(tvObj.get('activeIndex')===undefined){tvObj.set('activeIndex',0);}};var _createExifBoxElement=function(attr){var exifBox=document.createElement('div');Dom.addClass(exifBox,this.CLASSNAME);if(attr.id){exifBox.id=attr.id;}
var exifBg=document.createElement('div');Dom.addClass(exifBg,this.BACKGROUND_CLASSNAME);exifBox.appendChild(exifBg);var exifBgFirst=document.createElement('div');Dom.addClass(exifBgFirst,'first');exifBg.appendChild(exifBgFirst);var exifBgMain=document.createElement('div');exifBg.appendChild(exifBgMain);var exifBgLast=document.createElement('div');Dom.addClass(exifBgLast,'last');exifBg.appendChild(exifBgLast);var exifContent=document.createElement('div');Dom.addClass(exifContent,this.CONTENT_CLASSNAME);exifBox.appendChild(exifContent);var exifClose=document.createElement('a');Dom.addClass(exifClose,'closeButton');exifClose.href='#';var spacer=document.createElement('img');spacer.src='/img/spacer.gif';exifClose.appendChild(spacer);exifContent.appendChild(exifClose);var exifTitle=document.createElement('h3');exifContent.appendChild(exifTitle);var exifLink=document.createElement('a');Dom.addClass(exifLink,'title exifLink');exifLink.href='#';exifLink.target='_blank';exifLink.appendChild(document.createTextNode('Photo Information'));exifTitle.appendChild(exifLink);exifTitle.appendChild(document.createTextNode('(arrow keys change photo)'));return exifBox;};var _createTabViewObject=function(){var tvObj=new YAHOO.widget.TabView();tvObj.appendTo(this._contentParent);tvObj.addTab(new YAHOO.widget.Tab({'label':'Basic'}));tvObj.addTab(new YAHOO.widget.Tab({'label':'Detailed'}));return tvObj;};var _calculatePosition=function(){var documentDimensions=[Dom.getDocumentWidth(),Dom.getDocumentHeight()];var viewPortDimensions=[Dom.getViewportWidth(),Dom.getViewportHeight()];var docScrollY=document.documentElement.scrollTop||window.pageYOffset;var docScrollX=document.documentElement.scrollLeft||window.pageXOffset;var outerLimits=[(viewPortDimensions[0]>documentDimensions[0])?viewPortDimensions[0]:documentDimensions[0],(viewPortDimensions[1]>documentDimensions[1])?viewPortDimensions[1]:documentDimensions[1]];var viewRegion=new YAHOO.util.Region(docScrollY,docScrollX+viewPortDimensions[0],docScrollY+viewPortDimensions[1],docScrollX);var anchorEl=Dom.get(this.get('positionAnchor'));var anchorXY=Dom.getXY(anchorEl);var anchorRegion=YAHOO.util.Region.getRegion(anchorEl);var exifXY=null;exifXY=SM.util.getCookie(galleryStyle+'ExifPos');exifXY=(!exifXY||exifXY.indexOf(',')===-1)?[0,0]:exifXY.split(',');exifXY=[parseInt(exifXY[0],10),parseInt(exifXY[1],10)];exifXY=[anchorXY[0]+exifXY[0],anchorXY[1]+exifXY[1]];var exifEl=this.get('element');var exifRegion=new YAHOO.util.Region(exifXY[1],exifXY[0]+exifEl.offsetWidth,exifXY[1]+exifEl.offsetHeight,exifXY[0])
if(viewRegion.contains(anchorRegion)){exifXY=[(exifRegion.right<viewRegion.left)?viewRegion.left:exifRegion.left,(exifRegion.bottom<viewRegion.top)?viewRegion.top:exifRegion.top];exifXY=[(exifRegion.left>viewRegion.right)?viewRegion.right-(exifRegion.right-exifRegion.left):exifRegion.left,(exifRegion.top>viewRegion.bottom)?viewRegion.bottom-(exifRegion.bottom-exifRegion.top):exifXY[1]];}
return exifXY;};var _setPosition=function(){var currentXY=Dom.getXY(this.get('element'));var newXY=_calculatePosition.call(this);if(currentXY[0]===newXY[0]&&currentXY[1]===newXY[1]){return;}
var anim=new YAHOO.util.Motion(this.get('element'),{points:{to:_calculatePosition.call(this)}},.25);anim.animate();};SM.photo.ExifBox=ExifBox;})();
SM.namespace('cart.data','cart.UI','cart.context');(function(){var ProductCatalog=function(imageId){this.loaded=false;this.data={};_initEvents.call(this);};YAHOO.augment(ProductCatalog,YAHOO.util.EventProvider);var proto=ProductCatalog.prototype,Connect=YAHOO.util.Connect,Event=YAHOO.util.Event,Lang=YAHOO.lang,catalogUrl='/rpc/cart.mg?method=getCatalog&imageId=';proto.load=function(imageId){var sUrl=catalogUrl+imageId;var tx=Connect.asyncRequest('GET',sUrl,{success:function(o){var raw=eval('('+o.responseText+')');if(raw.status==='success'){var result=raw.result;_loadCatalog.call(this,raw.result);this.loaded=true;this.fireEvent('load',{'status':raw.status,'msg':raw.msg,'args':raw.args});}else{this.fireEvent('failure',{'status':raw.status,'msg':raw.msg,'args':raw.args});}},failure:function(o){YAHOO.log('call to '+sUrl+'failed: '+o.responseText);this.fireEvent('failure',o.responseText);},scope:this,timeout:0});};proto.getVendor=function(vendorId){if(!this.data.vendors){return null;}
if(!this.data.vendors[vendorId]){return null;}
return this.data.vendors[vendorId];};proto.getProduct=function(vendorId,productId){var vendor=this.getVendor(vendorId);if(!vendor||!vendor.products){return null;}
if(!productId){return vendor.products;}
if(!vendor.products[productId]){return null;}
return vendor.products[productId];};var _initEvents=function(){this.createEvent('load');this.createEvent('failure');};var _loadCatalog=function(catalog){this.productsAvailable=false;this.data.vendors={};for(var v in catalog.vendors){if(Lang.hasOwnProperty(catalog.vendors,v)){this.productsAvailable=true;this.data.vendors[v]=catalog.vendors[v];}}};SM.cart.data.ProductCatalog=ProductCatalog;})();(function(){var UserCart=function(data){this.loaded=false;this.returnMarkup=false;this.data={};this.cartId='';_initEvents.call(this);if(data){this.load(data);this.fireEvent('load');}};YAHOO.augment(UserCart,YAHOO.util.EventProvider);var proto=UserCart.prototype,Connect=YAHOO.util.Connect,Event=YAHOO.util.Event,Lang=YAHOO.lang;var _initEvents=function(){this.createEvent('load');this.createEvent('failure');this.createEvent('addItem');this.createEvent('removeItem');this.createEvent('changeCrop');this.createEvent('changeProduct');this.createEvent('changeColor');this.createEvent('changeQuantity');};var _loadCart=function(cart){for(var p in cart){if(Lang.hasOwnProperty(cart,p)){this.data[p]=cart[p];}}
this.loaded=true;};var _updateCart=function(args,callback){var sUrl='';args=Lang.merge({markup:this.returnMarkup,cartId:this.cartId},args);for(var a in args){if(Lang.hasOwnProperty(args,a)){if(sUrl!=''){sUrl+='&'}
sUrl+=(a+'='+args[a]);}}
var tx=Connect.asyncRequest('POST',this.cartUrl,{success:callback,failure:function(o){YAHOO.log('call to '+sUrl+'failed: '+o.responseText);},scope:this,timeout:0},sUrl);};proto.cartUrl='/rpc/cart.mg';proto.load=function(data){_loadCart.call(this,data);};proto.loadFromUrl=function(cartId){var args={method:'getUserCart'};var callback=function(o){var raw=eval('('+o.responseText+')');if(raw.status==='success'){_loadCart.call(this,raw.result);this.fireEvent('load',{'status':raw.status,'msg':raw.msg,'args':raw.args,'type':'load'});}};_updateCart.call(this,args,callback);};proto.getItemsByPhoto=function(photoId){if(!this.data.photos){return[];}
if(!this.data.photos[photoId]){return[];}
return this.getItems(this.data.photos[photoId].items);};proto.getItemsByVendor=function(vendorId){if(!this.data.vendors){return[];}
if(!this.data.vendors[vendorId]){return[];}
return this.getItems(this.data.vendors[vendorId].items);};proto.getItemsByProduct=function(productId){if(!this.data.products){return[];}
if(!this.data.products[productId]){return[];}
return this.getItems(this.data.products[productId].items);};proto.getItems=function(){var a,item,items=[];if(arguments.length>0){a=arguments[0];}
if(YAHOO.lang.isArray(a)){for(var i=0,len=a.length;i<len;i++){item=this.getItem(a[i]);if(item){items.push(item);}}}else if(a){item=this.getItem(a);if(item){items.push(item);}}else{for(var item in this.data.items){if(Lang.hasOwnProperty(this.data.items,item)){items.push(this.getItem(item));}}}
return items;};proto.getItem=function(cartItemId){return this.data.items[cartItemId];};proto.getPhoto=function(photoId){return this.data.photos[photoId];};proto.changeCrop=function(cartItemId,cropInfo){var item=this.getItem(cartItemId);if(!item||!item.crop){return;}
var defaultCrop={cropType:'Auto',cropW:0,cropH:0,cropX:0,cropY:0};cropInfo=Lang.merge(defaultCrop,cropInfo);var args={method:'changeCrop',cartItemId:cartItemId,cropType:cropInfo.cropType,cropW:cropInfo.cropW,cropH:cropInfo.cropH,cropX:cropInfo.cropX,cropY:cropInfo.cropY};var callback=function(o){var raw=eval('('+o.responseText+')');if(raw.status==='success'){var result={cartItemId:raw.args.cartItemId,prevValue:item.crop,newValue:raw.result.cropInfo,markup:raw.result.markup};this.data.items[cartItemId].crop=result.newValue;this.fireEvent('changeCrop',{status:raw.status,msg:raw.msg,args:raw.args,result:result,type:'changeCrop'});}else{this.fireEvent('failure',{status:raw.status,msg:raw.msg,args:raw.args,result:raw.result,type:'changeCrop'});}};_updateCart.call(this,args,callback);};proto.changeColor=function(cartItemId,color){var item=this.getItem(cartItemId);if(!item||!item.color){return;}
var args={method:'changeColor',cartItemId:cartItemId,color:color};var callback=function(o){var raw=eval('('+o.responseText+')');if(raw.status==='success'){var result={cartItemId:raw.args.cartItemId,prevValue:item.color,newValue:raw.result.color};this.data.items[cartItemId].crop=result.newValue;this.fireEvent('changeColor',{status:raw.status,msg:raw.msg,args:raw.args,result:result,type:'changeColor'});}else{this.fireEvent('failure',{status:raw.status,msg:raw.msg,args:raw.args,result:raw.result,type:'changeColor'});}};_updateCart.call(this,args,callback);};proto.addItem=function(imageId,vendorId,productId,quantity){var args={method:'addItem',imageId:imageId,vendorId:vendorId,productId:productId,quantity:quantity};var callback=function(o){var raw=eval('('+o.responseText+')');if(raw.status==='success'){var result={cartItemId:raw.result.item.id,item:raw.result.item,markup:raw.result.markup||''};var cartItemId=result.cartItemId,item=result.item;this.data.items[cartItemId]=item;if(!this.data.photos[item.photoId]){this.data.photos[item.photoId]={id:item.photoId,items:[]};}
this.data.photos[item.photoId].items.push(cartItemId);if(!this.data.vendors[item.vendorId]){this.data.vendors[item.vendorId]={id:item.vendorId,items:[]};}
this.data.vendors[item.vendorId].items.push(cartItemId);if(!this.data.products[item.productId]){this.data.products[item.productId]={id:item.productId,items:[]};}
this.data.products[item.productId].items.push(cartItemId);this.fireEvent('addItem',{status:raw.status,msg:raw.msg,args:raw.args,result:result,type:'addItem'});}else{this.fireEvent('failure',{status:raw.status,msg:raw.msg,args:raw.args,result:raw.result,type:'addItem'});}};_updateCart.call(this,args,callback);};proto.changeQuantity=function(cartItemId,quantity){var item=this.getItem(cartItemId);if(!item){return;}
var args={method:'changeQuantity',cartItemId:cartItemId,quantity:quantity};var callback=function(o){var raw=eval('('+o.responseText+')');if(raw.status==='success'){var result={cartItemId:raw.result.item.id,newValue:raw.result.item.quantity,prevValue:item.quantity};this.data.items[cartItemId].quantity=result.newValue;this.fireEvent('changeQuantity',{status:raw.status,msg:raw.msg,args:raw.args,result:result,type:'changeQuantity'});}else{this.fireEvent('failure',{status:raw.status,msg:raw.msg,args:raw.args,result:raw.result,type:'changeQuantity'});}};_updateCart.call(this,args,callback);};proto.removeItem=function(cartItemId){var item=this.getItem(cartItemId);if(!item){return;}
var args={method:'removeItem',cartItemId:cartItemId};var callback=function(o){var raw=eval('('+o.responseText+')');if(raw.status==='success'){var result={cartItemId:item.id};for(var i=0,len=this.data.products[item.productId].items.length;i<len;i++){if(this.data.products[item.productId].items[i]===item.id){this.data.products[item.productId].items.splice(i,1);}}
if(!this.getItemsByProduct(item.productId).length){delete this.data.products[item.productId];}
for(var i=0,len=this.data.vendors[item.vendorId].items.length;i<len;i++){if(this.data.vendors[item.vendorId].items[i]===item.id){this.data.vendors[item.vendorId].items.splice(i,1);}}
if(!this.getItemsByVendor(item.vendorId).length){delete this.data.vendors[item.vendorId];}
for(var i=0,len=this.data.photos[item.photoId].items.length;i<len;i++){if(this.data.photos[item.photoId].items[i]===item.id){this.data.photos[item.photoId].items.splice(i,1);}}
if(!this.getItemsByPhoto(item.photoId).length){delete this.data.photos[item.photoId];}
delete this.data.items[item.id];this.fireEvent('removeItem',{status:raw.status,msg:raw.msg,args:raw.args,result:result,type:'removeItem'});}else{this.fireEvent('failure',{status:raw.status,msg:raw.msg,args:raw.args,result:raw.result,type:'removeItem'});}};_updateCart.call(this,args,callback);};proto.changeProduct=function(cartItemId,vendorId,productId){var item=this.getItem(cartItemId);if(!item){return;}
var args={method:'changeProduct',cartItemId:cartItemId,vendorId:vendorId,productId:productId};var callback=function(o){var raw=eval('('+o.responseText+')');if(raw.status==='success'){var result={cartItemId:raw.args.cartItemId,prevValue:item,newValue:raw.result.item,markup:raw.result.markup};var prevValue=result.prevValue,newValue=result.newValue;for(var i=0,len=this.data.products[prevValue.productId].items.length;i<len;i++){if(this.data.products[prevValue.productId].items[i]===result.cartItemId){this.data.products[prevValue.productId].items.splice(i,1);}}
if(!this.getItemsByProduct(prevValue.productId).length){delete this.data.products[prevValue.productId];}
if(prevValue.vendorId!==newValue.vendorId){for(var i=0,len=this.data.vendors[prevValue.vendorId].items.length;i<len;i++){if(this.data.vendors[prevValue.vendorId].items[i]===result.cartItemId){this.data.vendors[prevValue.vendorId].items.splice(i,1);}}
if(!this.getItemsByVendor(prevValue.vendorId).length){delete this.data.vendors[prevValue.vendorId];}}
this.data.items[result.cartItemId]=result.newValue;if(!this.data.vendors[newValue.vendorId]){this.data.vendors[newValue.vendorId]={id:newValue.vendorId,items:[]};}
this.data.vendors[newValue.vendorId].items.push(result.cartItemId);if(!this.data.products[newValue.productId]){this.data.products[newValue.productId]={id:newValue.productId,items:[]};}
this.data.products[newValue.productId].items.push(result.cartItemId);this.fireEvent('changeProduct',{status:raw.status,msg:raw.msg,args:raw.args,result:result,type:'changeProduct'});}else{this.fireEvent('failure',{status:raw.status,msg:raw.msg,args:raw.args,result:raw.result,type:'changeProduct'});}};_updateCart.call(this,args,callback);};SM.cart.data.UserCart=UserCart;})();(function(){var AddCartSingle=function(){var uiFilters={};var cartFilters=SM.util.getCookie('cartfilters');if(cartFilters){cartFilters=cartFilters.split('|');if(cartFilters.length>0){for(var i=0,len=cartFilters.length;i<len;i+=1){uiFilters[cartFilters[i]]=true;}}}
this.currentContext={'cartId':null,'ch':null,'imageId':null,'imageKey':null,'vendorId':'EZprints','productId':null,'cartItemId':null,'pendingUpdates':[]};this.uiContext={'vendorPanel':null,'loadPanel':null,'container':null,'catalogPanel':null,'infoPanel':null,'cartItemsPanel':null,'updating':false,'catalogOptions':{'uiFilters':uiFilters}};this.dataContext={'catalog':new SM.cart.data.ProductCatalog(),'cart':SM.cart.userCart||new SM.cart.data.UserCart(),'photoInfo':new SM.util.SimpleAjaxCache('/rpc/image.mg'),'productInfo':new SM.util.SimpleAjaxCache('/rpc/cart.mg')};this.createEvent('show');this.createEvent('hide');this.dataContext.photoInfo.subscribe('load',_loadInfoPanel,this,true);this.dataContext.photoInfo.subscribe('failure',_failInfoPanel,this,true);this.dataContext.productInfo.subscribe('load',_showProductInfo,this,true);this.dataContext.cart.subscribe('load',_loadCatalog,this,true);this.dataContext.cart.subscribe('load',_loadCartItemsPanel,this,true);this.dataContext.cart.subscribe('addItem',_updateProductItem,this,true);this.dataContext.cart.subscribe('removeItem',_updateProductItem,this,true);this.dataContext.cart.subscribe('changeQuantity',_updateProductItem,this,true);this.dataContext.catalog.subscribe('load',_loadCatalog,this,true);this.dataContext.catalog.subscribe('load',_loadCartItemsPanel,this,true);this.dataContext.catalog.subscribe('failure',_failCatalog,this,true);_initUI.call(this);};YAHOO.augment(AddCartSingle,YAHOO.util.EventProvider);var proto=AddCartSingle.prototype,Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Connect=YAHOO.util.Connect,Lang=YAHOO.lang,Anim=YAHOO.util.Anim;proto.CHROME_MARKUP='<div class="top border"></div><div class="bottom border"></div><div class="left border"></div><div class="right border"></div><div class="top_left corner"></div><div class="top_right corner"></div><div class="bottom_right corner"></div><div class="bottom_left corner"></div><div class="bg"></div>';proto.LOADING_MARKUP='<h5>loading</h5><img src="/img/spacer.gif" />';proto.NOPRODUCTS_MARKUP='<h2 class="noProducts">Sorry, this photo has no products available for purchase.</h2>';proto.QUANTITY_MAX=999;proto.toString=function(){return"GalleryCart: "+this.uiContext.container.toString();};proto.show=function(imageId,cartId,ch,imageKey){var cCtx=this.currentContext,dCtx=this.dataContext,uiCtx=this.uiContext;if(imageId!=cCtx.imageId){cCtx.imageId=imageId;cCtx.imageKey=imageKey;cCtx.cartId=cartId||'';cCtx.ch=ch||'';_showLoadingPanel.call(this);uiCtx.catalogPanel.innerHTML='';uiCtx.cartItemsPanel.childNodes[0].innerHTML='';dCtx.catalog.loaded=false;dCtx.cart.cartId=cartId;_loadCartData.call(this);}
var zI=parseInt(Dom.getStyle('lightBoxStage','zIndex'),10);zI=zI<60000?60000:zI;uiCtx.container.cfg.setProperty('zIndex',zI+=2);this.fireEvent('show');uiCtx.container.show();};proto.hide=function(){this.fireEvent('hide');this.uiContext.container.hide();};var _initUI=function(){var uiCtx=this.uiContext;var cCtx=this.currentContext;uiCtx.container=new YAHOO.widget.Panel('cartUI',{'constraintoviewport':true,'underlay':'none','close':false,'visible':false,'draggable':false,'modal':true});uiCtx.nowShowing='photoInfo';uiCtx.selectedItem=null;uiCtx.chrome=document.createElement('div');uiCtx.chrome.className='chrome';uiCtx.chrome.innerHTML=this.CHROME_MARKUP;uiCtx.loadPanel=document.createElement('div');uiCtx.loadPanel.id='loadingPanel';uiCtx.loadPanel.innerHTML=this.LOADING_MARKUP;uiCtx.vendorPanel=document.createElement('div');uiCtx.vendorPanel.id='vendorPanel';uiCtx.cartItemsPanel=document.createElement('div');uiCtx.cartItemsPanel.id='itemsPanel';uiCtx.cartItemsPanel.innerHTML='<div class="itemSummaryBlock"></div><div id="cartContinue" class="cartBtn">&lt; Back to Photos</div><div id="cartCheckout" class="cartBtn">Checkout &gt;</div>';uiCtx.infoPanel=document.createElement('div');uiCtx.infoPanel.id='infoPanel';uiCtx.catalogPanel=document.createElement('div');uiCtx.catalogPanel.id='catalogPanel';uiCtx.container.innerElement.appendChild(uiCtx.chrome);uiCtx.container.innerElement.appendChild(uiCtx.loadPanel);uiCtx.container.appendToBody(uiCtx.cartItemsPanel);uiCtx.container.appendToBody(uiCtx.infoPanel);uiCtx.container.appendToBody(uiCtx.catalogPanel);uiCtx.container.render(document.body);_initUIEvents.call(this);};var _initUIEvents=function(){var uiCtx=this.uiContext;var cCtx=this.currentContext;YAHOO.widget.Overlay.windowResizeEvent.subscribe(uiCtx.container.center,uiCtx.container,true);uiCtx.container.showEvent.subscribe(uiCtx.container.center);uiCtx.container.sizeMask=function(){if(this.mask){this.mask.style.height=Dom.getDocumentHeight()+"px";this.mask.style.width='100%';}};uiCtx.container.beforeShowEvent.subscribe(function(){if(typeof keyDown==='function'){Event.removeListener(document,"keydown",keyDown);}});uiCtx.container.beforeHideEvent.subscribe(function(){if(typeof keyDown==='function'){Event.on(document,"keydown",keyDown);}});var checkOut=function(){if(cCtx.pendingUpdates.length){setTimeout(checkOut,200);}else{window.location.href=SM.hostConfig.cartUrl+'?back2shop='+window.location;}};Event.on('cartContinue','click',this.hide,this,true);Event.on('cartCheckout','click',checkOut);Event.on(uiCtx.catalogPanel,'mouseover',_catalogEventHandler,this,true);Event.on(uiCtx.catalogPanel,'mouseout',_catalogEventHandler,this,true);Event.on(uiCtx.catalogPanel,'click',_catalogEventHandler,this,true);var ku1=new YAHOO.util.KeyListener(uiCtx.catalogPanel,{'shift':true,'keys':9},{'fn':_catalogEventHandler,'scope':this,'correctScope':true},YAHOO.util.KeyListener.KEYUP);ku1.enable();var ku2=new YAHOO.util.KeyListener(uiCtx.catalogPanel,{'keys':[9,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105]},{'fn':_catalogEventHandler,'scope':this,'correctScope':true},YAHOO.util.KeyListener.KEYUP);ku2.enable();};var _loadCartData=function(){var dCtx=this.dataContext,cCtx=this.currentContext;if(!dCtx.cart.loaded){dCtx.cart.loadFromUrl(cCtx.cartId,cCtx.ch);}
dCtx.photoInfo.load({'method':'getImageInfo','imageId':cCtx.imageId,'imageKey':cCtx.imageKey});dCtx.catalog.load(cCtx.imageId);};var _showLoadingPanel=function(){var uiCtx=this.uiContext;Dom.setStyle([uiCtx.infoPanel,uiCtx.catalogPanel],'visibility','hidden');Dom.setStyle(uiCtx.loadPanel,'display','block');};var _hideLoadingPanel=function(){var uiCtx=this.uiContext;Dom.setStyle(uiCtx.loadPanel,'display','none');Dom.setStyle([uiCtx.infoPanel,uiCtx.catalogPanel],'visibility','inherit');};var _loadCartItemsPanel=function(){var dCtx=this.dataContext,cCtx=this.currentContext,uiCtx=this.uiContext;if(!dCtx.catalog.loaded||!dCtx.cart.loaded){return;}
var cartItems=dCtx.cart.getItems(),photoItems=dCtx.cart.getItemsByPhoto(cCtx.imageId),photoNumItems=0,photoCost=0,totalNumItems=0,totalCost=0;for(var i=0,len=photoItems.length;i<len;i++){photoNumItems+=photoItems[i].quantity;photoCost+=photoItems[i].quantity*photoItems[i].price;}
for(var i=0,len=cartItems.length;i<len;i++){totalNumItems+=cartItems[i].quantity;totalCost+=cartItems[i].quantity*cartItems[i].price;}
var str=[],rowTemplate='<div class="itemSummary">{0}: {1} item(s) for {2}</div>',fc=SM.util.formatCurrency,fn=SM.util.formatNumber,fs=SM.util.formatString;str.push(fs(rowTemplate,'This Photo',fn(photoNumItems),fc(photoCost)));str.push(fs(rowTemplate,'Your Cart',fn(totalNumItems),fc(totalCost)));Event.purgeElement(uiCtx.cartItemsPanel,false,'click');uiCtx.cartItemsPanel.childNodes[0].innerHTML=str.join('');};var _failInfoPanel=function(o){var uiCtx=this.uiContext;var status=o.status;var msg=o.msg;var args=o.args;var markup=[];for(var i=0,len=msg.length;i<len;i++){markup.push('<h5>'+msg[i]+'</h5>');}
uiCtx.infoPanel.innerHTML=markup.join('');};var _loadInfoPanel=function(){var uiCtx=this.uiContext,dCtx=this.dataContext,cCtx=this.currentContext,uiFilters=uiCtx.catalogOptions.uiFilters,isFiltered=false;var blurb='',fotoflot='';if(typeof(guestPage)!=='undefined'&&guestPage){blurb='<p style="margin: 0;">- Create photobooks with <a href="http://www.blurb.com/partner/smugmug" target="_blank" style="color: #ccc;">Blurb</a></p>';fotoflot='<p style="margin: 30px 0 5px;">- Mount your photos with <a href="http://www.fotoflot.com/smugmug?nickname='+(typeof(NickName)==='undefined'?'':NickName)+'&albumid='+AlbumID+'&albumKey='+AlbumKey+'&imageid='+ImageID+'&imageKey='+ImageKey+'" target="_blank" style="color: #ccc;">fotofl&#333;t</a></p>';}
var desc='<p>As you change quantities, your cart is updated magically.</p><p>Want other photos?  Click \'Back to Photos\' and find more to buy.</p><p>\'Checkout\' to see everything in your cart and make finishing touches.</p>'+fotoflot+blurb;var panelTemplate='<div id="catalogOptions"><h3>Catalog Options</h3><div class="catalogOptions"><div class="options"><fieldset><legend>Hide Photo Finishes</legend><ul id="finishFilter"><li id="filterLustre" class="{6}"><img class="checkbox" src="/img/spacer.gif" />Lustre</li><li id="filterMatte" class="{7}"><img class="checkbox" src="/img/spacer.gif" />Matte</li><li id="filterGloss" class="{8}"><img class="checkbox" src="/img/spacer.gif" />Gloss</li></ul></fieldset><ul><li id="filterCrop" class="{9}"><img class="checkbox" src="/img/spacer.gif" />Hide products that need to be cropped</li></ul><ul><li id="filterPrint" class="{11}"><img class="checkbox" src="/img/spacer.gif" />Hide products that cannot be purchased</li></ul><ul><li id="filterCart" class="{10}"><img class="checkbox" src="/img/spacer.gif" />Only show products in my cart</li></ul></div></div><a id="hideOptions">Show my photo &gt;&gt;</a></div>';panelTemplate+='<div id="photoInfo"><h3>Buy This Photo</h3><div class="photoInfo"><img class="photo" src="/img/spacer.gif" width="{1}" height="{2}" style="background-image: url(/photos/toolthumbs.mg?tool=realThumb&ImageID={0}&ImageKey={13}); width: {1}px; height: {2}px;"/><h5>How to Get the Goods:</h5><p class="desc">'+desc+'</p></div><div id="showOptions"><div id="filterMsg" style="{12}">You have options set that may limit which items are shown.</div><a>&lt;&lt; Simplify this page</a></div></div>';var p=dCtx.photoInfo.data;var thumbRatio=150/Math.max(p.OriginalWidth,p.OriginalHeight);var thumbH=Math.round(p.OriginalHeight*thumbRatio);var thumbW=Math.round(p.OriginalWidth*thumbRatio);for(var f in uiFilters){if(uiFilters[f]){isFiltered=true;break;}}
uiCtx.infoPanel.innerHTML=SM.util.formatString(panelTemplate,cCtx.imageId,thumbW,thumbH,p.OriginalWidth,p.OriginalHeight,p.FileName,uiFilters.lustre?'checked':'',uiFilters.matte?'checked':'',uiFilters.gloss?'checked':'',uiFilters.crop?'checked':'',uiFilters.cart?'checked':'',uiFilters.print?'checked':'',isFiltered?'':'visibility: hidden;',cCtx.imageKey?cCtx.imageKey:'');var doFilter=function(e,filter){var filterClasses={'crop':'needCrop','cart':'product','matte':'matteFinish','lustre':'lustreFinish','gloss':'glossFinish','print':'noPrint'};var re=/.+_.+_(.+)/;var simpleFilter=function(el){if(Dom.hasClass(el,'product')&&Dom.hasClass(el,filterClasses[filter])&&!re.test(el.id)&&!Dom.hasClass(el,'inCart')&&!Dom.hasClass(el.nextSibling,'inCart')){if(Dom.hasClass(el,'filtered')){for(var f in uiFilters){if(f!=filter&&uiFilters[f]&&Dom.hasClass(el,filterClasses[f])){return false;}}}
return true;}else{return false;}};var prods=Dom.getElementsBy(simpleFilter,'div',uiCtx.catalogPanel);var sb=uiCtx.categoryTabSet.get('activeTab').scrollBar;if(uiFilters[filter]){_expandProducts(prods,function(){if(sb){sb.resize();}},function(){Dom.removeClass(prods,'filtered');if(sb){sb.resize(true);}});Dom.removeClass(this,'checked');uiFilters[filter]=false;}else{_collapseProducts(prods,function(){if(sb){sb.resize();}},function(){Dom.addClass(prods,'filtered');if(sb){sb.resize(true);}});Dom.addClass(this,'checked');uiFilters[filter]=true;}
var onFilters=[];for(var f in uiFilters){if(uiFilters[f]){onFilters.push(f);}}
var filterMsg=Dom.get('filterMsg');if(onFilters.length===0){Dom.setStyle(filterMsg,'visibility','hidden');}else{Dom.setStyle(filterMsg,'visibility','inherit');}
SM.util.setCookie('cartfilters',onFilters.join('|'),365);};Event.on('showOptions','click',_showCatalogOptions,this,true);Event.on('hideOptions','click',_showPhotoInfo,this,true);Event.on('filterLustre','click',doFilter,'lustre');Event.on('filterGloss','click',doFilter,'gloss');Event.on('filterMatte','click',doFilter,'matte');Event.on('filterCrop','click',doFilter,'crop');Event.on('filterCart','click',doFilter,'cart');Event.on('filterPrint','click',doFilter,'print');};var _showProductInfo=function(o){var uiCtx=this.uiContext,dCtx=this.dataContext,cCtx=this.currentContext;var status=o.status;var msg=o.msg;var args=o.args;var prodInfo=dCtx.productInfo.data;var photoInfo=dCtx.photoInfo.data;var itemInfo=dCtx.cart.getItem(args.cartItemId);var cropW=0,cropH=0,cropX=0,cropY=0;if(itemInfo){cropW=itemInfo.crop.cropW;cropH=itemInfo.crop.cropH;cropX=itemInfo.crop.cropX;cropY=itemInfo.crop.cropY;}
var markup=SM.cart.generateCropMarkup(cCtx.imageId,photoInfo.OriginalWidth,photoInfo.OriginalHeight,prodInfo.RatioWidth,prodInfo.RatioHeight,cropW,cropH,cropX,cropY,photoInfo.imageKey);var pP=Dom.get('photoInfo');var prod=Dom.getElementsByClassName('productInfo','div',pP);var pI=Dom.getElementsByClassName('photoInfo','div',pP)[0];var p1=prod.length>0?prod[prod.length-1]:pI;var p2=pP.lastChild===p1?pP.appendChild(document.createElement('div')):pP.insertBefore(document.createElement('div'),p1.nextSibling);Dom.addClass(p2,'productInfo');p2.innerHTML=markup+SM.util.formatString('<h5>{0}</h5>',prodInfo.ProductName)+SM.util.formatString('<p class="desc">'+prodInfo.Description+'</p>',prodInfo.ProductName);if(uiCtx.nowShowing==='catalogOptions'){if(Dom.hasClass(p1,'productInfo')){p1.parentNode.removeChild(p1);}else{Dom.setX(p1,Dom.getX(p1)-pP.offsetWidth);}
Dom.setX(p2,Dom.getX(pP));_showPhotoInfo.call(this);}else{if(p1!=pI&&Dom.getX(pI)>Dom.getX(pP)-pP.offsetWidth){var a=new YAHOO.util.Motion(p1,{'points':{'to':[Dom.getX(pP)-pP.offsetWidth,Dom.getY(pI)]}},.5);a.animate();}
var anim=new YAHOO.util.Motion(p1,{'points':{'by':[-pP.offsetWidth,0]}},.5);var anim2=new YAHOO.util.Motion(p2,{'points':{'by':[-pP.offsetWidth,0]}},.5);anim2.onComplete.subscribe(function(){if(p1!=pI){if(p1.parentNode){p1.parentNode.removeChild(p1);}else if(p2.parentNode){p2.parentNode.removeChild(p2);}}});anim.animate();anim2.animate();}
uiCtx.nowShowing='productInfo';};var _showPhotoInfo=function(){var oP=Dom.get('catalogOptions');var pP=Dom.get('photoInfo');var photoInfo=Dom.getElementsByClassName('photoInfo','div',pP)[0];var prods=Dom.getElementsByClassName('productInfo','div',pP);if(this.uiContext.nowShowing==='catalogOptions'){var iP=this.uiContext.infoPanel;var iPXY=Dom.getXY(iP);if(!this.uiContext.selectedItem){Dom.setX(photoInfo,Dom.getX(pP));if(prods.length>0){Dom.batch(prods,function(el){el.parentNode.removeChild(el);});}}
var anim=new YAHOO.util.Motion(pP,{'points':{'to':iPXY}},.5);var anim2=new YAHOO.util.Motion(oP,{'points':{'to':[iPXY[0]-iP.offsetWidth,iPXY[1]]}},.5);anim.animate();anim2.animate();}else{var anim=new YAHOO.util.Motion(photoInfo,{'points':{'to':[Dom.getX(pP),Dom.getY(photoInfo)]}},.5);var anim2=new YAHOO.util.Motion(prods[0],{'points':{'to':[Dom.getX(pP)+pP.offsetWidth,Dom.getY(photoInfo)]}},.5);anim2.onComplete.subscribe(function(){Dom.batch(prods,function(el){if(el.parentNode){el.parentNode.removeChild(el);}});});anim.animate();anim2.animate();}
this.uiContext.nowShowing='photoInfo';};var _showCatalogOptions=function(e){var iP=this.uiContext.infoPanel;var iPXY=Dom.getXY(iP);var oP=Dom.get('catalogOptions');var pP=Dom.get('photoInfo');var anim=new YAHOO.util.Motion(oP,{'points':{'to':iPXY}},.5);var anim2=new YAHOO.util.Motion(pP,{'points':{'to':[iPXY[0]+iP.offsetWidth,iPXY[1]]}},.5);anim.animate();anim2.animate();this.uiContext.nowShowing='catalogOptions';};var _loadCatalog=function(){var cCtx=this.currentContext;var dCtx=this.dataContext;if(dCtx.catalog.loaded&&dCtx.cart.loaded&&cCtx.vendorId){_createCategoryTabSet.call(this);}};var _failCatalog=function(o){var uiCtx=this.uiContext;var status=o.status;var msg=o.msg;var args=o.args;var markup=[];for(var i=0,len=msg.length;i<len;i++){markup.push(msg[i]+'<br />');}
uiCtx.catalogPanel.innerHTML='<h2 class="noProducts">'+markup.join('')+'</h2>';_hideLoadingPanel.call(this);};var _createCategoryTabSet=function(){var cCtx=this.currentContext;var uiCtx=this.uiContext;var dCtx=this.dataContext;if(dCtx.catalog.productsAvailable){var categoryTabSet=new YAHOO.widget.TabView({'orientation':'top'});categoryTabSet.addClass('categoryTabs');categoryTabSet.appendTo(uiCtx.catalogPanel);categoryTabSet.addListener('activeTabChange',function(o){if(o.prevValue===o.newValue){return;}
var content=o.newValue.get('content');if(content){return;}
content=_buildTabContent.call(this,o.newValue.vendorId,o.newValue.categoryId);o.newValue.set('content',content);},this,true);categoryTabSet.addListener('beforeActiveTabChange',function(o){if(!o.prevValue){return;}
o.prevValue.set('contentVisible',false);},this,true);if(dCtx.catalog.getVendor(cCtx.vendorId)){_createCategoryTabs.call(this,cCtx.vendorId,categoryTabSet);}
if(dCtx.catalog.getVendor('SmugMug')){_createCategoryTabs.call(this,'SmugMug',categoryTabSet);}
categoryTabSet.set('activeIndex',0);uiCtx.categoryTabSet=categoryTabSet;}else{uiCtx.catalogPanel.innerHTML=this.NOPRODUCTS_MARKUP;}
_hideLoadingPanel.call(this);};var _createCategoryTabs=function(vendorId,tabSet){var cCtx=this.currentContext,dCtx=this.dataContext,uiCtx=this.uiContext;var categories=[];var catalog=dCtx.catalog.getVendor(vendorId);for(var c in catalog.categories){if(Lang.hasOwnProperty(catalog.categories,c)){categories.push(catalog.categories[c]);}}
categories.sort(function(a,b){var c1=a.sortIndex;var c2=b.sortIndex;if(c1<c2){return-1;}else{return 1;}});var tab;for(var i=0,len=categories.length;i<len;i+=1){tab=new YAHOO.widget.Tab({'label':categories[i].name});tab.addClass('tab_'+categories[i].id.toLowerCase());tab.vendorId=vendorId;tab.categoryId=categories[i].id;tabSet.addTab(tab);tab.addListener('activeChange',function(o){var tabClass='tab_'+this.categoryId.toLowerCase();if(o.newValue){cCtx.categoryId=this.categoryId;this.replaceClass(tabClass,tabClass+'_active');this.set('title','');}else{this.replaceClass(tabClass+'_active',tabClass);}},this);tab.addListener('contentChange',_addScrollBar);}};var _buildTabContent=function(vendorId,categoryId){var dCtx=this.dataContext,cCtx=this.currentContext,uiCtx=this.uiContext;var vendor=dCtx.catalog.getVendor(vendorId),category=vendor.categories[categoryId],subCategories=vendor.categories[categoryId].subCategories,products=vendor.products;var subCats=[];for(var s in subCategories){if(Lang.hasOwnProperty(subCategories,s)){subCats.push(subCategories[s]);}}
subCats.sort(function(a,b){if(a.sortIndex<b.sortIndex){return-1;}else{return 1;}});var prods=[];for(var p in products){if(Lang.hasOwnProperty(products,p)&&products[p].Category===categoryId){prods.push(products[p]);}}
prods.sort(function(a,b){var s1=parseInt(category.subCategories[a.SubCategory].sortIndex,10);var s2=parseInt(category.subCategories[b.SubCategory].sortIndex,10);if(s1===s2){var p1=parseInt(a.ProductGroup,10);var p2=parseInt(b.ProductGroup,10);if(p1===p2){var i1=parseInt(a.SortIndex,10);var i2=parseInt(b.SortIndex,10);if(i1===i2){return 0;}else if(i1<i2){return-1;}else{return 1;}}else if(p1<p2){return-1;}else{return 1;}}else if(s1<s2){return-1;}else{return 1;}});var str=[];var product,pId,pVendor,pSubCat,pSubCatName,pSubCatDesc,pName,pPrice,pProPrice,pPrintable,pColor,pFinish,pNeedsCrop;var prodId,prodClass,prodStyle,prodMsg,isFiltered;var productItems,cItem,itemCrop,itemColor;var subHeading,subHeadClass,iQty;var fs=SM.util.formatString,fn=SM.util.formatNumber,fc=SM.util.formatCurrency;var productTemplate='<div class="{0}" id="{1}" style="{7}"><div class="costTotal numeric">{2}</div><div class="quantity">{3}</div><div class="costEach numeric">{4}</div><div class="productName">{5}</div>{6}</div>';str.push(fs('<div class="subCatLinks"><h5>{0} categories:</h5><ul>',vendor.categories[categoryId].name));for(var i=0,len=subCats.length;i<len;i+=1){str.push(fs('<li id="_{0}_{1}">{1}</li>',categoryId,subCats[i].name));}
str.push('</ul></div>');str.push('<div class="productsHeader"><div class="costTotal">Cost</div><div class="quantity">Qty.</div><div class="costEach">Cost ea.</div><div class="productName">Product</div></div>');str.push('<div class="productsContainer"><div class="productsList">');for(var i=0,len=prods.length;i<len;i+=1){product=prods[i];pId=product.id;pVendor=vendorId;pSubCat=product.SubCategory;pSubCatName=vendor.categories[categoryId].subCategories[pSubCat].name;pSubCatDesc=vendor.categories[categoryId].subCategories[pSubCat].description;pName=product.ProductName;pPrice=parseFloat(product.price);pProPrice=Lang.hasOwnProperty(product,'proPrice')?product.proPrice:null;pPrintable=product.printable;pColor=product.defaultColor;prodId=pVendor+'_'+pId;prodClass='product';prodStyle='';prodMsg='';pNeedsCrop=product.needsCrop;isFiltered=false;productItems=dCtx.cart.getItemsByProduct(pId);if(pProPrice!==null){prodMsg+=fs('<div class="proPrice message">Your customer&#39;s price: {0}</div>',parseFloat(pProPrice)===0?'not for sale':fc(pProPrice));}
if(!pPrintable){prodClass+=' noPrint';prodMsg+='<div class="noPrint message"><img src="/img/spacer.gif" />The photo is too small to buy this item</div>';if(uiCtx.catalogOptions.uiFilters.print){isFiltered=true;}}else if(pNeedsCrop){prodClass+=' needCrop';prodMsg+='<div class="needCrop message">Needs cropping in checkout</div>';if(uiCtx.catalogOptions.uiFilters.crop){isFiltered=true;}}
if(categoryId==='download'&&pPrice==0){pPrintable=false;prodClass+=' noPrint';prodMsg+='<div class="noPrint message"><img src="/img/spacer.gif" />You may not purchase downloads of your photos</div>';}
if(categoryId==='prints'){pFinish=/\((\S+)\)/.exec(pName);if(pFinish){prodClass+=' '+pFinish[1].toLowerCase()+'Finish';if(uiCtx.catalogOptions.uiFilters[pFinish[1].toLowerCase()]){isFiltered=true;}}}
iQty=0;if(subHeading!=pSubCat){subHeadClass=!subHeading?'first':'';subHeading=pSubCat;str.push(fs('<h5 id="{0}_{1}" class="{2}">{1}<div class="desc">{3}</div></h5>',categoryId,pSubCatName,subHeadClass,pSubCatDesc));prodClass+=' first';}
if(productItems.length>0&&uiCtx.catalogOptions.uiFilters.cart){isFiltered=true;}
if(isFiltered){prodClass+=' filtered';prodStyle='height: 0px; display: none;';}
str.push(fs(productTemplate,prodClass,prodId,fc(pPrice*iQty),(pPrintable?'<div class="sm-spinner"><div class="sm-spinner-less"></div><div class="sm-spinner-more"></div><input type="text" class="sm-spinner-input numeric" size="3" value="'+iQty+'" maxlength="3" /></div>':iQty),fc(pPrice),pName,prodMsg,prodStyle));if(productItems.length>0){prodClass+=' inCart';prodMsg='<div class="message">Previously added to your cart</div>';for(var j=0,jlen=productItems.length;j<jlen;j++){cItem=productItems[j];if(cItem.photoId!=cCtx.imageId){continue;}
if(cItem.crop.cropType==='Crop'&&cItem.crop.cropW*cItem.crop.cropH!=0){itemCrop='Cropped';}else if(cItem.crop.cropType==='Crop'){itemCrop='Not Cropped';}else{itemCrop='Do Not Crop';}
if(cItem.color==='True'){itemColor='True Color';}else{itemColor='Auto Color';}
prodId=pVendor+'_'+pId+'_'+cItem.id;pName=itemCrop+', '+itemColor;iQty=cItem.quantity;str.push(fs(productTemplate,prodClass,prodId,fc(pPrice*iQty),(pPrintable?'<div class="sm-spinner"><div class="sm-spinner-less"></div><div class="sm-spinner-more"></div><input type="text" class="sm-spinner-input numeric" size="3" value="'+iQty+'" maxlength="3"/></div>':iQty),fc(pPrice),pName,prodMsg,prodStyle));}}}
str.push('</div></div>');str=str.join('');return str;};var _addScrollBar=function(o){var tabContentEl=this.get('contentEl');var productContainer=tabContentEl.childNodes[2];if(!productContainer){return;}
var sHeight=productContainer.scrollHeight;var oHeight=productContainer.offsetHeight;this.scrollBar=new SM.cart.UI.ScrollBar(productContainer,{'mouseWheel':true});if(sHeight<=oHeight){Dom.setStyle(this.scrollBar.sb,'visibility','hidden');}
this.addListener('contentVisibleChange',function(o){if(o.newValue&&!o.prevValue){this.scrollBar.resize(true);var sliderOffset=this.scrollBar.thumb.getYValue();sliderOffset+=(sliderOffset===0)?0:1;if(sliderOffset!=0){this.scrollBar.fireEvent('change',sliderOffset);}}});};var spinningSpinner=null,activeSpinners={};var _catalogEventHandler=function(){if(arguments.length===2){var e=arguments[0];}else{var e=arguments[1][1];}
var self=this,dCtx=this.dataContext,cCtx=this.currentContext,uiCtx=this.uiContext,type=e.type,target=Event.getTarget(e),targetTag=null,product=null;if(target){targetTag=target.tagName.toLowerCase();product=findParentProduct(target,this);}
switch(type){case'mouseover':case'mouseout':if(product){mouseHoverHandler(type);}
break;case'click':if(product){productClickHandler();spinClickHandler();}else{linkClickHandler();}
break;case'keyup':target=uiCtx.selectedItem.getElementsByTagName('input')[0];keyHandler(e);}
function findParentProduct(child,ancestor){var test=function(node){return Dom.hasClass(node,'product');};var getProductParts=function(product){var parts=/([^_]+)_([^_]+)(?:_([^_]+))?/.exec(product.id);return{'el':product,'imageId':cCtx.imageId,'vendorId':parts[1],'productId':parts[2],'cartItemId':parts[3]||null};};if(test(child)){return getProductParts(child);}
while((child=child.parentNode)&&(child!==ancestor)){if(test(child)){return getProductParts(child);}}
return null;}
function mouseHoverHandler(){switch(type){case'mouseover':Dom.addClass(product.el,'hover');break;case'mouseout':Dom.removeClass(product.el,'hover');break;}}
function linkClickHandler(){if(targetTag!='li'){return;}
var linkId=target.id.substr(1);var linkEl=Dom.get(linkId);if(!Dom.hasClass(target.parentNode.parentNode,'subCatLinks')){return;}
var productContainer=linkEl.parentNode.parentNode;var a=new YAHOO.util.Scroll(productContainer,{'scroll':{'to':[0,linkEl.offsetTop]}},.5,YAHOO.util.Easing.easeOut);a.animate();}
function productClickHandler(){if(Dom.hasClass(product.el,'selected')){if(!Dom.hasClass(target.parentNode,'sm-spinner')){Dom.removeClass(product.el,'selected');uiCtx.selectedItem=null;_showPhotoInfo.call(self);}}else{Dom.removeClass(uiCtx.selectedItem,'selected');Dom.addClass(product.el,'selected');uiCtx.selectedItem=product.el;var qtyEl=product.el.getElementsByTagName('input')[0];if(qtyEl){qtyEl.select();Event.stopEvent(e);}
dCtx.productInfo.load({'method':'getProductInfo','vendorId':product.vendorId,'productId':product.productId,'cartItemId':product.cartItemId});}}
function beforeChangeHandler(product){var updateId=product.cartItemId||product.productId;if(!cCtx.pendingUpdates[updateId]){cCtx.pendingUpdates.push(updateId);}}
function changeHandler(product,el){var cost=Dom.getElementsByClassName('costTotal','div',product.el)[0];_lockProductItem(el);cost.innerHTML='&nbsp;';Dom.addClass(cost,'ajaxBusy_small');if(!product.cartItemId){dCtx.cart.addItem(product.imageId,product.vendorId,product.productId,el.value)}else if(parseInt(el.value,10)===0){dCtx.cart.removeItem(product.cartItemId)}else{dCtx.cart.changeQuantity(product.cartItemId,el.value)}}
function keyHandler(e){if(e.keyCode===9){if(!product){return;}else{var sel=uiCtx.selectedItem,sib=e.shiftKey?sel.previousSibling:sel.nextSibling;while(sib){if(Dom.hasClass(sib,'product')){product=findParentProduct(sib,sib);productClickHandler();return;}
sib=e.shiftKey?sib.previousSibling:sib.nextSibling;}}}else{spinClickHandler();}}
function spinClickHandler(){var minValue=0;var maxValue=(uiCtx.categoryTabSet.get('activeTab').get('label')==='Downloads'?1:self.QUANTITY_MAX);var delay=1000;if(!Dom.hasClass(target.parentNode,'sm-spinner')){return;}
spinningSpinner=uiCtx.selectedItem.id;if(activeSpinners[spinningSpinner]){clearTimeout(activeSpinners[spinningSpinner].spinChangeTimer);delete activeSpinners[spinningSpinner];}
activeSpinners[spinningSpinner]=product;var targetEl=activeSpinners[spinningSpinner].el.getElementsByTagName('input')[0];if(targetEl.disabled){return;}
var newValue=targetEl.value;try{var oldValue=dCtx.cart.getItem(activeSpinners[spinningSpinner].cartItemId).quantity;}catch(err){var oldValue=0;}
if(!/^\d+$/.test(newValue)){newValue=(!/^\d+$/.test(oldValue))?0:oldValue;}
newValue=parseInt(newValue,10);if(Dom.hasClass(target,'sm-spinner-more')&&(maxValue===null||newValue<maxValue)){newValue+=1;}else if(Dom.hasClass(target,'sm-spinner-less')&&(minValue===null||newValue>minValue)){newValue-=1;}
targetEl.value=newValue;if(oldValue===newValue){return;}
var updateProduct=activeSpinners[spinningSpinner];activeSpinners[spinningSpinner].spinChangeTimer=setTimeout(function(){delete activeSpinners[spinningSpinner];spinningSpinner=null;beforeChangeHandler(updateProduct);changeHandler(updateProduct,targetEl);},delay);}};var _updateProductItem=function(o){var cCtx=this.currentContext,uiCtx=this.uiContext,dCtx=this.dataContext;var status=o.status;var msg=o.msg;var args=o.args;var type=o.type;var result=o.result;var row=Dom.get(args.vendorId+'_'+args.productId+'_'+args.cartItemId);if(row&&type==='removeItem'){if(Dom.hasClass(row,'inCart')){var sb=uiCtx.categoryTabSet.get('activeTab').scrollBar;_collapseProducts(row,function(){if(sb){sb.resize();}},function(){row.parentNode.removeChild(row);var p=Dom.get(args.vendorId+'_'+args.productId);if(!p){return;}
var qtyInput=p.getElementsByTagName('input')[0];if(!qtyInput){return;}
qtyInput.select();});}else{row.id=args.vendorId+'_'+args.productId;}}else if(!row){row=Dom.get(args.vendorId+'_'+args.productId);row.id=args.vendorId+'_'+args.productId+'_'+args.cartItemId;}
var errors=Dom.getElementsByClassName('error','ul',row);for(var i=0,len=errors.length;i<len;i+=1){errors[i].parentNode.removeChild(errors[i]);}
var cost=Dom.getElementsByClassName('costTotal','div',row)[0];Dom.removeClass(cost,'ajaxBusy_small');_unlockProductItem(row.getElementsByTagName('input')[0]);var qtyInput=row.getElementsByTagName('input')[0];if(qtyInput){qtyInput.select();}
if(status==='success'){if(type==='removeItem'){cost.innerHTML='$0.00';}else{cost.innerHTML=SM.util.formatCurrency(dCtx.catalog.getProduct(args.vendorId,args.productId).price*dCtx.cart.getItem(args.cartItemId).quantity);}
_loadCartItemsPanel.call(this);}else{var errEl=document.createElement('ul');errEl.className='error message';var message='';for(var i=0,len=msg.length;i<len;i+=1){message+='<li>'+msg[i]+'</li>';}
errEl.innerHTML=message;row.appendChild(errEl);}
var i=0;while(i<cCtx.pendingUpdates.length){if(cCtx.pendingUpdates[i]===args.cartItemId||cCtx.pendingUpdates[i]===args.productId){cCtx.pendingUpdates.splice(i,1);}else{i++;}}};var _lockProductItem=function(el){el.disabled=true;};var _unlockProductItem=function(el){el.disabled=false;};var _collapseProducts=function(prods,fn1,fn2){if(!YAHOO.lang.isArray(prods)){var tmp=prods;prods=[];prods[0]=tmp;}
if(prods.length===0){return;}
Dom.setStyle(prods,'overflow','hidden');var anim=new YAHOO.util.Anim(prods,{'opacity':{'to':0}},.5);anim.onComplete.subscribe(function(){var anim2;for(var i=0,len=prods.length;i<len;i+=1){prods[i].setAttribute('sm-height',Dom.getStyle(prods[i],'height'));prods[i].setAttribute('sm-border-top-width',Dom.getStyle(prods[i],'border-top-width'));prods[i].setAttribute('sm-border-bottom-width',Dom.getStyle(prods[i],'border-bottom-width'));prods[i].setAttribute('sm-padding-top',Dom.getStyle(prods[i],'padding-top'));prods[i].setAttribute('sm-padding-bottom',Dom.getStyle(prods[i],'padding-bottom'));Dom.setStyle(prods[i],'border-top-width','0px');Dom.setStyle(prods[i],'border-bottom-width','0px');Dom.setStyle(prods[i],'padding-top','0px');Dom.setStyle(prods[i],'padding-bottom','0px');}
anim2=new YAHOO.util.Anim(prods,{'height':{'to':0}},.5);anim2.onComplete.subscribe(function(){Dom.setStyle(prods,'display','none');});if(fn1){anim2.onTween.subscribe(fn1);}
if(fn2){anim2.onComplete.subscribe(fn2);}
anim2.animate();});anim.animate();};var _expandProducts=function(prods,fn1,fn2){if(!YAHOO.lang.isArray(prods)){var tmp=prods;prods=[];prods[0]=tmp;}
if(prods.length===0){return;}
var anim,anim2,pHeight;for(var i=0,len=prods.length;i<len;i+=1){Dom.setStyle(prods[i],'display','block');Dom.setStyle(prods[i],'border-top-width',prods[i].getAttribute('sm-border-top-width'));Dom.setStyle(prods[i],'border-bottom-width',prods[i].getAttribute('sm-border-bottom-width'));Dom.setStyle(prods[i],'padding-top',prods[i].getAttribute('sm-padding-top'));Dom.setStyle(prods[i],'padding-bottom',prods[i].getAttribute('sm-padding-bottom'));pHeight=prods[i].getAttribute('sm-height')||prods[i].scrollHeight;prods[i].removeAttribute('sm-border-top-width');prods[i].removeAttribute('sm-border-bottom-width');prods[i].removeAttribute('sm-padding-top');prods[i].removeAttribute('sm-padding-bottom');anim=new YAHOO.util.Anim(prods[i],{'height':{'to':pHeight}},.5);if(i===prods.length-1){if(fn1){anim.onTween.subscribe(fn1);}
anim.onComplete.subscribe(function(){Dom.batch(prods,function(el){Dom.setStyle(el,'overflow','visible');Dom.setStyle(el,'height','auto');});anim2=new YAHOO.util.Anim(prods,{'opacity':{'to':1}},.5);if(fn2){anim2.onComplete.subscribe(fn2);}
anim2.animate();});}
anim.animate();}};SM.cart.AddCartSingle=AddCartSingle;})();SM.cart.generateCropMarkup=function(imageId,imageW,imageH,productW,productH,cropW,cropH,cropX,cropY,imageKey){var imageRatio=Math.max(imageW,imageH)/Math.min(imageW,imageH);var productRatio=Math.max(productW,productH)/Math.min(productW,productH);var needCrop=false;if(productRatio>0&&imageRatio!==productRatio){needCrop=true;}
var thumbRatio=150/Math.max(imageW,imageH);var thumbH=Math.round(imageH*thumbRatio);var thumbW=Math.round(imageW*thumbRatio);if(cropW!=0&&cropH!=0){cropW=Math.round(cropW*thumbRatio);cropH=Math.round(cropH*thumbRatio);cropX=Math.round(cropX*thumbRatio);cropY=Math.round(cropY*thumbRatio);}else if(needCrop){if(parseInt(imageW,10)>parseInt(imageH,10)){cropH=thumbH;cropW=Math.round(cropH*productRatio);if(cropW>thumbW){cropW=thumbW;cropH=Math.round(cropW/productRatio);}}else if(parseInt(imageH,10)>parseInt(imageW,10)){cropW=thumbW;cropH=Math.round(cropW*productRatio);if(cropH>thumbH){cropH=thumbH;cropW=Math.round(cropH/productRatio);}}else{if(parseFloat(productW)>parseFloat(productH)){cropW=thumbW;cropH=Math.round(cropW/productRatio);}else{cropH=thumbH;cropW=Math.round(cropH/productRatio);}}
cropX=Math.round((thumbW-cropW)/2);cropY=Math.round((thumbH-cropH)/2);}else{cropW=thumbW;cropH=thumbH;cropX=0;cropY=0;}
var markup='<div class="photo cropContainer" style="width: {0}px; height: {1}px; background-image: url(/photos/toolthumbs.mg?tool=realThumb&ImageID={2}&ImageKey={7}); background-repeat: no-repeat; background-position: center center;"><div class="cropMask"></div><div class="cropBorder" style="left: {3}px; top: {4}px; width: {5}px; height: {6}px; background-image: url(/photos/toolthumbs.mg?tool=realThumb&ImageID={2}&ImageKey={7}); background-repeat: no-repeat; background-position: -{3}px -{4}px;"></div></div>';return SM.util.formatString(markup,thumbW,thumbH,imageId,cropX,cropY,cropW,cropH,imageKey);};(function(){var ScrollBar=function(targetEl,attr){targetEl=Dom.get(targetEl);if(!targetEl){return;}
attr=attr||{};var oHeight=targetEl.offsetHeight;var scrollId=attr.id||Dom.generateId('','sb');var mouseWheel=attr.mouseWheel||false;var sliderMinHeight=Math.floor(oHeight*(attr.sliderMinHeight||.15));var sliderMaxHeight=Math.floor(oHeight*(attr.sliderMaxHeight||.85));var scrollAmount=attr.scrollAmount||15;var scrollContainer=document.createElement('div');scrollContainer.className='scrollContainer';var sb=document.createElement('div');sb.className='scrollBar';var sliderBg=document.createElement('div');sliderBg.id=scrollId+'_sb';sliderBg.className='scrollBg';var sliderUp=document.createElement('div');sliderUp.className='scrollUp';var sliderDown=document.createElement('div');sliderDown.className='scrollDown';var sliderThumb=document.createElement('div');sliderThumb.id=scrollId+'_st';sliderThumb.className='scrollThumb';sliderThumb.innerHTML='<div class="top"></div><div class="bottom"></div>';sliderBg.appendChild(sliderThumb);sb.appendChild(sliderBg);sb.appendChild(sliderUp);sb.appendChild(sliderDown);targetEl.parentNode.insertBefore(scrollContainer,targetEl);scrollContainer.appendChild(targetEl);scrollContainer.appendChild(sb);var sHeight,sliderHeight,ratio,maxOffset;var setSize=function(){sHeight=Math.max(targetEl.scrollHeight,oHeight);sliderHeight=Math.min(Math.max(Math.floor(sHeight/(sHeight-oHeight)*100),sliderMinHeight),sliderMaxHeight);maxOffset=oHeight-sliderUp.offsetHeight-sliderDown.offsetHeight-sliderHeight;ratio=(sHeight-oHeight)/maxOffset;};setSize();Dom.setStyle(sliderThumb,'height',sliderHeight+'px');var scrollBar=YAHOO.widget.Slider.getVertSlider(sliderBg.id,sliderThumb.id,0,maxOffset);scrollBar.sb=sb;scrollBar.resize=function(checkVisibility){setSize();scrollBar.thumb.setYConstraint(0,maxOffset);Dom.setStyle(sliderThumb,'height',sliderHeight+'px');if(scrollBar.thumb.getYValue()+sliderHeight>maxOffset){scrollBar.setValue(maxOffset,true,true);}else{scrollBar.fireEvent('change',scrollBar.thumb.getYValue());}
if(!checkVisibility){return;}
var sHeight=targetEl.scrollHeight,oHeight=targetEl.offsetHeight,vis=Dom.getStyle(sb,'visibility');if(sHeight<=oHeight&&vis!='hidden'){var anim=new YAHOO.util.Anim(sb,{'opacity':{'to':0}},.5);anim.onComplete.subscribe(function(){Dom.setStyle(sb,'visibility','hidden');});anim.animate();}else if(sHeight>oHeight&&vis==='hidden'){Dom.setStyle(sb,'visibility','inherit');var anim=new YAHOO.util.Anim(sb,{'opacity':{'to':1}},.5);anim.animate();}};scrollBar.scrollTargetBy=function(xDelta){targetEl.scrollTop+=xDelta;};var fireEvent=true;var scrollClickTimer;var clickedEl;var doScroll=function(){if(clickedEl===sliderDown){scrollBar.scrollTargetBy(scrollAmount);}else if(clickedEl===sliderUp){scrollBar.scrollTargetBy(-(scrollAmount));}else{return;}
var scrollInterval=100;scrollClickTimer=setTimeout(doScroll,scrollInterval);};var mouseDown=function(e){clickedEl=this;doScroll();};var mouseUp=function(e){Event.stopEvent(e);if(scrollClickTimer){clearTimeout(scrollClickTimer);scrollClickTimer=null;}};var scrollTarget=function(e){fireEvent=false;scrollBar.setValue(this.scrollTop/ratio,true,true);fireEvent=true;};Event.on(targetEl,'scroll',scrollTarget);Event.on([sliderDown,sliderUp],'mousedown',mouseDown);Event.on([sliderDown,sliderUp],'mouseup',mouseUp);scrollBar.subscribe('change',function(offsetY){if(fireEvent){targetEl.scrollTop=offsetY*ratio;}});scrollBar.thumb.onMouseUp=function(){Event.on(targetEl,'scroll',scrollTarget);scrollBar.thumbMouseUp();};scrollBar.thumb.onMouseDown=function(){Event.removeListener(targetEl,'scroll',scrollTarget);return scrollBar.focus();};if(mouseWheel){var DOMTarget,DOMEvent;if(Event.isIE){DOMTarget=document;DOMEvent='mousewheel';}else if(Event.isSafari){DOMTarget=window;DOMEvent='mousewheel';}else{DOMTarget=window;DOMEvent='DOMMouseScroll';}
Event.on(DOMTarget,DOMEvent,_handleMouseWheel,{'targetObj':scrollContainer,'scrollBar':scrollBar});}
return scrollBar;};var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang;var _handleMouseWheel=function(e,parms){var event=Event.getEvent(e);var eventTarget=Event.getTarget(e);var targetObj=parms.targetObj;var scrollBar=parms.scrollBar;var multiplier=15;var scrollOffset;if(Event.isIE){scrollOffset=120;}else if(Event.isSafari){scrollOffset=120;}else{scrollOffset=1;}
if(eventTarget===targetObj||Dom.isAncestor(targetObj,eventTarget)){Event.stopEvent(e);var wheelDelta=(event.wheelDelta?-(event.wheelDelta):event.detail)/scrollOffset;var scrollBy=Math.floor(wheelDelta*multiplier);if(scrollBy){scrollBar.scrollTargetBy(scrollBy);}}};SM.cart.UI.ScrollBar=ScrollBar;})();
var lightBoxImageID='';var lightBoxImageKey='';var lightBoxCaption=false;var lightBoxSize='Medium';var checkingLBSize=false;var lbImage=[];var lbLoaded=false;var prevLBPhoto='';var nextLBPhoto='';var canPrintLB='';var canPrintGuid='';var lightBoxOn=true;var newWin=null;function getCustomResizeSizes(targetWidth,targetHeight,baseWidth,baseHeight){var sizes={};var ratio=Math.min(baseWidth,baseHeight)/Math.max(baseWidth,baseHeight);if(baseHeight>baseWidth){sizes.height=Math.min(targetWidth,targetHeight);sizes.width=Math.ceil(sizes.height*ratio);}else{sizes.width=Math.max(targetWidth,targetHeight);sizes.height=Math.ceil(sizes.width*ratio);}
return sizes;}
function getPerfectSize(lbImage){var reqSize='';var screenWidth=YD.getViewportWidth()-40;var screenHeight=YD.getViewportHeight()-40;var widthSize=0;var heightSize=0;var lbImageOWidth=lbImage.OriginalWidth;var lbImageOHeight=lbImage.OriginalHeight;var mediumSize=getCustomResizeSizes(600,400,lbImageOWidth,lbImageOHeight);var largeSize=getCustomResizeSizes(800,600,lbImageOWidth,lbImageOHeight);var xlargeSize=getCustomResizeSizes(1024,768,lbImageOWidth,lbImageOHeight);var x2largeSize=getCustomResizeSizes(1280,960,lbImageOWidth,lbImageOHeight);var x3largeSize=getCustomResizeSizes(1600,1200,lbImageOWidth,lbImageOHeight);if(screenWidth<=mediumSize.width-1){widthSize=1;}else if(screenWidth>=mediumSize.width&&screenWidth<=largeSize.width-1){widthSize=2;}else if(screenWidth>=largeSize.width&&screenWidth<=xlargeSize.width-1){widthSize=3;}else if(screenWidth>=xlargeSize.width&&screenWidth<=x2largeSize.width-1){widthSize=4;}else if(screenWidth>=x2largeSize.width&&screenWidth<=x3largeSize.width-1){widthSize=5;}else if(screenWidth>=x3largeSize.width){widthSize=6;}
if(screenHeight<=mediumSize.height-1){heightSize=1;}else if(screenHeight>=mediumSize.height&&screenHeight<=largeSize.height-1){heightSize=2;}else if(screenHeight>=largeSize.height&&screenHeight<=xlargeSize.height-1){heightSize=3;}else if(screenHeight>=xlargeSize.height&&screenHeight<=x2largeSize.height-1){heightSize=4;}else if(screenHeight>=x2largeSize.height&&screenHeight<=x3largeSize.height-1){heightSize=5;}else if(screenHeight>=x3largeSize.height){heightSize=6;}
var perfectSize=Math.min(heightSize,widthSize);switch(perfectSize){case 1:reqSize='Small';break;case 2:reqSize='Medium';break;case 3:reqSize='Large';break;case 4:reqSize='XLarge';break;case 5:reqSize='X2Large';break;case 6:reqSize='X3Large';break;}
return reqSize;}
function resizeStage(){YD.setStyle('lightBoxStage','height',YD.getDocumentHeight()+'px');}
function prepLB(ImageID,reqSize,setSize,ImageKey){lightBoxImageID=ImageID;lightBoxImageKey=ImageKey;canPrintLB='';closePhotoBar();closeSmugPopular();if(lightBoxOn){var postArray=[];postArray.autoSize=false;if(reqSize===''){reqSize=SM.util.getCookie('lbSize');if(!reqSize){reqSize="Medium";}}
if(setSize){SM.util.setCookie('lbSize',setSize,365);}
if(reqSize.toLowerCase()=="auto"){postArray.autoSize=true;reqSize=getPerfectSize(lbImage[ImageID]);if(!checkingLBSize){checkingLBSize=true;YE.addListener(window,'resize',checkLBSize);}}else{checkingLBSize=false;YE.removeListener(window,'resize',checkLBSize);}
lightBoxSize=reqSize;if(useLightbox){YD.addClass(document.body,'masked');var lbStage=YD.get('lightBoxStage');YD.setStyle(lbStage,'zIndex',getZindex(document.body)+1);YD.setStyle(lbStage,'display','block');YD.setStyle(lbStage,'height',YD.getDocumentHeight()+'px');YE.on(window,'scroll',resizeStage);YE.on(window,'resize',resizeStage);window.scrollTo('',0)
var lbCaption=YD.get('lightBoxCaption');if(lbCaption&&lbCaption.offsetWidth){lightBoxCaption=true;}
YD.setStyle('lightBoxCaption','display','none');lbLoaded=false;YD.get('lightBoxNav').innerHTML="<span class='title'>loading</span>";lbLoading(0);document.onkeydown='';postArray.tool='lightBoxImage';postArray.ImageID=ImageID;postArray.ImageKey=ImageKey;postArray.AlbumKey=AlbumKey;postArray.AlbumID=AlbumID;postArray.size=reqSize;postArray.pageType=pageType;postArray.pageTypeDetails=pageTypeDetails;postArray.pageScope=pageScope;postArray.pageDrawBy=pageDrawBy;if(typeof siteUser!=='undefined'){postArray.siteUser=siteUser;}
postArray.community=community;postArray.screenWidth=YD.getViewportWidth()-40;postArray.screenHeight=YD.getViewportHeight()-40;if(YD.hasClass(document.body,'smugmug_ajax')){postArray.ajaxNav=true;}else{postArray.ajaxNav='';}
ajax_query(prepLBimg,'/rpc/gallery.mg',postArray,true);}else if(popWidth!==''&&popHeight!==''){imagePopUp('/photos/popup.mg?ImageID='+ImageID+'&ImageKey='+ImageKey+'&Size='+reqSize+'&popUp=1','console',popWidth,popHeight);}}}
function openLB(lbID,reqSize,setSize){var ImageKey='';var pieces=lbID.split('_');var ImageID=pieces[0];if(pieces.length>1){ImageKey=pieces[1];}
if(reqSize=="Auto"&&!lbImage[ImageID]){var handleSuccess=function(o){if(o.responseText!==undefined){var returnedData=eval('('+o.responseText+')');for(var i in returnedData){lbImage[i]=returnedData[i];}
if(lbImage[ImageID].CloseLB){location.hash=ImageID+'_'+ImageKey;}else{prepLB(ImageID,reqSize,setSize,ImageKey);}}};var handleFailure=function(o){};var callback={success:handleSuccess,failure:handleFailure,scope:this};var postArray=[];postArray.push('ImageID='+ImageID);postArray.push('ImageKey='+ImageKey);postArray.push('Size=Original');postArray.push('tool=imageSize');var sUrl="/rpc/gallery.mg";var imageRequest=YAHOO.util.Connect.asyncRequest('POST',sUrl,callback,postArray.join('&'));}else{prepLB(ImageID,reqSize,setSize,ImageKey);}}
function checkLBSize(){var perfectSize=getPerfectSize(lbImage[lightBoxImageID]);if(lightBoxSize!=perfectSize){openLB(lightBoxImageID+'_'+lightBoxImageKey,'Auto');}}
function lbLoading(count){if(!lbLoaded){if(count<=3){var loading='';for(var i=1;i<=count;i++){loading+='.';}
if(count==3){count=0;}else{count++;}
YD.get('lightBoxNav').innerHTML="<span class='title'>loading "+loading+"</span>";var string='lbLoading('+count+');';setTimeout(string,500);}else{var lbNav=URLDecode(count);if(canPrintLB!==''){lbNav+='|&nbsp;<a href="javascript:addCartSingle('+canPrintLB+', \''+canPrintKey+'\');"><img src="/img/spacer.gif" alt="buy this photo" title="buy this photo" width="21" height="18" hspace="0" vspace="0" border="0" class="cart_add" /></a>';}
if(YD.hasClass(document.body,'smugmug_ajax')){lbNav+='|&nbsp;<a href="#'+lightBoxImageID+'_'+lightBoxImageKey+'" class="title">Close</a>';}else{lbNav+='|&nbsp;<a href="javascript:void(0);" onmouseup="closeLB(event);" class="title">Close</a>';}
YD.get('lightBoxNav').innerHTML=lbNav;lbLoaded=true;}}}
function swapPreLoad(lightBoxInfo){var newIMG=lightBoxInfo.newIMG;var Nav=lightBoxInfo.Nav;var newWidth=lightBoxInfo.newWidth;var newHeight=lightBoxInfo.newHeight;var caption=lightBoxInfo.caption;if(YD.get('lightBoxImage')){removeFromDOM('lightBoxImage');}
if(YD.get('smugMovieDiv')){smugPlayer.pause();var purgeObj=YD.get('smugMovieDiv');while(purgeObj.hasChildNodes()){purgeObj.removeChild(purgeObj.childNodes[0]);}
removeFromDOM('smugMovieDiv');}
var lightBoxPhoto=YD.get('lightBoxPhoto');document.onkeydown=lbNavigation;var lightBoxImage=document.createElement("img");lightBoxImage.setAttribute("id","lightBoxImage");if(YD.hasClass(document.body,'smugmug_ajax')){var preloadLBimageAnchor=document.createElement("a");preloadLBimageAnchor.setAttribute("href","#"+lightBoxImageID+'_'+lightBoxImageKey);lightBoxPhoto.appendChild(preloadLBimageAnchor);preloadLBimageAnchor.appendChild(lightBoxImage);}else{lightBoxPhoto.appendChild(lightBoxImage);YE.addListener(lightBoxImage,'mouseup',closeLB);}
YE.addListener(lightBoxImage,'mouseover',function(e){if(displaySmugPopular){if(!YD.hasClass(document.body,'smugmug_ajax')||(photoInfo[lightBoxImageID]!==undefined&&photoInfo[lightBoxImageID].displayPopular!=='')){smugPopular(this.id,lightBoxImageID,lightBoxImageKey);}}});lightBoxImage.style.background="url("+newIMG+")";lightBoxImage.style.width=newWidth+"px";lightBoxImage.style.height=newHeight+"px";YE.removeListener(lightBoxImage,'load');YE.addListener(lightBoxImage,'load',function(){lbLoading(Nav);});lightBoxImage.className="protected";lightBoxImage.setAttribute("src","/img/spacer.gif");if(caption!==''&&lightBoxCaption){YD.setStyle('lightBoxCaption','display','block');YD.get('lightBoxCaption').innerHTML=caption;}
if(YD.get('preloadLBimage')){removeFromDOM('preloadLBimage');}}
function prepLBimg(response){var lbInfo=eval('('+response+')');var newIMG=lbInfo.newIMG;var imageKey=lbInfo.ImageKey;var Nav=lbInfo.Nav;var newWidth=lbInfo.newWidth;var newHeight=lbInfo.newHeight;var protect=lbInfo.protect;var caption=lbInfo.caption;var showCart=lbInfo.showCart;prevLBPhoto=lbInfo.prevPhoto;nextLBPhoto=lbInfo.nextPhoto;if(showCart){canPrintLB=lbInfo.ImageID;canPrintKey=lbInfo.ImageKey;}
if(YD.hasClass(document.body,'smugmug_ajax')){loadedImageRPC(lbInfo.ImageID,lbInfo.Size,imageKey);}
var lightBoxPhoto=YD.get('lightBoxPhoto');if(!lbInfo.isMovie){if(!Yua.webkit&&protect){var preloadLBimage=document.createElement("img");preloadLBimage.setAttribute("id","preloadLBimage");lightBoxPhoto.appendChild(preloadLBimage);preloadLBimage.style.width="10px";preloadLBimage.style.height="10px";preloadLBimage.style.position="absolute";preloadLBimage.style.zIndex="1000000";preloadLBimage.style.visibility="hidden";YE.on(preloadLBimage,'load',function(){swapPreLoad(lbInfo);});preloadLBimage.setAttribute("src",newIMG);}else{if(YD.get('lightBoxImage')){removeFromDOM('lightBoxImage');}
if(YD.get('smugMovieDiv')){smugPlayer.pause();var purgeObj=YD.get('smugMovieDiv');while(purgeObj.hasChildNodes()){purgeObj.removeChild(purgeObj.childNodes[0]);}
removeFromDOM('smugMovieDiv');}
document.onkeydown=lbNavigation;var lightBoxImage=document.createElement("img");lightBoxImage.setAttribute("id","lightBoxImage");YE.addListener(lightBoxImage,'mouseover',function(e){if(displaySmugPopular){if(!YD.hasClass(document.body,'smugmug_ajax')||(photoInfo[lightBoxImageID]!==undefined&&photoInfo[lightBoxImageID].displayPopular!=='')){smugPopular(this.id,lightBoxImageID,lightBoxImageKey);}}});YE.removeListener(lightBoxImage,'load');YE.addListener(lightBoxImage,'load',function(){lbLoading(Nav);});lightBoxImage.style.width=newWidth+"px";lightBoxImage.style.height=newHeight+"px";if(YD.hasClass(document.body,'smugmug_ajax')){var preloadLBimageAnchor=document.createElement("a");preloadLBimageAnchor.setAttribute("href","#"+lightBoxImageID+'_'+lightBoxImageKey);lightBoxPhoto.appendChild(preloadLBimageAnchor);preloadLBimageAnchor.appendChild(lightBoxImage);}else{lightBoxPhoto.appendChild(lightBoxImage);YE.addListener(lightBoxImage,'mouseup',closeLB);}
if(!Yua.webkit){lightBoxImage.setAttribute("src",newIMG);}else{if(protect){lightBoxImage.style.background="url("+newIMG+")";lightBoxImage.className="protected";lightBoxImage.setAttribute("src","/img/spacer.gif");}else{lightBoxImage.setAttribute("src",newIMG);}}
if(caption!==''&&lightBoxCaption){YD.setStyle('lightBoxCaption','display','block');YD.get('lightBoxCaption').innerHTML=caption;}}
var tempStyle=YD.getStyle('lightBoxPhoto','display');YD.setStyle('lightBoxPhoto','display','inline');YD.setStyle('lightBoxPhoto','display',tempStyle);}
else{var lightBoxPhoto=YD.get('lightBoxPhoto');document.onkeydown=lbNavigation;if(YD.get('lightBoxImage')){removeFromDOM('lightBoxImage');}
if(YD.get('smugMovieDiv')){smugPlayer.pause();var purgeObj=YD.get('smugMovieDiv');while(purgeObj.hasChildNodes()){purgeObj.removeChild(purgeObj.childNodes[0]);}
removeFromDOM('smugMovieDiv');}
var smugMovieDiv=document.createElement("div");smugMovieDiv.id='smugMovieDiv';lightBoxPhoto.appendChild(smugMovieDiv);smugPlayer=new SM.flash.Video('smugMovieDiv','',{'videoKey':lbInfo.ImageKey,'videoId':lbInfo.ImageID,'width':lbInfo.movieWidth,'height':lbInfo.movieHeight,'format':lbInfo.format,'src':lbInfo.movieSrc,'albumId':lbInfo.AlbumID,'albumKey':lbInfo.AlbumKey,'share':lbInfo.share});YD.removeClass(smugMovieDiv,'qtMovie');lbLoading(Nav);if(caption!=""&&lightBoxCaption==true){YD.setStyle('lightBoxCaption','display','block');YD.get('lightBoxCaption').innerHTML=caption;}}}
function closeLB(e){if(!e){e=window.event;}
if(e&&e.button==2){return true;}
if(YD.get('lightBoxImage')){removeFromDOM('lightBoxImage');}else if(YD.get('smugMovieDiv')){smugPlayer.pause();var purgeObj=YD.get('smugMovieDiv');while(purgeObj.hasChildNodes()){purgeObj.removeChild(purgeObj.childNodes[0]);}
removeFromDOM('smugMovieDiv');}else{return true;}
removeFromDOM('smugPopular');removeFromDOM('smugPopularContent');closeSmugPopular();checkingLBSize=false;YE.removeListener(window,'resize',checkLBSize);YE.removeListener(document,'mousemove',watchMouseOverPhoto);YD.get('lightBoxCaption').innerHTML='';document.onkeydown='';YD.setStyle('lightBoxStage','display','none');YE.removeListener(window,'scroll',resizeStage);YE.removeListener(window,'resize',resizeStage);YD.removeClass(document.body,'masked');scroll(0,1);scroll(0,-1);photoHovering=false;if(YD.hasClass(document.body,'smugmug_ajax')){removeFromDOM('photoBar');removeFromDOM('photoBarContent');YE.removeListener(document,'mousemove',watchPhotoBar);}
lightBoxImageID='';lightBoxImageKey='';lightBoxSize='';}
var closeLightBox=closeLB;function lbNavigation(e){if(!e){e=window.event;}
var whichPhoto;if(e.keyCode==37){whichPhoto=prevLBPhoto;}else if(e.keyCode==39){whichPhoto=nextLBPhoto;}else{return true;}
if(YD.hasClass(document.body,'smugmug_ajax')){if(whichPhoto){var reqSize=getHash().split('-')[1];var breakDown=whichPhoto.split(',');var thisHash=breakDown[0].split('(')[1].replace(/\'/g,'')+'-'+reqSize+'-'+'LB';location.hash=thisHash;SM.history.add(thisHash);}}else{eval(whichPhoto);}
return false;}
function imagePopUp(strURL,strType,strWidth,strHeight){var windowWidth,windowHeight;if(parseInt(parseInt(strWidth,10)+50,10)>=YD.getViewportWidth()){windowWidth=YD.getViewportWidth();}else{windowWidth=parseInt(parseInt(strWidth,10)+50,10);}
if(parseInt(parseInt(strHeight,10)+50,10)>=YD.getViewportHeight()){windowHeight=YD.getViewportHeight();}else{windowHeight=parseInt(parseInt(strHeight,10)+50,10);}
if(newWin!==null&&!newWin.closed){newWin.close();}
var strOptions='top='+((self.screen.height-windowHeight)/2)+', left='+((self.screen.width-windowWidth)/2)+',';if(strType=='console'){strOptions+='resizable, scrollbars, height='+windowHeight+', width='+windowWidth;}
if(strType=='fixed'){strOptions+='status, height='+windowHeight+', width='+windowWidth;}
if(strType=='elastic'){strOptions+='toolbar, menubar, scrollbars, resizable, location, height='+windowHeight+', width='+windowWidth;}
newWin=window.open(strURL,'newWin',strOptions);if(!newWin||typeof(newWin)==='undefined'){if(window.location.href.split("#")[1].indexOf('-LB')>-1){var hash=window.location.href.split("#")[1];location.replace(window.location.href.split("#")[0]+'#'+hash.split("-")[0]);}}else{newWin.focus();}}
var totalComments=0;var totalRating=0;var commentOn=0;var commentPageOn=1;var commentsPerPage=10;var closeMe='';function submitTitle(AlbumID,AlbumKey){pageWorking('Saving Gallery Title');var postArray=[];postArray.tool='editTitle';postArray.AlbumID=AlbumID;postArray.AlbumKey=AlbumKey;postArray.Title=YD.get('newTitle').value;ajax_query(editTitleRPCResult,'/rpc/gallery.mg',postArray,true);}
function editTitleRPCResult(response){var returnedData=eval('('+response+')');YD.get('albumTitle').innerHTML=returnedData.Title+" <a href=\"javascript:toggleDIV('editTitle','albumTitle', 'inline');\" class=\"copy\">edit<\/a> ";toggleDIV('albumTitle','editTitle','inline');removePageWorking();}
function renumberGallery(AlbumID,AlbumKey,ImageIDs,startPosition){pageWorking('Saving Positions');var postArray=[];postArray.tool='renumberGallery';postArray.AlbumID=AlbumID;postArray.AlbumKey=AlbumKey;postArray.ImageIDs=ImageIDs.join(",");postArray.startPosition=startPosition;ajax_query(removePageWorking,'/rpc/gallery.mg',postArray,true);}
function submitDescription(AlbumID,AlbumKey){pageWorking('Saving Gallery Desc.');var postArray=[];postArray.tool='editDescription';postArray.AlbumID=AlbumID;postArray.AlbumKey=AlbumKey;postArray.Description=YD.get('newDescription').value;ajax_query(editDescriptionRPCResult,'/rpc/gallery.mg',postArray,true);}
function editDescriptionRPCResult(response){var returnedData=eval('('+response+')');YD.get('albumDescription').innerHTML=returnedData.Description+" <a href=\"javascript:toggleDIV('editDescription','albumDescription', 'block');\">edit<\/a> ";toggleDIV('albumDescription','editDescription','block');if(galleryStyle==="filmstrip"){move4IE(0);}
removePageWorking();}
function submitCaption(ImageID,ImageKey,Caption){pageWorking('Saving Caption');var postArray=[];postArray.tool='editCaption';postArray.ImageID=ImageID;postArray.ImageKey=ImageKey;postArray.Caption=Caption;ajax_query(editCaptionRPCDone,'/rpc/gallery.mg',postArray,true);}
function editCaptionRPCDone(response){var returnedData=eval('('+response+')');var displayCaption=returnedData.displayCaption;var editCaption=returnedData.editCaption;var altCaption=returnedData.altCaption;var imageId=returnedData.imageId;var editText=displayCaption===''?'add caption':'edit';if(YD.hasClass(document.body,'smugmug_ajax')){photoInfo[imageId].caption=displayCaption;photoInfo[imageId].editCaption=editCaption;photoInfo[imageId].altCaption=altCaption;updateCaption();}else{var captions=galleryStyle==='journal'?YD.get('caption'+imageId):YD.getElementsByClassName('caption','div','bodyWrapper');var journalId=galleryStyle==='journal'?imageId:'';if(captions){YD.batch(captions,function(caption){caption.innerHTML=displayCaption+" <a href=\"javascript:toggleDIV('editCaption"+journalId+"', 'caption"+journalId+"', 'block');\">"+editText+"<\/a>";var editBox=YD.getNextSibling(caption)
if(editBox&&YD.getStyle(editBox,'display')==='block'){YD.setStyle(caption,'display','block');YD.setStyle(editBox,'display','none');}});}}
removePageWorking();}
function submitKeywords(ImageID,ImageKey,Keywords){pageWorking('Saving Keywords');var postArray=[];postArray.tool='editKeywords';postArray.ImageID=ImageID;postArray.ImageKey=ImageKey;postArray.Keywords=Keywords;ajax_query(editKeywordsRPCDone,'/rpc/gallery.mg',postArray,true);}
function editKeywordsRPCDone(response){var returnedData=eval('('+response+')');var newKeywords=returnedData.newKeywords;var textAreaKeywords=returnedData.textAreaKeywords;if(newKeywords==='dontShow'){YD.get('photoKeywords').innerHTML="";}else if(newKeywords!==""){YD.get('photoKeywords').innerHTML="<span class=\"title\">keywords:<\/span> "+newKeywords+" &#183; <a href=\"javascript:toggleDIV('editKeywords','photoKeywords','block');\">edit<\/a>";}else{YD.get('photoKeywords').innerHTML="<span class=\"title\">keywords:<\/span> <a href=\"javascript:toggleDIV('editKeywords','photoKeywords', 'block');\">add<\/a>";}
if(YD.hasClass(document.body,'smugmug_ajax')){if(newKeywords==='dontShow'){newKeywords='';}
photoInfo[ImageID].keywords=newKeywords;photoInfo[ImageID].editKeywords=textAreaKeywords;}
toggleDIV('photoKeywords','editKeywords','block');removePageWorking();}
function changeGalleryComments(){if(showGalleryComments===true){showGalleryComments=false;SM.util.setCookie('showGalleryComments','false',365);YD.get('showGalleryComments').innerHTML='gallery comments hidden';}else{showGalleryComments=true;SM.util.setCookie('showGalleryComments','true',-365);YD.get('showGalleryComments').innerHTML='hide gallery comments';}
showCommentPage(1);}
function approveComment(CommentID,Type,TypeID,TypeKey){pageWorking('Approving Comment');var postArray=[];postArray.tool='approveComment';postArray.CommentID=CommentID;postArray.Type=Type;postArray.TypeID=TypeID;postArray.TypeKey=TypeKey;ajax_query(handleJS,'/rpc/gallery.mg',postArray,true);}
function deleteComment(CommentID,Type,TypeID,TypeKey){pageWorking('Deleting Comment');var postArray=[];postArray.tool='deleteComment';postArray.CommentID=CommentID;postArray.Type=Type;postArray.TypeID=TypeID;postArray.TypeKey=TypeKey;ajax_query(handleJS,'/rpc/gallery.mg',postArray,true);}
function showCommentPage(newPage){newPage=parseInt(newPage,10);if(isNaN(newPage)){commentPageOn=1;}else{commentPageOn=newPage;}
var postArray=[];if(YD.hasClass(document.body,'traditional')||YD.hasClass(document.body,'slideshow')||YD.hasClass(document.body,'allthumbs')||YD.hasClass(document.body,'journal')){postArray.Type='Album';postArray.TypeID=AlbumID;postArray.TypeKey=AlbumKey;}else{postArray.Type='Image';postArray.TypeID=ImageID;postArray.TypeKey=ImageKey;}
if(YD.inDocument('commentType')){postArray.alsoGetAlbum='true';}else{postArray.alsoGetAlbum='false';}
postArray.tool='getComments';ajax_query(drawCommentsRPCResult,'/rpc/gallery.mg',postArray,true);}
function submitComment(Type,TypeID,TypeKey){var postArray=[];postArray.tool='addComment';var submitThis=true;var commentType=YD.get('commentType');if(commentType){postArray.captchaType='Combined';if(commentType.value==='Image'){postArray.Type='Image';postArray.TypeID=ImageID;postArray.TypeKey=ImageKey;}else if(commentType.value==='Album'){postArray.Type='Album';postArray.TypeID=AlbumID;postArray.TypeKey=AlbumKey;}else{submitThis=false;alert("You must choose to either comment on the gallery or photo.");}}else{postArray.captchaType=Type;postArray.Type=Type;postArray.TypeID=TypeID;postArray.TypeKey=TypeKey;}
if(!YD.inDocument('noCaptchaNeeded')){postArray.Captcha=YD.get('AlbumCaptcha').value;}
postArray.Rating=YD.get('albumCommentRating').value;postArray.Comment=YD.get('albumComment').value;if(YD.inDocument('albumCommentName')){postArray.Name=YD.get('albumCommentName').value;}
if(YD.inDocument('albumCommentLink')){postArray.Email=YD.get('albumCommentLink').value;}
if(SM.util.trimString(postArray.Comment)===''){alert('You can not leave an empty comment.');}else if(submitThis===true){pageWorking('Submitting Comment');ajax_query(handleJS,'/rpc/gallery.mg',postArray,true);}}
function redoCaptcha(Type,error){if(error==='true'){if(YD.inDocument('commentType')){Type='Album';}
YD.get(Type+'CaptchaConfirm').className="title alert";YD.get(Type+'Captcha').value="try again";alert("Whoops, the spam-foiling code didn't match.  Please try again.");}
if(YD.inDocument('commentType')){document.images.AlbumCaptchaSource.src="/photos/captcha.mg?width=100&height=25&Type=Combined&randomBits="+randomString(8);}else{document.images[Type+'CaptchaSource'].src="/photos/captcha.mg?width=100&height=25&Type="+Type+"&randomBits="+randomString(8);}
removePageWorking();}
function commentApprovedResult(Type,TypeID,TypeKey){removePageWorking();if(YD.inDocument('commentApproval')&&YD.getStyle('commentApproval','display')!=="none"){pageWorking('Awaiting Approval');}
if(YD.inDocument('commentType')){Type='Album';}
if(!YD.inDocument('noCaptchaNeeded')){YD.get(Type+'CaptchaConfirm').className="title";YD.get(Type+'Captcha').value='';}
if(YD.hasClass(document.body,'critique')){var postArray=[];postArray.Type='Image';postArray.TypeID=ImageID;postArray.TypeKey=ImageKey;postArray.alsoGetAlbum='';postArray.tool='getCommentSummary';ajax_query(handleJS,'/rpc/gallery.mg',postArray,true);}
if(Type==='Image'&&!YD.inDocument('commentType')){if(YD.inDocument('imageCommentName')){YD.get('imageCommentName').value='';}
if(YD.inDocument('imageCommentLink')){YD.get('imageCommentLink').value='';}
YD.get('imageComment').value='';toggleDIV('imageCommentSummary','addImageComment','inline');}else{if(YD.inDocument('albumCommentName')){YD.get('albumCommentName').value='';}
if(YD.inDocument('albumCommentLink')){YD.get('albumCommentLink').value='';}
YD.get('albumComment').value='';toggleDIV('toggleAlbumComment','addAlbumComment','inline');}
showCommentPage('');}
function drawCommentsSummaryRPCResult(totalComments,totalRating,Type){if(YD.inDocument('rating')){var output='';var imageRating=Math.floor(totalRating);if(imageRating>0){output="";for(var i=0;i<imageRating;i++){output+='<img src="/img/spacer.gif" alt="star" title="star" width="25" height="25" hspace="0" vspace="0" border="0" class="bigStarSolid" />';}
for(var i=5;i>imageRating;i--){output+='<img src="/img/spacer.gif" alt="star" title="star" width="25" height="25" hspace="0" vspace="0" border="0" class="bigStarTrans" />';}}
YD.get('rating').innerHTML=output;}}
var showGalleryComments=true;var commentsDrawing=false;function drawCommentsRPCResult(response){removePageWorking();if(!commentsDrawing){var returnedData=eval('('+response+')');var comments=[];for(var i in returnedData){comments[comments.length]=returnedData[i];}
commentsDrawing=true;var str=[];var ct='<div class="box {0}"><div class="boxTop nav"><div class="boxNote">{1}{2}{3}{4}{5}</div><span class="foreground">{6}. </span>{7}{8} wrote about this<span class="title"> {9} </span>{10}<span class="title">{11}</span><div class="spacer"></div></div><div class="boxBottom">{12}<p class="foreground">{13}</p><div class="spacer"></div></div></div></div>';var output='no photo comments';if(comments!==undefined){var hideGalleryCommentsBox=true;var imageCommentCount=0;var showCommentStart=(commentPageOn-1)*commentsPerPage;var showCommentStop=showCommentStart+commentsPerPage;if(showCommentStop>comments.length){showCommentStop=comments.length;}
var commentCount,loopCounter=0;var CommentID,poster,nofollow,Rating,Comment,commentDate,Status,thisCommentType,thisCommentTypeID,thisCommentTypeKey,userImage,confirmedUser,commentOwner;var flipFlop,approveLink,deleteLink,slashDivider,smallFullStar,smallTranStar,posterLink,userLink,commentType,yearOn,userPhoto;for(var commentCount=0;commentCount<comments.length;commentCount++){CommentID=comments[commentCount].CommentID;poster=comments[commentCount].poster;nofollow=comments[commentCount].nofollow;Rating=comments[commentCount].Rating;Comment=comments[commentCount].Comment;commentDate=comments[commentCount].commentDate;Status=comments[commentCount].Status;thisCommentType=comments[commentCount].thisCommentType;thisCommentTypeID=comments[commentCount].thisCommentTypeID;thisCommentTypeKey=comments[commentCount].thisCommentTypeKey;userImage=comments[commentCount].userImage;confirmedUser=comments[commentCount].confirmedUser;commentOwner=comments[commentCount].commentOwner;if((showGalleryComments===true||(showGalleryComments!==true&&thisCommentType!=='Album'))&&showCommentStart<showCommentStop){if(loopCounter<(commentPageOn-1)*commentsPerPage){loopCounter++;}else{showCommentStart++;if(showCommentStart%2===1){flipFlop='odd';}else{flipFlop='even';}
approveLink='';deleteLink='';if(commentOwner===true){if(Status==='Pending'){approveLink='<a class="alert" href="javascript:approveComment('+CommentID+',\''+thisCommentType+'\',\''+thisCommentTypeID+'\',\''+thisCommentTypeKey+'\');">approve</a><span>&nbsp;&#183;&nbsp</span>';}
deleteLink='<a class="alert" href="javascript:deleteComment('+CommentID+',\''+thisCommentType+'\',\''+thisCommentTypeID+'\',\''+thisCommentTypeKey+'\');">delete</a>';}
slashDivider='';smallFullStar='';smallTranStar='';if(Rating!==0){if(commentOwner===true){slashDivider=' | ';}
for(var i=0;i<Rating;i++){smallFullStar+='<img class="star" src="/img/spacer.gif">';}
for(var i=5;i>Rating;i--){smallTranStar+='<img class="starTrans" src="/img/spacer.gif">';}}
posterLink='';userLink='';if(confirmedUser){posterLink=poster.split('"')[1];userLink='<a href="'+posterLink+'"><img class="openID" src="/img/spacer.gif"></img></a>';}
if(thisCommentType==='Album'){commentType='gallery';}else{commentType='photo';}
yearOn='';if(commentDate.indexOf('year')===-1){yearOn='on ';}
posterLink='';userPhoto='';if(userImage!==''){posterLink=poster.split('"')[1];userPhoto='<a href="'+posterLink+'"><img class="imgBorder userCommentPhoto" src="'+userImage+'" /></a>';}
str.push(SM.util.formatString(ct,flipFlop,approveLink,deleteLink,slashDivider,smallFullStar,smallTranStar,showCommentStart,userLink,poster,commentType,yearOn,commentDate,userPhoto,Comment));}}
if(thisCommentType==='Album'){hideGalleryCommentsBox=false;}else{imageCommentCount++;}}
if(YD.inDocument('hideGalleryComments')){if(hideGalleryCommentsBox!==true){YD.setStyle(YD.get('hideGalleryComments'),'display','inline');if(showGalleryComments===true){YD.get('showGalleryComments').innerHTML='hide gallery comments';}else{YD.get('showGalleryComments').innerHTML=comments.length-imageCommentCount+' gallery comments hidden';}}else{YD.setStyle(YD.get('hideGalleryComments'),'display','none');}}
var commentPageNavCount=0;for(var commentCount=0;commentCount<comments.length;commentCount++){thisCommentType=comments[commentCount].thisCommentType;if(showGalleryComments===true||(showGalleryComments!==true&&thisCommentType!=='Album')){commentPageNavCount++;}}
var totalPages=Math.ceil(commentPageNavCount/commentsPerPage),output='';if(commentPageNavCount>0){output='<span class="title">page:<\/span> ';if(commentPageOn>1){output+='<a href="javascript:showCommentPage('+(commentPageOn-1)+');" class="nav">&lt;<\/a> ';}
for(var i=1;i<=totalPages;i++){if(commentPageOn!==i){output+='<a href="javascript:showCommentPage('+i+');" class="nav">'+i+'<\a> ';}else{output+=i+' ';}}
if(commentPageOn<totalPages){output+='<a href="javascript:showCommentPage('+(commentPageOn+1)+');" class="nav">&gt;<\/a>';}}}
if(YD.get('comment_nav')){YD.get('comment_nav').innerHTML=output;}
if(YD.get('comments')){YD.get('comments').innerHTML=str.join('');}
commentsDrawing=false;}else{setTimeout(function(){drawCommentsRPCResult(response);},500);}}
if(typeof moveTool==='undefined'){var moveTool=false;}
var moveWarning=false;function moveStatus(){if(moveWarning){alert("New positions will not be shown until you change the gallery sort options to Position in your gallery settings.");moveWarning=false;}
if(moveTool===true){moveTool=false;YD.setStyle(YD.getElementsByClassName('photoLink','a'),'cursor','pointer');if(YD.get('mouseFollow')){var el=YD.get('mouseFollow');el.parentNode.removeChild(el);}
scrollAreas('remove');YD.removeClass('arrangePhotosText','title');}else{moveTool=true;YD.setStyle(YD.getElementsByClassName('photoLink','a'),'cursor','move');var body=document.getElementsByTagName("body")[0];var mouseFollow=document.createElement("div");mouseFollow.setAttribute("id","mouseFollow");mouseFollow.className="photo";body.appendChild(mouseFollow);scrollAreas('add');YD.addClass('arrangePhotosText','title');}}
var startBox=-1;var holdThis="";function pickPhoto(t,e){if(moveTool===true){startBox=t.parentNode;while(!YD.hasClass(startBox,'photo')){startBox=startBox.parentNode;}
startBox=parseInt(startBox.id.replace("photoBox_",""),10);holdThis=imageIDs[startBox];YD.get('mouseFollow').innerHTML=YD.get('photoBox_'+startBox).innerHTML;YD.get('photoBox_'+startBox).innerHTML="";YD.setStyle('mouseFollow','display','block');YD.setStyle('scrollTop','display','block');YD.setStyle('scrollBottom','display','block');if(!e){var e=window.event;}
document.onselectstart=function(){return false;};document.onmouseup=placePhoto;movePhoto(e);document.onmousemove=movePhoto;}}
function placePhoto(){if(moveTool===true&&startBox>=0){scrollUnit=0;if(scrolly!==""){clearInterval(scrolly);}
document.onmousemove="";document.onselectstart="";document.onmouseup="";YD.get('photoBox_'+startBox).innerHTML=YD.get('mouseFollow').innerHTML;YD.setStyle('photoBox_'+startBox,'width',prevPhotoBoxWidth+'px');YD.setStyle('photoBox_'+startBox,'height',prevPhotoBoxHeight+'px');YD.get('photoBox_'+startBox).className="photo";YD.setStyle('mouseFollow','display','none');YD.setStyle('scrollTop','display','none');YD.setStyle('scrollBottom','display','none');imageIDs[startBox]=holdThis;startBox=-1;var startPosition=0;if(galleryStyle==='smugmug_small'){startPosition=(pageOn-1)*10;}else if(galleryStyle==='smugmug'){startPosition=(pageOn-1)*16;}else if(galleryStyle==='traditional'){startPosition=(pageOn-1)*17;}
renumberGallery(AlbumID,AlbumKey,imageIDs,startPosition);}}
function movePhoto(e){if(!e){e=window.event;}
var posx=0;var posy=0;if(e.pageX||e.pageY){posx=e.pageX;posy=e.pageY;}else if(e.clientX||e.clientY){posx=e.clientX+document.documentElement.scrollLeft;posy=e.clientY+document.documentElement.scrollTop;}
if(posx>0&&posy>0){YD.setStyle('mouseFollow','top',posy+1+'px');YD.setStyle('mouseFollow','left',posx+1+'px');}}
var prevPhotoBoxHeight='';var prevPhotoBoxWidth='';var newPhotoBoxHeight='';var newPhotoBoxWidth='';function cyclePhotos(boxNum){if(moveTool===true&&startBox>=0){if(prevPhotoBoxHeight===""&&newPhotoBoxHeight===""){prevPhotoBoxWidth=parseInt(YD.getStyle('photoBox_0','width'),10);prevPhotoBoxHeight=parseInt(YD.getStyle('photoBox_0','height'),10);newPhotoBoxWidth=prevPhotoBoxWidth-2;newPhotoBoxHeight=prevPhotoBoxHeight-2;}
if(boxNum!==startBox){if(boxNum>startBox){for(var i=startBox;i<boxNum;i++){YD.get('photoBox_'+i).innerHTML=YD.get('photoBox_'+(i+1)).innerHTML;YD.get('photoBox_'+i).className="photo";YD.setStyle('photoBox_'+i,'width',prevPhotoBoxWidth+'px');YD.setStyle('photoBox_'+i,'height',prevPhotoBoxHeight+'px');imageIDs[i]=imageIDs[i+1];}}else if(boxNum<startBox){for(var i=startBox;i>boxNum;i--){YD.get('photoBox_'+i).innerHTML=YD.get('photoBox_'+(i-1)).innerHTML;YD.get('photoBox_'+i).className="photo";YD.setStyle('photoBox_'+i,'width',prevPhotoBoxWidth+'px');YD.setStyle('photoBox_'+i,'height',prevPhotoBoxHeight+'px');imageIDs[i]=imageIDs[i-1];}}
YD.get('photoBox_'+i).innerHTML="";YD.setStyle('photoBox_'+i,'width',newPhotoBoxWidth+'px');YD.setStyle('photoBox_'+i,'height',newPhotoBoxHeight+'px');YD.get('photoBox_'+i).className="photo photoTarget";startBox=i;}}}
var scrollUnit="";var scrolly="";function goScroll(gUnit){scrollUnit=gUnit*3;if(scrollUnit===0){clearInterval(scrolly);}else{scrolly=setInterval("scrollPage()",5);}}
function scrollPage(){scrollBy(0,scrollUnit);}
var photoHovering=false;var photoHoveringAnimation=false;var photoBarTimeout='';var closingPhotoBar=false;function photoHover(photoID,photoImageID,waited){var position=SM.PhotoBar.config.position||'right';var hoverPhoto=YD.get(photoID);if(photoInfo[photoImageID].Format!=="ARC"){if(!showPhotoBar||hoverPhoto.offsetWidth*hoverPhoto.offsetHeight<30000||photoInfo[photoImageID]===undefined||photoHovering||photoInfo[photoImageID].Format==="MPG"||(YD.inDocument('themeChoicesContainer')&&parseInt(YD.getStyle('themeChoicesContainer','height'),10)!==0)){return;}}
if(!waited){YE.addListener(document,'mousemove',watchPhotoBar,photoID);photoBarTimeout=setTimeout("photoHover('"+photoID+"', '"+photoImageID+"', true)",photoBarDelay*1000);return;}
if(YD.inDocument('photoBarBg')&&YD.inDocument('photoBarContent')&&!YD.hasClass('photoBarContent','photoId_'+photoImageID)){removeFromDOM('photoBarBg');removeFromDOM('photoBarContent');}
var hoverRegion=YAHOO.util.Region.getRegion(hoverPhoto);var photoBarBg=YD.get('photoBarBg');var photoBarContent=YD.get('photoBarContent');if(!photoBarBg){photoBarBg=document.createElement('div');photoBarBg.setAttribute('id','photoBarBg');photoBarBg.className=position;document.body.appendChild(photoBarBg);YD.setStyle(photoBarBg,'zIndex',getZindex(hoverPhoto)+1);photoBarBg.innerHTML='<div class="first"></div><div class="middle"></div><div class="last"></div>';YE.on(window,'resize',function(){if(photoBarBg&&photoBarBg.offsetWidth<=1){YD.setStyle(photoBarBg,'left',0);if(photoBarContent){YD.setStyle(photoBarContent,'left',0);}}});}
var photoImageKey=photoInfo[photoImageID].ImageKey;if(!photoBarContent){photoBarContent=document.createElement("div");photoBarContent.setAttribute('id','photoBarContent');YD.addClass(photoBarContent,position);YD.addClass(photoBarContent,'photoId_'+photoImageID);document.body.appendChild(photoBarContent);YD.setStyle(photoBarContent,'zIndex',getZindex(photoBarBg)+1);if(displaySmugPopular&&photoInfo[photoImageID].Format!=="ARC"){if(photoInfo[photoImageID].displayPopular){var photoRank=document.createElement('div');YD.addClass(photoRank,'photoRank');photoRank.id='photoRank';if(photoBarContent.childNodes.length===0){YD.addClass(photoRank,'first');}
photoBarContent.appendChild(photoRank);var postArray=[];postArray.tool='smugPopular';postArray.ImageID=photoImageID;postArray.ImageKey=photoImageKey;if(Yua.ie!==6){ajax_query(smugPopularResponse,'/rpc/gallery.mg',postArray,true);}}}
if(photoInfo[photoImageID].Format!=="MP4"&&photoInfo[photoImageID].Format!=="ARC"){if(YD.getStyle(YD.get('lightBoxStage'),'display')!=="block"){var photoSizes=document.createElement("div");YD.addClass(photoSizes,"photoSizes");photoSizes.setAttribute("id","photoSizes");if(photoBarContent.childNodes.length===0){YD.addClass(photoSizes,'first');}
photoBarContent.appendChild(photoSizes);photoSizes.innerHTML='<h4>Photo Sizes</h4>';var photoSizesContent=document.createElement("ul");photoSizes.appendChild(photoSizesContent);photoSizesContent.innerHTML+='<li><a href="#'+photoImageID+'_'+photoImageKey+'-S-LB">Small<\/a></li>';photoSizesContent.innerHTML+='<li><a href="#'+photoImageID+'_'+photoImageKey+'-M-LB">Medium<\/a></li>';if(photoInfo[photoImageID].albumLarges){photoSizesContent.innerHTML+='<li><a href="#'+photoImageID+'_'+photoImageKey+'-L-LB">Large<\/a></li>';if(photoInfo[photoImageID].hasXLarges){if(photoInfo[photoImageID].albumXLarges){photoSizesContent.innerHTML+='<li><a href="#'+photoImageID+'_'+photoImageKey+'-XL-LB">XLarge<\/a></li>';}
if(photoInfo[photoImageID].albumX2Larges){photoSizesContent.innerHTML+='<li><a href="#'+photoImageID+'_'+photoImageKey+'-X2-LB">X2Large<\/a></li>';}
if(photoInfo[photoImageID].albumX3Larges){photoSizesContent.innerHTML+='<li><a href="#'+photoImageID+'_'+photoImageKey+'-X3-LB">X3Large<\/a></li>';}}
if(photoInfo[photoImageID].albumOriginals){photoSizesContent.innerHTML+='<li><a href="#'+photoImageID+'_'+photoImageKey+'-O-LB">Original<\/a></li>';}}}}else if(photoInfo[photoImageID].Format!=="ARC"){var photoSizes=document.createElement("div");YD.addClass(photoSizes,"photoSizes");photoSizes.setAttribute("id","photoSizes");if(photoBarContent.childNodes.length===0){YD.addClass(photoSizes,'first');}
photoBarContent.appendChild(photoSizes);photoSizes.innerHTML='<h4>Save Movie</h4>';photoSizes.innerHTML+='<img id="savePhotoButton" src="/img/spacer.gif" width="28" height="31" border="0" style="cursor: pointer" />';YE.on('savePhotoButton','click',function(){if(YD.getStyle('photoSizesContent','display')!=='block'){YD.setStyle('photoSizesContent','display','block');}else{YD.setStyle('photoSizesContent','display','none');}
YD.setStyle(photoBarBg.childNodes[1],'height',photoBarContent.offsetHeight-photoBarBg.childNodes[0].offsetHeight+'px');YD.setStyle(photoBarBg,'height',YD.getStyle(photoBarBg.childNodes[1],'height'));});var photoSizesContent=document.createElement("ul");photoSizesContent.id='photoSizesContent';YD.setStyle(photoSizesContent,'display','none');YD.setStyle(photoSizesContent,'marginTop','3px');photoSizes.appendChild(photoSizesContent);photoSizesContent.innerHTML+='<li style="margin-bottom: 3px;"><strong style="text-decoration: underline;">Size:</strong></li>';photoSizesContent.innerHTML+='<li><a href="/photos/'+photoImageID+'_'+photoImageKey+'-320D.mp4">Web<\/a></li>';if(photoInfo[photoImageID]['640Movie']){photoSizesContent.innerHTML+='<li><a href="/photos/'+photoImageID+'_'+photoImageKey+'-640D.mp4">iPod/DVD<\/a></li>';}
if(photoInfo[photoImageID]['960Movie']){photoSizesContent.innerHTML+='<li><a href="/photos/'+photoImageID+'_'+photoImageKey+'-960D.mp4">Mid-Def<\/a></li>';}
if(photoInfo[photoImageID]['1280Movie']){photoSizesContent.innerHTML+='<li><a href="/photos/'+photoImageID+'_'+photoImageKey+'-1280D.mp4">HiDef<\/a></li>';}
if(photoInfo[photoImageID].Archive){photoSizesContent.innerHTML+='<li style="margin: 5px 0 3px 0;"><strong style="text-decoration: underline;">Archive:</strong></li>';for(var i in photoInfo[photoImageID].Archive){var obj=photoInfo[photoImageID].Archive[i];photoSizesContent.innerHTML+='<li><a href="'+obj.URL+'" title="'+obj.FileName+'" alt="'+obj.FileName+'">'+obj.FileName.split('.').pop().toUpperCase()+'<\/a></li>';}}}
if(photoInfo[photoImageID].displayEXIF&&photoInfo[photoImageID].Format!=="MP4"&&photoInfo[photoImageID].Format!=="ARC"){var photoExif=document.createElement("div");photoExif.setAttribute("id","photoExif");if(photoBarContent.childNodes.length===0){YD.addClass(photoExif,'first');}
photoBarContent.appendChild(photoExif);photoExif.innerHTML='<h4>Photo Info</h4>';photoExif.innerHTML+='<a href="javascript:exifDetails('+photoImageID+', \''+photoImageKey+'\');"><img id="photoInfoButton" src="/img/spacer.gif" width="27" height="27" border="0" /></a>';}
if((photoInfo[photoImageID].canEdit||(photoInfo[photoImageID].albumOriginals&&!photoInfo[photoImageID]['protected']))&&photoInfo[photoImageID].Format!=="MP4"){var photoSave=document.createElement("div");photoSave.setAttribute("id","photoSave");if(photoBarContent.childNodes.length===0){YD.addClass(photoSave,'first');}
photoBarContent.appendChild(photoSave);if(photoInfo[photoImageID].canEdit){photoSave.innerHTML='<h4>Owner Save</h4>';}
else if(photoInfo[photoImageID].Format==="ARC"){photoSave.innerHTML='<h4>Save File</h4>';}
else{photoSave.innerHTML='<h4>Save Photo</h4>';}
photoSave.innerHTML+='<img id="savePhotoButton" src="/img/spacer.gif" width="28" height="31" border="0" style="cursor:pointer" />';if(photoInfo[photoImageID].Archive&&((photoInfo[photoImageID].Format==="ARC"&&photoInfo[photoImageID].Archive.length>1)||photoInfo[photoImageID].Format!=="ARC")){YE.on('savePhotoButton','click',function(){if(YD.getStyle('photoSaveContent','display')!=='block'){YD.setStyle('photoSaveContent','display','block');}else{YD.setStyle('photoSaveContent','display','none');}
YD.setStyle(photoBarBg.childNodes[1],'height',photoBarContent.offsetHeight-photoBarBg.childNodes[0].offsetHeight+'px');YD.setStyle(photoBarBg,'height',YD.getStyle(photoBarBg.childNodes[1],'height'));});var photoSaveContent=document.createElement("ul");photoSaveContent.id='photoSaveContent';YD.setStyle(photoSaveContent,'display','none');YD.setStyle(photoSaveContent,'marginTop','3px');photoSave.appendChild(photoSaveContent);photoSaveContent.innerHTML+='<li style="margin-bottom: 3px;"><strong style="text-decoration: underline;">File:</strong></li>';if(photoInfo[photoImageID].Format!=="ARC"){photoSaveContent.innerHTML+='<li><a href="/photos/'+photoImageID+'_'+photoImageKey+'-D.jpg">Original<\/a></li>';}
for(var i in photoInfo[photoImageID].Archive){var obj=photoInfo[photoImageID].Archive[i];photoSaveContent.innerHTML+='<li><a href="'+obj.URL+'" title="'+obj.FileName+'" alt="'+obj.FileName+'">'+obj.FileName.split('.').pop().toUpperCase()+'<\/a></li>';}}
else{if(photoInfo[photoImageID].Format==="ARC"){var linkage=photoInfo[photoImageID].Archive[0].URL;}
else{var linkage='/photos/'+photoImageID+'_'+photoImageKey+'-D.jpg';}
YE.on('savePhotoButton','click',function(){location.href=linkage;});}}
if(Yua.ie===6&&hoverPhoto.offsetHeight<photoBarContent.offsetHeight+20){YD.setStyle('photoTools','visibility','hidden');}}
switch(position){case'right':YD.setStyle(photoBarBg.childNodes[1],'height',photoBarContent.offsetHeight-photoBarBg.childNodes[0].offsetHeight+'px');YD.setStyle(photoBarBg,'height',YD.getStyle(photoBarBg.childNodes[1],'height'));YD.setXY(photoBarBg,[hoverRegion.right,hoverRegion.top]);YD.setXY(photoBarContent,[hoverRegion.right-photoBarContent.offsetWidth,hoverRegion.top]);var attr={'left':{'by':-97},'width':{'to':96}};break;case'bottom':if(Yua.ie===6){YD.setStyle(photoBarBg.childNodes[1],'width',photoBarContent.offsetWidth+'px');}else{YD.setStyle(photoBarBg.childNodes[1],'width',photoBarContent.offsetWidth-photoBarBg.childNodes[0].offsetWidth+'px');}
YD.setStyle(photoBarBg,'width',YD.getStyle(photoBarBg.childNodes[1],'width'));YD.setXY(photoBarBg,[hoverRegion.right-(hoverPhoto.offsetWidth/2)-(photoBarBg.offsetWidth/2),hoverRegion.bottom]);if(Yua.ie===6){YD.setXY(photoBarContent,[hoverRegion.right-(hoverPhoto.offsetWidth/2)-(photoBarBg.offsetWidth/2)+photoBarBg.childNodes[0].offsetWidth,hoverRegion.bottom+7]);}else{YD.setXY(photoBarContent,[hoverRegion.right-(hoverPhoto.offsetWidth/2)-(photoBarBg.offsetWidth/2),hoverRegion.bottom]);}
var attr={'height':{'to':100}};if(Yua.ie===6){YD.setStyle('photoTools','visibility','hidden');}}
photoHovering=true;switch(position){case'right':if(parseInt(YD.getStyle(photoBarBg,'width'),10)>0){YD.setStyle(photoBarBg,'width',0);}
break;case'bottom':if(parseInt(YD.getStyle(photoBarBg,'height'),10)>0){YD.setStyle(photoBarBg,'height',0);}
break;}
photoHoveringAnimation=new YAHOO.util.Anim(photoBarBg,attr,.5,YAHOO.util.Easing.backOut);photoHoveringAnimation.onComplete.subscribe(function(e){if(Yua.ie===6){var postArray=[];postArray.tool='smugPopular';postArray.ImageID=photoImageID;postArray.ImageKey=photoImageKey;ajax_query(smugPopularResponse,'/rpc/gallery.mg',postArray,true);}
if(photoHovering){YD.setStyle('photoBarContent','visibility','visible');}});photoHoveringAnimation.animate();}
function watchPhotoBar(e,photoID){if(!e){e=window.event;}
var posX=0;var posY=0;if(e.pageX||e.pageY){posX=e.pageX;posY=e.pageY;}else if(e.clientX||e.clientY){posX=e.clientX+document.documentElement.scrollLeft;posY=e.clientY+document.documentElement.scrollTop;}
var photoId=YD.get(photoID);var photoXY=YD.getXY(photoId);var photoBarBg=YD.get('photoBarBg');var barXY=YD.getXY(photoBarBg);if(YD.inDocument('photoBarBg')){if((posX+3<photoXY[0]||posX-3>parseInt(photoId.offsetWidth+photoXY[0],10)||posY+3<photoXY[1]||posY-3>parseInt(photoId.offsetHeight+photoXY[1],10))&&(posX+3<barXY[0]||posX-3>parseInt(photoBarBg.offsetWidth+barXY[0],10)||posY+3<barXY[1]||posY-3>parseInt(photoBarBg.offsetHeight+barXY[1],10))){closePhotoBar();}}else if(posX+3<photoXY[0]||posX-3>parseInt(photoId.offsetWidth+photoXY[0],10)||posY+3<photoXY[1]||posY-3>parseInt(photoId.offsetHeight+photoXY[1],10)){clearTimeout(photoBarTimeout);YE.removeListener(document,'mousemove',watchPhotoBar);}}
function closePhotoBar(){clearTimeout(photoBarTimeout);YE.removeListener(document,'mousemove',watchPhotoBar);photoHovering=false;var photoBarBg=YD.get('photoBarBg');if(photoBarBg){if(photoHoveringAnimation.isAnimated()){photoHoveringAnimation.stop();}
YD.setStyle(YD.get('photoBarContent'),'visibility','hidden');var position=SM.PhotoBar.config.position||'right';switch(position){case'right':var attr={'width':{'to':0},'left':{'by':photoBarBg.offsetWidth}};break;case'bottom':var attr={'height':{'to':0}};break;}
closingPhotoBar=new YAHOO.util.Anim(photoBarBg,attr,.5,YAHOO.util.Easing.backIn);if(Yua.ie===6){closingPhotoBar.onComplete.subscribe(function(e){if(YD.getStyle('lightBoxStage','display')!=="block"){YD.setStyle('photoTools','visibility','visible');}});}
closingPhotoBar.animate();}}
function exifDetails(imageId,imageKey){var cCtx=SM.currentContext;var imageId_Key=imageId+'_'+imageKey;if(!cCtx.exifBox){cCtx.exifBox=new SM.photo.ExifBox({'imageId_Key':imageId_Key,'autoPosition':true,'positionAnchor':'displayPhoto','draggable':true});cCtx.exifBox.open();}else if(cCtx.exifBox.get('visible')){cCtx.exifBox.close();}else{cCtx.exifBox.set('imageId_Key',imageId_Key);cCtx.exifBox.open();}}
var smugPopularPhoto="";var smugPopularTimeout='';function smugPopular(photoID,ImageID,ImageKey,waited){if(!displaySmugPopular){return;}
if(!YD.hasClass(document.body,'smugmug_ajax')||(photoInfo[ImageID]!==undefined&&photoInfo[ImageID].displayPopular)){if(!YD.hasClass(document.body,'smugmug_ajax')||lightBoxOn===true){photoHovering=true;}
if(pageLoaded&&displaySmugPopular){if(waited!==true){YE.addListener(document,'mousemove',watchMouseOverPhoto,photoID);smugPopularTimeout=setTimeout("smugPopular('"+photoID+"', '"+ImageID+"', '"+ImageKey+"', true)",500);}else{smugPopularPhoto=photoID;if(!YD.inDocument('smugPopular')&&photoHovering===true){var body=document.body;var smugPopular=document.createElement("div");var smugPopularContent=document.createElement("div");smugPopular.setAttribute("id","smugPopular");smugPopularContent.setAttribute("id","smugPopularContent");body.appendChild(smugPopular);body.appendChild(smugPopularContent);var popPhoto=YD.get(smugPopularPhoto);var photoWrapper=YD.get('photoWrapper');YD.setStyle(smugPopular,'zIndex',getZindex(popPhoto));YD.setStyle(smugPopularContent,'zIndex',getZindex(smugPopular));if(YD.hasClass(document.body,'singleImage')&&YD.hasClass(document.body,'Original')&&photoWrapper.offsetWidth<popPhoto.offsetWidth){YD.setX(smugPopular,YD.getX(photoWrapper)+photoWrapper.offsetWidth-smugPopular.offsetWidth-5);YD.setX(smugPopularContent,YD.getX(smugPopular));}else{YD.setX(smugPopular,YD.getX(popPhoto)+popPhoto.offsetWidth-smugPopular.offsetWidth-5);YD.setX(smugPopularContent,YD.getX(smugPopular));}
YD.setY(smugPopular,YD.getY(popPhoto)+parseInt(YD.getStyle(smugPopularPhoto,'borderTopWidth'),10));YD.setY(smugPopularContent,YD.getY(smugPopular));var myAnim=new YA('smugPopular',{'height':{'to':70}},.3,YAHOO.util.Easing.backOut);myAnim.onComplete.subscribe(function(e){var postArray=[];postArray.tool='smugPopular';postArray.ImageID=ImageID;postArray.ImageKey=ImageKey;ajax_query(smugPopularResponse,'/rpc/gallery.mg',postArray,true);});myAnim.animate();}}}}}
function smugPopularResponse(response){if(YD.inDocument('smugPopular')){YD.get('smugPopularContent').innerHTML=response;YD.setStyle(YD.get('smugPopularContent'),'visibility','visible');}
if(YD.inDocument('photoRank')&&response.indexOf('prepLBimg')!==0){YD.get('photoRank').innerHTML='<h4>PhotoRank</h4>'+response;}}
var smugPopularTotal=0;function showSmugPopular(total){}
function smugPopularVote(Side,ImageID,ImageKey){var postArray=[];postArray.tool='smugPopularVote';postArray.ImageID=ImageID;postArray.ImageKey=ImageKey;postArray.Side=Side;if(YD.inDocument('smugPopularContainer')){postArray.newPopular=true;}else{postArray.newPopular=false;}
ajax_query(smugPopularResponse,'/rpc/gallery.mg',postArray,true);}
function watchMouseOverPhoto(e,photoID){if(!e){e=window.event;}
var posX=0;var posY=0;if(e.pageX||e.pageY){posX=e.pageX;posY=e.pageY;}else if(e.clientX||e.clientY){posX=e.clientX+document.documentElement.scrollLeft;posY=e.clientY+document.documentElement.scrollTop;}
var photoId=YD.get(photoID);var photoXY=YD.getXY(photoId);if(posX+3<YD.getX(YD.get(photoID))||posX-3>parseInt(photoId.offsetWidth+photoXY[0],10)||posY+3<photoXY[1]||posY-3>parseInt(photoId.offsetHeight+photoXY[1],10)){closeSmugPopular();}}
function closeSmugPopular(){clearTimeout(smugPopularTimeout);YE.removeListener(document,'mousemove',watchMouseOverPhoto);if(YD.inDocument('smugPopular')){YD.setStyle(YD.get('smugPopularContent'),'visibility','hidden');var myAnim=new YA('smugPopular');myAnim.attributes.height={to:0};myAnim.duration=.3;myAnim.method=YAHOO.util.Easing.backIn;myAnim.onComplete.subscribe(function(e){if(YD.inDocument('smugPopular')){removeFromDOM('smugPopular');removeFromDOM('smugPopularContent');}});myAnim.animate();smugPopularPhoto="";smugVote="";}}
function getProPrices(AlbumID,ImageID,Type,AlbumKey,ImageKey){pageWorking('Getting Album Prices');var postArray=[];postArray.tool='getProPrices';postArray.ImageID=ImageID;postArray.ImageKey=ImageKey;postArray.AlbumID=AlbumID;postArray.AlbumKey=AlbumKey;postArray.Type=Type;ajax_query(handleJS,location.protocol+'//'+location.hostname+'/hack/RPC/tools.mg',postArray,true);}
YE.addListener(document,"keyup",function(e){if(YE.getTarget(e).nodeName.toLowerCase()==="input"||YE.getTarget(e).nodeName.toLowerCase()==="textarea"||e.metaKey){return;}
if(e.keyCode===72&&YD.inDocument('hidePhotoTool')){hidePhoto(null,ImageID,ImageKey);}});function hidePhoto(status,ImageID,ImageKey){var postArray=[];postArray.ImageID=ImageID;postArray.ImageKey=ImageKey;if(status===true){postArray.Action="Hide";}else if(status===false){postArray.Action="Unhide";}else{var hidePhotoBox=YD.get('hidePhotoTool');if(hidePhotoBox.checked){hidePhotoBox.checked=false;postArray.Action="Unhide";}else{hidePhotoBox.checked=true;postArray.Action="Hide";}}
if(galleryStyle==="smugmug"){if(postArray.Action==="Hide"){photoInfo[ImageID].Status='Hidden';}els