function id(x) {
  if (typeof x == "string") return document.getElementById(x);
  return x;
  }


// Set colours


function setMixA(){
setTimeout (setRed , 1);
setTimeout (setYellow , 1000);
setTimeout (setGreen , 2000);
setTimeout (setDarkBlue , 3000);
}


function setMixB(){
setTimeout (setLime , 1);
setTimeout (setOrange , 1000);
setTimeout (setYellow , 2000);
setTimeout (setPurple , 3000);
}

function setMixC(){
setTimeout (setPink , 1);
setTimeout (setMauve , 1000);
setTimeout (setLime , 2000);
setTimeout (setPurple , 3000);
}


function setRed() {
  id('LabelView').style.color = '#ffffff';
  id('LabelView').style.backgroundColor = '#ff0000';
  invertImg();
}

function setYellow() {
  id('LabelView').style.color = '#000000';
  id('LabelView').style.backgroundColor = '#ffcc00';
  invertImg();
}

function setGreen() {
  id('LabelView').style.color = '#ffffff';
  id('LabelView').style.backgroundColor = '#009900';
  invertImg();
}

function setDarkBlue() {
  id('LabelView').style.color = '#ffffff';
  id('LabelView').style.backgroundColor = '#000066';
  invertImg();
}

function setLime() {
  id('LabelView').style.color = '#000000';
  id('LabelView').style.backgroundColor = '#99ff00';
  invertImg();
}

function setOrange() {
  id('LabelView').style.color = '#ffffff';
  id('LabelView').style.backgroundColor = '#ff6600';
  invertImg();
}

function setPurple() {
  id('LabelView').style.color = '#ffffff';
  id('LabelView').style.backgroundColor = '#6633cc';
  invertImg();
}

function setPink() {
  id('LabelView').style.color = '#ffffff';
  id('LabelView').style.backgroundColor = '#ff99aa';
  invertImg();
}


function setMauve() {
  id('LabelView').style.color = '#ffffff';
  id('LabelView').style.backgroundColor = '#9999cc';
  invertImg();
}



// Set styles

function setGillSans() {
  id('pre').style.fontFamily="Gill Sans MT Condensed,sans-serif";
  id('pre').style.letterSpacing= '0px';
  id('pre').style.fontWeight='300';
}


function setBradley_hand_itc() {
  id('pre').style.fontFamily ='bradley hand itc,sans-serif';
  id('pre').style.letterSpacing= '-2px';
}

function setArial() {
  id('pre').style.fontFamily="arial narrow,sans-serif";
  id('pre').style.letterSpacing= '-1px';
  id('pre').style.fontWeight='900';
}

//Get colour div.

function showCol(){   // define attributes of the colour div.
var obj    = id("ShowCol");
obj.style.display = "block";
obj.style.background = "#ffffff";
obj.style.position = "absolute";
obj.style.zindex   = "999";
obj.style.width    =  "500px";
obj.style.height   =  "280px";
obj.style.top = "230px";
obj.style.left = "250px";

}

function alertWinCol(title, msg, w, h){ 
	
	var iWidth = document.documentElement.clientWidth; 
	var iHeight = document.documentElement.clientHeight; 
	
	var coldiv=id("ShowCol");
		coldiv.style.cssText = "position:absolute;top:"+(iHeight-h)/2+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;border:1px solid ;padding:1px;line-height:22px;z-index:102;display:none;overflow:scroll;";
     document.body.appendChild(coldiv);
	var table = document.createElement("table");
	coldiv.appendChild(table);
	table.style.cssText = "margin:0px;border:0px;padding:0px;";
	table.cellSpacing = 0;
	
	var titleBarCol = id('colTitle');
	titleBarCol.style.cssText = "width:100px;text-align:left;border:1px solid ;cursor:move;padding:3px 50px 5px 50px; background-color: #e2eaf8";
	var moveX = 0;
	var moveY = 0;
	var moveTop = 0;
	var moveLeft = 0;
	var moveable = false;
	var docMouseMoveEvent = document.onmousemove;
	var docMouseUpEvent = document.onmouseup;
	titleBarCol.onmousedown = function() {
		var evt = getEvent();
		moveable = true; 
		moveX = evt.clientX;
		moveY = evt.clientY;
		moveTop = parseInt(coldiv.style.top);
		moveLeft = parseInt(coldiv.style.left);
		
		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
				if ( x > 0 && y > 0 ) {
					coldiv.style.left = x + "px";
					coldiv.style.top = y + "px";
				}
			}	
		};
		document.onmouseup = function () { 
			if (moveable) { 
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false; 
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			} 
		};
	}
	
	

function getEvent() {
	    return window.event || arguments.callee.caller.arguments[0];
    }

}

function hideCol(){  //hide colour div.
    id("ShowCol").style.display = "none";

}

