var isIE = (navigator.appName.indexOf("Microsoft") != -1 && navigator.appVersion.indexOf("Windows") > -1)+1-1;
try { if (isIE) document.execCommand('BackgroundImageCache', false, true); } catch(e) {}

var hasFlash = function(){
	var nRequiredVersion = 8;
	if(isIE){
		document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & ' + nRequiredVersion + '))) \n</script\> \n');
		if(window.hasFlash != null){ return window.hasFlash;};
	};
	if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
		var flashDescription = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description;
		var vr = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1)); if (vr < 4) vr += 10;	
		return vr >= nRequiredVersion;
	};
	return false;
}();


function zetKaartFlash(naam) {
	if (hasFlash){
	   eId('kaartjeHome').innerHTML = flash("/grafiek/" + naam + ".swf", 345, 377, "#FFFFFF", "transparent", "", "", "kaartje");
	}	   
}

$(document).ready(function() {

	$("#slinger a, #iconen a, .verwanticoon").each(function() {$(this).attr('title', $(this).children('img').attr('title')); $(this).children('img').attr('alt',''); $(this).children('img').attr('title',''); });
	$("#slinger a, #iconen a, .verwanticoon, #mediavak a, #derooij, #canontekst a[href='#']").each(function() {$(this).data('title', $(this).attr('title')); $(this).attr('title', '');}).mousemove(tt);							
	$('body').append('<div id="tt"></div>');
	
	$("#canontekst a[href='#']").addClass('woordverklaring').click(function() {return false});
	
	// vindt de match 
	$(".onevenrij.laatsterij").addClass('laatsterijrechts');
	$(".evenrij.laatsterij").addClass('laatsterijlinks');

	$("a[rel='colorbox']").colorbox({transition:"fade", maxWidth:"95%", maxHeight:"95%", opacity:"0.8"});	

});

//tooltip
function tt(e){
		var tit = $(this).data('title');
		if (tit.indexOf('|') > 1){
			arr_title = tit.split('|');
			$('#tt').html(arr_title[1] + '<br /><strong>' + arr_title[0] + '</strong><br />' + arr_title[2]);
		} else {$('#tt').html(tit)}
		$('#tt').show();
		$('#tt').css('top', e.pageY + 'px'); $('#tt').css('left', e.pageX + 'px');
		$(this).mouseout(function(e){$('#tt').hide();});

		var xtra = 0 ; if (eId('strookknoppen')) xtra=20;
		var ttw =  $('#tt').width();
		if ((e.pageX + ttw + 10) > $(window).width()) { 
			$('#tt').css('marginLeft', '-' + (ttw + xtra) +  'px');
		} else {$('#tt').css('marginLeft', (0 + xtra) + 'px')}
}

//iconenrij

function scrolliconen(scrollWidth2){
	if (eId('iconen')) eId('iconen').scrollLeft += scrollWidth2;
	if (eId('slinger')) eId('slinger').scrollLeft += scrollWidth2;	
	eId('naarlinks').style.display = 'block';
}
function startscroll(scrollWidth2){
	scrollInterval = setInterval("scrolliconen(" + scrollWidth2 + ")", 200);
}

function stopscroll(){
	clearInterval(scrollInterval);
}

function getVensterPosition () {
	$('#content').append('<a onmousedown="startscroll(-78)" onclick="scrolliconen(-78)" onmouseup="stopscroll()" id="naarlinks"></a><a onmousedown="startscroll(78)" onclick="scrolliconen(78)" onmouseup="stopscroll()" id="naarrechts"></a>');
	$('#naarrechts').show();
	var totScrollPos = (pos -1) * scrollWidth;
	eId('iconen').scrollLeft += totScrollPos;
	if (pos != 1) { $('#naarlinks').show();} 
}


//timerime
function timerime(tb){
	if (hasFlash){
		window.onunload = bewaartijdbalk;
		var flashvars = "timelineXML=/timerime?search=" + tb;
		document.write(flash("/timerime/timerimeSWF.swf", 750, 500, "#FFFFFF", "", flashvars, "/timerime/", "timerimeSWF"));
	} else {dcument.write("Voor de tijdbalk is Flash benodigd...");}
}

