/**
 *	Scripts for Snelweerwel.
 *	mixed jQuery and 'old school', sorry ;)
 *
 *	@author frank at frankbosma dot nl
 */

$(document).ready(function(){
	if($("body").attr("id") == "body"){

		/** Clock */
		var clock	= new Clock("clock");

		/** Add mouse over submenu's */
		createSubMenuus();

		/** Scale site to available height */
		resizeSite();


		$("form[@name='screener']").each(function(){
			/** init functions for the Screener form */
			initScreener($(this));

			$(this).bind("submit", function(){

				return checkScreener($(this));
			});
		});

		$("form[@name='aanmelden']").each(function(){

			initAanmeldForm($(this));

			$(this).bind("submit", function(){

				return checkAanmeldForm($(this));
			});
		});
	}

    if ($('#moreSites').length > 0) {
        $('#moreSites select').bind('change', function() {
            if ($(this).val() != '-1') {
                window.open($(this).val(), '_blank');
            }
            $(this).blur();
        });
    }
});

/**************************************************************************
 * Screener functions
 */

var Screener = {
	SCQTYPE_TEXT: 		1,
	SCQTYPE_PULL: 		2,
	SCQTYPE_RADIO: 		3,
	SCQTYPE_SCALE: 		4,
	SCQTYPE_SPECIAL1: 	5,
	SCQTYPE_SPECIAL2: 	6,

	ieLow: (($.browser.msie && !isNaN($.browser.version) && parseInt($.browser.version) < 7)? true : false)
};
var Subscriber = {

	picker: null
};

	/************************
	 * NAW
	 */

function checkNAWForm(){

	var objForm = document.forms['naw'];
	var arrFields = [
		{ element: "surName",
title:"Achternaam",    type: "string" },
        { element: "initials",  title: "Voorletters",   type: "string" },
		//{ element: "birthdate", title: "Geboortedatum", type: "date" },
		//{ element: "town",      title: "Woonplaats",    type: "string" },
		{ element: "email",     title: "E-mail",	    type: "email"  }
	];

	for(var i=0; i<arrFields.length; i++){

		var val = objForm[arrFields[i].element].value;
		if(val == ""){
			alert("Het veld '"+ arrFields[i].title +"' is verplicht!");
			return;
		}else if(arrFields[i].type == "email"){
			if(!echeck(val)){
				alert("Vul een geldig e-mailadres in!");
				return;
			}
		}else if(arrFields[i].type == "date"){
			if(!val.match(/^[0-9]{2}-[0-9]{2}-[0-9]{4}$/i)) {
				alert("Vul de geboortedatum in als dd-mm-jjjj (bijvoorbeeld 30-06-1960).");
				return;
			}
		}
	}

	objForm.action = "index.php";
	objForm.submit();
}

	/************************
	 * Subscribe
	 */

