jQuery(document).ready(function() {
	jQuery('#mycarousel').jcarousel({
		auto: 4,
		wrap: 'circular',
		animation: 'slow',
		initCallback: mycarousel_initCallback
	});
	setSpider("spider");

});
function elID(element){
	return document.getElementById(element);
}
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

function calCalendar(maand,jaar)
{
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("calendar").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","ajax.php?aId=calendar&month="+maand+"&year="+jaar,true);
	xmlhttp.send();
}
function toggle(id){
	//alert(document.getElementById(id).style.display);
	if(document.getElementById(id).style.display!='block'){
		document.getElementById(id).style.display='block';
	}else{
		document.getElementById(id).style.display='none';
	}
}
function pageWidth() {
	var width;
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 if (typeof window.innerWidth != 'undefined'){
		  width = window.innerWidth
	 }
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	 else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0){
		   width = document.documentElement.clientWidth
	 }
	 // older versions of IE
	 else{
		   width = document.getElementsByTagName('body')[0].clientWidth
	 }
	 return width-70;
}
function pageHeight() {
	var height;
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 if (typeof window.innerWidth != 'undefined'){
		  height = window.innerHeight
	 }
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	 else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0){
		   height = document.documentElement.clientHeight
	 }
	 // older versions of IE
	 else{
		   height = document.getElementsByTagName('body')[0].clientHeight
	 }
	 return height-40;
}

function setSpider(id){
	var spider=document.getElementById(id);
	var direction=Math.round(Math.random()*2);
	spider.style.top=Math.round(Math.random()*pageHeight())+"px";
	spider.style.left=Math.round(Math.random()*pageWidth())+"px";
	if(direction==1){
		spider.src="img/spiderl.gif";
	}else{
		spider.src="img/spiderr.gif";
	}
	moveSpider(id,direction);
}
function moveSpider(id,direction,teller,updown){
	var spider=document.getElementById(id);
	var top=parseFloat(spider.style.top.replace("px", ""));
	var left=parseFloat(spider.style.left.replace("px", ""));
	if(!teller){teller=1;}
	teller++;
	if(teller==50){
		updown=Math.round(Math.random()*10);
		teller=1;
	}
	
	if(top>pageHeight()){
		top=pageHeight();
	}
	if(top<0){
		top=0;
	}
	if(left>pageWidth()){
		left=pageWidth();direction=1;spider.src="img/spiderl.gif";
	}
	if(left<0){
		left=0;direction=0;spider.src="img/spiderr.gif";
	}
	if(direction==1){
		spider.style.left=left-1+'px';
	}else{
		spider.style.left=left+1+'px';
	}
	if(updown==2){
		spider.style.top=top+0.1+'px';
	}
	if(updown==4){
		spider.style.top=top-0.1+'px';
	}
	
	setTimeout("moveSpider('"+id+"','"+direction+"','"+teller+"','"+updown+"');",100);
}

function make_editor(editorname)
{
	if(elID(editorname)){
		CKEDITOR.replace(
			editorname,{
				toolbar :
					[						['Source','-','Preview'],						
						['Cut','Copy','Paste','PasteText'],
						['Undo','Redo','-','SelectAll','RemoveFormat'],
						['Table','HorizontalRule','Smiley','SpecialChar',],
						'/',
						['Styles','Format'],
						['Bold','Italic','Strike'],
						['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],						['Link','Unlink','Anchor'],												['Image','Flash'],
						['Maximize']

					]
				}
		);
	}
}$(document).ready(function() {	$("a.fancybox").fancybox({		'transitionIn'	:	'elastic',		'transitionOut'	:	'elastic',		'speedIn'		:	600, 		'speedOut'		:	200, 
		'overlayShow'	:	false	});});
