/*************************************************************
     TEMPLATE BASED WEBSITE DESIGNED AND DEVELOPED BY
           VEBRA GRAPHICS (VEBRA SOLUTIONS LTD.)
                      COPYRIGHT 2006

      AUTHOR: DAVID SWALLOW (david.swallow@vebra.com)
                        21/04/2006

                      www.vebra.info
/*************************************************************/ 

//*************************
//    COLOR FADE FUNCTIONS
//*************************

//Changes the colour.
function fadeColour(id, startColour, endColour, type, numOfSteps, currentStep) {
	
	var element = document.getElementById(id);
	var degreesOfChange = numOfSteps-1;
	var step = currentStep / degreesOfChange;
	//in the format fadeColour( 'ff0098', 'fe0934', 0.23 )
	var oF = [], oT = [], oP = [];
	var oH = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
	//get the red, green and blue substrings ...
	for( var x = 0; x < 3; x++ ) {
		//... and convert them from hex into decimal ...
		oF[x] = eval( '0x' + startColour.substring( 2 * x, ( 2 * x ) + 2 ) );
		oT[x] = eval( '0x' + endColour.substring( 2 * x, ( 2 * x ) + 2 ) );
		//... add on the required portion of difference between the two ...
		oP[x] = Math.round( oF[x] + ( ( oT[x] - oF[x] ) * step ) );
		//... and convert it back into hex ...
		oP[x] = oH[ ( oP[x] - ( oP[x] % 16 ) ) / 16 ] + oH[ oP[x] % 16 ];
	}
	//... and put them back together again as a colour string
	var newColor = '#' + oP.join('');  
	if(type == "fg"){element.style.color = newColor;}
	if(type == "bg"){element.style.backgroundColor = newColor;}
}

//Creates the fade.
var fadeDelay = new Array();

function changeColour(id, startColour, endColour, type, numOfSteps, millisec) {
	var speed = Math.round(millisec / 100);
    var timer = 0;
	for(i = 0; i <= numOfSteps; i++) {
		fadeDelay[i] = setTimeout("fadeColour('" + id + "','" + startColour + "', '" + endColour + "', '" + type + "', '" + numOfSteps + "', '" + i + "')",(timer * speed));
		timer++;
	}
}