function initAanmeldForm(objForm){
	/** calendar creation */
	objForm.find("div.calendar").each(function(){

		var objPicker = new Picker({

			holder: $(this).find("> .picker"),
			onPick: function(chosen){

				if(typeof chosen != "undefined"){

					/** show a loader */
					/*...*/

					$.ajax({
					   async:	true,
					   type: 	"GET",
					   url: 	"scripts/dateInfo.php?acc=" + $(document).getUrlParam("acc"),
					   dataType:"json",
					   data:	"dateId="+ chosen.id,
					   complete: function(){
						   /** hide loader */
							/*...*/
					   },
					   success:	function(data){
						   if(typeof data != "undefined"){
								showCalendarInfo(chosen.date, data, objPicker.holder.parent());
						   }
						},
						error: function(date, msg, e){
							alert(msg);
						}
					 });
				}

			},

            /**
             * Door ALTIJD de group= mee te geven, worden nooit 'alle groepen' geselecteerd (in de admin bijvoorbeeld wel, en dat kan
             * door aan de availableDate.php GEEN group GET-var mee te geven (ook niet leeg).
             * de group GET-var wordt bepaald door de GET-var van het huidige document (getUrlParam is een jQuery-plugin)
             *
             * Ook het accountId ('acc'-GET var van het huidige document) wordt meegegeven als GET-var ('acc')
             */
			updateURL: "scripts/availableDates.php?group=" + (($(document).getUrlParam("group")) ? $(document).getUrlParam("group") : 0) + '&acc=' + $(document).getUrlParam("acc"),
			onUpdate: function(){
				clearCalendarInfo(this.holder);
			}
		});
		Subscriber.picker = objPicker;
	});

	/** formtype based functionality */
	var type = parseInt(objForm.find("div.aanmelden").attr("class").match(/[\d]+$/)[0]);
	switch(type){

		case 0:
			/** subscribe to */
			objForm.find("input[@name='subscribeTo']").bind("click", function(){

				if(this.checked){

					var id = parseInt(this.value);
					if(id == 1){
						objForm.find("div.acceptTerms").show();
						objForm.find("div.subscribe"+ 1).show();
						objForm.find("div.subscribe"+ 2).hide();
					}else{
						objForm.find("div.acceptTerms").hide();
						objForm.find("div.subscribe"+ 2).show();
						objForm.find("div.subscribe"+ 1).hide();
					}
					window.focus();
					this.blur();
					window.onresize();
				}

			});

			/** there is only 1 select */
			objForm.find("select").each(function(){

				$(this).bind("change", function(){

					var val = parseInt($(this).val());
					var anim = 200;
					if(Screener.ieLow){anim=0;}

					switch(val){

						case 4: case 6:

							$(this).parents("div.subscribe1").find("> .scqInput").show(anim, function(){window.onresize();});
							break;

						default:
							$(this).parents("div.subscribe1").find("> .scqInput").hide(anim, function(){window.onresize();});
							break;
					}

					window.focus();
					$(this).blur();
				});
				/** will create an unused one if not existing as event */
				$(this)[0].onmousewheel = function(){
					return false;
				}
			});
			break;
	}


	objForm.find("input[@name='adviesHow']").each( function(){

		$(this).bind("click", function(){

			function showCalendar(){

				if(Subscriber.picker){

					if(!Subscriber.picker.inited){
						/** set updateURL and init */
						Subscriber.picker.init();
					}
					var parent = Subscriber.picker.holder.parents("div.preferredDate");
					if(parent.css("display") == "none"){
						parent.show();
						window.onresize();
					}
				}
				window.onresize();
			}
			window.focus();
			this.blur();

			setTimeout(showCalendar, 100);/** first feedback from select, then calendar creation */

			if(parseInt(this.value) == 10){

				$(this).parents("div.aanmelden").find("span.moreInfo").show();/** these spans are only used in the calendar so */

			}else if(parseInt(this.value) == 11){

				$(this).parents("div.aanmelden").find("span.moreInfo").hide();
			}

		});
		if(this.checked){
			/** click to show the calendar on start */
			$(this).trigger("click");
		}
	});
}

