var debug = true;

$().ready(function()
{
	log("ready");
	
	setSifr();
});

sIFR.activate(chatoband);

function setSifr()
{
	var color = $("h1.cha").css("color") + '';
	if (color.indexOf('rgb') > -1) color = rgbToHex(color);

	sIFR.replace(chatoband, {
	    selector: '.textbox h1.cha'
	    ,css: [
	      '.sIFR-root { text-align: center; font-weight: normal; color: ' + color + '; font-size: 20px; line-height: 10px; }'
	      ,'a { text-decoration: none; }'
	      ,'a:link { color: ' + color + '; }'
	      ,'a:hover { color: ' + color + '; }'
	    ]
		,leading: -40
	    ,wmode: 'transparent'
	});

	sIFR.replace(chatoband, {
	    selector: '#footer h1.cha'
	    ,css: [
	      '.sIFR-root { text-align: left; font-weight: normal; color: ' + color + '; font-size: 20px; line-height: 10px; }'
	      ,'a { text-decoration: none; }'
	      ,'a:link { color: ' + color + '; }'
	      ,'a:hover { color: ' + color + '; }'
	    ]
		,leading: -40
	    ,wmode: 'transparent'
	});
}

function log(s)
{
	if (debug && self.console) console.log(s);
}


function rgbToHex(rgb) {
	var rgbvals = /rgb\((.+),(.+),(.+)\)/i.exec(rgb);
	var rval = parseInt(rgbvals[1]);
	var gval = parseInt(rgbvals[2]);
	var bval = parseInt(rgbvals[3]);
	return '#' + (
		rval.toString(16) +
		gval.toString(16) +
		bval.toString(16)
	);
}