var TRPhotoViewer=new Class({

	initialize:function(options){
		this.frameDiv=$(options.frameDivId);
		this.frameDiv.makeDraggable();
		this.src=options.src;
		this.im=null;
		this.targetIm=$(options.targetImId);
		this.frameHead=$(options.frameHeadId);
		this.frameCloseBtn=$(options.frameCloseBtnId);
		frameDiv=this.frameDiv;
		this.targetIm.onclick=this.frameCloseBtn.onclick=function(){
			frameDiv.setStyle('display','none');
		};
		this.frameDiv.oncontextmenu=function(){
			return false;
		};
	},
	
	place:function(){
		this.targetIm.src=this.src;
		this.targetIm.width=0;
		
		this.frameDiv.setStyles({
			display:'block',
			width:this.im.width,
			top:this.srcImg.getTop()+200,
			left:(document.body.clientWidth-this.im.width)/2
		});
		this.targetIm.width=this.im.width;
		
		//alert(document.body.clientWidth+":"+document.body.offsetWidth);
	},
	
	setSrcImg:function(srcImg){
		this.srcImg=srcImg;
	},
	
	setSrc:function(src){
		this.src=src;
	},
	
	load:function(){
		this.im=new Image();
		this.im.src=this.src;
		if(this.im && this.im.width>0 && this.im.height>0){
			this.place();
		}else{
			var tmpFrame=this;
			this.im.onload=function(){
				tmpFrame.place();
			}
		}
	}
});
