/*
 * init javascript by CCI IT GROEP
 * http://www.cci-itgroep.nl/
 * Copyright (c) 2009 CCI IT GROEP
 */

/*== HideEmptyImages ==*/
function HideEmptyImages()
{	
	var regex_1 = new RegExp("(shownoimg)\.gif$");
	
	for (var i=0; i < document.images.length; i++)
	{
		if (regex_1.test(document.images[i].src))
		{
			document.images[i].style.display = "none";
		}
	}
}
/*== ==*/

/*== initTemplateFunctions ==*/
function initTemplateFunctions()
{
	if (typeof(templateFunctions) == "function")
	{
		templateFunctions();
	}
}
/*== ==*/

/*== deleteEmptyElements ==*/
function deleteEmptyElements()
{
	$('h2').each(function ()
	{
	  if($.trim($(this).text()) == "")
	  {
		$(this).remove();
	  }
	}); 

	$('.tekst').each(function()
	{
		var imageCount = 0;
		var imageEmptyCount = 0;
		
		$(this).find('img').each(function()
		{
			if ($(this).attr("src").match(/shownoimg.gif/))
			{
				imageEmptyCount++;
			}
			
			imageCount++;
		});
		
		if (imageCount == imageEmptyCount)
		{
			if($.trim($(this).text()) == "")
			{
				$(this).remove();
			}
		}
	});

	$('#rechterkolom').each(function ()
	{
	  if($.trim($(this).text()) == "")
	  {	
		$(this).parent().parent().parent().addClass("breed");
		$(this).remove();
	  }
	});
}
/*== ==*/

/*== Body onload ==*/
$(document).ready(function()
{
	HideEmptyImages();
	deleteEmptyElements();
	initTemplateFunctions();
	
	/*
	$("h2:empty").remove();

	if($.trim($("h2").text()) == "") {
	  $("h2").remove();
	};

	$(".tekst:empty").remove();
	if($.trim($(".tekst").val()) == "") {
	 $(".tekst:empty").remove();
	};

	if($.trim($("#rechterkolom").text()) == "") {
	$("#rechterkolom:empty").parent().parent().parent().addClass("breed");
	  $("#rechterkolom").remove();
	}
	$("#rechterkolom:empty").parent().parent().parent().addClass("breed");
	$("#rechterkolom:empty").remove();
	*/	
});
