/*
Count down until any date script-
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
*/

//change the text below to reflect your own,
var before="Christmas!"
var current="Today is Christmas. Merry Christmas!"
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function countdown(yr,m,d){
  theyear=yr;themonth=m;theday=d
  var today=new Date()
  var todayy=today.getYear()
  if (todayy < 1000)
    todayy+=1900
  var todaym=today.getMonth()
  var todayd=today.getDate()
  var todayh=today.getHours()
  var todaymin=today.getMinutes()
  var todaysec=today.getSeconds()
  var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
  futurestring=montharray[m-1]+" "+d+", "+yr
  dd=Date.parse(futurestring)-Date.parse(todaystring)
  dday=Math.floor(dd/(60*60*1000*24)*1)
  dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
  dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
  dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
  if(dday >= 0)
    document.getElementById("count").innerHTML=dday
  else
    document.getElementById("count").innerHTML="0"
}
//enter the count down date using the format year/month/day + 1 dag
//countdown(2010,3,7)

//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/classes/timeline [rev. #0]

TimeLine = function(fps, f){
	this.fps = fps, this.frames = f;
};
with({o: TimeLine, $: TimeLine.prototype}){
	o.timers = [];
	$.running = !!($.current = +(o.timer = $.time = null));
	o.run = function(){
		var o = this;
		o.timer || (o.timer = setInterval(function(){
			for(var h, d = +(new Date), t = o.timers, i = t.length; i--;){
				(!t[i].running || ((d - t[i].time) / (1e3 / t[i].fps) > t[i].current + 1 &&
				t[i].onframe(++t[i].current), t[i].current >= t[i].frames)) &&
				(h = t.splice(i, 1)[0], h.stop(1));
			}
		}, 1));
	};
	$.start = function(c){
		var o = this, t = TimeLine;
		if(o.running) return;
		o.running = true, o.current = c || 0;
		o.time = new Date, o.onstart && o.onstart();
		if(!o.onframe || o.frames <= 0 || o.fps <= 0)
			return o.stop(1);
		t.timers.push(this), t.run();
	};
	$.stop = function(){
		var o = this;
		o.running = false;
		if(!TimeLine.timers.length)
			TimeLine.timer = clearInterval(TimeLine.timer), null;
		arguments.length && o.onstop && o.onstop();
	};
}

/* SmoothMovement.js - facilitates the smooth movement of display components
 *
 * The author of this program, Safalra (Stephen Morley), irrevocably releases
 * all rights to this program, with the intention of it becoming part of the
 * public domain. Because this program is released into the public domain, it
 * comes with no warranty either expressed or implied, to the extent permitted
 * by law.
 *
 * For more public domain JavaScript code by the same author, visit:
 * http://www.safalra.com/programming/javascript/
 */

/* Creates a SmoothMovement. A SmoothMovement produces integer position values
 * representing movement towards a target position, with a maximum acceleration
 * or deceleration of one distance unit per time unit squared. The parameters
 * are:
 *
 * position - the initial position
 * target   - the target position
 * velocity - the initial velocity. The first call to the updatePosition
 *            function will adjust the position by this value. This parameter is
 *            optional, and if it is not present it is assumed to be 0.
 *
 * All three parameters are rounded to the nearest integer.
 */
