/**
 * sIFR config/execution
 * 
 * prereq: sIFR 3(.436), jQuery (1.3.2)
 * load: body
 * 
 * Customized with jQuery code
 * Main reason for a lot of the customization was because of the web &
 * replacement font really differed in vertical geometry
 * With some trickery we minimize/prevent vertical shifting
 * 
 * beta version
 * 
 * @author AK
 */


if (typeof sIFR !== 'undefined') {
	var sIFRFont = {
		src: '/flash/sifr-vredenburg.swf',
		ratios: [6, 1.24, 11, 1.21, 19, 1.13, 27, 1.09, 31, 1.07, 32, 1.08, 40, 1.07, 62, 1.06, 63, 1.05, 64, 1.06, 109, 1.05, 114, 1.04, 122, 1.05, 1.04]
	};
	
	sIFR.useStyleCheck = true;
	//sIFR.fitExactly = true;
	//sIFR.useDomLoaded = false; // default: true
	//sIFR.fixWrap = true;
	//sIFR.forceClear = true;
	//sIFR.forceWidth = false;
	//sIFR.forceTextTransform = true;
	//sIFR.preserveSingleWhitespace  = false;
	
	var iHeightCorrectionExtra = 0;
	if ($.browser.msie) {
		iHeightCorrectionExtra = 4;
	}
	
	var oElements = {
		0: {
			selector: '#content #nieuwsItem h3',
			heightCorrection: 7 + iHeightCorrectionExtra,
			leading: -6,
			preventWrap: true,
			color: '#df2626'
		},
		1: {
			selector: '.contentItem h3.redDash',
			heightCorrection: 19,
			leading: -8,
			color: '#df2626'
		},
		2: {
			selector: '.contentItem h3.contentText',
			heightCorrection: 19,
			leading: -8,
			color: '#df2626'
		},
		3: {
			selector: '#bodyConcerten #content .mainInfo h2',
			heightCorrection: 3,
			leading: -6,
			color: '#ffffff'
		},
		4: {
			selector: '#bodyConcerten #content.showOverview h2',
			heightCorrection: 3,
			leading: -6,
			color: '#ffffff'
		}
	};
	
	var oReplacements = {};
	
	$.each(oElements, function(i) {
		var $this = $(this.selector);
		var iHeightCorrection = this.heightCorrection;
		var iLeading = this.leading;
		var sColor = this.color;
		var bPreventWrap = (typeof this.preventWrap !== 'undefined' && this.preventWrap === true) ? true : false;
		if ($this.length) {
			$this.each(function(j) {
				var $this = $(this);
				var sClassName = 'sIFR-toReplace-' + i + '-' + j;
				$this.addClass('sIFR-toReplace ' + sClassName);
				var iHeight = $this.height() + iHeightCorrection;
				oReplacements[i+j] = {
					selector: '.' + sClassName,
					height: iHeight,
					leading: iLeading,
					preventWrap: bPreventWrap,
					color: sColor
				};
			});
		}
	});
	
	sIFR.activate(sIFRFont);
	
	// in IE8 sIFR doesn't wrap properly at times
	var iMarginRight = 0;
	if ($.browser.msie && parseFloat($.browser.version) == 8) {
		iMarginRight = 6;
	}
	
	$.each(oReplacements, function() {
		var oReplacement = this;
		$(oReplacement.selector).height(oReplacement.height);
		sIFR.replace(sIFRFont, {
			selector: oReplacement.selector,
			css: [
				'.sIFR-root { margin-right: ' + iMarginRight + 'px; color: ' + oReplacement.color + '; text-transform: uppercase; leading: ' + oReplacement.leading + ';  }',
				'a { text-decoration: none; }',
				'a:link { color: #df2626; }',
				'a:hover { color: #000000; }'
			],
			onReplacement: function() {
				$(oReplacement.selector).css('height', 'auto');
			},
			forceSingleLine : oReplacement.preventWrap,
			wmode: 'transparent'
		});
	});

}
