/**
 * @author frank
 */

initializeHeaders = function() {
	$$('div#main h1').each( function(el) {
		var classes = [['orange']];
		var extracontent = color = '';
		classes.each( function(cls) {
			el.getElements('span.'+cls).each( function(ei) {
				color = ei.getStyle('color');
				//new Element('font').set('html', ei.get('html')).setProperty('color',color).replaces(ei);
				extracontent = ei.get('html');
				ei.dispose();
			});
		});
		var content = el.get('html');
		var div = new Element('div').addClass('headercontainer').addClass(el.get('tag')).inject(el,'after');
		if(ie6) div.addClass('ignorepng');
		el.inject(div,'inside');
		var obj = new Swiff('/img/swf/nw-'+el.get('tag')+'.swf', {
		    width: 580,
		    height: 25,
		    params: {
		        wmode: 'transparent'
		    },
		    vars: {
		        txt: content,
				extra: extracontent,
				color: color.substr(1)
		    }
		});
		obj.replaces(el);

	});
	
	$$('div#main h2').each( function(el) {
		var classes = [['orange']];
		var extracontent = color = '';
		classes.each( function(cls) {
			el.getElements('span.'+cls).each( function(ei) {
				color = ei.getStyle('color');
				//new Element('font').set('html', ei.get('html')).setProperty('color',color).replaces(ei);
				extracontent = ei.get('html');
				ei.dispose();
			});
		});
		var content = el.get('html');
		var div = new Element('div').addClass('headercontainer').addClass(el.get('tag')).inject(el,'after');
		if(ie6) div.addClass('ignorepng');
		el.inject(div,'inside');
		var obj = new Swiff('/img/swf/nw-'+el.get('tag')+'.swf', {
		    width: 580,
		    height: 25,
		    params: {
		        wmode: 'transparent'
		    },
		    vars: {
		        txt: content,
				extra: extracontent,
				color: color.substr(1)
		    }
		});
		obj.replaces(el);

	});
	
}

initHeight = function(){
	var website = $('website').getSize().y;
	var header = $('header').getSize().y;
	var main = $('main').getSize().y;
	var sidebar = $('sidebar').getSize().y;
	var footer = $('footer').getSize().y;
	//alert(main +' > '+ (sidebar-header +' - '+ $('content').getSize().y));
	
	var column1 = (header + (main + footer));
	var column2 = (sidebar + footer);
	if (column1 < column2) {
		//$('website').setStyle('height', (column2) + 'px');
		$('content').setStyle('height', (sidebar-header) + 'px');
	}
}

initVideo = function(){
	if ($('banner-bekijk-de-video')) {
		//call multiBox
		var initMultiBox = new multiBox({
			mbClass: '.mbVideo',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
			container: $(document.body),//where to inject multiBox
			path: '/img/flv/',//path to mp3 and flv players
			useOverlay: false,//use a semi-transparent background. default: false;
			maxSize: {
				w: 1000,
				h: 1000
			},//max dimensions (width,height) - set to null to disable resizing
			addDownload: false,//do you want the files to be downloadable?
			pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
			addRollover: false,//add rollover fade to each multibox link
			addOverlayIcon: false,//adds overlay icons to images within multibox links
			addChain: false,//cycle through all images fading them out then in
			recalcTop: false,//subtract the height of controls panel from top position
			addTips: false,
			showControls: false//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
		});
	}
}

initMultiBox = function(){
	if ($$('.mb')) {
		//call multiBox
		var initMultiBox = new multiBox({
			mbClass: '.mb',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
			container: $(document.body),//where to inject multiBox
			path: '/img/flv/',//path to mp3 and flv players
			useOverlay: false,//use a semi-transparent background. default: false;
			maxSize: {
				w: 600,
				h: 400
			},//max dimensions (width,height) - set to null to disable resizing
			addDownload: false,//do you want the files to be downloadable?
			pathToDownloadScript: './Scripts/ForceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
			addRollover: false,//add rollover fade to each multibox link
			addOverlayIcon: false,//adds overlay icons to images within multibox links
			addChain: false,//cycle through all images fading them out then in
			recalcTop: false,//subtract the height of controls panel from top position
			addTips: false//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
		});
	}
}

initResults = function(){
	if($('search_results')){
		$$('div#search_results div.starter').each(function(el){
			el.addEvents({
				'mouseenter': function(){
					if(ie6){
						el.setStyles({
							'background': 'none',
							'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader (src="/img/pagina/png/bg-starter2.png", sizingMethod="image")'
						});
					}else{
						el.setStyle('background-image', 'url(/img/pagina/png/bg-starter2.png)');
					}
				},
				'mouseleave': function(){
					if(ie6){
						el.setStyles({
							'background': 'none',
							'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader (src="/img/pagina/png/bg-starter.png", sizingMethod="image")'
						});
					}else{
						el.setStyle('background-image', 'url(/img/pagina/png/bg-starter.png)');
					}
				},
				'click': function(){
					window.location = el.getElement('a').get('href');
				}
			});
		});
	}
}

var ie6 = false;
window.addEvent('domready', function() {
	if(Browser.Engine.trident && Browser.Engine.version == 4) ie6 = true;
	initializeHeaders();
	new Inputfocus('inputfocus');
	initVideo();
	initResults();
	initMultiBox();
});
