var anim; // global

function hex2string(hex){
	hex += '';//forced to string
	hex = hex.replace(/#/g, '');
	hex = hex.replace(/\s+/g, '');

	var output=[];
	for(var s=0; s<hex.length; s+=2){
		output.push(parseInt(hex.substring(s,s+2), 16));
	}
	
	output = 'rgb('+output.join(', ')+')';
	return output;
}

animateLogo = function() {
	var header = document.getElementById('header').getElementsByTagName('h1')[0];
	
	var lightRed = hex2string("#E13337");
	var darkRed  = hex2string("#643337");
	// var darkRed  = hex2string("#000000");
	
	var curColour = YAHOO.util.Dom.getStyle(header, 'backgroundColor')
	var colour = (curColour == lightRed) ? darkRed : lightRed;
				
	var attributes = { 
		backgroundColor: { to: colour } 
	};
	
	var dur = 16; // should represent hotness of site

	anim = new YAHOO.util.ColorAnim(header, attributes, dur, YAHOO.util.Easing.easeBoth);
	anim.onComplete.subscribe(animateLogo); // loop
	anim.animate();
}

YAHOO.util.Event.onAvailable('header', this.animateLogo);
