function DragAndDropTargetPanel(panelDescription, border, parent, srclist)
{
	this.description = panelDescription;
   	this.border = border;
   	this.dndpanel = parent;
   	this.srclist = srclist
   	this.div;
   	this.top;
   	this.left;
   	this.width;
   	this.height;
	
	DragAndDropTargetPanel.prototype.createNewTarget = function()
	{
		var newdiv  = window.parent.ContentFrame.document.getElementById(this.description);
		newdiv.type = "dndtar";
		newdiv.style.zIndex = 999;
		this.top = parseInt(getStyle(this.description, "top"))
		this.left = parseInt(getStyle(this.description, "left"))
		this.width = parseInt(getStyle(this.description, "width"))
		this.height = parseInt(getStyle(this.description, "height"))
		newdiv.parent = this.dndpanel.getDiv();
		newdiv.dndpanel = this.dndpanel;
		newdiv.srcobj = this;
		this.div = newdiv;		
		if(border.length > 0)
		{
			if(border == "circle")
			{
				newdiv.style.border = "thin solid transparent";
				this.circleBorder("#000000");	
			}else
				newdiv.style.border = border;
		}
		if(document.all)
		{
			newdiv.isIE = true;
			this.isIE = true;
		}		
		if(this.currentsrc != null)
			this.snapToCenter(this.currentsrc)	
	}
	
	DragAndDropTargetPanel.prototype.getWidth = function()
	{
		return this.width
	}
	
	DragAndDropTargetPanel.prototype.getHeight = function()
	{
		return this.height
	}
	
	DragAndDropTargetPanel.prototype.getDescription = function()
	{
		return this.description
	}
	
	DragAndDropTargetPanel.prototype.getTop = function()
	{
		return this.top
	}	
	
	DragAndDropTargetPanel.prototype.getLeft = function()
	{
		return this.left
	}
	
	DragAndDropTargetPanel.prototype.getDiv = function()
	{
		return this.div
	}
	
	DragAndDropTargetPanel.prototype.getSourceList = function()
	{
		return this.srclist
	}	
	
	DragAndDropTargetPanel.prototype.acceptSource = function(src)
	{
		if(src.dndpanel.showCircleBorder())
			return this.checkCircleBoundary(src);
		else
			return this.checkRectangleBoundary(src);
	}
	
	DragAndDropTargetPanel.prototype.checkRectangleBoundary = function(src)
	{
		var retval = false;
		if(src != null)
		{
			var targettop = parseInt(getStyle(this.description, "top"))
			var targetleft = parseInt(getStyle(this.description, "left"))
			var targetwidth = parseInt(getStyle(this.description, "width"))
			var targetheight = parseInt(getStyle(this.description, "height"))
			if(src.getCenterX() > targetleft && src.getCenterX() < (targetleft+targetwidth) &&
				src.getCenterY() > targettop && src.getCenterY() < (targettop+targetheight))
				retval = true;
		}
		return retval;
	}
	
	DragAndDropTargetPanel.prototype.checkCircleBoundary = function(src)
	{
		if(src != null)
		{
			var targettop = parseInt(getStyle(this.description, "top"))
			var targetleft = parseInt(getStyle(this.description, "left"))
			var targetwidth = parseInt(getStyle(this.description, "width"))
			var targetheight = parseInt(getStyle(this.description, "height"))
			
			var aSquared=(targetwidth*targetwidth/4);
			var bSquared=(targetheight*targetheight/4);
			var abSquared=aSquared*bSquared;
			var srcXRel=-targetleft-targetwidth/2+src.getCenterX();
			var srcYRel=targettop+targetheight/2-src.getCenterY();
			var ellipticRadiusSquared=bSquared*srcXRel*srcXRel+aSquared*srcYRel*srcYRel;
			return ellipticRadiusSquared<abSquared;				
		}

	}	
	
	DragAndDropTargetPanel.prototype.snapToCenter = function(src)
	{
		if(this.currentsrc != null)
		{
			var currdiv = this.currentsrc.getDiv();
			currdiv.style.top = this.currentsrc.getTop()+'px';
			currdiv.style.left = this.currentsrc.getLeft()+'px';
		}
		var div = src.getDiv();
		div.style.left = this.left+((this.width-src.getWidth())/2) + 'px';
		div.style.top = this.top+((this.height-src.getHeight())/2) + 'px';
	}
	
	DragAndDropTargetPanel.prototype.circleBorder = function(color)
	{
	    var pele = null
	    var list = new Array();
	    var tartop = parseInt(getStyle(this.description, "top"))
	    var tarleft = parseInt(getStyle(this.description, "left"))
	    var tarwidth = parseInt(getStyle(this.description, "width"))
	    var tarheight = parseInt(getStyle(this.description, "height"))
	    var circ = Math.PI * tarwidth;
	    for(var x=0; x<circ; x++)
	    {
	    	pele  = window.parent.ContentFrame.document.createElement("p");
		pele.innerHTML = ".";
		pele.style.position = "absolute";
		pele.style.color = color;
		pele.style.zIndex = -1;
		tar.appendChild(pele);
	    	list[x] = pele
	    }

	    this.createCircle(tarwidth,tarheight,tartop,tarleft,list)
	}

	DragAndDropTargetPanel.prototype.createCircle = function(w, h, top, left, list)
	{
	      for (var i = 0; i < list.length; i++)
	      {
	        angle = 2 * Math.PI * i/list.length
	        var x = parseInt(Math.cos(angle) * w)
	        var y = parseInt(Math.sin(angle) * h)
	        if(document.all)
		{
	        	list[i].style.left = ((x-8)/2) + (w/2);
	        	list[i].style.top = ((y-32)/2) + (h/2);
	        }else if(navigator.userAgent.indexOf('Safari')>0)
	        {
	        	list[i].style.left = ((x-5)/2) + (w/2);
	        	list[i].style.top = ((y-58)/2) + (h/2);
	        }else
	        {
	        	list[i].style.left = ((x-3)/2) + (w/2);
	        	list[i].style.top = ((y-62)/2) + (h/2);
	        }
	      }
	}
	
	DragAndDropTargetPanel.prototype.getCurrentSource = function()
	{
   		return this.currentsrc;   	
   	}	
	
	DragAndDropTargetPanel.prototype.setCurrentSource = function(source)
	{
   		var src = window.parent.ContentFrame.document.getElementById(source);
	   	if(src != null)
	   	{
	   		this.currentsrc = src.srcobj;
	   		this.highlightBorder(src);
	   		this.snapToCenter(src.srcobj);
	   	}
   	}
   	
   	DragAndDropTargetPanel.prototype.highlightBorder = function(srcdiv, color)
	{
		if(this.dndpanel.highlightAnswer() && this.dndpanel.showBorders())
		{
			if(color != null)
			{
				if(this.dndpanel.useCircleBorders())
					this.circleBorder("#000000");
				else
					this.div.style.border = "thin solid #000000";
				return;
			}
			var sList = this.getSourceList();
			var correct = sList[0];
			if(correct == srcdiv.srcobj.getDescription())
			{
				if(this.dndpanel.useCircleBorders())
					this.circleBorder("#00FF00");
				else
					this.div.style.border = "thin solid #00FF00";
			}else
			{
				if(this.dndpanel.useCircleBorders())
					this.circleBorder("#FF0000");
				else
					this.div.style.border = "thin solid #FF0000";
			}
		}
	}	

	this.createNewTarget();
}