function checkAanmeldForm(objForm){

	try{
		var blnGo 	= true;
		var type 	= parseInt(objForm.find("div.aanmelden").attr("class").match(/[\d]+$/)[0]);

		var arrFields = [
			{ element: "surName",   title: "Achternaam",     type: "" },
			{ element: "initials",  title: "Voorletters",    type: "" },
			{ element: "sex",       title: "Geslacht",       type: "" },
			{ element: "birthdate", title: "Geboortedatum",  type: "date" },
			{ element: "address",   title: "Adres",          type: "" },
			{ element: "postal",    title: "Postcode",       type: "" },
			{ element: "town",      title: "Woonplaats",     type: "" },
			{ element: "telephone", title: "Telefoonnummer", type: "" },
			{ element: "email",     title: "E-mail",         type: "email" }
		];

		/** depending on the choices other fields may be required */

		var subscribeTo;
		if(type == 1){
			subscribeTo = parseInt(objForm.find("input[@name='subscribeTo']").val());
		}else{


			var subscribeTo = -1;
			objForm.find("input[@name='subscribeTo']").each(function(){
				if(this.checked){
					subscribeTo = parseInt(this.value);
				}
			});

	 	}

		if( subscribeTo == -1 ){

			alert("Selecteer waar u zich voor wilt aanmelden.");
			return false;

		}else{

			switch(subscribeTo){

				case 1:

					var val = parseInt(objForm.find("select").val());
					switch(val){

						case -1:
							/** nothing selected */
							alert("Selecteer hoe u de cursus wilt volgen.");
							return false;

							break;

						case 4: case 6:
							if(objForm.find("select").parents("div.subscribe1").find("> div.scqInput :checked").length == 0){
								alert("Selecteer uw ondersteuningsvoorkeur.");
								return false;

							}else{

								if(parseInt(objForm.find("select").parents("div.subscribe1").find("> div.scqInput :checked").eq(0).val()) == 9){

									arrFields.push({
										element:"telephone",
										msg: "Vergeet niet uw telefoonnumer indien u ondersteuning 'Per telefoon' heeft gekozen.",
										type: "string"
									});
								}
							}
							break;
					}

					arrFields.push({
						element: "acceptTerms",
						msg: "U moet akkoord gaan met de algemene voorwaarden",
						type: "check"
					});

					break;

				case 2:
					var adviesHow = -1;
					objForm.find("input[@name='adviesHow']").each(function(){
						if(this.checked){
							adviesHow = parseInt(this.value);
						}
					});
					if( adviesHow == -1){

						alert("Selecteer de manier waarop u een Persoonlijk Adviesgesprek wilt.");
						return false;

					}else{

						if( parseInt(adviesHow) == 11 ){
							arrFields.push({
								element:"telephone",
								msg: "Vergeet niet uw telefoonnumer indien u voor 'telefonisch' heeft gekozen.",
								type: "string"
							});
						}
					}

					arrFields.push({
						element:"preferredDates",
						msg: "Vergeet niet een of meerdere voorkeurdata aan te geven.",
						type: "string"
					});
					break;

			}
		}


		for(var i=0; i<arrFields.length; i++){

			if(arrFields[i].type == "check"){

				if(!objForm[0][arrFields[i].element].checked){
					alert(arrFields[i].msg);
					blnGo = false;
					break;
				}

			}else{
				var val = objForm[0][arrFields[i].element].value;
				if(val == ""){
					if(typeof arrFields[i].msg != "undefined"){
						alert(arrFields[i].msg);
					}else{
						alert("Het veld '"+ arrFields[i].title +"' is verplicht!");
					}
					blnGo = false;
					break;

				}else if(arrFields[i].type == "email"){

					if(!echeck(val)){
						alert("Vul een geldig e-mailadres in!");
						blnGo = false;
						break;
					}
                }else if(arrFields[i].type == "date"){
                    if(!val.match(/^[0-9]{2}-[0-9]{2}-[0-9]{4}$/i)) {
                        alert("Vul de geboortedatum in als dd-mm-jjjj (bijvoorbeeld 30-06-1960).");
						blnGo = false;
                        break;
                    }
                }
			}
		}

		if(!blnGo){
			return false;
		}else{
			return true;
		}
	}catch(e){
		return false;
	}
}

function showCalendarInfo(date, info, calendar){

	/** show timeparts with a checkbox and location info on mouseover */

	var objInfo = calendar.find("> div.info");
	objInfo.empty();
	objInfo.append("<div class=\"formRow\"><strong>Datum:</strong> <span>"+
					(date.getDate() +"-"+ (date.getMonth()+1) +"-"+ date.getFullYear()) +"</span></div><br />");

	var selection = selectedDates(calendar);
	for(var id in info){

		var selected = (typeof selection[id] != "undefined")? " checked=\"checked\"" : "";
		objInfo.append("<div class=\"formRow dateInfo\">"+
						"<input type=\"checkbox\" name=\"date"+ id +"\" id=\"date"+ id +"\" "+ selected +" /> "+
						"<label for=\"date"+ id +"\">"+ info[id].tijd +"</label><pre>    </pre>"+
						"<span class=\"moreInfo\" title=\"Locatie: "+ info[id].locatie.replace('"', '&quote;') +"\">i</span></div>"
		);
	}

	/** tooltips */
	var adviesHow = -1;
	calendar.parents("div.aanmelden").find("input[@name='adviesHow']").each(function(){
		if(this.checked){
			adviesHow = parseInt(this.value);
		}
	});
	if(adviesHow == 11){
		objInfo.find("span.moreInfo").hide();
	}

	objInfo.find("input[@type='checkbox']").bind("click", function(){

		if(this.checked){

			/** select */
			addSelection(objInfo.parent(), {
				id: $(this).attr("id").match(/[\d]+$/)[0],
				datum: objInfo.find("> div").eq(0).find("> span").text(),
				tijd: $(this).parent().find("> label").text()
			});

		}else{

			/** remove */
			removeSelection(objInfo.parent(), $(this).attr("id").match(/[\d]+$/)[0]);
		}
		window.focus();
		this.blur();
	});
}

