var carousel;var dialog;var carouselInit=function(C,B){var D=B[0];var A=B[1];requestItems(D,(A-D+1)*2)};var carouselPrev=function(D,B){var E=B[0];var A=B[1];var C=B[2];if(!C){requestItems(E,(A-E+1)*2)}};var carouselNext=function(D,B){var E=B[0];var A=B[1];var C=B[2];if(!C){requestItems(E,(A-E+1)*2)}};var carouselButtonStateChanged=function(B,A){A[1].disabled=!A[0]};var onRequestItemsSuccess=function(A){var D=A.responseXML;if(D){var F=D.getElementsByTagName("photo");var E=A.argument[0];for(var B=0;B<F.length;B++){var C=buildPhoto(F[B]);carousel.addItem(E+B,C)}showButtons()}else{alert("Cannot load Photos")}};var onRequestItemsFailure=function(A){alert("Cannot request for photos")};var requestItems=function(D,A){var B="start="+D+"&limit="+A;var C={success:onRequestItemsSuccess,failure:onRequestItemsFailure,argument:[D,A]};YAHOO.util.Connect.asyncRequest("POST","/"+USERNAME+"/albums/"+ALBUM,C,B)};var buildPhoto=function(B){var E="";var A="";var C="";var D="";var G="";var F=0;var L=0;for(var I=0;I<B.attributes.length;I++){var J=B.attributes[I].name;var K=B.attributes[I].value;switch(J){case"id":E=K;break;case"src":A=K;break;case"name":C=K;break;case"url":D=K;break;case"date":G=K;break;case"width":F=K;break;case"height":L=K;break}}var H='<img src="'+A+'" title="'+C+'" alt="'+C+'" />';return'<a href="javascript:void(0)" onclick="photoClicked(\''+E+"', '"+D+"');return false\">"+H+"</a>"};var showButtons=function(){YAHOO.util.Dom.setStyle("prev-arrow","visibility","visible");YAHOO.util.Dom.setStyle("next-arrow","visibility","visible")};var photoClicked=function(B,A){if(B!=PHOTO){document.location=A}};var showThumbnail=function(E,C,B,D,A){var F=document.getElementById("photo_thumbnail");if(F){F.src=E;F.setAttribute("alt",C);document.getElementById("photo_name").innerHTML=C;document.getElementById("photo_date").innerHTML=B;document.getElementById("photo_width").innerHTML=D;document.getElementById("photo_height").innerHTML=A}};var enlargePhoto=function(C){var E=document.getElementById("photo_thumbnail");var B=parseInt(document.getElementById("photo_width").innerHTML);var A=parseInt(document.getElementById("photo_height").innerHTML);if(E){var D=(B>E.width+20||A>E.height+20)?E.src.replace("/m_","/l_"):E.src;if(dialog){dialog.destroy()}dialog=new YAHOO.widget.SimpleDialog("dialog",{width:(B+20)+"px",height:(A+50)+"px",fixedcenter:true,visible:false,draggable:false,modal:true,close:true,text:'<div style="height:'+(A+40)+'px;text-align:center"><span id="loading"><img src="/images/load.gif" /> Loading...</span><img src="'+D+'" onload="onLoadComplete(this)" style="display:none" /></div>',constraintoviewport:true});dialog.setHeader("Photo");dialog.render(document.body);dialog.show()}};var onLoadComplete=function(A){A.previousSibling.style.display="none";A.style.display=""};var init=function(){carousel=new YAHOO.extension.Carousel("dhtml-carousel",{prevElement:"prev-arrow",nextElement:"next-arrow",size:TOTAL,numVisible:SIZE,firstVisible:START,animationSpeed:0.7,scrollInc:SIZE,navMargin:10,loadInitHandler:carouselInit,loadPrevHandler:carouselPrev,loadNextHandler:carouselNext,prevButtonStateHandler:carouselButtonStateChanged,nextButtonStateHandler:carouselButtonStateChanged});YAHOO.util.Event.addListener(["photo_thumbnail","enlarge"],"click",enlargePhoto)};YAHOO.util.Event.onDOMReady(init);