function SmoothMovement(position, target, velocity){

  // initialise the position, target, and velocity
  position = Math.round(position);
  target   = Math.round(target);
  velocity = (velocity ? Math.round(velocity) : 0);

  /* Updates the position and velocity of this SmoothMovement and returns the
   * new position. The position is updated before the new velocity is
   * calculated, so the position is adjusted by the initial velocity the first
   * time this function is called. If this SmoothMovement was created with an
   * initial velocity of 0, or without the initial velocity being specified, the
   * position will not change the first time this function is called.
   *
   * The velocity changes by at most a single unit. The velocity decreases if
   * this SmoothMovement would otherwise overshoot the target position (which
   * may still occur if the initial velocity was too great). The velocity
   * increases if doing so will not lead to this SmoothMovement overshooting the
   * target position. In all other cases, the velocity does not change.
   */
  this.updatePosition = function(){
    position += velocity;
    if (velocity < 0){
      if (position - velocity * (velocity  - 1) / 2 < target){
        velocity++;
      }else if (position - (velocity - 1) * (velocity - 2) / 2 >= target){
        velocity--;
      }
    }else{
      if (position + velocity * (velocity + 1) / 2 > target){
        velocity--;
      }else if (position + (velocity + 1) * (velocity + 2) / 2 <= target){
        velocity++;
      }
    }
    return position;
  }
  
  /* Changes the target position of this SmoothMovement will maintaining its
   * current position and velocity. The parameter is:
   *
   * newTarget - the new target position, which is rounded to the nearest
   *             integer
   */
  this.changeTarget = function(newTarget){
    target = Math.round(newTarget);
  }
  
  /* Returns the current position of this SmoothMovement.
   */
  this.getPosition = function(){
    return position;
  }

  /* Returns the current velocity of this SmoothMovement.
   */
  this.getVelocity = function(){
    return velocity;
  }
  
  /* Returns true if this SmoothMovement has stopped, and false otherwise. This
   * SmoothMovement has stopped if its position equals its target position and
   * its velocity is 0.
   */
  this.hasStopped = function(){
    return (position == target && velocity == 0);
  }
}

