

	function PuzzleElement(x,y,w,h,imgw,imgh,imgx,imgy,img, ch,fontsizepercent, fontcol, fonttp) {
		this.Dynlayer=DynLayer;
		this.Dynlayer(null,x,y,w,h);

		this.img = img;
		this.imgx = imgx;
		this.imgy = imgy;
		this.imgw = imgw;
		this.imgh = imgh;
		
		if (fontsizepercent==null) fontsizepercent = 1;
		if (fontsizepercent<=0) fontsizepercent = 100;
		if (fontsizepercent>100) fontsizepercent = 100;
		this.fontcol = fontcol;
		this.fonttp = fonttp;
		this.fontsizepercent = fontsizepercent;

		
		this.ch = ch;
		
		this.onPreCreate(PuzzleElement.PreCreate);
		this.onCreate(function() { this.addEventListener(PuzzleElement.listener); });
//		DragEvent.enableDragEvents(this);

	}
	var p = dynapi.setPrototype('PuzzleElement','DynLayer');
	PuzzleElement.PreCreate = function() {
	//	this.setBgColor('#EEEEEE')	

		// create child layer for caption
		this.addChild(new DynLayer(null,this.imgx,this.imgy,this.imgw,this.imgh),'dyncaption');
		if (this.img!=null) {
			this.dyncaption.setHTML(this.img);
		}		
		if (this.ch!=null){
				this.lblLetter = new LetterBox(0,0,this.w, this.h,this.ch, this.fontsizepercent, this.fontcol,this.fonttp);
//				this.lblLetter.setFontBold(true,true);
//				this.lblLetter.setFontSize(100,true);
//				this.lblLetter.setFontColor('green',true);

			this.addChild(this.lblLetter);
//			alert(this.lblLetter.getHeight());
		//	this.lblLetter.setLocation(20,20);
		}	
		
	//	this.dyncaption.setBorder(1,'red');
		//this.setInnerBorder(1,'#cccccc');
		// add 3D looking borders at the edges of the widget


		this.setVisible(true); // make sure the widget is visible

		// add layer for event handling
		this.dynevents = new DynLayer(null,0,0,this.w,this.h); 
		this.addChild(this.dynevents);

	};
	PuzzleElement.listener = {
			onclick : function(e) { 
			var o=e.getSource();
			clearBackShift();
			shiftPieceToEmptyPosition(o);
			o.slideTo(o._currentx*o.w,o._currenty*o.h);
			//	alert('elementdblclick');
		}

	}