function clearCalendarInfo(holder){

	holder.parent().find("> div.info").empty();
}


function selectedDates(calendar){

	var selected 	= {};
	var selection 	= calendar.find("input[@name='preferredDates']").val();

	if(typeof selection != "undefined" && selection != ""){

		var arrSel 	= selection.split(",");
		var sl 		= arrSel.length;
		for(var s=0; s<sl; s++){
			selected[arrSel[s]] = true;
		}
	}
	return selected;
}

/**
 * @param {jQuery} calendar

 * @param {object} date
 */
function addSelection(calendar, date){

	var selected = selectedDates(calendar);
	if(typeof selected[date.id] == "undefined"){

		calendar.find("> div.chosen > div > em").remove();/** clear the standard expression when it exists */

		/** add date sorted */
		/*
		var arrDates = new Array();
		calendar.find("> div.chosen > div > div").each(function(){

			var id = $(this).attr("id").match(/[\d]+$/)[0];
			var date = $(this).html().replace(/[\s\(\)]+/, "");
			alert(date);
		});
		*/

		calendar.find("> div.chosen > div").append("<div id=\"selecteddate"+ date.id +"\">"+ date.datum +" ("+ date.tijd +")</div>");

		/** add to input */
		selected[date.id] 	= true;
		var arrIds 			= new Array();
		for(id in selected){
			arrIds.push(id);
		}
		calendar.find("input[@name='preferredDates']").val(arrIds.join(","));

		window.onresize();

		/** sorting ? */
	}
}

function sortByDate(arrA, arrB){



}

function removeSelection(calendar, id){

	var selected = selectedDates(calendar);
	if(typeof selected[id] != "undefined"){


		calendar.find("#selecteddate"+ id).remove();


		var arrIds = new Array();
		for(sid in selected){
			if(sid != id){arrIds.push(sid);}
		}
		calendar.find("input[@name='preferredDates']").val(arrIds.join(","));

		if(arrIds.length == 0){
			calendar.find("> div.chosen > div").append("<em>Niets geselecteerd.</em>");/** clear the standard expression when it exists */
		}
	}
}

	/************************
	 * Screener
	 */

