function getStyle(el,styleProp)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}


function getHexRGBColor(color)
{
  color = color.replace(/\s/g,"");
  var aRGB = color.match(/^rgb\((\d{1,3}[%]?),(\d{1,3}[%]?),(\d{1,3}[%]?)\)$/i);

  if(aRGB)
  {
    color = '';
    for (var i=1;  i<=3; i++) color += Math.round((aRGB[i][aRGB[i].length-1]=="%"?2.55:1)*parseInt(aRGB[i])).toString(16).replace(/^(.)$/,'0$1');
  }
  else color = color.replace(/^#?([\da-f])([\da-f])([\da-f])$/i, '$1$1$2$2$3$3');
  
  return color;
}


function splitRGB(color)
{
  color = getHexRGBColor(color); 
  var matches = color.match(/^#?([\dabcdef]{2})([\dabcdef]{2})([\dabcdef]{2})$/i);
    
  if (!matches) return false;
  
  for (var i=1, rgb = new Array(3);  i<=3; i++) rgb[i-1] = parseInt(matches[i],16);
  
  return rgb;
}

h_fc = new Array()

function fadeColor(domArray_index, targetColor){
	
	var currenElement = kidNodes[domArray_index]
	
	var realStyle = (currenElement.currentStyle) ? currenElement.currentStyle : document.defaultView.getComputedStyle(currenElement, null)	
	var currentColor = realStyle.color
	
	var currentRGB = splitRGB(currentColor)
	
	var targetRGB = splitRGB(targetColor)	
	
	var trendR = (currentRGB[0] < targetRGB[0]) ? 1 : (currentRGB[0] == targetRGB[0]) ? 0 : -1
	var trendG = (currentRGB[1] < targetRGB[1]) ? 1 : (currentRGB[1] == targetRGB[1]) ? 0 : -1
	var trendB = (currentRGB[2] < targetRGB[2]) ? 1 : (currentRGB[2] == targetRGB[2]) ? 0 : -1

	currentRGB[0] += trendR
	currentRGB[1] += trendG
	currentRGB[2] += trendB

	
	currenElement.style.color = "rgb(" + currentRGB[0] + "," + currentRGB[1] + "," + currentRGB[2] + ")"
	
	h_fc[domArray_index] = setTimeout("fadeColor(" + domArray_index + ",'" + targetColor + "')", 10)
	
	if (currentRGB[0] == targetRGB[0] && currentRGB[1] == targetRGB[1] && currentRGB[2] == targetRGB[2]){
		clearTimeout(h_fc[domArray_index])
		
	}
}

function changeColorOver(domElem, targColor, currentColor){
	for (var i=0; i < kidNodes.length; i++){
		if (kidNodes[i] != domElem){
			//kidNodes[i].style.color = commonColor
			fadeColor(i, targColor)
		}
		else
			var currIndex = i
	}
	fadeColor(currIndex, currentColor)
}
