
	function FancyBorder()
	{
	    this.x = 0;
	    this.y = 0;
		this.width = 0;
		this.height = 0;
		this.position = "relative";
		this.name = "";
		this.index = 0;
		this.borderwidth = 0;
		this.borderheight = 0;
		this.topleftimage = "";
		this.topimage = "";
		this.toprightimage = "";
		this.leftimage = "";
		this.middleimage = "";
		this.rightimage = "";
		this.bottomleftimage = "";
		this.bottomimage = "";
		this.bottomrightimage = "";
		this.parentDiv = 'myDiv';
	}
	
	FancyBorder.prototype.BuildMe = function(){

		var txt = document.createElement("div");
		this.htmlelement = txt;
		document.getElementById(this.parentDiv).appendChild(txt);
		this.PaintMe();
	}
	
	FancyBorder.prototype.PaintMe = function()
	{
	
		if (typeof document.body.style.maxHeight != "undefined") {
		} else {
			this.topleftimage = this.topleftimage.replace(".png",".gif");
			this.topimage = this.topimage.replace(".png",".gif");
			this.toprightimage = this.toprightimage.replace(".png",".gif");
			this.leftimage = this.leftimage.replace(".png",".gif");
			this.middleimage = this.middleimage.replace(".png",".gif");
			this.rightimage = this.rightimage.replace(".png",".gif");
			this.bottomleftimage = this.bottomleftimage.replace(".png",".gif");
			this.bottomimage = this.bottomimage.replace(".png",".gif");
			this.bottomrightimage = this.bottomrightimage.replace(".png",".gif");
		}
	
		var divText;
		divText = "<div id='Border" + this.index + "' ";
		//divText += "onclick='myArray[" + this.index + "].OnClick();' ";
		divText += "style=\"";
		divText += "position:" + this.position + ";";
		divText += "left:" + this.x + ";";
		divText += "top:" + this.y + ";";
		if(this.width>0){
			divText += "width:" + this.width + ";";
		}
		if(this.height>0){
			divText += "height:" + this.height + ";";
		}
		divText += "float:left;";
		divText += "\">";

		divText += this.BuildBorder();
		
		divText += "<div id='BorderContent" + this.index + "' style=\"width:" + this.width + ";height:" + this.height + ";\"></div>";
		this.contentDiv = "BorderContent" + this.index
		
		divText += "</div>";
		
		this.htmlelement.innerHTML = divText;
	}
	
	FancyBorder.prototype.Resize = function()
	{
		this.height = this.height - 10;
		this.PaintMe();
	}
	
	FancyBorder.prototype.OnClick = function(){
		this.Resize();
	}
	
	FancyBorder.prototype.BuildBorder = function()
	{
		
		var buildhtml;
		var borderwidthdiff;
		var borderheightdiff;
		var tempborderwidth;
		var tempborderheight;
		buildhtml = "";
		
		tempborderwidth = this.borderwidth;
		tempborderheight = this.borderheight;
		
		borderwidthdiff = this.width - (this.borderwidth*2);
		if(borderwidthdiff<0){
			tempborderwidth = this.borderwidth + (borderwidthdiff/2);
		}
		
		borderheightdiff = this.height - (this.borderheight*2);
		if(borderheightdiff<0){
			tempborderheight = this.borderheight + (borderheightdiff/2);
		}

		//Top Row
		buildhtml+= "<div style=\"position:absolute; left:0px; top:0px; width:"+tempborderwidth+"px; height:"+tempborderheight+"px; background-image:url("+this.topleftimage+"); background-repeat: repeat-x; \"></div>";
		if(borderwidthdiff>0){
			buildhtml+= "<div style=\"position:absolute; left:"+tempborderwidth+"px; top:0px; width:"+borderwidthdiff+"px; height:"+tempborderheight+"px; background-image:url("+this.topimage+"); background-repeat: repeat-x; \"></div>";
		}
		buildhtml+= "<div style=\"position:absolute; left:"+(this.width-tempborderwidth)+"px; top:0px; width:"+tempborderwidth+"px; height:"+tempborderheight+"px; background-image:url("+this.toprightimage+"); background-repeat: repeat-x; \"></div>";

		//Middle Row
		if(borderheightdiff>0){
			buildhtml+= "<div style=\"position:absolute; left:0px; top:"+tempborderheight+"px; width:"+tempborderwidth+"px; height:"+borderheightdiff+"px; background-image:url("+this.leftimage+"); \"></div>";
			if(this.middleimage){
				if(borderwidthdiff>0){
					buildhtml+= "<div style=\"position:absolute; left:"+tempborderwidth+"px; top:"+tempborderheight+"px; width:"+borderwidthdiff+"px; height:"+borderheightdiff+"px; background-image:url("+this.middleimage+"); \"></div>";
				}
			}
			buildhtml+= "<div style=\"position:absolute; left:"+(this.width-tempborderwidth)+"px; top:"+tempborderheight+"px; width:"+tempborderwidth+"px; height:"+borderheightdiff+"px; background-image:url("+this.rightimage+"); \"></div>";
		}

		//Bottom Row
		buildhtml+= "<div style=\"position:absolute; left:0px; top:"+(this.height-tempborderheight)+"px; width:"+tempborderwidth+"px; height:"+tempborderheight+"px; background-image:url("+this.bottomleftimage+"); background-repeat: repeat-x; \"></div>";
		if(borderwidthdiff>0){
			buildhtml+= "<div style=\"position:absolute; left:"+tempborderwidth+"px; top:"+(this.height-tempborderheight)+"px; width:"+borderwidthdiff+"px; height:"+tempborderheight+"px; background-image:url("+this.bottomimage+"); background-repeat: repeat-x; \"></div>";
		}
		buildhtml+= "<div style=\"position:absolute; left:"+(this.width-tempborderwidth)+"px; top:"+(this.height-tempborderheight)+"px; width:"+tempborderwidth+"px; height:"+tempborderheight+"px; background-image:url("+this.bottomrightimage+"); background-repeat: repeat-x; \"></div>";
		
		return buildhtml;
	}
	