function initScreener(objForm){

	objForm.find("> .question").each(function(){

		var objQuestion = $(this);
		var type = parseInt($(this).attr("class").match(/\d+$/)[0]);

        objQuestion.find('em.value').each(function() {
            $(this).hide();
        });

        switch(type){

			case Screener.SCQTYPE_TEXT:

				break;

			case Screener.SCQTYPE_PULL:

				objQuestion.find("select").each(function(){

					$(this).bind("change", function(){
						window.focus();$(this).blur();
					});
					/** will create an unused one if not existing as event */
					$(this)[0].onmousewheel = function(){
						return false;
					}
				});
				break;

			case Screener.SCQTYPE_RADIO:
				//objQuestion.find("input[@type='radio']").bind("click", function(){window.focus();$(this).blur();});

                    objQuestion.find("input[@type='radio']").each(function() {
                        if (this.checked) {
                            var els = $(this).parents("div.question").find("em.value" + this.value).each(function() {
                                $(this).show();
                            });
                        }
                    });

                    /*
					var els = $(this).parents("div.question").find("em.value").each(function() {
                        if (this.className.indexOf("value" + objInput.value) > -1) {
                            $(this).show();
                        } else {
                            $(this).hide();
                        }
                    });
                    */

				objQuestion.find("input[@type='radio']").bind("click", function(){

                    var objInput = this;

					var els = $(this).parents("div.question").find("em.value").each(function() {
                        if (this.className.indexOf("value" + objInput.value) > -1) {
                            $(this).slideDown(200, function(){window.onresize();});
                        } else {
                            $(this).slideUp(200, function(){window.onresize();});
                        }
                    });

					$(this).blur();
				});

                break;

			case Screener.SCQTYPE_SCALE:

				/** init scaler */
				var fractions 	= objQuestion.find("input[@type='radio']").length;
				var grid		= Math.floor(objQuestion.find("> .slider").width() / (fractions-1));

				for(var i=0; i<fractions; i++){

					objQuestion.find("> .slider > input").eq(i).css({

						position:	"absolute",
						zIndex:		3,
						left: 		(grid*i-5) +"px",
						cursor:		"pointer"

					}).bind("click", function(){

						$(this).parents("div.question").find("span.answer").html("Uw antwoord: "+ $(this).attr("title"));
						window.focus();$(this).blur();
					});
				}

				objQuestion.find("span.minimum").html(objQuestion.find("input[@type='radio']").eq(0).attr("title"));
				objQuestion.find("span.maximum").html(objQuestion.find("input[@type='radio']").eq(fractions-1).attr("title") +"&nbsp;");

				/** show preselected answer */
				if(objQuestion.find(":checked").length > 0){
					objQuestion.find("span.answer").html("Uw antwoord: "+ objQuestion.find(":checked").attr("title"));
				}else{
					objQuestion.find("span.answer").html("Uw antwoord:");
				}

				window.onresize();

				break;

			case Screener.SCQTYPE_SPECIAL1:
				/***/
				objQuestion.find("select").bind("change", function(){

					var val = parseInt($(this).val());

					var anim = 200;
					if(Screener.ieLow){anim=0;}

					switch(parseInt(this.value)){

						case 91: case 93:

							$(this).parents("div.question").find("> .scqInput").show(anim, function(){window.onresize();});
							break;

						default:
							$(this).parents("div.question").find("> .scqInput").hide(anim, function(){window.onresize();});
							break;
					}
					$(this).blur();
					window.focus();
				});

				/** will create an unused one if not existing as event */
				objQuestion.find("select")[0].onmousewheel = function(){
					return false;
				}

				break;

			case Screener.SCQTYPE_SPECIAL2:
				/***/
				objQuestion.find("input[@type='radio']").bind("click", function(){

					var objInput 		= $(this).parents("div.formRow").find("> input");
					objInput[0].disabled= false;

					$(this).parents("div.question").find("input[@type='text']").filter(function(){
						return (this.name != objInput[0].name);
					})[0].disabled = true;

					$(this).blur();
					objInput[0].focus();
				});

				break;
		}

		objQuestion.find("em.info").each(function(){

			$(this).before(" <span class=\"moreInfo\">i</span>");
			$(this).parent().find("> span.moreInfo").bind("mouseover", function(){

				$(this).parent().find("> em.info").slideDown(200, function(){window.onresize();});

			}).bind("mouseout", function(){

				$(this).parent().find("> em.info").slideUp(200, function(){window.onresize();});
			});
		});

	});
}

function checkScreener(objForm){

	var blnGo = true;

	objForm.find("> .question").each(function(){

		if(!blnGo){
			return;
		}

		var type = parseInt($(this).attr("class").match(/\d+$/)[0]);
		switch(type){

			case Screener.SCQTYPE_TEXT:
				if($(this).find("textarea").val() == ""){
					blnGo = false;
				}
				break;

			case Screener.SCQTYPE_PULL:
				var val = parseInt($(this).find("select").val());
				switch(val){

					case -1:
						/** nothing selected */
						blnGo = false;
						break;
				}
				break;

			case Screener.SCQTYPE_RADIO: case Screener.SCQTYPE_SCALE:

				if($(this).find(":checked").length == 0){
					blnGo = false;
				}
				break;

			case Screener.SCQTYPE_SPECIAL1:

				var val = parseInt($(this).find("select").val());
				switch(val){

					case -1:
						/** nothing selected */
						blnGo = false;
						break;

					case 91: case 93:
						if($(this).find("> div.scqInput :checked").length == 0){
							blnGo = false;
						}
						break;
				}
				break;

			case Screener.SCQTYPE_SPECIAL2:
				if($(this).find(":checked").length == 0){
					blnGo = false;
				}else{
					if($(this).find(":checked").parents("div.formRow").find("> input").val() == ""){
						blnGo = false;
					}
				}
				break;
		}
		if(!blnGo){
			alert("Vergeet vraag "+ $(this).find("> p > strong").text().match(/[\d]+/)[0] +" niet!");
		}
	});

	if(!blnGo){
		return false;
	}else{
		return true;
	}
}

function goBack(folderId, offset){
	/** set document.location.href to go back */
	document.location.href = "index.php?fId="+ folderId +"&offset="+ offset;
}


/**************************************************************************
 * Conventional functions
 */

function popupper(strURL, strName, intWidth, intHeight, strScroll){
	window.open(strURL, strName,'height='+intHeight+',width='+intWidth+',toolbar=no,scrollbars='+ strScroll +',menubar=no,resizable=yes');

}

