
function CommandID(id, text, hidden, callback)
{
	this.id = id;
	if(!document.getElementById(id))
	{
			var textEl = document.createElement("div");
			textEl.className = "commands";
			textEl.id = id;
			document.body.appendChild(textEl);
			this.textEl = textEl;
	} else
		this.textEl = document.getElementById(id);
		
	this.shadow = false;
	this.setText = setText;
	this.setCoord = setCoord;
	this.addShadow = addShadow;
	this.cleanShadow = cleanShadow;
	this.setVisibility = setVisibility;
	this.copyTypography = copyTypography;
	this.onmouseover = invertColor;
	this.onmouseout = invertColor;
	this.onclick = callback;
	this.textEl.onmouseover	= this.onmouseover;
	this.textEl.onmouseout	= this.onmouseout;
	this.textEl.onclick	= this.onclick;
	
	this.setText(text);
	if (hidden){
		this.setVisibility(0);
	}
	else
		this.addShadow();
}


function Command(id, text, top, left, hidden, callback)
{
	this.id = id;
	if(!document.getElementById(id))
	{
			var textEl = document.createElement("div");
			textEl.className = "commands";
			textEl.id = id;
			document.body.appendChild(textEl);
			this.textEl = textEl;
	} else
		this.textEl = document.getElementById(id);
		
	this.shadow = false;
	this.setText = setText;
	this.setCoord = setCoord;
	this.addShadow = addShadow;
	this.cleanShadow = cleanShadow;
	this.setVisibility = setVisibility;
	this.copyTypography = copyTypography;
	this.onmouseover = invertColor;
	this.onmouseout = invertColor;
	if (callback){
		this.onclick = callback;
		this.textEl.onclick	= callback;
	}
	this.textEl.onmouseover	= this.onmouseover;
	
	this.textEl.onmouseout	= this.onmouseout;
	
	this.setText(text);
	this.setCoord(top, left);
	if (hidden){
		this.setVisibility(0);
	}
	else
		this.addShadow();
}
function getRComp(rgb)
{
	var par1 = rgb.indexOf("(");
	var com1 = rgb.indexOf(",");
	return parseInt(rgb.substring(par1+1,com1));
}
function getGComp(rgb)
{
	var com1 = rgb.indexOf(","); 
	var com2 = rgb.substring(com1+1).indexOf(",");
	return parseInt(rgb.substr(com1+1,com2));
}
function getBComp (rgb)
{
	var com1 = rgb.indexOf(","); 
	var com2 = com1 + 1 + rgb.substring(com1+1).indexOf(",");
	var par2 = rgb.substring(com2+1).indexOf(")");
	return parseInt(rgb.substr(com2+1,par2));
	
}
function invertColor(evt)
{
	evt = (evt) ? evt :((window.event) ?event : null);
	var elem = (evt.target) ? evt.target : ((evt.srcElement) ?  evt.srcElement : null);
	 
    var color_string = getStyleValue(elem, "color");
    var newR = 255 - getRComp(color_string);
    var newG = 255 - getGComp(color_string);
    var newB = 255 - getBComp(color_string);
	elem.style.color="rgb("+newR+", "+newG+", "+newB+")";
}


function commandOnClick(evt)
{
	evt = (evt) ? evt :((window.event) ?event : null);
	var elem = (evt.target) ? evt.target : ((evt.srcElement) ?  evt.srcElement : null);
	if(elem.id == "commEnlph")
		TogglePhotoSize();
}

function RoomLabel(id, text, top, left)
{
	this.id = id;
	if(!document.getElementById(id))
	{
			var textEl = document.createElement("div");
			textEl.className = "room_label";
			textEl.id = id;
			this.textEl = document.body.appendChild(textEl);
	} else
		this.textEl = document.getElementById(id);
	this.shadow = false;
	this.setText = setText;
	this.setCoord = setCoord;
	this.addShadow = addShadow;
	this.cleanShadow = cleanShadow;
	this.setVisibility = setVisibility;
	this.copyTypography = copyTypography;
	

	this.setText(text);
	this.setCoord(top, left);
}
	
	
function TextObject(id)
{
	this.id = id;
	if(!document.getElementById(id))
	{
			var textEl = document.createElement(id);
			textEl.id = id;
			document.body.appendChild(textEl);
			this.textEl = textEl;
	} else
		this.textEl = document.getElementById(id);
	this.shadow = false;
	this.setText = setText;
	this.setCoord = setCoord;
	this.addShadow = addShadow;
	this.cleanShadow = cleanShadow;
	this.setVisibility = setVisibility;
	this.copyTypography = copyTypography;
}


function setText(text)
{
	if (this.shadow){
		this.cleanShadow();
		this.textEl.innerHTML = text;
		this.addShadow();
	}
	else 
		this.textEl.innerHTML = text;
		
}

function setCoord(left, top)
{
	this.textEl.style.position = "absolute";
	this.textEl.style.left = left; 
	this.textEl.style.top = top;
	if (this.shadow){
		cleanShadow();
		addShadow();
	}
}

function addShadow()
// only works for absolute placement (no div or td)
{
	if (this.shadow)
		this.cleanShadow();
	var xx = GetAbsoluteLeft(this.textEl);  //parseInt(this.textEl.style.left.replace(/px/,""));
	var yy = GetAbsoluteTop(this.textEl);  //parseInt(this.textEl.style.top.replace(/px/,""));
	this.shadowTextEl1 = document.createElement(this.id + "shadow1");
	this.shadowTextEl1.innerHTML = this.textEl.innerHTML ;
	this.shadowTextEl1.className = "shadow";
	this.copyTypography(this.shadowTextEl1);
  	this.shadowTextEl1.style.top = yy+2;
	this.shadowTextEl1.style.left = xx+2;
	document.body.appendChild(this.shadowTextEl1);
	this.shadow = true;

}

function cleanShadow()
{ 
	if (this.shadow){
		this.shadow = false;
		document.body.removeChild(this.shadowTextEl1);
		document.body.removeChild(this.shadowTextEl2);
		document.body.removeChild(this.shadowTextEl3);
	}
}

function setVisibility (vis)
{
	if (vis)
		this.textEl.style.visibility = "visible";
	else
		this.textEl.style.visibility = "hidden";
}

 
function copyTypography(recepient)
{
	var originalStyle;
	if (window.getComputedStyle ){
		originalStyle = getComputedStyle(this.textEl,""); 
		recepient.style.fontFamily = originalStyle.getPropertyValue("font-family");
		recepient.style.fontSize = originalStyle.getPropertyValue("font-size");
		recepient.style.textAlign = originalStyle.getPropertyValue("text-align");
		recepient.style.textDecoration = originalStyle.getPropertyValue("text-decoration");
		recepient.style.left = originalStyle.getPropertyValue("left");
		recepient.style.right = originalStyle.getPropertyValue("right");
	}
	else {
		originalStyle =	this.textEl.currentStyle;
		recepient.style.fontFamily = originalStyle.fontFamily;
		recepient.style.fontSize = originalStyle.fontSize;
		recepient.style.textAlign = originalStyle.textAlign;
		recepient.style.textDecoration = originalStyle.textDecoration;
		recepient.style.left = originalStyle.left;
		recepient.style.right = originalStyle.right;
	}
}

<!-- 
 --><!-- 
 -->
