

var showGotoMyProfile = function(id) {
	if (!document.getElementById(id))
		return;
	var el = document.getElementById(id);
	el.innerHTML = '<a id="text_loggedin_vervanging" href="\/cms\/showpage.aspx?id=11">Naar mijn profiel</a>';
	el.style.visibility = "visible";

}

$(function() {

	//$("#CCIPlaceHolder_Header").prependTo("#frame").css("display","block");

	$('ul.sf-menu').superfish({
		autoArrows: false,
		dropShadows: true,
		speed: 1,
		delay: 0
	});

	var cleansedURL = window.location.href;

	$("#sitemapButton").click(function() {
		$("#sitemapNavigation").toggle();

		if (this.className == "opened") {
			this.className = "closed";
			window.location = cleansedURL + "#";
		} else {
			this.className = "opened";

			window.location = cleansedURL.replace(/\#.*/, "") + "#sitemap";
		}
		return false;
	});
	showGotoMyProfile('text_loggedin')
	;
	/* Zoekformulier */
	$('.zoekknop').click(function() {
		searchSubmit($(this));
		return false;
	});
	var searchSubmit = function(sNode) {
		var theForm = $(sNode).parent();
		var searchInputText = $(theForm).find('input:text');
		var searchInputHidden = $(theForm).find('input:hidden');
		searchTerm = encodeURIComponent(searchInputText.val());
		if (searchTerm.length > 1) {
			$("form").submit(function() { return false });
			var searchUrl = searchInputHidden.val();
			searchUrl += searchTerm;
			window.location = searchUrl;
		} else {
			alert('Vul minstens twee tekens in om te zoeken.');
			return false;
		}
	}
	$("#zoek input:text").each(function() {
		$(this).keydown(
			function(e) {
				if (e.keyCode == 13) {
					searchSubmit($(this));
					return false;
				}
			}
		);
		$(this).focus(
			function() {
				this.value = '';
				//				this.className = 'zoekveld';
			}
		);
		$(this).blur(
			function() {
				if (this.value == '') {
					this.value = 'Search on keyword...';
					//					this.className = 'zoekveld';
				}
			}
		)
	}
	)


	/*


	$("#input_container_username input:text").each(function() {
	$(this).keydown(
	function(e) {
	if (e.keyCode == 13) {
	searchSubmit($(this));
	return false;
	}
	}
	);
	$(this).focus(
	function() {
	this.value = '';
	this.idName = 'Login___txtUserName__';
	}
	);
	$(this).blur(
	function() {
	if (this.value == '') {
	this.value = 'Gebruikersnaam';
	this.idName = 'Login___txtUserName__';
	}
	}
	)
	}
	)

	$("#input_container_password input:password").each(function() {
	$(this).keydown(
	function(e) {
	if (e.keyCode == 13) {
	searchSubmit($(this));
	return false;
	}
	}
	);
	$(this).focus(
	function() {
	this.value = '';
	this.idName = 'Login___txtPassword__';
	}
	);
	$(this).blur(
	function() {
	if (this.value == '') {
	this.value = 'Wachtwoord';
	this.idName = 'Login___txtPassword__';
	}
	}
	)
	}
	)*/
	initFontResize();
	showGotoMyProfile('text_loggedin');
});

var initFontResize = function() {
	setFont();
	$("#fontGrootteM").click(function() {
		setFont("");
	});

	$("#fontGrootteL").click(function() {
		setFont("groot");
	});
}

function setFont(fontSize) {

	fontSize = (fontSize != undefined ? fontSize : readCookie("fontType") || "");
	createCookie("fontType", fontSize, 366);
	if (fontSize == "groot") {
		$("#frame").addClass("groot");
	} else {
		$("#frame").removeClass("groot");
	}
}
/*
* Superfish v1.4.8 - jQuery menu widget
* Copyright (c) 2008 Joel Birch
*
* Dual licensed under the MIT and GPL licenses:
* 	http://www.opensource.org/licenses/mit-license.php
* 	http://www.gnu.org/licenses/gpl.html
*
* CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
*/

; (function($) {
	$.fn.superfish = function(op) {

		var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="', c.arrowClass, '"> &#187;</span>'].join('')),
			over = function() {
				var $$ = $(this), menu = getMenu($$);
				clearTimeout(menu.sfTimer);
				$$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function() {
				var $$ = $(this), menu = getMenu($$), o = sf.op;
				clearTimeout(menu.sfTimer);
				menu.sfTimer = setTimeout(function() {
					o.retainPath = ($.inArray($$[0], o.$path) > -1);
					$$.hideSuperfishUl();
					if (o.$path.length && $$.parents(['li.', o.hoverClass].join('')).length < 1) { over.call(o.$path); }
				}, o.delay);
			},
			getMenu = function($menu) {
				var menu = $menu.parents(['ul.', c.menuClass, ':first'].join(''))[0];
				sf.op = sf.o[menu.serial];
				return menu;
			},
			addArrow = function($a) { $a.addClass(c.anchorClass).append($arrow.clone()); };

		return this.each(function() {
			var s = this.serial = sf.o.length;
			var o = $.extend({}, sf.defaults, op);
			o.$path = $('li.' + o.pathClass, this).slice(0, o.pathLevels).each(function() {
				$(this).addClass([o.hoverClass, c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
			});
			sf.o[s] = sf.op = o;

			$('li:has(ul)', this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over, out).each(function() {
				if (o.autoArrows) addArrow($('>a:first-child', this));
			})
			.not('.' + c.bcClass)
				.hideSuperfishUl();

			var $a = $('a', this);
			$a.each(function(i) {
				var $li = $a.eq(i).parents('li');
				$a.eq(i).focus(function() { over.call($li); }).blur(function() { out.call($li); });
			});
			o.onInit.call(this);

		}).each(function() {
			var menuClasses = [c.menuClass];
			if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
			$(this).addClass(menuClasses.join(' '));
		});
	};

	var sf = $.fn.superfish;
	sf.o = [];
	sf.op = {};
	sf.IE7fix = function() {
		var o = sf.op;
		if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity != undefined)
			this.toggleClass(sf.c.shadowClass + '-off');
	};
	sf.c = {
		bcClass: 'sf-breadcrumb',
		menuClass: 'sf-js-enabled',
		anchorClass: 'sf-with-ul',
		arrowClass: 'sf-sub-indicator',
		shadowClass: 'sf-shadow'
	};
	sf.defaults = {
		hoverClass: 'sfHover',
		pathClass: 'overideThisToUse',
		pathLevels: 1,
		delay: 800,
		animation: { opacity: 'show' },
		speed: 'normal',
		autoArrows: true,
		dropShadows: true,
		disableHI: false, 	// true disables hoverIntent detection
		onInit: function() { }, // callback functions
		onBeforeShow: function() { },
		onShow: function() { },
		onHide: function() { }
	};
	$.fn.extend({
		hideSuperfishUl: function() {
			var o = sf.op,
				not = (o.retainPath === true) ? o.$path : '';
			o.retainPath = false;
			var $ul = $(['li.', o.hoverClass].join(''), this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').hide().css('visibility', 'hidden');
			o.onHide.call($ul);
			return this;
		},
		showSuperfishUl: function() {
			var o = sf.op,
				sh = sf.c.shadowClass + '-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility', 'visible');
			sf.IE7fix.call($ul);
			o.onBeforeShow.call($ul);
			$ul.animate(o.animation, o.speed, function() { sf.IE7fix.call($ul); o.onShow.call($ul); });
			return this;
		}
	});

})(jQuery);


function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	}
	else expires = "";
	document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
	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) return c.substring(nameEQ.length, c.length);
	}
	return null;
}

		$(document).ready(function(){
			$('h3').each(function ()
			{
			  if($.trim($(this).text()) == "")
			  {
				$(this).remove();
			  }
			}); 
			
			

			$('.tekst').each(function ()
			{
			  if($.trim($(this).text()) == "")
			  {
				$(this).remove();
			  }
			});			

			$('.meer_info').each(function ()
			{
			  if($.trim($(this).text()) == "")
			  {
				$(this).remove();
			  }
			});
		
			$('.blok').each(function ()
			{
			  if($.trim($(this).text()) == "")
			  {
				$(this).remove();
			  }
			});		
		
			$('#CCIPlaceHolder_Content_Kolom1').each(function ()
			{
			  if($.trim($(this).text()) == "")
			  {
				$(this).remove();
			  }
			});				

			$('#CCIPlaceHolder_Content_Kolom2').each(function ()
			{
			  if($.trim($(this).text()) == "")
			  {
				$(this).remove();
			  }
			});	
			
			$("h3:empty").remove();
			$(".afbeelding:empty").remove();
			$(".tekst:empty").remove();
			$(".meer_info:empty").remove();
			$(".blok:empty").remove();
			$("#CCIPlaceHolder_Content_Kolom1:empty").remove();
			$("#CCIPlaceHolder_Content_Kolom2:empty").remove();
			
			$("body:has('#CCIPlaceHolder_Linkerkant:empty')").addClass("breed"); 
			$("input:radio").addClass("noBorder");
			$("input:checkbox").addClass("noBorder");
		});
		

