﻿/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 ************************************************************************
 *
 *	Copyright notice
 *	(c) 2006 Arno Dudek, Vienna (office@adgrafik.at)
 *
 ************************************************************************
 ** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


//	Color differenze if you roll over a table row
var roRowColor = new Array('-15,-15,-15', '15,15,15');

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *	setRowPointer(obj, io)
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

function setRowPointer(obj, io) {

	var tdCells = obj.getElementsByTagName('td');
	var newColor = (io) ? roRowColor[0] : roRowColor[1];

	//	DOM compatible browsers except Opera else with other browsers
	(typeof(window.opera) == 'undefined' && typeof(obj.getAttribute) != 'undefined') ? 
		domDetect = true : domDetect = false;

	for (var i=0; i<tdCells.length; i++) {
		(domDetect) ? 
			tdCells[i].setAttribute('bgcolor', hexCalc(tdCells[i].getAttribute('bgcolor'), newColor), 0) : 
			tdCells[i].setAttribute('bgcolor', hexCalc(tdCells[i].getAttribute('bgcolor'), newColor), 0);
	}
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *	hexCalc(hex, r, g, b)
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

function hexCalc(hex, rgb) {

	if (hex != null && hex.substr(0, 3) == 'rgb') {
		var oldColor = hex.replace(/rgb\((.*)\)/, '$1').split(',');

		var oldColorR = oldColor[0];
		var oldColorG = oldColor[1];
		var oldColorB = oldColor[2];
	}
	else {
		hex = (hex == null || hex == '') ? 'ffffff' : hex.substring(1);

		var oldColorR = h2d(hex.substr(0, 2));
		var oldColorG = h2d(hex.substr(2, 2));
		var oldColorB = h2d(hex.substr(4, 2));
	}

	var rgbColor = rgb.split(',');
	var newColorR = Number(oldColorR) + Number(rgbColor[0]);
	var newColorG = Number(oldColorG) + Number(rgbColor[1]);
	var newColorB = Number(oldColorB) + Number(rgbColor[2]);

	return '#' + d2h(newColorR) + d2h(newColorG) + d2h(newColorB);
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *	d2h(d)
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

function d2h(d) {
	d = (d > 255) ? d = 255 : ((d < 0) ? d = 0 : d)
	var hD = '0123456789ABCDEF';
	var h = hD.substr(d&15, 1);
	while(d > 15) { d >>= 4; h = hD.substr(d&15, 1) + h; }
	return h;
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *	h2d(h)
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

function h2d(h) {
	return parseInt(h, 16);
}