function popupFotoGroot(fId, eId){

	var intW = document.getElementById("foto_"+ eId).width;
	var intH = document.getElementById("foto_"+ eId).height;
	var strURL = "foto.php?fId="+ fId +"&eId="+ eId;

	if(intW > intH){
		popupper(strURL, "Foto", 756, 300, "yes");
	}else{
		popupper(strURL, "Foto", 656, 400, "yes");
	}
}

function tryResizeFotoPopup(strId){

	var intMaxH = 632;

	var intW = document.getElementById(strId).width + 380;
	var intH = document.getElementById(strId).height+32;
	if(intH > intMaxH){
		window.resizeTo(intW, intMaxH);
	}else{
		window.resizeTo(intW, intH);
	}
}

function echeck(str) {
	var objReg = /[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	var matched = str.match(objReg);

	if(matched){
		if(matched.length == 1){
			return true;
		}

	}
	return false;
}

function isBrowserSupported(){
	return(typeof(document.getElementById) != "undefined");
}


function resizeSite(){
	if(isBrowserSupported()){

		var objWrapper 	= document.getElementById("siteWrapper");
		var objContent 	= document.getElementById("content");
		var objSide		= document.getElementById("sidebar");
		var hStart 		= document.getElementById("header").offsetHeight;

		if(Screener.ieLow){
			window.onresize = function(){}
		}else{
			window.onresize = function(){

				intBh = getInnerHeight();
				intCh = hStart + ((objContent.offsetHeight > objSide.offsetHeight)? objContent.offsetHeight : objSide.offsetHeight) + 30;

				if(intBh > intCh){
					objWrapper.style.height = intBh +"px";
				}else{
					objWrapper.style.height = intCh +"px";
				}
			};
			window.onresize();
		}
	}
}

function getInnerHeight(){
	if(self.innerWidth){
		return self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		return document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		return document.body.clientHeight;
	}
	else return 0;
}

/**
 *	XMLHttpRequest extracted from code by Andrew Gregory
 *	http://www.scss.com.au/family/andrew/webdesign/xmlhttprequest
 */
function XMLHttpRequester(){
	if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	}else if(window.ActiveXObject){
		var msxmls = new Array(
		//*** keep version updates in mind though
		  'Msxml2.XMLHTTP.5.0',
		  'Msxml2.XMLHTTP.4.0',
		  'Msxml2.XMLHTTP.3.0',
		  'Msxml2.XMLHTTP',
		  'Microsoft.XMLHTTP');
		for (var i=0;i<msxmls.length;i++) {
		  try{return new ActiveXObject(msxmls[i]);}catch(e){}
		}
	}return null;
}

/**
 * A simple clock with Dutch date abbreviations.
 */
function Clock(divClock){

	this.divClock		= divClock;//***	String, Div id
	this.intervalClock;
	this.arrDutchMonths = new Array("Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec");
	this.arrDutchDays = new Array("Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za");

	this._init();
}

Clock.prototype._init = function(){
	this.draw_clock();
	this.setInterval(this, "draw_clock", 1000*10, new Array());//*** each 10 seconds
};

Clock.prototype.get_dutch_date = function(dateNow){
	return( this.get_dutch_day(dateNow) +" "+ dateNow.getDate() +" "+ this.arrDutchMonths[dateNow.getMonth()]);
};

Clock.prototype.get_dutch_day = function(dateNow){
	return(this.arrDutchDays[dateNow.getDay()]);
};

Clock.prototype.draw_clock = function(){

	var dateNow	= new Date();

	var strDate	= this.get_dutch_date(dateNow);

	var strMin	= ""+ dateNow.getMinutes();
	if(strMin.length == 1){strMin	= "0"+ strMin;}

	var strHours	= ""+ dateNow.getHours();
	if(strHours.length == 1){strHours	= "0"+ strHours;};

	if(typeof(document.getElementById) != "undefined"){
		strDate += " "+ strHours +":"+ strMin;
		if(strDate != document.getElementById(this.divClock).innerHTML){
			document.getElementById(this.divClock).innerHTML	= "<span>"+ strDate.toLowerCase() +"</span>";
		}
	}
};

Clock.prototype.setInterval = function(a, b, c, arrArgs){
	var ID, func = function(){
		a[b].apply(a, arrArgs);
	}
	ID = setInterval(func, c, arrArgs);
	return ID;
}