Date.prototype.setISO8601 = function (string) {
    var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
        "(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
        "(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
    var d = string.match(new RegExp(regexp));

    var offset = 0;
    var date = new Date(d[1], 0, 1);

    if (d[3]) { date.setMonth(d[3] - 1); }
    if (d[5]) { date.setDate(d[5]); }
    if (d[7]) { date.setHours(d[7]); }
    if (d[8]) { date.setMinutes(d[8]); }
    if (d[10]) { date.setSeconds(d[10]); }
    if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); }
    if (d[14]) {
        offset = (Number(d[16]) * 60) + Number(d[17]);
        offset *= ((d[15] == '-') ? 1 : -1);
    }

    // offset -= date.getTimezoneOffset();
    time = (Number(date) + (offset * 60 * 1000));
    this.setTime(Number(time));
}

Date.prototype.show = function(endDate){
	var d = this;
	
	var monthArray = ['Jan','Feb','Mrt','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'];
	var y = this.getYear();

	var t = "";
	t += this.getDate() + " ";
	t += monthArray[this.getMonth() ] + "  ";
	t += y> 1900 ? y : (y+1900);

	if (endDate && endDate.toDateString() != this.toDateString()) {
		y = endDate.getYear();
		t += " - ";
		t += endDate.getDate() + " ";
		
		t += monthArray[endDate.getMonth() ] + "  ";
		t += y> 1900 ? y : (y+1900);
	}

	return t;
}