function bewaartijdbalk(){
	//alert($('#eerstetijdbalk').val());
	document.cookie = "tijdbalk1=" + $('#eerstetijdbalk').val() + "; path=/";
	document.cookie = "tijdbalk2=" + $('#tweedetijdbalk').val() + "; path=/";
}

function reposition(nHeight)
{
	nHeight += "px";
	eId("timerimeSWF").style.height = nHeight;
}

function showTimeline(tl)
{	location.hash = tl;
	eId("timerimeSWF").newTimeline("/timerime?search=" + tl);
}

function showPeriod(begin,end){
	eId("timerimeSWF").expandPeriod(begin,end);
}

function swfLoaded() {
	c2 = location.hash.replace('#','');
	if (c2 != '') {showTimeline(c2); eId("tweedetijdbalk").value = c2;}
	eId("timerimeSWF").expandPeriod('1750','2000');
}

//hulpfuncties

function eId(id){return document.getElementById(id);}

function getCookie(name, defval) {
	var nameEQ = name + "="; var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) {
			ck = '' + c.substring(nameEQ.length,c.length); if (ck != '') return ck;}
	}
	return defval;
}

function flash(movie, w, h, bg, wm, flashvars, bas, id){
	if (isIE){
		return '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="' + id + '" width="'+ w + '" height="' + h + '"><param name="movie" value="' + movie + '" /><param name="FlashVars" value="' + flashvars + '" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="' + wm + '" /><param name="bgcolor" value="' + bg + '" /><param name="allowScriptAccess" value="always" /><param name="base" value="' + bas + '" /><param name="allowfullscreen" value="true" /></object>';
	} else {
		return '<embed src="' + movie + '" id="' + id + '" quality="high" wmode="' + wm + '" bgcolor="' + bg + '" menu="false" width="'+ w + '" base="' + bas + '" height="'+ h + '" FlashVars="' + flashvars + '" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowfullscreen="true" />';}
}



// sociaal
var url = window.document.location;
var title = window.document.title;
var email;

function sociaalmenu(eml){
	email = eml; if (email == '') email = 'post|ab-c.nl';
	var favtit = "voeg toe aan favorieten"
	if (!isIE) favtit = "sleep naar bookmarks";	
	var r = '';
	r += '<div id="alg"' + (isIE ? ' class="ie"' : '') + '>';
	r += '<a href="javascript:window.print()" id="print" title="printen"><span>print</span></a>';
	r += '<a href="javascript:pdf()" id="pdf" title="opslaan als pdf"><span>pdf</span></a>';
	r += '<a href="#" id="mail" title="reageren of doorsturen"><span>mailen</span></a>';
	r += '<a href="' + url + '" onclick="fav(); return false;" style="border: !important" id="fav" title="' + favtit + '"><span>' + title + '</span>&nbsp;&nbsp;&nbsp;&nbsp;</a>';
	r += '<a target="_blank" href="http://www.delicious.com/post?url=' + escape(url) + '&title=' + escape(title) + '" title="Delicious"></a>';
	r += '<a target="_blank" href="http://twitter.com/home?status=' + escape(title + ' ' + url) + '" title="Twitter"></a>';				
	r += '<a target="_blank" href="http://www.hyves.nl/profilemanage/add/tips/?name=' + escape(title) + '&text=' + escape(url) + '&type=12" title="Hyves"></a>';		
	r += '<a target="_blank" href="http://www.google.com/buzz/post?url=' + escape(url) + '" title="Google Buzz"></a>';
	r += '<a target="_blank" href="http://favorites.live.com/quickAdd.aspx?url=' + escape(url) + '&title=' + escape(title) + '" title="Msn/Live Favorite"></a>';	
	r += '<a target="_blank" href="http://www.facebook.com/sharer.php?u=' + escape(url) + '&t=' + escape(title) + '" title="Facebook"></a>';	
		
	r += '</div>';
	
	document.write(r);
	
	$('#mail').colorbox({href:"/post/mail.htm", width:"550px"}, function(){mailform();});
}

