addNamespace("Aspacts.Idios3.I_CAP.ClientInteraction.ActiveElement")

Aspacts.Idios3.I_CAP.ClientInteraction.ActiveElement.ToolBox_class = function(elementParser)
{
	this.elementParser = elementParser
	this.currentElement = null
}

Aspacts.Idios3.I_CAP.ClientInteraction.ActiveElement.ToolBox_class.prototype.PrepareElement = function()
{
	this.elementToolBox = document.createElement("div")
	document.body.insertBefore(this.elementToolBox, document.body.firstChild)
	this.elementToolBox.style.display = "none"
	
	this.elementToolBox.style.height = "20px"
	this.elementToolBox.style.width = "20px"
	
	
	this.elementToolBox.style.position= "absolute"  
   	this.elementToolBox.style.left="0px"
	this.elementToolBox.style.top="0px"
	
	this.elementToolBox.style.padding="0px"
	this.elementToolBox.style.margin="0px"
	this.elementToolBox.style.textAlign= "left"  
	
	
	this.elementToolBox.style.zIndex = 1000000
	this.elementToolBox.refOwner = this
	this.elementToolBox.className = "ActiveElementToolBox"
	
	
	this.elementToolBoxBackGround = document.createElement("div")   		
	this.elementToolBox.appendChild(this.elementToolBoxBackGround)
	this.elementToolBoxBackGround.style.position= "absolute"  
	this.elementToolBoxBackGround.style.width = "100%"
	this.elementToolBoxBackGround.style.height = "100%"
	this.elementToolBoxBackGround.style.top =  "0px"
	this.elementToolBoxBackGround.style.left= "0px"       
	
	this.elementToolBoxBackGround.style.filter="alpha(opacity=30)";
		 
	this.elementToolBoxBackGround.style.MozOpacity = 0.3
	this.elementToolBoxBackGround.style.backgroundColor="black"
	this.elementToolBoxBackGround.className = "ActiveElementToolBoxBG"
	
	
	this.elementToolBoxContent = 	 document.createElement("div")   		
	this.elementToolBox.appendChild(this.elementToolBoxContent)
	this.elementToolBoxContent.style.position= "absolute"  
	this.elementToolBoxContent.style.width = "100%"
	this.elementToolBoxContent.style.height = "100%"
	this.elementToolBoxContent.style.top =  "0px"
	this.elementToolBoxContent.style.left= "0px"    
	this.elementToolBoxContent.style.whiteSpace = "nowrap"  
	this.elementToolBoxContent.className = "ActiveElementToolBoxFR"   
	
	Aspacts.Idios3.I_CAP.Scripting.Core.ImplementEvent(this.elementToolBox)
	this.elementToolBox.addEventListener('mouseout', function(evt){this.refOwner.elementParser.HandleElementMouseOut(evt||event, this.refOwner.currentElement)}, true)
}

Aspacts.Idios3.I_CAP.ClientInteraction.ActiveElement.ToolBox_class.prototype.Show = function(callingElement)
{
	this.currentElement = callingElement
	this.ClearActions()
	this.elementToolBox.style.display = "block"
	
	this.elementToolBox.style.width = "auto"
	this.elementToolBoxContent.style.width = "auto"
	this.elementToolBoxBackGround.style.width = "auto"
	this.elementToolBox.style.height = "auto"
	this.elementToolBoxContent.style.height = "auto"
	this.elementToolBoxBackGround.style.height = "auto"
	
	var intWidth = this.elementToolBoxContent.offsetWidth + (this.currentElement.actions.length *2)
	var intHeight = this.elementToolBoxContent.offsetHeight + 2
	
	
	for (var i=0;i<this.currentElement.actions.length;i++)
	{
		var refElem = this.currentElement.actions[i].GetElement()
		this.elementToolBoxContent.appendChild(refElem)
		intWidth += refElem.offsetWidth
		intHeight = Math.max(refElem.offsetHeight, intHeight)
	}
	
	if (MS.Browser.MajorVersion == 6 && MS.Browser.isIE)
	{
		intWidth+=1
	}
	
	this.elementToolBox.style.width = intWidth + "px"
	this.elementToolBoxContent.style.width = intWidth + "px"
	this.elementToolBoxBackGround.style.width = intWidth + "px"
	this.elementToolBox.style.height = intHeight + "px"
	this.elementToolBoxContent.style.height = intHeight + "px"
	this.elementToolBoxBackGround.style.height = intHeight + "px"
	
	var intToolBoxOffetTop = parseInt(this.elementParser.GetOption(this.currentElement.refElement.getAttribute("CAP_OptionGroup") || "default", "intToolBoxOffsetTop", 0))
	var intToolBoxOffetLeft = parseInt(this.elementParser.GetOption(this.currentElement.refElement.getAttribute("CAP_OptionGroup") || "default", "intToolBoxOffsetLeft", 0))
	this.elementToolBox.style.top = ((parseInt(this.currentElement.refCoverLayer.style.top) -this.elementToolBox.offsetHeight) + intToolBoxOffetTop) + "px"
	this.elementToolBox.style.left = (parseInt(this.currentElement.refCoverLayer.style.left) + intToolBoxOffetLeft) + "px"
	
	var strBackground = this.elementParser.GetOption(this.currentElement.refElement.getAttribute("CAP_OptionGroup") || "default", "strCoverLayerBackgroundColor", "black")
	strBackground = this.elementParser.GetOption(this.currentElement.refElement.getAttribute("CAP_OptionGroup") || "default", "strToolBoxBackgroundColor",strBackground)
	strBackground = this.currentElement.refElement.getAttribute("CAP_LayerBackgroundColor") || strBackground
	
	this.elementToolBoxBackGround.style.backgroundColor = strBackground
}

Aspacts.Idios3.I_CAP.ClientInteraction.ActiveElement.ToolBox_class.prototype.Hide = function(callingElement)
{
		if(this.currentElement == callingElement || callingElement==null)
			this.elementToolBox.style.display = "none"
}

Aspacts.Idios3.I_CAP.ClientInteraction.ActiveElement.ToolBox_class.prototype.ClearActions = function()
{
	
	 while (this.elementToolBoxContent.childNodes[0]) {
				    this.elementToolBoxContent.removeChild(this.elementToolBoxContent.childNodes[0]);
					}
	//while (this.elementToolBoxContent.childNodes.length > 0)
	{
	//	this.elementToolBoxContent.removeNode(this.elementToolBoxContent.childNodes[0])
	}
}
