var photoalbum=$.inherit(Module,{__constructor:function(elem){this.__base(elem); this.type="photoalbum";this.slideBinOffset=0;this.currentPage=0;this.slideshowId=0;this.slideshowTimer=null;this.draggingTd=null;this.canDelSlide=null;this.isDelSlide=false;this.showspams=false;this.resizeBy=null;this.minWidth=160;this.maxWidth=600;this.hideSlideWidth=300;this.cacheDims=[];this.thumbX=558;this.thumbY=400;var tmp=this;this.addEventListener('showManage',function(e){tmp.onLightbox(e);});this.addEventListener('retrieveRemaining',function(e){tmp.onRetrieveRemaining(e);});this.addEventListener('getComments',function(e){tmp.setCommentsHTML(e);});this.addEventListener('saveRename',function(e){tmp.onSaveRename(e);});this.addEventListener('managePhotos',function(e){tmp.onManagePhotos(e);});this.addEventListener('rotatePhoto',function(e){tmp.onRotatePhoto(e);});this.addEventListener('addMediaByIds',function(e){tmp.onAddMediaByIds(e);});this.addEventListener('deletePhotos',function(e){tmp.onDeletePhotos(e);});this.addEventListener('switchPhoto',function(e){tmp.onSwitchPhoto(e);});

// Bind the "editLink" links to functionality in this class
var _this = this;
$('[id*=editLink]').live('click', function(e) {
	e.preventDefault();
	var thisCommentBody = $('#commentBody' + $(this).attr('id').replace('editLink', ''));
	var thisCommentId = $(this).attr('id').replace('editLink', '').split('_')[1];
	var thisPhotoalbumId = _this.id;
	var thisCommentSpan = thisCommentBody.find('span');

	var editFormHTML = '<form class="commentEditForm">\
				<textarea style="width: 100%; height: 100px;">' + $.trim(thisCommentBody.find('span').html()) + '</textarea>\
				<input type="button" class="editCommentSubmitButton" value="Submit" />\
				<input type="button" class="editCommentCancelButton" value="Cancel" />\
			    </form>';
				
	// Hide the span with the current comment
	thisCommentSpan.hide();

	// Add the comment editing div
	$('<div class="commentEditDiv"></div>')
		.attr('id', 'editing_' + thisCommentId)
		.css({ 'width': '100%' })
		.append(editFormHTML)
		.appendTo(thisCommentBody);

	// Submit button
	$('.editCommentSubmitButton', thisCommentBody).click(function() {
		var formOptions = { id: thisCommentId, comment: $('.commentEditForm').find('textarea').val() };

		var nb=NotifyQueue.addWaitMessage("Saving comment...");

		$.post('/adm/ajax.php?a=editComment&m=' + thisPhotoalbumId, formOptions, 
			function() {
				// Refresh this comment
				thisCommentSpan.html(formOptions.comment).show();
				$('.commentEditDiv').remove();
				nb.setIcon("success");
				nb.setMessage("Comment Saved");
				nb.finish();
			},
			'json'
		);
	});

	// Cancel button
	$('.editCommentCancelButton', thisCommentBody).click(function() {
		$('.commentEditDiv').remove();
		thisCommentSpan.show();
	});
});

// Bind the "editLink" links to functionality in this class
$('[id*=deleteLink]').live('click', function(e) {
	e.preventDefault();
	var thisCommentAll = $(this).parents('.commentAll');
	var thisCommentBody = $('#commentBody' + $(this).attr('id').replace('deleteLink', ''));
	var thisCommentId = $(this).attr('id').replace('editLink', '').split('_')[1];
	var thisPhotoalbumId = _this.id;
	var thisCommentSpan = thisCommentBody.find('span');


	// Show a confirm dialog
	var sure = confirm("Are you sure you'd like to delete this comment?");

	if (sure) {
		var nb=NotifyQueue.addWaitMessage("Deleting comment...");
		var formOptions = { id: thisCommentId };

		$.post('/adm/ajax.php?a=deleteComment&m=' + thisPhotoalbumId, formOptions,
			function() {
				// Remove the comment div
				thisCommentAll.remove();

				// Decrement the "comments on this photo" text
				var numCommentsSpan = $('[id*=numComments]', _this.container);
				numCommentsSpan.html(parseInt(numCommentsSpan.html()) - 1);

				// Show success message
				nb.setIcon("success");
				nb.setMessage("Comment Deleted");
				nb.finish();
			},
			'json'
		);
	}
});

// Bind the "Leave a comment" link
$('[id*=leaveCommLink]').live('click', function(e) {
	e.preventDefault();
	alert("Please visit your published site to leave a comment.");
});

},


getMainId:function(){return parseInt(document.getElementById("mainId"+this.instId).innerHTML);},checkPhoto:function(){this.soonHideControls();var str=document.location+'';if(str.match(/\#photo/)=="#photo"){var arr=str.split("#photo");var id=arr[arr.length-1];if(id.length>0){return this.switchPhoto(id,true,true);}}
var firstId=this.getMainId();if(firstId!=0){document.getElementById("photo"+this.instId+"_"+firstId).className+=" selected ";return this.switchPhoto(firstId,true,true);}},showControls:function(){this.clearControlTimer();var bg=document.getElementById("infoBarBg"+this.instId);if(bg){if(bg.style.display!="none")return;bg.style.display="";}
var p=document.getElementById("infoBarP"+this.instId);if(p){$(p).fadeIn("fast");p.style.display="";}},soonHideControls:function(){this.controlTimer=setTimeout(this.jsObj+".hideControls()",1500);},hideControls:function(){var p=document.getElementById("infoBarP"+this.instId);if(p){$(p).fadeOut("fast");}
var bg=document.getElementById("infoBarBg"+this.instId);if(bg){bg.style.display="none";}
this.clearControlTimer();},clearControlTimer:function(){if(this.controlTimer){clearTimeout(this.controlTimer);this.controlTimer=null;}},displayPopup:function(id){document.getElementById("popupImg"+this.instId).src=document.getElementById("smallurl"+this.instId+"_"+id).value;var phot=document.getElementById("photo"+this.instId+"_"+id);var abs1=[$(phot).position().top,$(phot).position().left];var abs2=[$(phot.parentNode).position().top,$(phot.parentNode).position().left];var offsetx=abs1[0]-abs2[0]+this.slideBinOffset;var popup=document.getElementById("popup"+this.instId);var dim=[$(popup).width(),$(popup).height()];var offsety=dim[1];popup.style.left=(23+offsetx)+"px";popup.style.top=(-120+(110-offsety))+"px";popup.style.display="";},hidePopup:function(id){document.getElementById("popup"+this.instId).style.display="none";document.getElementById("popupImg"+this.instId).src="";},getCurrentPhotoComments:function(){ var curr=document.getElementById("photo"+this.instId+"_"+this.slideshowId);if(curr){var id=this.getPhotoId(curr);this.getComments(id);}},getComments:function(id){ this.lyAjaxObj({showspams:(this.showspams?"yes":"no"),id:id,region:this.region},"getComments");},retrieveRemaining:function(postRetrieveCheck){var perslide=9;var photos=[];if(this.retrieveOffset>=this.allToRetrieve.length){return;}
for(var i=this.retrieveOffset;i<this.retrieveOffset+perslide&&i<this.allToRetrieve.length;i++){photos.push(this.allToRetrieve[i]);}
this.retrieveOffset+=perslide;var count=parseInt(document.getElementById("photoBinCount"+this.instId).innerHTML);var pages=parseInt(count/perslide);var fullCount=document.getElementById("photoBinFullCount"+this.instId);if(count%9==0&&fullCount.innerHTML==0&&photos.length>0){fullCount.innerHTML="retrieving";this.lyAjaxObj({"photos":photos,"check":(postRetrieveCheck?true:false)},"retrieveRemaining");}},switchPhoto:function(id,changeLoc,switchData){this.resizeBy=null;if(!this.selectPhoto(id)){this.retrieveRemaining(true);return false;}
this.slideshowId=id;if(changeLoc)
window.location.hash="#photo"+id;document.getElementById("viewSpanNoComments"+this.instId).style.display="none";document.getElementById("viewSpan"+this.instId).style.display="none";if(switchData){this.pauseSlideshow();document.getElementById("switchingTo"+this.instId).innerHTML=id;this.lyAjaxObj({showspams:(this.showspams?"yes":"no"),id:id,region:this.region},"switchPhoto");}
else{document.getElementById("acl"+this.instId).value="N";}
document.getElementById("comments_"+this.instId).innerHTML="";return false;},findSlideshowId:function(last){if(this.slideshowId==0){var bin=document.getElementById("photoBin"+this.instId);var divs=bin.getElementsByTagName("li");if(divs.length>0){if(last)
this.slideshowId=this.getPhotoId(divs[divs.length-1]);else
this.slideshowId=this.getPhotoId(divs[0]);}}
return this.slideshowId;},jumpLeft:function(){this.pauseSlideshow();var curr=document.getElementById("photo"+this.instId+"_"+this.findSlideshowId());if(curr){var next=curr.previousSibling;while(next&&(next.nodeType!=1||next.tagName!="LI")){next=next.previousSibling;}
if(next)
this.switchPhoto(this.getPhotoId(next),true,true);else{this.slideshowId=0;this.switchPhoto(this.findSlideshowId(true),true,true);}}
return false;},jumpRight:function(){this.pauseSlideshow();this.retrieveRemaining();var curr=document.getElementById("photo"+this.instId+"_"+this.findSlideshowId());if(curr){var next=curr.nextSibling;while(next&&(next.nodeType!=1||next.tagName!="LI")){next=next.nextSibling;}
if(next)
this.switchPhoto(this.getPhotoId(next),true,true);else{this.slideshowId=0;this.switchPhoto(this.findSlideshowId(),true,true);}}
return false;},slideshow:function(){if(this.slideshowTimer==null){document.getElementById("slideshowText"+this.instId).innerHTML="pause"+(this.region=="sidebar"?"":" slideshow");if(!this.startSlideshow()){document.getElementById("slideshowText"+this.instId).innerHTML="play"+(this.region=="sidebar"?"":" slideshow");}}
else{this.pauseSlideshow();this.switchPhoto(this.slideshowId,true,true);}
return false;},startSlideshow:function(){if(this.slideshowId==0){var bin=document.getElementById("photoBin"+this.instId);var divs=bin.getElementsByTagName("li");if(divs.length==0)return false;this.switchPhoto(this.getPhotoId(divs[0]),false,false);this.slideshowTimer=setTimeout(this.jsObj+".runSlideshow()",3000);}
else{this.runSlideshow();}
return true;},pauseSlideshow:function(){document.getElementById("slideshowText"+this.instId).innerHTML="play"+(this.region=="sidebar"?"":" slideshow");clearTimeout(this.slideshowTimer);this.slideshowTimer=null;},runSlideshow:function(){if(this.slideshowId==0)return;var curr=document.getElementById("photo"+this.instId+"_"+this.slideshowId);var next=curr.nextSibling;while(next&&(next.nodeType!=1||next.tagName!="LI")){next=next.nextSibling;}
if(!next){var bin=document.getElementById("photoBin"+this.instId);var divs=bin.getElementsByTagName("li");if(divs.length==0){this.pauseSlideshow();return;}
next=divs[0];}
this.switchPhoto(this.getPhotoId(next),false,false);this.slideshowTimer=setTimeout(this.jsObj+".runSlideshow()",3000);if(this.toRetrieve){this.retrieveRemaining();this.toRetrieve=false;}
else{this.toRetrieve=true;}},slidePhotos:function(direction){var $bin=$("#photoBin"+this.instId);var numImages=$bin.find("li").length;var imgWidth=$bin.find("li").first().outerWidth(true);var screenLength=8;var screenWidth=screenLength*imgWidth;var numPages=Math.ceil(numImages/screenLength);if(((direction==1)&&(this.currentPage>0))||((direction==-1)&&(this.currentPage<numPages-1))){this.currentPage-=direction;var offset=direction*screenWidth;$("#photoBin"+this.instId).animate({left:"+="+offset},600);}
return false;},slideBinOver:function(){var bin=document.getElementById("photoBin"+this.instId);$(bin).animate("left",this.slideBinOffset+"px","fast");},selectPhoto:function(id){document.getElementById("switchingTo"+this.instId).innerHTML=0;var oldId=this.getMainId();if(oldId!=id&&document.getElementById("photo"+this.instId+"_"+id)){var offClass=document.getElementById("photo"+this.instId+"_"+id).className;var oldDiv=document.getElementById("photo"+this.instId+"_"+oldId);if(oldDiv!=undefined)
oldDiv.className=offClass;document.getElementById("photo"+this.instId+"_"+id).className=" selected "+offClass;}
document.getElementById("comments_"+this.instId).innerHTML="";if(document.getElementById("url"+this.instId+"_"+id)){document.getElementById("mainId"+this.instId).innerHTML=id;var url=document.getElementById("url"+this.instId+"_"+id).value;var desc=document.getElementById("desc"+this.instId+"_"+id).value;var ind=document.getElementById("index"+this.instId+"_"+id).value;var img=document.getElementById("mainImg"+this.instId);var tmp=this;img.onload=function(){tmp.setImageSize(this);};img.style.visibility="hidden";img.src=url;document.getElementById("mainDesc"+this.instId).innerHTML=desc;document.getElementById("mainIndex"+this.instId).innerHTML=ind;}
if(oldId==id||document.getElementById("photo"+this.instId+"_"+id))
return oldId;else
return 0;},setImageSize:function(img,newWidth,newHeight){var parentNode=img.parentNode;while(parentNode.tagName!='DIV'){parentNode=parentNode.parentNode;}
var imgW=0;var imgH=0;if(!img){img=document.getElementById("mainImg"+this.instId);}
var dims=Lycos.util.imageNaturalDimensions(img);if(dims[0]==0||dims[1]==0){setTimeout(this.jsObj+".setImageSize()",400);return;}
if(dims[0]>dims[1]){if(dims[0]<parseInt(parentNode.offsetWidth)){newWidth=dims[0];}
else{newWidth=parseInt(parentNode.offsetWidth);}
imgW=(newWidth-10)+"px";imgH="auto";}
else{if(dims[1]<parseInt(parentNode.offsetHeight)){newHeight=dims[1];}
else{newHeight=parseInt(parentNode.offsetHeight);}
imgH=(newHeight-10)+"px";imgW="auto";}
img.style.width=imgW;img.style.height=imgH;img.style.visibility='visible';},showAdd:function(){Lycos.ui.mediapicker.pick("callerid"+this.instId,null,'image',true);},showManage:function(){Lycos.ui.lightbox.show();this.lyAjaxObj({},"showManage");return false;},deletePhoto:function(){var id=this.getMainId();if(id!=0){resp=confirm("Would you like to remove this photo from the album?");if(resp){this.lyAjaxObj({photos:{id:id}},"deletePhotos");}}
return false;},getPhotoId:function(elem){if(!elem)return 0;var loc=elem.id.indexOf("_");return elem.id.substr(loc+1);},startRenamePhoto:function(){if(this.getMainId()==0)
return;this.pauseSlideshow();var desc=document.getElementById("mainDesc"+this.instId);var tmp=this;var f=desc.ownerDocument.createElement("form");f.id="mainDescEditForm"+this.instId;f.onsubmit=function(event){tmp.saveRename();};var i=desc.ownerDocument.createElement("input");i.id="mainDescEdit"+this.instId;i.value=desc.innerHTML;i.onblur=function(event){tmp.saveRename();};desc.style.display="none";desc.parentNode.insertBefore(f,desc);f.appendChild(i);i.focus();i.select();},rotatePhoto:function(id){var id=this.getMainId();if(id!=0){var img=document.getElementById("mainImg"+this.instId);img.src="/adm/media/ajax-loader.gif";img.style.width="auto";img.style.height="auto";document.getElementById("photo"+this.instId+"_"+id).style.backgroundImage="";this.resizeBy=null;this.cacheDims[id+"_"]=null;this.lyAjaxObj({id:id},"rotatePhoto");}
return false;},saveRename:function(){var desc=document.getElementById("mainDesc"+this.instId);var newValue=document.getElementById("mainDescEdit"+this.instId).value;var frm=document.getElementById("mainDescEditForm"+this.instId);if(frm)frm.parentNode.removeChild(frm);document.getElementById("mainDesc"+this.instId).style.display="";if(newValue!=desc.innerHTML){desc.innerHTML="...";this.lyAjaxObj({id:this.getMainId(),newDescription:newValue},"saveRename");}
return false;},lyHandleEvents:function(data){if(data.action=="addMediaByArray"){Lycos.ui.lightbox.show();var newids=[];for(var i=0;i<data.items.length;i++){newids.push(data.items[i].id);}
this.lyAjaxObj({ids:newids,tag:data.tag},"addMediaByIds");}
else if(data.action=="done")
Lycos.ui.lightbox.hide();return;},handleAddMedia:function(photos,noIncrement){if(photos==null)
return 0;var addCount=0;var currCount=parseInt(document.getElementById("photoBinCount"+this.instId).innerHTML)+1;var bin=document.getElementById("photoBin"+this.instId);for(i=0;i<photos.length;i++){bin.innerHTML+="<li id=\"photo"+this.instId+"_"+photos[i].id+"\" class=\"addOnBorder\" onMouseOver=\""+this.jsObj+".displayPopup("+photos[i].id+")\" onMouseOut=\""+this.jsObj+".hidePopup()\" onClick=\"return "+this.jsObj+".switchPhoto("+photos[i].id+", true, true);\"><span class=\"pad\"><img src=\""+photos[i].thumbURL+"\" /></span><input type=\"hidden\" id=\"index"+this.instId+"_"+photos[i].id+"\" value=\""+(currCount++)+"\" /><input type=\"hidden\" id=\"url"+this.instId+"_"+photos[i].id+"\" value=\""+photos[i].largeURL+"\" /><input type=\"hidden\" id=\"smallurl"+this.instId+"_"+photos[i].id+"\" value=\""+photos[i].thumbURL+"\" /><input type=\"hidden\" id=\"desc"+this.instId+"_"+photos[i].id+"\" value=\""+photos[i].caption+"\" />";addCount++;}
document.getElementById("photoBinCount"+this.instId).innerHTML=currCount-1;if(!noIncrement){var newCount=parseInt(document.getElementById("mainCount"+this.instId).innerHTML)+addCount;document.getElementById("mainCount"+this.instId).innerHTML=newCount;document.getElementById("photoBg"+this.instId).className=document.getElementById("photoBg"+this.instId).className.replace(/ gray/,'')+(newCount>0?"":" gray");}
return addCount;},slideToFirst:function(noSwitch){var curroffset=parseInt(document.getElementById("photoBinOffset"+this.instId).innerHTML);var bin=document.getElementById("photoBin"+this.instId);var divs=bin.getElementsByTagName("li");if(divs.length>0){if(!noSwitch){var firstId=this.getPhotoId(divs[0]);this.switchPhoto(firstId,true,true);}
this.slidePhotos(-1*(curroffset));}
else{document.getElementById("mainId"+this.instId).innerHTML=0;document.getElementById("comments_"+this.instId).innerHTML="";document.getElementById("mainImg"+this.instId).src="";document.getElementById("mainImg"+this.instId).style.visibility="hidden";document.getElementById("mainIndex"+this.instId).innerHTML="0";document.getElementById("mainDesc"+this.instId).innerHTML="This album has no photos";document.getElementById("acl"+this.instId).value="N";this.slideshowId=0;}
document.getElementById("mainCount"+this.instId).innerHTML=divs.length;document.getElementById("photoBg"+this.instId).className=document.getElementById("photoBg"+this.instId).className.replace(/ gray/,'')+(divs.length>0?"":" gray");},onAddComment:function(evt){if(evt.lyResponse.isedit=="yes")return;if(typeof(evt.lyResponse.error)=='undefined'){commentCount=parseInt(document.getElementById("numComments"+this.instId).innerHTML)+1;document.getElementById("numComments"+this.instId).innerHTML=commentCount;document.getElementById("viewSpanNoComments"+this.instId).style.display="none";document.getElementById("viewSpan"+this.instId).style.display="inline";}},onDeleteComment:function(evt){commentCount=parseInt(document.getElementById("numComments"+this.instId).innerHTML)-1;if(commentCount<=0){commentCount=0;document.getElementById("viewSpanNoComments"+this.instId).style.display="inline";document.getElementById("viewSpan"+this.instId).style.display="none";}
document.getElementById("numComments"+this.instId).innerHTML=commentCount;},onMarkCommentAsSpam:function(evt){objNumSpams=document.getElementById("numSpams"+this.instId);spamCount=parseInt(objNumSpams.innerHTML)+1;document.getElementById("viewSpam"+this.instId).style.display="inline";objNumSpams.innerHTML=spamCount;this.onDeleteComment(evt);},onUnmarkCommentAsSpam:function(evt){objNumSpams=document.getElementById("numSpams"+this.instId);spamCount=parseInt(objNumSpams.innerHTML)-1;if(spamCount<=0){spamCount=0;document.getElementById("viewSpam"+this.instId).style.display="none";}
objNumSpams.innerHTML=spamCount;this.onAddComment(evt);},setShowSpams:function(b){this.showspams=b;},toggleShowSpams:function(){this.showspams=!this.showspams;this.getCurrentPhotoComments();},setCommentsHTML:function(data){ if(data.commentCount>0){document.getElementById("viewSpanNoComments"+this.instId).style.display="none";document.getElementById("viewSpan"+this.instId).style.display="inline";}
else{document.getElementById("viewSpan"+this.instId).style.display="none";document.getElementById("viewSpanNoComments"+this.instId).style.display="inline";}
try{if(data.spamCount>0){document.getElementById("viewSpam"+this.instId).style.display="inline";}
else{document.getElementById("viewSpam"+this.instId).style.display="none";}
document.getElementById("numSpams"+this.instId).innerHTML=data.spamCount;document.getElementById("showSpamsLink"+this.instId).innerHTML=this.showspams?"hide":"show";}
catch(e){}
document.getElementById("numComments"+this.instId).innerHTML=data.commentCount;document.getElementById("comments_"+this.instId).innerHTML=data.commentsHTML;},onLightbox:function(evt){var data=evt.lyResponse;Lycos.ui.lightbox.show();Lycos.ui.lightbox.populate(data.html);if(data.onshow)eval(data.onshow);},onRetrieveRemaining:function(evt){document.getElementById("photoBinFullCount"+this.instId).innerHTML=0;if(evt.lyResponse.photos.length>0){this.handleAddMedia(evt.lyResponse.photos,true);}
else{document.getElementById("photoBinFullCount"+this.instId).innerHTML=1;}
if(evt.lyResponse.check){this.checkPhoto();}},onSwitchPhoto:function(evt){ this.cachedEvt = evt; var data=evt.lyResponse;if((data.subinstance+"")!=(document.getElementById("switchingTo"+this.instId).innerHTML+"")){return;}
if(this.getMainId()!=data.subinstance)
this.selectPhoto(data.subinstance);document.getElementById("acl"+this.instId).value=data.acl;if(data.commentsId>0){this.setCommentsHTML(data);document.getElementById("comments_"+this.instId).style.display="";var instance=Lycos.webon.getInstance('comments',parseInt(data.commentsId),data.subinstance);if(!instance){return;}
if(!instance["init_cb_"+this.instId]){instance["init_cb_"+this.instId]=true;var tmp=this;instance.addEventListener("editComment",function(e){tmp.onAddComment(e);});instance.addEventListener("approve",function(e){tmp.onAddComment(e);});instance.addEventListener("delete",function(e){tmp.onDeleteComment(e);});instance.addEventListener("markSpam",function(e){tmp.onMarkCommentAsSpam(e);});instance.addEventListener("unmarkSpam",function(e){tmp.onUnmarkCommentAsSpam(e);});}
instance.jsWindow=this.jsWindow;if(this.jsWindow.initTinyMCE)
this.jsWindow.initTinyMCE();}
if(data.raterId!=0){if(typeof(raterObj[data.raterId])=="undefined"){raterObj[data.raterId]=new Object();raterObj[data.raterId][data.subinstance]=Lycos.webon.getInstance("rater",data.raterId,data.subinstance);}}},onSaveRename:function(evt){var data=evt.lyResponse;document.getElementById("mainDesc"+this.instId).innerHTML=data.newDescription;document.getElementById("desc"+this.instId+"_"+data.id).value=data.newDescription;;},onManagePhotos:function(evt){Lycos.ui.lightbox.hide();document.getElementById("photoCover"+this.instId).innerHTML=evt.lyResponse.html;this.slideToFirst();},onRotatePhoto:function(evt){var data=evt.lyResponse;var mudge="?z="+(new Date()).getTime();document.getElementById("url"+this.instId+"_"+data.id).value=data.largeThumb+mudge;document.getElementById("smallurl"+this.instId+"_"+data.id).value=data.smallThumb+mudge;var img=document.getElementById("mainImg"+this.instId);var tmp=this;img.onload=function(){tmp.setImageSize(this);};img.src=data.largeThumb+mudge;img.style.width="auto";img.style.height="auto";document.getElementById("photo"+this.instId+"_"+data.id).style.backgroundImage="url("+data.smallThumb+mudge+")";},onAddMediaByIds:function(evt){var photos=evt.lyResponse.photos;Lycos.ui.lightbox.hide();var curroffset=parseInt(document.getElementById("photoBinOffset"+this.instId).innerHTML);var count=parseInt(document.getElementById("photoBinCount"+this.instId).innerHTML);var pages=parseInt((count)/this.perslide);if(this.handleAddMedia(photos)>0){this.switchPhoto(photos[0].id,false,true);this.slidePhotos((curroffset-pages));}},onDeletePhotos:function(evt){var data=evt.lyResponse;Lycos.ui.lightbox.hide();var curr=this.getMainId();var delCount=0;for(i=0;i<data.photos.length;i++){if(data.photos[i].id==curr)
curr=0;var x=document.getElementById("photo"+this.instId+"_"+data.photos[i].id);x.parentNode.removeChild(x);delCount++;}
document.getElementById("photoBinCount"+this.instId).innerHTML=parseInt(document.getElementById("photoBinCount"+this.instId).innerHTML)-delCount;var newCount=parseInt(document.getElementById("mainCount"+this.instId).innerHTML)-delCount;document.getElementById("mainCount"+this.instId).innerHTML=newCount;document.getElementById("photoBg"+this.instId).className=document.getElementById("photoBg"+this.instId).className.replace(/ gray/,'')+(newCount>0?"":" gray");this.reindexPhotoSlide();var curroffset=parseInt(document.getElementById("photoBinOffset"+this.instId).innerHTML);var count=parseInt(document.getElementById("photoBinCount"+this.instId).innerHTML);var pages=parseInt((-1*count)/this.perslide);this.slidePhotos(-1*(curroffset-pages));if(curr==0){this.slideToFirst();}},reindexPhotoSlide:function(){var bin=document.getElementById("photoBin"+this.instId);var photos=bin.getElementsByTagName("li");for(var i=0;i<photos.length;i++){var id=photos[i].id.replace(/photo/,"index");document.getElementById(id).value=i+1;}},recalculatePerSlide:function(newWidth){newWidth=newWidth-84;var newPerSlide=parseInt(newWidth/55);if(newPerSlide>2&&newPerSlide<15)
this.perslide=newPerSlide;},lyOnResizing:function(newWidth,newHeight){Lycos.ui.regionCtrl.startResizePos.minWidth=Math.max(this.minWidth,Lycos.ui.regionCtrl.startResizePos.minWidth);Lycos.ui.regionCtrl.startResizePos.maxWidth=Math.min(this.maxWidth,Lycos.ui.regionCtrl.startResizePos.maxWidth);newWidth=Math.max(this.minWidth,newWidth);newWidth=Math.min(this.maxWidth,newWidth);if(newWidth>=this.hideSlideWidth){document.getElementById("photoCover"+this.instId).style.display="";document.getElementById("slideshowText"+this.instId).style.display="";}
else{document.getElementById("photoCover"+this.instId).style.display="none";document.getElementById("slideshowText"+this.instId).style.display="none";}
newHeight=parseInt(newWidth*this.thumbY/this.thumbX);document.getElementById("photoBg"+this.instId).style.width=newWidth+"px";document.getElementById("photoBg"+this.instId).style.height=newHeight+"px";document.getElementById("photoCover"+this.instId).style.width=(newWidth-84)+"px";newWidth-=30;newHeight=parseInt(newWidth*this.thumbY/this.thumbX);this.cacheDims=[];this.setImageSize(img);},lyOnResize:function(newWidth,newHeight){this.slideToFirst(true);this.recalculatePerSlide(newWidth);}});

