// JavaScript Document
<!--
var bgW=0;
var bgH=0;

function resizeBg() {
	if (bgW==0) bgW=document.getElementById('backgroundImage').width;
	if (bgH==0) bgH=document.getElementById('backgroundImage').height;
	var ratio=bgW/bgH;
	
	//window.status=bgW+'x'+bgH+' '+ratio;
  var h = self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
  var w = self.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  var elem = document.getElementById('backgroundImage');

	if (h<w/ratio) {
		elem.width = w;
		elem.height = w/ratio;
	} else {
		elem.width = h*ratio;
		elem.height = h;
	}
	window.onresize=resizeBg;
}

var moverStatus=new Array();
function mover(t) {
	t=document.getElementById(t);
	l=t.src.length;
	if (t.src.substr(l-5,1)=='A' || t.src.substr(l-5,1)=='2') {
		moverStatus[t.src]='A';
		return;
	}
	e=t.src.substr(l-4,4);
	i=t.src.substr(0,l-4);
	t.src=i+"A"+e;
}
function mout(t) {
	t=document.getElementById(t);
	l=t.src.length;
	if (moverStatus[t.src]=='A' || moverStatus[t.src]=='2') return;
	if (t.src.substr(l-5,1)=='A') {
		e=t.src.substr(l-4,4);
		i=t.src.substr(0,l-5);
		t.src=i+e;
	}
}
function mover2(t) {
	t=document.getElementById(t);
	l=t.src.length;
	if (t.src.substr(l-5,1)=='A' || t.src.substr(l-5,1)=='2') {
		moverStatus[t.src]='A';
		return;
	}
	t.src=t.src+'&fg=000000';
}
function mout2(t) {
	t=document.getElementById(t);
	l=t.src.length;
	if (moverStatus[t.src]=='A' || moverStatus[t.src]=='2') return;
	if (t.src.substr(l-10,10)=='&fg=000000') {
		t.src=t.src.substr(0,l-10);
	}
}

function agendaGenre(t) {
	window.location.href='/film/agenda/'+t.options[t.selectedIndex].value;
}

var curX=0;

function movePhoto(goto) {
	t=document.getElementById('fotos');
	d=(goto-curX)/2.5;
	if (d<0.5 && d>-0.5) 
		curX=goto;
	else {
		curX=curX+d;
		setTimeout('movePhoto('+goto+')',50);
	}
	t.scrollLeft=Math.round(curX);
}

function prevPhoto() {
	movePhoto(0);
	//t=document.getElementById('fotos');
	//t.scrollLeft=t.scrollLeft-100;
}
function nextPhoto() {
	movePhoto(400);
	//t=document.getElementById('fotos');
	//t.scrollLeft=t.scrollLeft+100;
}

function mijnhoogtSluiten() {
	document.getElementById('mijnhoogt').className='mijnhoogtHidden';
	document.getElementById('iframe').src='';
	$('.youtube-player').show();
}
function mijnhoogt(url) {
	document.getElementById('mijnhoogt').className='mijnhoogt';
	if (url==undefined)
		url='http://bestellen.hoogt.nl/2010/Login.aspx';
	document.getElementById('iframe').src=url;
	$('.youtube-player').hide();
}
function koopticket(id) {
	mijnhoogt('http://bestellen.hoogt.nl/2010/ProgrammaDetail.aspx?id='+id+'&Display=edit')
}

var agenda=0;
function agendaNext() {
	document.getElementById('agendaScroll').scrollLeft=770;
	document.getElementById('next').style.display='';
	document.getElementById('prev').style.display='';
}
function agendaPrev() {
	document.getElementById('agendaScroll').scrollLeft=0;
	document.getElementById('next').style.display='';
	document.getElementById('prev').style.display='';
}

function agendaScroll() {
	if (agenda<=0) { agenda=0; $('#prev').hide(); } else $('#prev').show();
	if ((agenda+1)*770>$('#agendaScroll3').width()) { $('#next').hide(); } else $('#next').show();
	$('#agendaScroll').animate({scrollLeft: agenda*770},300);
}

function slideSwitch(t,speed) {
	var $active=$(t+' .slide.active');
	if ($active.length==0) $active=$(t+' .slide:last');
	var $next=$active.next().length ? $active.next() : $(t+' .slide:first');
	$active.addClass('last-active');
	$next.addClass('active')
		.hide()
		.fadeIn(speed, function() {
			$active.removeClass('active last-active');
		});
}
function slidePrev(t,speed) {
	var $active=$(t+' .slide.active');
	if ($active.length==0) $active=$(t+' .slide:last');
	var $next=$active.prev().length ? $active.prev() : $(t+' .slide:first');
	$active.addClass('last-active');
	$next.addClass('active')
		.hide()
		.fadeIn(speed, function() {
			$active.removeClass('active last-active');
		});
}

function ticker() {
	$('#ticker').scrollLeft($('#ticker').scrollLeft()+2);
	if ($('#ticker').scrollLeft()-2800>=$('#ticker DIV').width()-$('#ticker').width()) $('#ticker').scrollLeft(0);
	window.status=$('#ticker').scrollLeft()+' '+($('#ticker DIV').width()-$('#ticker').width());
}

$(document).ready(function() {
	if ($('#ticker').width()>100) setInterval('ticker()',30);

	$('#next').click(function() {
		agenda++;
		agendaScroll();
	});
	$('#prev').click(function() {
		agenda--;
		agendaScroll();
	});
	$('a[rel=enlarge]').fancybox({
		'padding':10,
		'opacity':true,
		'cyclic':true,
		'centerOnScroll':true,
		'hideOnContentClick':true,
		'overlayOpacity':0.7,
		'overlayColor':'#000',
		'overlayShow':true,
		'titleShow':true,
		'titlePosition':'inside',
		'transitionIn':'elastic',
		'transitionOut':'fade',
		'speedIn':250,
		'speedOut':100,
		'changeSpeed':100,
		'showCloseButton':true,
		'showNavArrows':true,
		'enableEscapeButton':true,
		'type':'image'
	});
	$('a.fancybox').fancybox({
		'padding':10,
		'width':815,
		'height':578,
		'autoScale':true,
		'opacity':true,
		'cyclic':true,
		'centerOnScroll':true,
		'hideOnContentClick':true,
		'overlayOpacity':0.7,
		'overlayColor':'#000',
		'overlayShow':true,
		'titleShow':true,
		'titlePosition':'inside',
		'transitionIn':'elastic',
		'transitionOut':'fade',
		'speedIn':250,
		'speedOut':100,
		'changeSpeed':100,
		'showCloseButton':true,
		'showNavArrows':true,
		'enableEscapeButton':true,
		'type':'iframe'
	});
	setInterval("slideSwitch('#carrousel',0)",6000);
});
