  //**      **//
 //** Vote **//
//**      **//

function vote(id) {
	new Request({
		evalScripts:	false,
		url:			'template/ajax/vote.php',
		method:			'get',
		onRequest:		function() {
							var element = $('video-' + id).getElement('a.thumbs-up');
							var myFx = new Fx.Tween(element, {property: 'opacity', duration: '300'});
							myFx.start(1,0).chain(
								function() {
									var a = element.innerHTML;
									element.innerHTML = (Number(a.substr(0, a.indexOf(' ')) ) + 1) + ' x';
									element.setProperty('onclick', 'return false;');
									element.addClass('thumbs-noclick');
									this.start(0,1);
								}
							);
						}
	}).send('video=' + id + '&vote=1');
}

function page_vote(id, vote) {
	new Request({
		evalScripts:	false,
		url:			'template/ajax/vote.php',
		method:			'get',
		onRequest:		function() {
							var myFx = new Fx.Tween($('vote'), {property: 'opacity', duration: '300'});
							myFx.start(1,0).chain(
								function() {
									var a = $('vote').getElement('span');
									var b = a.innerHTML;
									if (vote == '1') {
										a.innerHTML = (Number(b.substr(0, b.indexOf(' ')) ) + 1) + ' x';
										$('vote').getElement('a.plus').fade('hide');
										$('vote').getElement('a.minus').fade('show');
									}
									else {
										a.innerHTML = (Number(b.substr(0, b.indexOf(' ')) ) - 1) + ' x';
										$('vote').getElement('a.minus').fade('hide');
										$('vote').getElement('a.plus').fade('show');
									}
									this.start(0,1);
								}
							);
						}
	}).send('video=' + id + '&vote=' + vote);
}

  //**       **//
 //** Login **//
//**       **//

function toggleTopButton(i) {
	var a = $('toggle-login');
	if (a.hasClass('active') == true) {
		a.setStyles( {
			'background-color': '#ff8900',
			'color': '#fff'
		});
		a.removeClass('active');
	}
	else {
		a.setStyles( {
			'background-color': '#fff',
			'color': '#ff8900'
		});
		a.addClass('active');
	}
}

  //**       **//
 //** Popup **//
//**       **//

function popup() {
	var el = new Element('div', { 'id': 'popup_container' });
	el.set('html', '<div id="popup_overlay" style="background-color: rgb(0, 0, 0); opacity: 0;" onclick="hide_popup()"></div>');
	el.inject(document.body, 'bottom');
	$('popup_overlay').tween('opacity', [0, 0.8]);
}
function hide_popup() {
	$('popup_overlay').fade('in').get('tween').chain(function() { $('popup_container').fade('out').get('tween').chain(function() { $('popup_container').destroy(); }) });
}

function test_popup() {
	popup();
	setTimeout(function() {
		var el = new Element('div', { 'id': 'login', 'html': 'TEXT' });
		el.inject($('popup_container'), 'bottom');
		el.tween('opacity', [0, 1] );
	}, 500);
}

  //**        **//
 //** Follow **//
//**        **//

function follow(tag) {
	var a = $('content').getElement('a.notification');
	new Request({
		evalScripts:	false,
		url:			'template/ajax/follow.php',
		method:			'get',
		onRequest:		function() {
							a.fade('out');
						},
		onComplete:		function() {
							a.setProperties({
								href: 'mijntags/',
								onclick: ''
							});
							a.innerHTML = 'Je volgt deze tag in je profiel. Klik hier voor het overzicht.';
							a.morph({ 'background-color' : '#9acf43', 'border-color' : '#7dc900' } );
							a.fade('in');
						}
	}).send('id=' + tag);
}