function fav(){
	if (isIE) {window.external.AddFavorite(url,title)} else {alert('Sleep het aangeklikte icoontje naar de bookmark-balk van uw browser!')}
}

function pdf(){location.href='/post/pdf.aspx?url=' + url;}




// ColorBox v1.2.7
(function(B){var G,V,W,d,z,k,b,F,c,Q,D,e,s,j,m,P,l,H,t;var X,i,g,a,p,A,T,w,I,q="colorbox",o="hover";var y,f,R,L,K,J,r,M;var x="cbox_open",O="cbox_load",u="cbox_complete",h="cbox_close",n="cbox_closed";var C={transition:"elastic",speed:350,width:false,height:false,initialWidth:"400",initialHeight:"400",maxWidth:false,maxHeight:false,resize:true,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:true,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,overlayClose:true,slideshow:false,slideshowAuto:true,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow"};B(function(){R()});function N(Y){if(Y.keyCode==37){Y.preventDefault();H.click()}else{if(Y.keyCode==39){Y.preventDefault();l.click()}}}function E(Y,Z){Z=Z=="x"?document.documentElement.clientWidth:document.documentElement.clientHeight;return(typeof Y=="string")?(Y.match(/%/)?(Z/100)*parseInt(Y,10):parseInt(Y,10)):Y}function v(Y){return T.photo?true:Y.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(.*))?$/i)}function U(){for(var Y in T){if(typeof(T[Y])=="function"){T[Y]=T[Y].call(p)}}}B.fn.colorbox=function(Z,Y){if(this.length){this.each(function(){var aa=B(this).data(q)?B.extend({},B(this).data(q),Z):B.extend({},C,Z);B(this).data(q,aa).addClass("cboxelement")})}else{B(this).data(q,B.extend({},C,Z))}B(this).unbind("click.colorbox").bind("click.colorbox",function(ab){p=this;T=B(p).data(q);U();B().bind("keydown.cbox_close",function(ac){if(ac.keyCode==27){ac.preventDefault();t.click()}});if(T.overlayClose===true){G.css({cursor:"pointer"}).one("click",M)}p.blur();I=Y||false;var aa=T.rel||p.rel;if(aa&&aa!="nofollow"){c=B(".cboxelement").filter(function(){var ac=B(this).data(q).rel||this.rel;return(ac==aa)});A=c.index(p);if(A<0){c=c.add(p);A=c.length-1}}else{c=B(p);A=0}if(!w){B.event.trigger(x);t.html(T.close);G.css({opacity:T.opacity}).show();w=true;K(E(T.initialWidth,"x"),E(T.initialHeight,"y"),0);if(B.browser.msie&&B.browser.version<7){Q.bind("resize.cboxie6 scroll.cboxie6",function(){G.css({width:Q.width(),height:Q.height(),top:Q.scrollTop(),left:Q.scrollLeft()})})}}r();L();ab.preventDefault()});if(Z&&Z.open){B(this).triggerHandler("click.colorbox")}return this};R=function(){function Y(Z){return B('<div id="cbox'+Z+'"/>')}Q=B(window);V=B('<div id="colorbox"/>');G=Y("Overlay").hide();W=Y("Wrapper");d=Y("Content").append(D=Y("LoadedContent").css({width:0,height:0}),e=Y("LoadingOverlay"),s=Y("LoadingGraphic"),j=Y("Title"),m=Y("Current"),P=Y("Slideshow"),l=Y("Next"),H=Y("Previous"),t=Y("Close"));W.append(B("<div/>").append(Y("TopLeft"),z=Y("TopCenter"),Y("TopRight")),B("<div/>").append(k=Y("MiddleLeft"),d,b=Y("MiddleRight")),B("<div/>").append(Y("BottomLeft"),F=Y("BottomCenter"),Y("BottomRight"))).children().children().css({"float":"left"});B("body").prepend(G,V.append(W));if(B.browser.msie&&B.browser.version<7){G.css("position","absolute")}d.children().addClass(o).mouseover(function(){B(this).addClass(o)}).mouseout(function(){B(this).removeClass(o)}).hide();X=z.height()+F.height()+d.outerHeight(true)-d.height();i=k.width()+b.width()+d.outerWidth(true)-d.width();g=D.outerHeight(true);a=D.outerWidth(true);V.css({"padding-bottom":X,"padding-right":i}).hide();l.click(f);H.click(y);t.click(M);d.children().removeClass(o)};K=function(ab,aa,Z,ac){var ad=document.documentElement.clientHeight;var af=ad/2-aa/2;var ae=document.documentElement.clientWidth/2-ab/2;if(aa>ad){af-=(aa-ad)}if(af<0){af=0}if(ae<0){ae=0}af+=Q.scrollTop();ae+=Q.scrollLeft();ab=ab-i;aa=aa-X;W[0].style.width=W[0].style.height="9999px";function ag(ah){z[0].style.width=F[0].style.width=d[0].style.width=ah.style.width;s[0].style.height=e[0].style.height=d[0].style.height=k[0].style.height=b[0].style.height=ah.style.height}var Y=(V.width()===ab&&V.height()===aa)?0:Z;V.dequeue().animate({height:aa,width:ab,top:af,left:ae},{duration:Y,complete:function(){ag(this);W[0].style.width=(ab+i)+"px";W[0].style.height=(aa+X)+"px";if(ac){ac()}},step:function(){ag(this)}})};J=function(ad){if(!w){return}Q.unbind("resize.cbox_resize");var ab=T.transition=="none"?0:T.speed;D.remove();D=B(ad);var Z;var aj;function ah(){if(T.width){Z=maxWidth}else{Z=maxWidth&&maxWidth<D.width()?maxWidth:D.width()}return Z}function ag(){if(T.height){aj=maxHeight}else{aj=maxHeight&&maxHeight<D.height()?maxHeight:D.height()}return aj}D.hide().appendTo("body").attr({id:"cboxLoadedContent"}).css({width:ah()}).css({height:ag()}).prependTo(d);if(B.browser.msie&&B.browser.version<7){B("select").not(B("#colorbox select")).filter(function(){return B(this).css("visibility")!="hidden"}).css({visibility:"hidden"}).one(h,function(){B(this).css({visibility:"inherit"})})}var Y=B("#cboxPhoto")[0];if(Y&&T.height){var ae=(aj-parseInt(Y.style.height,10))/2;Y.style.marginTop=(ae>0?ae:0)+"px"}function ai(am){var al=Z+a+i;var an=aj+g+X;K(al,an,am,function(){if(!w){return}if(B.browser.msie){if(Y){D.fadeIn(100)}V.css("filter","")}d.children().show();B("#cboxIframeTemp").after("<iframe id='cboxIframe' name='iframe_"+new Date().getTime()+"' frameborder=0 src='"+(T.href||p.href)+"' />").remove();e.hide();s.hide();P.hide();if(c.length>1){m.html(T.current.replace(/\{current\}/,A+1).replace(/\{total\}/,c.length));l.html(T.next);H.html(T.previous);B().unbind("keydown",N).one("keydown",N);if(T.slideshow){P.show()}}else{m.hide();l.hide();H.hide()}j.html(T.title||p.title);B.event.trigger(u);if(I){I.call(p)}if(T.transition==="fade"){V.fadeTo(ab,1,function(){if(B.browser.msie){d.css("filter","")}})}Q.bind("resize.cbox_resize",function(){K(al,an,0)})})}if(T.transition=="fade"){V.fadeTo(ab,0,function(){ai(0)})}else{ai(ab)}if(T.preloading&&c.length>1){var ac=A>0?c[A-1]:c[c.length-1];var af=A<c.length-1?c[A+1]:c[0];var ak=B(af).data(q).href||af.href;var aa=B(ac).data(q).href||ac.href;if(v(ak)){B("<img />").attr("src",ak)}if(v(aa)){B("<img />").attr("src",aa)}}};L=function(){p=c[A];T=B(p).data(q);U();B.event.trigger(O);e.show();s.show();t.show();var Y=T.height?E(T.height,"y")-g-X:false;var ab=T.width?E(T.width,"x")-a-i:false;if(T.maxHeight){maxHeight=T.maxHeight?E(T.maxHeight,"y")-g-X:false;Y=Y&&Y<maxHeight?Y:maxHeight}if(T.maxWidth){maxWidth=T.maxWidth?E(T.maxWidth,"x")-a-i:false;ab=ab&&ab<maxWidth?ab:maxWidth}maxHeight=Y;maxWidth=ab;var Z=T.href||p.href;if(T.inline){B('<div id="cboxInlineTemp" />').hide().insertBefore(B(Z)[0]).bind(O+" "+h,function(){D.children().insertBefore(this);B(this).remove()});J(B(Z).wrapAll("<div/>").parent())}else{if(T.iframe){J(B("<div><div id='cboxIframeTemp' /></div>"))}else{if(T.html){J(B("<div/>").html(T.html))}else{if(v(Z)){var aa=new Image();aa.onload=function(){aa.onload=null;if((maxHeight||maxWidth)&&T.resize){var ae=this.width;var ac=this.height;var ag=0;var af=this;var ad=function(){ac+=ac*ag;ae+=ae*ag;af.height=ac;af.width=ae};if(maxWidth&&ae>maxWidth){ag=(maxWidth-ae)/ae;ad()}if(maxHeight&&ac>maxHeight){ag=(maxHeight-ac)/ac;ad()}}J(B("<div />").css({width:this.width,height:this.height}).append(B(this).css({width:this.width,height:this.height,display:"block",margin:"auto",border:0}).attr("id","cboxPhoto")));if(c.length>1){B(this).css({cursor:"pointer"}).click(f)}if(B.browser.msie&&B.browser.version==7){this.style.msInterpolationMode="bicubic"}};aa.src=Z}else{B("<div />").load(Z,function(ac,ad){if(ad=="success"){J(B(this))}else{J(B("<p>Request unsuccessful.</p>"))}})}}}}};f=function(){A=A<c.length-1?A+1:0;L()};y=function(){A=A>0?A-1:c.length-1;L()};r=function(){var Z,Y,aa="cboxSlideshow_";P.bind(h,function(){clearTimeout(Y);P.unbind()});function ab(){P.text(T.slideshowStop).bind(u,function(){Y=setTimeout(f,T.slideshowSpeed)}).bind(O,function(){clearTimeout(Y)}).one("click",function(){Z();B(this).removeClass(o)});V.removeClass(aa+"off").addClass(aa+"on")}Z=function(){clearTimeout(Y);P.text(T.slideshowStart).unbind(u+" "+O).one("click",function(){ab();Y=setTimeout(f,T.slideshowSpeed);B(this).removeClass(o)});V.removeClass(aa+"on").addClass(aa+"off")};if(T.slideshow&&c.length>1){if(T.slideshowAuto){ab()}else{Z()}}};M=function(){B.event.trigger(h);w=false;B().unbind("keydown",N).unbind("keydown.cbox_close");Q.unbind("resize.cbox_resize resize.cboxie6 scroll.cboxie6");G.css({cursor:"auto"}).fadeOut("fast");d.children().hide();V.stop(true,false).removeClass().fadeOut("fast",function(){p.focus();D.remove();V.css({opacity:1});B.event.trigger(n)})};var S=B.fn.colorbox;S.init=R;S.next=f;S.prev=y;S.close=M;S.load=L;S.position=K;S.dimensions=J;S.element=function(){return p};S.settings=C})(jQuery);