//konquerorBrowser = navigator.userAgent.indexOf("Konqueror");
//var konquerorMenuWidth = 0;
function show5(){
	if (!document.layers&&!document.all&&!document.getElementById)
	return
	var Digital=new Date()
	var hours=Digital.getHours()
	var minutes=Digital.getMinutes()
	if (minutes<=9)
		minutes="0"+minutes
	myclock=hours+":"+minutes
	if (document.all)
		liveclock.innerHTML=myclock
	else if (document.getElementById)
		document.getElementById("liveclock").innerHTML=myclock
	setTimeout("show5()",30000)
}
var bodyWidth = 0, bodyHeight = 0;
function windowSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    bodyWidth = window.innerWidth;
    bodyHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    bodyWidth = document.documentElement.clientWidth;
    bodyHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    bodyWidth = document.body.clientWidth;
    bodyHeight = document.body.clientHeight;
  }
}
var tijdlijn1 = new TimeLine(30, 80);
var beweging = new SmoothMovement(0, 500);
tijdlijn1.onframe = function(){
	document.getElementById('kmenu').style.height = beweging.updatePosition() + "px";
	document.getElementById('kmenu').style.width = beweging.getPosition() * 4 / 5 + "px";
//	if(konquerorBrowser == -1) // Niet meer nodig 4.3
		document.getElementById('kmenu').style.opacity = beweging.getPosition() / 500;
	if (beweging.hasStopped())
		tijdlijn1.stop();
};
tijdlijn1.onstart = function(){
	if (document.getElementById('kmenu').style.height == "0px") {
		beweging.changeTarget(500);
	}
	else {
		beweging.changeTarget(0);
	}
	document.getElementById('pindamenu').style.overflow = "hidden";
//	if(konquerorBrowser != -1) //patch Konqueror
//		document.getElementById('kmenu').style.visibility = "";
};
var allHTMLTags = new Array();
var allHTMLTags=document.getElementsByTagName('div');
var pindamenuHeight = 0;
tijdlijn1.onstop = function(){
	if (pindamenuHeight == 0) {
		pindamenuHeight = 500 - document.getElementById('pindamenu').offsetTop;
		document.getElementById('pindamenu').style.height = pindamenuHeight + "px";
		for (i=0; i < allHTMLTags.length; i++) {
			if (allHTMLTags[i].className=='psmenu') {
				allHTMLTags[i].style.height= pindamenuHeight + "px";
			}
		}
	}
	document.getElementById('pindamenu').style.overflow = "auto";
/*	if(konquerorBrowser != -1) { //patch Konqueror
		konquerorMenuWidth = beweging.getPosition() * 4 / 5;
		document.getElementById('viewer').style.left = konquerorMenuWidth + 12 + "px";
		document.getElementById('viewer').style.width = (bodyWidth - 176 - konquerorMenuWidth) + "px";
		if(konquerorMenuWidth == 0)
			document.getElementById('kmenu').style.visibility = "hidden";
	}
*/
};
var tijdlijnSlidePsmenu = new TimeLine(30, 80);
var bewegingSlidePsmenu = new SmoothMovement(400, 0);
var knotenSlidePsmenu;
tijdlijnSlidePsmenu.onframe = function(){
	knotenSlidePsmenu.style.left= bewegingSlidePsmenu.updatePosition() + "px";
	knotenSlidePsmenu.style.width= 400 - bewegingSlidePsmenu.getPosition() + "px";
	if (bewegingSlidePsmenu.hasStopped())
		tijdlijnSlidePsmenu.stop();
};
tijdlijnSlidePsmenu.onstart = function(){
	knotenSlidePsmenu.style.overflow = "hidden";
	knotenSlidePsmenu.firstChild.style.height = knotenSlidePsmenu.style.height; 
	if (knotenSlidePsmenu.style.left == "0px") {
		bewegingSlidePsmenu = new SmoothMovement(0, 400);
	}
	else {
		bewegingSlidePsmenu = new SmoothMovement(400, 0);
	}
};
tijdlijnSlidePsmenu.onstop = function(){
	if (bewegingSlidePsmenu.getPosition() == 0) {
		if (knotenSlidePsmenu.scrollHeight > parseInt(knotenSlidePsmenu.style.height)) {
			knotenSlidePsmenu.firstChild.style.height = knotenSlidePsmenu.scrollHeight + "px";
			knotenSlidePsmenu.style.overflow = "auto";
		}
		else {
			knotenSlidePsmenu.firstChild.style.height = knotenSlidePsmenu.style.height;
			knotenSlidePsmenu.style.overflow = "hidden";
		}
	} 
};
function slidePsmenu(element) {
	knotenSlidePsmenu = element.nextSibling;
	while ( knotenSlidePsmenu.className != "psmenu") {
		knotenSlidePsmenu = knotenSlidePsmenu.nextSibling;
	}
	tijdlijnSlidePsmenu.start();
}
function slideBack(element) {
	knotenSlidePsmenu = element.parentNode;
	tijdlijnSlidePsmenu.start();
}
function hideProgress(){
	document.getElementById('loader').style.visibility = 'hidden';
}
function showProgress(){
//	if(konquerorBrowser == -1) //patch Konqueror
		document.getElementById('loader').style.visibility = '';
}
function pmenuclick(element) {
	showProgress();
	tijdlijn1.start();
}

// Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-27795208-1']);
_gaq.push(['_trackPageview']);
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

// ajax
function ajaxObject(url, callbackFunction) {
  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;                          
    if (window.XMLHttpRequest) {              
      that.AJAX=new XMLHttpRequest();              
    } else {                                  
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }                                             
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4) {             
          that.updating=false;
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();                              
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.setRequestHeader("Content-Length", passData.length);
        that.AJAX.send(passData);
      } else {
        var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }                                                                           
  }
  var urlCall = url;        
  this.callback = callbackFunction || function () { };
}
function replace(url, id) {
	var ajaxReplace = new ajaxObject(url);
	ajaxReplace.callback = function(responseText, responseStatus, responseXML) {
		// responseStatus == 200 indien bereikbaar (enkel online)
		document.getElementById(id).innerHTML=responseText;
	}
	ajaxReplace.update('','GET');
}
// einde ajax
