function mo(ref) {
	a = document.getElementById('disp');
	c = document.getElementById('disptx');
	e = document.getElementById('disprgb');
	g = document.getElementById('disptxrgb');
	a.style.backgroundColor = ref.style.backgroundColor;
	c.innerHTML = "Hex: " + ref.innerHTML; // + " " + ref.style.backgroundColor; 
	e.style.backgroundColor = ref.style.backgroundColor;
	g.innerHTML = "RGB: " + hex2num(ref.innerHTML.slice(7,13)); // + " " + ref.style.backgroundColor; 
}

function cl(ref) {
	b = document.getElementById('selc');
	d = document.getElementById('selctx');
	f = document.getElementById('selcrgb');
	h = document.getElementById('selctxrgb');
	b.style.backgroundColor = ref.style.backgroundColor;
	d.innerHTML = "Hex: <a href=\"full.php?color=" + ref.innerHTML.slice(7,13) + "\">" + ref.innerHTML + "</a>"; // + " " + ref.style.backgroundColor; 
	f.style.backgroundColor = ref.style.backgroundColor;
	h.innerHTML = "RGB: <a href=\"full.php?color=" + ref.innerHTML.slice(7,13) + "\">" + hex2num(ref.innerHTML.slice(7,13)) + "</a>"; // + " " + ref.style.backgroundColor; 
}

function hex2num(hex) {
	if(hex.charAt(0) == "#") hex = hex.slice(1); //Remove the '#' char - if there is one.
	hex = hex.toUpperCase();
	var hex_alphabets = "0123456789ABCDEF";
	var value = new Array(3);
	var k = 0;
	var int1,int2;
	for(var i=0;i<6;i+=2) {
		int1 = hex_alphabets.indexOf(hex.charAt(i));
		int2 = hex_alphabets.indexOf(hex.charAt(i+1)); 
		value[k] = (int1 * 16) + int2;
		k++;
	}
	return(value);
}

