function resizeFrame(iPixels){
    iPixels = iPixels + 30;
    f = document.getElementById('FrameHexon');
    f.style.height = iPixels + 'px';
}

window.addEvent('domready', function(){

    $$('#contentlayerprint img').each(function(img){
        if (img.src.contains('-hover-off')) {
            img.addEvent('mouseover', function(){
                img.src = img.src.replace('-hover-off', '-hover-on');
            });
            img.addEvent('mouseout', function(){
                img.src = img.src.replace('-hover-on', '-hover-off');
            });
        }
    });
});

var MooCountdown = new Class({

    Implements: [Events, Options],
    
    options: {
        // public options
        container: 'countdown',
        futureDate: $empty,
        onlySeconds: false,
        dayText: 'dagen',
        hourText: 'uren',
        minuteText: 'minuten',
        secondText: 'seconden',
        onCompleteText: '',
        startFont: '32px',
        finishFont: '16px',
        duration: 1000,
        onComplete: $empty,
        // private options
        amount: $empty,
        amountTotal: $empty,
        days: $empty,
        hours: $empty,
        minutes: $empty,
        seconds: $empty
    },
    
    initialize: function(options){
        this.setOptions(options);
        
        if (this.options.onlySeconds === true) {
            this.options.amountTotal = this.options.futureDate;
            this.startOnlySeconds();
        }
        else {
            this.start();
        }
    },
    
    start: function(){
        this.getCount();
    },
    
    getCount: function(){
    
        var out = '';
        this.now = new Date();
        
        this.options.amount = this.options.futureDate - this.now.getTime();
        
        this.options.amount = Math.floor(this.options.amount / 1000);
        this.options.amountTotal = this.options.amount;
        
        this.options.days = Math.floor(this.options.amount / 86400);
        this.options.amount = this.options.amount % 86400;
        
        this.options.hours = Math.floor(this.options.amount / 3600);
        this.options.amount = this.options.amount % 3600;
        
        this.options.minutes = Math.floor(this.options.amount / 60);
        this.options.amount = this.options.amount % 60;
        
        this.options.seconds = this.options.amount;
        
        if (this.options.days != 0) {
            out += this.options.days + " " + this.options.dayText + ((this.options.days != 1) ? "s" : "") + ", ";
        }
        if (this.options.days != 0 || this.options.hours != 0) {
            out += this.options.hours + " " + this.options.hourText + ((this.options.hours != 1) ? "s" : "") + ", ";
        }
        if (this.options.days != 0 || this.options.hours != 0 || this.options.minutes != 0) {
            out += this.options.minutes + " " + this.options.minuteText + ((this.options.minutes != 1) ? "s" : "") + ", ";
        }
        
        $(this.options.container).set('text', out);
        
        var elSeconds = new Element('span', {
            id: "seconds",
            html: this.options.seconds
        });
        
        elSeconds.inject(this.options.container);
        
        this.options.amountTotal--;
        var fx = new Fx.Tween($("seconds"), {
            duration: this.options.duration,
            onComplete: function(){
                if (this.options.amountTotal >= 0) {
                    this.getCount();
                }
                else {
                    $(this.options.container).set('text', this.options.onCompleteText);
                    this.fireEvent('complete');
                }
            }
.bind(this)
        }).start('font-size', [this.options.startFont, this.options.finishFont]);
        
    },
    
    startOnlySeconds: function(){
    
        $(this.options.container).set('text', this.options.amountTotal);
        
        this.options.amountTotal--;
        var fx = new Fx.Tween(this.options.container, {
            duration: this.options.duration,
            onComplete: function(){
                if (this.options.amountTotal >= 0) {
                    this.startOnlySeconds();
                }
                else {
                    $(this.options.container).set('text', this.options.onCompleteText);
                    this.fireEvent('complete');
                }
            }
.bind(this)
        }).start('font-size', [this.options.startFont, this.options.finishFont]);
        
    }
    
});

var currentNewsSplashItem = 1;
var totalNewsSplashItems = 0;
var newsTimerRunning = false; // boolean flag
var newsTimer = null;

function switchActiveNewsItem(id){
	if (totalNewsSplashItems >= 1) {
	
		for (i = 1; i <= totalNewsSplashItems; i++) {
			if ($('newsItem' + i).hasClass('newsActive')) {
				$('newsItem' + i).removeClass('newsActive');
				$('newsImg' + i).removeClass('showNewsImg');
			}
		}
		currentNewsSplashItem = id;
		$('newsItem' + id).addClass('newsActive');
		$('newsImg' + id).addClass('showNewsImg');
	}
}

function stopTimer(id){
    if (newsTimerRunning) {
        clearTimeout(newsTimer);
    }
    switchActiveNewsItem(id);
}

