var fireOn = (Browser.Engine.trident) ? 'load' : 'domready';
var orgValue = false;
window.addEvent(fireOn,function(){
	Slimbox.scanPage();
	/**
	 * Cufon
	 */
	Cufon.replace('div#header div.ornament blockquote p', {
		fontFamily:'helvetica_bold', 
		textShadow: '#459ba7 1px -1px',
		hover:true
	});
	
	Cufon.replace('h1', {
		fontFamily:'helvetica_bold', 
		hover:true
	});
	
	Cufon.replace('h2', {
		fontFamily:'helvetica_light', 
		hover:true
	});
	
	Cufon.replace('div#content div.default_markup h2', {
		fontFamily:'helvetica_bold', 
		hover:true
	});
	
	Cufon.replace('h3', {
		fontFamily:'helvetica_light', 
		hover:true
	});
	
	Cufon.replace('div#header div.ornament form label', {
		fontFamily:'helvetica_light'
	});
	
	Cufon.replace('div#header ul li', {
		fontFamily:'helvetica_light'
	});
	
	Cufon.replace('ul.aanbod_overview li div.text strong', {
		fontFamily:'helvetica_light'
	});
	
	Cufon.replace('div#content div.aanbod_right h2', {
		fontFamily:'helvetica_bold'
	});
	
	Cufon.replace('div#referenceSlider h2', {
		fontFamily:'helvetica_light'
	});
	
	Cufon.replace('div.reference_footer div', {
		fontFamily:'helvetica_light'
	});
	
	Cufon.replace('div#sidebar.missie div.box p', {
		fontFamily:'helvetica_light'
	});
	
	Cufon.replace('form h2', {
		fontFamily:'helvetica_light'
	});
	
	if($defined($('sliderContainer')))
	{
		var referenceSlider = new Slider('sliderContainer',
		{
			previousEl: $('arrowLeft')
			,nextEl: $('arrowRight')
		});
	}
	
	$('newsletter_email').addEvent('click', function(e)
	{
		if(orgValue == "") orgValue = e.target.value;
		if(e.target.value == orgValue) e.target.value = "";
	});
	
	$('newsletter_email').addEvent('blur', function(e)
	{
		if(e.target.value == "") e.target.value = orgValue;
	});
	
	if($$('#postit .center').length > 0) {
        if ($$('#postit .center')[0].getStyle('height').replace('px', '') < 158) {
            $$('#postit .bottom a').setStyle('display', 'none');
        }
	   	$$('#postit .center').setStyle('height', 10);
		$$('#postit .bottom a').addEvent('click', function(e) {
			e.stop();
			$$('#postit .center').setStyle('height', 'auto');
		});
	}



});

var Slider = new Class({
	Implements: Options,
	options: {
		width: 0
		,maxLeft: 0
		,currentLeft: 0
	}
	,initialize: function(el, options)
	{
		this.setOptions(options);
		this.el = $(el);
		//this.el.setStyle('width', 100);
		this.options.width = this.el.getStyle('width').replace('px', '').toInt();
		
		this.el = this.el.getElement('ul');
		
		$each(this.el.getElements('li'), function(el)
		{
			this.options.maxLeft += el.getStyle('width').replace('px', '').toInt();
		}.bind(this));
		
		this.options.previousEl.src = "/design/images/layout/arrow_left_inactive.png";
		if(this.options.maxLeft < this.options.width)
		{
			this.options.nextEl.src = "/design/images/layout/arrow_right_inactive.png";
		}
		else
		{
			this.options.previousEl.addEvent('click', this.previous.bind(this));
			this.options.nextEl.addEvent('click', this.next.bind(this));
		}
	}
	,previous: function()
	{
		this.options.currentLeft = this.options.currentLeft + this.options.width;
		this.options.nextEl.src = "/design/images/layout/arrow_right.png";
		if(this.options.currentLeft >= 0)
		{
			this.options.currentLeft = 0;
			this.options.previousEl.src = "/design/images/layout/arrow_left_inactive.png";
		}
		else
		{
			this.options.previousEl.src = "/design/images/layout/arrow_left.png";
		}
		this.el.tween('left', this.options.currentLeft);
	}
	,next: function()
	{
		this.options.currentLeft = this.options.currentLeft - this.options.width;
		this.options.previousEl.src = "/design/images/layout/arrow_left.png";
		if(this.options.currentLeft <= -this.options.maxLeft)
		{
			this.options.currentLeft = -this.options.maxLeft;
			this.options.nextEl.src = "/design/images/layout/arrow_right_inactive.png";
		}
		else
		{
			this.options.nextEl.src = "/design/images/layout/arrow_right.png";
		}
		this.el.tween('left', this.options.currentLeft);
	}
});
