function photoHoverLeft(photoID,photoImageID,waited){var position=SM.PhotoBar.config.position||'right';var hoverPhoto=YD.get(photoID);if(SM.menus.menuOpen>0){return;}
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"&&(photoInfo[photoImageID].canEdit||(!photoInfo[photoImageID].canEdit&&!photoInfo[photoImageID]['protected']))){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.left,hoverRegion.top]);YD.setXY(photoBarContent,[hoverRegion.left-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.left-(hoverPhoto.offsetWidth/2)-(photoBarBg.offsetWidth/2),hoverRegion.bottom]);if(Yua.ie===6){YD.setXY(photoBarContent,[hoverRegion.left-(hoverPhoto.offsetWidth/2)-(photoBarBg.offsetWidth/2)+photoBarBg.childNodes[0].offsetWidth,hoverRegion.bottom+7]);}else{YD.setXY(photoBarContent,[hoverRegion.left-(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 photoHover(photoID, photoImageID, waited) {
   photoHoverLeft(photoID, photoImageID, waited);
};


// code to insert a download button for any gallery that has originals enabled

function IsSmugmugView()
{
    return(YD.hasClass(document.body, "smugmug"));
}

function IsGalleryPage()
{
	return(YD.hasClass(document.body, "galleryPage"));
}

onPhotoShow.subscribe(ProcessDownloadButton);

function ProcessDownloadButton()
{
	// set onlyInGalleries to true if you only want a download button in gallery views
	// set onlyInGalleries to false if you want a download button in other views too like (search, keywords, date, etc...)
	var onlyInGalleries = false;
	if (IsSmugmugView() && (IsGalleryPage() || !onlyInGalleries))
	{
		if (photoInfo[ImageID].albumOriginals && !photoInfo[ImageID]['protected'] && (photoInfo[ImageID].Format !== "MP4"))
		{
			var downloadParent = "cartButtonsWrapper";
			if (!document.getElementById("cartButtonsWrapper"))
			{
				downloadParent = "altViews";
			}
			InsertDownloadButton(downloadParent);
		}
		else
		{
			// disable the button
			var downloadButton = YAHOO.widget.Button.getButton("downloadButtonId");
			if (downloadButton)
			{
				downloadButton.set("disabled", true);
			}
		}
	}
}

function InsertDownloadButton(parentId)
{
	// now add the download button
	var parentDiv = document.getElementById(parentId);
	var downloadButton = document.getElementById("downloadButtonId");
	if (downloadButton)
	{
		// make sure it is enabled
	YAHOO.widget.Button.getButton("downloadButtonId").set("disabled", false);
	}
	else if (parentDiv)
	{
		var downloadButtonInfo =
		{
			id: "downloadButtonId",
			label: "Download Image...",
			container: parentDiv,
			type: "button",
			className: "sm-button sm-button-small themesButton glyphButton",
			onclick: { fn: InitiateDownloadImage }
		};
		
		var dButtonObj = new YAHOO.widget.Button(downloadButtonInfo);
	}
}

function InitiateDownloadImage()
{
	// construct the download URL
	window.location = "/photos/" + ImageID + "_" + ImageKey + "-D.jpg";
}


