//********************************************************************* 
// Functions:
// stdbtnType1() - Constructer
// stdbtnType1(locx, locy, width, height, btntext, textcolor, btnNameStem, btnNameExt, parentNode, alttext, txtx, txty)
// 
// stdbtnType1.prototype.renderbtn = function()
// stdbtnType1.prototype.SetLink = function(LinkUrl, TargetLocation)
// stdbtnType1.prototype.onmouseaction = function(ContainerObj, MouseAction)
//*********************************************************************
function stdbtnType1(locx, locy, width, height, btntext, textcolor, btnNameStem, btnNameExt, parentNode, alttext, txtx, txty)
{ 	
	this.parentNode = parentNode;
	if(this.parentNode == undefined)
		this.parentNode = document.getElementsByTagName("body").item(0);

    this.x = locx;		  
	this.y = locy;		  
	this.w = width;		  
	this.h = height;	
	this.alttext = alttext;	  
	this.textcolor = textcolor; 
	this.btnNameStem = btnNameStem;
	this.btnNameExt = btnNameExt;
	this.btntext = btntext;
	this.txtx = txtx;
	this.txty = txty;
	
	this.targetLocation = "_top";
	this.LinkUrl = ""; 
		
	// Load button images.
	this.btnout = new Image(this.x, this.y); 
	this.btnout.src = this.btnNameStem + "out." + btnNameExt;
	this.btnsel = new Image(this.x, this.y);
	this.btnsel.src = this.btnNameStem + "sel." + btnNameExt;	 
}


new stdbtnType1(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);


stdbtnType1.prototype.renderbtn = function()
{
	this.divContainer = document.createElement("div");	
	this.divContainer.style.position = "absolute";  
	this.divContainer.style.left = this.x;
	this.divContainer.style.top = this.y;
 	this.divContainer.style.width = this.w;
 	this.divContainer.style.height = this.h;
	this.divContainer.style.visibility = "visible";
	this.divContainer.style.overflow = "hidden";
	
	this.stdbtnImg = document.createElement("img");	
	this.stdbtnImg.setAttribute("title", this.alttext);   
	this.stdbtnImg.setAttribute("src", this.btnout.src);
	
	this.stdbtnImg.objContainer = this;
	this.stdbtnImg.mouseover = 0;
	this.stdbtnImg.mouseout = 1;
	this.stdbtnImg.mousedown = 2;
	this.stdbtnImg.mouseup = 3;
	this.stdbtnImg.onmouseover = new Function("stdbtnType1.prototype.onmouseaction(this.objContainer, this.mouseover);");
	this.stdbtnImg.onmouseout = new Function("stdbtnType1.prototype.onmouseaction(this.objContainer, this.mouseout);");
 	this.stdbtnImg.onmousedown = new Function("stdbtnType1.prototype.onmouseaction(this.objContainer, this.mousedown);");
	this.stdbtnImg.onmouseup = new Function("stdbtnType1.prototype.onmouseaction(this.objContainer, this.mouseup);");


	this.txtContainer = document.createElement("div");
	this.txtContainer.style.position = "absolute"; 
	this.txtContainer.style.color = this.textcolor;
	this.txtContainer.style.left = this.txtx;
	this.txtContainer.style.top = this.txty;
	this.txtContainer.style.fontSize = 12;		
	this.txtContainer.style.fontWeight = 600;  	
	this.txtContainer.style.fontFamily = "arial";  	
	this.txtNode = document.createTextNode(this.btntext);
	this.txtContainer.appendChild(this.txtNode);
	
	this.txtContainer.objContainer = this;
	this.txtContainer.mouseover = this.stdbtnImg.mouseover;
	this.txtContainer.mouseout = this.stdbtnImg.mouseout;
	this.txtContainer.mousedown = this.stdbtnImg.mousedown;
	this.txtContainer.mouseup = this.stdbtnImg.mouseup;
	this.txtContainer.onmouseover = new Function("stdbtnType1.prototype.onmouseaction(this.objContainer, this.mouseover);");
	this.txtContainer.onmouseout = new Function("stdbtnType1.prototype.onmouseaction(this.objContainer, this.mouseout);");
 	this.txtContainer.onmousedown = new Function("stdbtnType1.prototype.onmouseaction(this.objContainer, this.mousedown);");
	this.txtContainer.onmouseup = new Function("stdbtnType1.prototype.onmouseaction(this.objContainer, this.mouseup);");

	this.divContainer.appendChild(this.txtContainer);
	this.divContainer.appendChild(this.stdbtnImg);
	
	this.parentNode.appendChild(this.divContainer);
}


stdbtnType1.prototype.onmouseaction = function(ContainerObj, MouseAction)
{
	switch(MouseAction)
	{
		case ContainerObj.stdbtnImg.mouseover:
			ContainerObj.stdbtnImg.setAttribute("src", ContainerObj.btnsel.src);
		break;

		case ContainerObj.stdbtnImg.mouseout:
			ContainerObj.stdbtnImg.setAttribute("src", ContainerObj.btnout.src);	
		break;
		
		case ContainerObj.stdbtnImg.mousedown:
			ContainerObj.stdbtnImg.setAttribute("src", ContainerObj.btnsel.src);		
			if(ContainerObj.LinkUrl != "")
			{				
				ContainerObj.targetLocation.location = ContainerObj.LinkUrl;
			}	
		break;
		
		case ContainerObj.stdbtnImg.mouseup:
			ContainerObj.stdbtnImg.setAttribute("src", ContainerObj.btnsel.src);		
		break;
	}
}


stdbtnType1.prototype.SetLink = function(LinkUrl, TargetLocation)
{
	this.targetLocation = TargetLocation;
	this.LinkUrl = LinkUrl; 
}

