// JavaScript Document
var pag='home';
var nieuwsid = null;

// GLOBALS
var artikelnr = new Array();
var bekeken = new Array();

window.addEvent('domready', function(){
	initvideomore();
	inithovers();
	});

window.addEvent('load', function(){
	slideshow = new SlideShow('head', 'getSlidesHome.php');
	$('meerschouwblog').setStyle('display' ,'block');
	if (nieuwsid) toonNieuws('n'+nieuwsid);
	});

// BEKEKEN
/*
function get_bekeken () {
	str_bekeken = Cookie.read('bekeken');
	if (str_bekeken) {
		bekeken = str_bekeken.split(',');
		}
	artikelkoppen = $('nieuws').getElements('.titel')
	for (i=0; i<artikelkoppen.length; i++) {
		artikelnr[i] = artikelkoppen[i].id;
		}
	for (i=0; i<bekeken.length; i++) {
		nummer = bekeken[i];
		if (!artikelnr.contains(nummer)) bekeken.remove(nummer);
		}
}


window.addEvent('domready', function(){
	//get_bekeken();
	var artikelkoppen = $$('#nieuws .titel');
	for (var i=0; i<artikelkoppen.length; i++) {
		if (bekeken.contains(''+artikelkoppen[i].id))  artikelkoppen[i].getElements('a').setStyle('color', '#666');
		artikelkoppen[i].addEvent('click', function(e){
			new Event(e).stop();
			toonNieuws(this.id);
			if (!bekeken.contains(this.id)) {
				var data = {item: this.getElements('a').innerHTML, soort_item:'nieuws'};
				var url = "log.php";
				//new Ajax(url, {method: 'post', data: data}).request();
				bekeken.include(this.id);
				}
			this.getElements('a').setStyle('color', '#666');
			});
		}
});

window.addEvent('unload', function(){
	//Cookie.write('bekeken', bekeken, {duration: 100})
	});
*/



function initvideomore() {
	var slideschouwblog = new Fx.Slide('meerschouwblog').hide();
	if ($('togglemeerschouwblog')) $('togglemeerschouwblog').addEvent('click', function(){slideschouwblog.toggle()});
}

function inithovers() {
	//$$('.nieuws .datum').fade('hide');
	$$('.nieuws .pijltje').fade('hide');
	$$('.horeca .pijlgeel').fade('hide');
	
	// binnenkort
	$(document.body).getElements('.vrstitem').addEvent('mouseenter', function() {
		this.morph({'background-color': '#333'});
		//this.getElement('h3').morph({'color': '#A01'});
		})
	$(document.body).getElements('.vrstitem').addEvent('mouseleave', function() {
		this.morph({'background-color': '#060606'});
		//this.getElement('h3').morph({'color': '#EEE'});
		})
	$(document.body).getElements('.blok').addEvent('click', function() {
		window.location.href = this.getElement('a').getProperty('href');
		})
	
	// nieuws
	$(document.body).getElements('.nieuws .item').addEvent('mouseenter', function() {
		this.morph({'background-color': '#FFF0EA'});
		this.getElement('.kort').morph({'color': '#111'});
		//this.getElement('.datum').fade('in');
		this.getElement('.pijltje').fade('in');
		})
	$(document.body).getElements('.nieuws .item').addEvent('mouseleave', function() {
		this.morph({'background-color': '#FFF'});
		this.getElement('.kort').morph({'color': '#555'});
		//this.getElement('.datum').fade('out');
		this.getElement('.pijltje').fade('out');
		})
	$(document.body).getElements('.nieuws .item').addEvent('click', function(e) {
		e.stop();
		toonNieuws(this.id);
		})
	
	// video
	$(document.body).getElements('#video .item').addEvent('mouseenter', function() {
		this.morph({'background-color': '#7DB8FF'});
		this.getElements('.ythumb').morph({'width': '70', 'height': '54', 'left': '-61', 'top': '-11'});
		})
	$(document.body).getElements('#video .item').addEvent('mouseleave', function() {
		this.morph({'background-color': '#1065cd'});
		this.getElements('.ythumb').morph({'width': '35', 'height': '28', 'left': '-43', 'top': '2'});
		})
	$(document.body).getElements('#video .item').addEvent('click', function(e) {
		e.stop();										
		window.location.href = this.getElement('a').getProperty('href');
		})
	$(document.body).getElements('#video .meer').addEvent('mouseenter', function() {
		this.morph({'background-color': '#7DB8FF'});
		})
	$(document.body).getElements('#video .meer').addEvent('mouseleave', function() {
		this.morph({'background-color': '#1065cd'});
		})
	
	// wijzigingen
	$('wijzigingen').addEvent('click', function(e) {
		e.stop();
		toonNieuws('n320');
		})
	
	$('wijzigingen').addEvent('mouseenter', function(e) {
		this.morph({'background-color': '#FC0'});
		})
	$('wijzigingen').addEvent('mouseleave', function(e) {
		this.morph({'background-color': '#FFF'});
		})
	
	// veiling
	$$('.horeca').addEvent('mouseenter', function(e) {
		this.morph({'background-color': '#333'});
		this.getElement('.pijlgeel').fade('in');
		})
	$$('.horeca').addEvent('mouseleave', function(e) {
		this.morph({'background-color': '#111'});
		this.getElement('.pijlgeel').fade('out');
		})
		
	// socialmedia
	$(document.body).getElements('#socialmedia img').addEvent('mouseenter', function() {
		this.morph({'width': '32', 'height': '32'});
		})
	$(document.body).getElements('#socialmedia img').addEvent('mouseleave', function() {
		this.morph({'width': '26', 'height': '26'});
		})
}

var twitterRequest = new RequestTwitter({
    parameters: {
        screen_name: 'schouwburgcuijk',
		include_rts: true,
        count: 10
    }
}).addEvents({
    success: function(data) {          
        data.each(function(tweet, i) {			
			new Element('div', {
                html: '' + tweet.text + '<br />',
                'class': 'tweet'
            }).inject($('twitter'));
			
        });
    }
}).send();

