function Picture(page, id, pos, color, pic, alt, free,layerZone){this.page= page;this.app= this.page.app;if(!this.app.pictures[id]){this.id= id
this.type= PICTURE_TYPE
this.index= this.app.pictures.length;this.appObjectModelPath= APP_NAME + ".pictures[" + this.index + "]"
this.changePic= changePic;this.alt= alt?alt:"";this.free= free
this.size= null;this.pic= null;this.html= "";this.changePic(pic)
this.pos= (!pos?this.app.WORKSPACE_COORD1.getCopy():pos.getCopy());this.frameWidth= 0;this.frameColor= color= !color?null:color;this.layer= this.app.createLayer(page, id + "Picture", this.pos, this.size, color, false, (this.free?layerZone:EMBEDDED_PICTURES_ZINDEX_ZONE));this.layer.ownerObject= this;this.layer.nextHtml= this.html;this.makeFrame= makeFrame;this.use= use;this.show= showPicture;this.hide= this.layer.hide;this.setColor=this.layer.setColor;this.setScrClip=this.layer.setScrClip
this.slideCircle= this.layer.slideCircle;this.moveTo= moveToPicture
this.addLink= addLinkPicture
this.app.pictures[this.app.pictures.length]= this.app.pictures[id]= this}else{return this.app.pictures[id]}
return this}
function showPicture(noFade){this.layer.rewrite(this.html,'middle','center');this.layer.show(noFade)}
function changePic(pic){if(pic){var prei= (pic.type==PREIMAGE_TYPE?pic:this.app.preImages[pic]);var lnk= (pic.type==LINK_TYPE?pic:this.app.links[pic]);pic= prei?prei:lnk;if(pic && this.pic!=pic){this.pic= pic
this.size= this.pic.size.getCopy()
this.html= this.pic.getHtml(this.size,this.alt)
if(this.layer)this.layer.nextHtml= this.html
if(this.pic.type==PREIMAGE_TYPE)this.page.assignPreImage(this.pic)}}else{this.size= this.app.WORKSPACE_SIZE.getCopy()}}
function use(pic,alt, pos,frameWidth,frameColor){var newPage= (!this.free || this.page!=this.app.mainPage?(this.app.nextPage?this.app.nextPage:this.app.curPage):this.page);if(this.page!=newPage){this.page=newPage;this.page.assignLayer(this.layer)}
this.alt= alt?alt:this.alt
this.changePic(pic)
this.makeFrame(pos,frameWidth,frameColor)
if(this.page==this.app.curPage)this.show()}
function makeFrame(pos,frameWidth,frameColor){this.moveTo(pos)
this.frameColor= frameColor;this.layer.setColor(frameColor);if(frameWidth && !isNaN(frameWidth)){this.frameWidth= frameWidth;if(this.size.width!=this.pic.size.width || this.size.height!=this.pic.size.height)this.size= this.pic.size.getCopy()
this.size.add(new Size(frameWidth*2,frameWidth*2))}else{this.frameWidth= 0}
this.layer.resize(this.size.width,this.size.height)}
function addLinkPicture(id, preImageOff, evalOnClick, label, alt, preImageOn, preImageSel, target, evalOnMouseOver, evalOnMouseOut,size){var pic= new Link(this.layer, id, preImageOff, evalOnClick, label, alt, preImageOn, preImageSel, target, evalOnMouseOver, evalOnMouseOut,size)
this.changePic(pic);return this.pic}
function moveToPicture(position){if(position && position.type==COORD_TYPE && (position.x!=this.pos.x || position.y!=this.pos.y)){this.pos= position;this.layer.moveTo(this.pos.x, this.pos.y)}}
