//config sIFR
var Carnevalee = {
	src: '/domains/liquidforce.nl/generate/Carnevalee_Freakshow.swf'
//	,ratios: [8, 1.41, 9, 1.33, 10, 1.35, 15, 1.31, 19, 1.28, 20, 1.27, 28, 1.26, 29, 1.24, 30, 1.25, 40, 1.24, 43, 1.23, 44, 1.24, 64, 1.23, 72, 1.22, 73, 1.23, 115, 1.22, 116, 1.21, 119, 1.22, 121, 1.21, 1.22]
};
sIFR.useStyleCheck = true;
sIFR.activate(Carnevalee);

/* == Converts color to HEX == */
var hex = function(N) {
	if(N==null) return "00";
	N = parseInt(N);
	if(N==0 || isNaN(N)) return "00";
	N = Math.max(0, N);
	N = Math.min(N, 255);
	N = Math.round(N);
	return "0123456789ABCDEF".charAt((N - N%16) / 16) + "0123456789ABCDEF".charAt(N%16);
};
/* == Converts colors to HEX == */
var hexed = function(color) {
	if(!color) { return false; }
	if(color.search('rgb') > -1) {
		color = color.substr(4,color.length-5).split(', ');
		color = hex(color[0]) + hex(color[1]) + hex(color[2]);
	}
	color = color.replace('#','');
	if(color.length < 6) {
		color = color.substr(0, 1) + color.substr(0, 1) + color.substr(1, 1) + color.substr(1, 1) + color.substr(2, 1) + color.substr(2, 1);
	}
	return '#' + color;
};

//my own routine to do a calculated sifr replacement.
var jquery_sifr_replacement = function(obj){
	$title = obj;
	sIFR.replace(Carnevalee, {
							elements: $title
							,wmode: 'transparent'
							,css: [
							  '.sIFR-root { font-size: ' + (parseInt($title.css('fontSize'))) + '; color: ' + hexed($title.css('color')) + '; }'
							  ,'a { text-decoration: none; color: ' + hexed($title.css('color')) + '; }'
							  ,'a:hover { color: ' + hexed($title.css('color:hover')) + '; }'
							]
						});
}


// start scripts
$(document).ready(function(){

	//do menu
	$("#menu ul a").not("#menu ul ul a").each(function(i){
		t = $(this).text();
		$(this).html('<img src="/domains/liquidforce.nl/generate/button.php?txt=' + escape(t) +'" alt="" border="0" />');
	});

	//sifr
	jquery_sifr_replacement($(".article h1,.content span.title"));

});

//emulate popup function...
function popWindow(u,w,h){
	//get data...
	$.getJSON("/domains/liquidforce.nl/js/getShopPicture.php?" + u.split('?')[1],function(JSONdata){
		$("<img width=\"" + JSONdata['width'] + "\" height=\"" + JSONdata['height'] + "\">")
			.attr('src',JSONdata['image'])
			.appendTo('#container')
			.displayBox();
	});
}
