
// scripts.js
// Well, it contains all the scripts for the admin panel!
// ------------------------------------------------------------------------------------------------
// Created: PGLH 2007-12-05
// Updated: PGLH 2008-01-15

// Help functions
// ------------------------------------------------------------------------------------------------

var hexChars = "0123456789ABCDEF";
function Dec2Hex (Dec) { var a = Dec % 16; var b = (Dec - a)/16; hex = "" + hexChars.charAt(b) + hexChars.charAt(a); return hex; }

function createHelpBox(imgid, boxid, text)
{
	if( document.getElementById && document.getElementById(imgid) )
	{
		document.getElementById(imgid).onclick = function()
		{
			if(document.getElementById(boxid).innerHTML == ''){
				document.getElementById(boxid).innerHTML = text;
				/*document.getElementById(boxid).style.display = 'block';
				document.getElementById(boxid).style.backgroundColor = '#FFFFBB';*/
				document.getElementById(boxid).setAttribute('class', 'helpBoxShow');
				document.getElementById(boxid).setAttribute('className', 'helpBoxShow');
				document.getElementById(boxid).style.backgroundColor = '#FFB';
				setTimeout('highlightHelpBox(\''+boxid+'\', 0, 40, 255, 255, 187)', 1000);
			} else {
				document.getElementById(boxid).innerHTML = '';
				document.getElementById(boxid).setAttribute('class', 'helpBoxHide');
				document.getElementById(boxid).setAttribute('className', 'helpBoxHide');
			}
			return false;
		}
	}
}

function highlightHelpBox(id, number, max, r, g, b) {

	var dr = calcd(r, 255, number, max);
	var dg = calcd(g, 255, number, max);
	var db = calcd(b, 255, number, max);

	document.getElementById(id).style.backgroundColor = '#'+dr+dg+db;  //.setAttribute('style', 'background-color: #'+dr+dg+db+';');
	
	if( number < max )
	{
		setTimeout('highlightHelpBox(\''+id+'\', '+(number+1)+', '+max+', '+r+', '+g+', '+b+')', 10); 
	}
	else
	{
		document.getElementById(id).setAttribute('style', 'background-color: #FFF;');
	}
}

function calcd(start, end, number, max)
{
	return Dec2Hex(Math.round( start + ( ( (end-start) / max) * number ) ));
}

window.onload = function()
{
	createHelpBox('adnInfo', 'availabledomainnames', 'You can select any of the domains below. If you want hosting with the domain simply choose from the drop down options. If you just want a domain name only select that option from the list.');
	createHelpBox('odnInfo','otherdomainnames','The domains below are not available to purchase.  If you own one of these domains you can still select the domain, you just need to change your domain settings so it points at our hosting platform.');
}
