
function MakeArray(n){
	this.length = n;
	for(var i = 1; i <= n; i++) { this[i] = i - 1; };
	return(this);
};

var hex = new MakeArray(16);
hex[11]="A"; hex[12]="B"; hex[13]="C";
hex[14]="D"; hex[15]="E"; hex[16]="F";

function ToHex(x){  // Changes a int to hex (in the range 0 to 255)
	
	var high = x / 16;
	var s = high + "";		//1
	
	s = s.substring(0, 2);		//2 the combination of these = trunc funct.
	high = parseInt(s, 10);		//3
	var left = hex[high + 1];	// left part of the hex-value
	var low = x - high * 16;	// calculate the rest of the values
	s = low + "";			//1
	s = s.substring(0, 2);		//2 the combination of these = trunc funct.
	low = parseInt(s, 10);		//3
	var right = hex[low + 1];	// right part of the hex-value
	var string = left + "" + right;	// add the high and low together
	return string;
	
};

function ChangeBackColor(objBanner, iColor, sIncr) {
	iColor = parseInt(iColor);
	if (isNaN(iColor)) { iColor = 0; };
	if (document.getElementById) {
		var mCol = document.getElementById(objBanner.toString()).bgColor;
		if (mCol.substring(0, 1) == "#") {
			mCol = mCol.substring(3, 5);
			if (!isNaN(parseInt("0x" + mCol))) {
				if (sIncr == "-") {
					iColor -= 5;
					if (iColor < 1) { 
						sIncr = "+"
						iColor = 0;
					};
				} else {
					iColor += 5;
					if (iColor > 254) { 
						sIncr = "-"
						iColor = 255;
					};
				};
				//mCol = ToHex(iColor);
				//mCol = "#FFFF" + mCol + "";
				mCol = "#" + ToHex(255 - iColor) + "FF" + ToHex(iColor) + "";
				//alert(mCol);
				//if (!confirm("" + mCol)) return;
				document.getElementById(objBanner.toString()).bgColor = mCol;
				setTimeout("ChangeBackColor('" + objBanner.toString() + "', " + iColor + ", '" + sIncr + "')", 30);
			};
		};
	};
};

//ChangeBackColor("tabBanner", "0xF0", "+");
