<!--

function swapToLevel(o, nIndex)
{
	if (o.length > 1)
	{
		o.each(function()
		{
			$(this).css("z-index",nIndex);
		});
	}
	else
	{
		o.css("z-index",nIndex);	
	}
}


function getSelectionTotal()
{
	var sSer = $("#frmFilters").serialize();
	if (sSer != "")
	{
		sSer = "&" + sSer
	}
	
	var sURL = _root + "include/ajax/getSelectionTotal.asp?cat=" + _cat + "&folder=" + _folder + sSer;

	$.ajax({
		type: "GET",
		url: sURL,
		cache: false,
		async: true,
		beforeSend: function(){},
		success: function(data) 
		{
			$(".filterBox .selection").each(function()
			{
				$(this).html(data);	
			});
		}, 
		error: function(XMLHttpRequest, textStatus, errorThrown) 
		{
			alert(XMLHttpRequest.responseText);
		}
	});	
	
}

function getSelectionContent()
{
	var sSer = $("#frmFilters").serialize();
	if (sSer != "")
	{
		sSer = "&" + sSer
	}	
	
	var sURL = _root + "include/ajax/getSelectionContent.asp?cat=" + _cat + "&folder=" + _folder + sSer;

	$.ajax({
		type: "GET",
		url: sURL,
		cache: false,
		async: true,
		beforeSend: function()
		{
			showProgress("#collectieContent");
		},
		success: function(data) 
		{
			$("#collectieContent").html(data);	
		}, 
		error: function(XMLHttpRequest, textStatus, errorThrown) 
		{
			alert(XMLHttpRequest.responseText);
		}
	});	
	
}

function isChecked(id)
{
	switch ($(id + " input:checked").length)
	{
		case 0:
			return false;
			break;
		default:
			return true;
			break;
	}
}

function setEraseButton(nTop, nLeft, o)
{

	if ($("#a" + o).length <= 0)
	{
		var sHTML = $(".temp").html();
		
		$(".temp2").html(sHTML);
		$(".temp2 a").attr("id","a" + o);
		$(".temp2 a").css("position","absolute").css("z-index","4").css("top",nTop + "px").css("left",nLeft+120 + "px");
		$("#collectieHeader").prepend($(".temp2").html());
		$(".temp2").html("");
		
		$("#collectieHeader a:first").click(function()
		{
			$("#p" + o + " a.erase").trigger("click");
			$("#a" + o).remove();
			$("#" + o).removeClass("active")
		})
	}
}

function setActive()
{
	var aF = _ss.split("&");
	
	for (var i = 0; i < aF.length; i++)
	{
		var aItem = aF[i].split("=");
		
		for (var j = 0; j < aItem.length; j++)
		{
	
			$("input[name='"+ aItem[0] + "']").each(function()
			{
				
				if ($(this).attr("value") == aItem[1])
				{
					var nTop = $("#" + aItem[0]).offset().top - $("#collectieHeader").offset().top;
					var nLeft = $("#" + aItem[0]).offset().left - $("#collectieHeader").offset().left;
					
					setEraseButton(nTop, nLeft, aItem[0]);
					$("#" + aItem[0]).addClass("down").addClass("active");
					$(this).attr("checked","checked");
				}					
			});

		}
	}	
}

jQuery.fn.slideFadeToggle = function(speed, easing, callback) 
{
	return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);  
};

$(document).ready(function() 
{	

	$("#s0").click(function()
	{
		if ($(this).attr("checked") == true)
		{
			$("input[name=sin]").each(function()
			{
				$(this).attr("checked",true);
			});
		}
		else
		{
			$("input[name=sin]").each(function()
			{
				$(this).attr("checked",false);
			});	
		}
	});

	$("#hAdvanced").click(function()
	{  
		$("#dAdvanced").slideFadeToggle('fast', function() {});
		$("#hAdvanced").toggleClass("up");
		return false;	
	});
	
	$("#collectieHeader a.button").each(function()
	{
		$(this).click(function()
		{
			if ($("#p" + $(this).attr("id")).css("display") != "block")
			{
				$("#filters div.filterBox").each(function()
				{
					$(this).hide();
					$("#collectieHeader a.button").each(function()
					{
						$(this).removeClass("up");	
					});
					
				});
				
				nTop = $(this).offset().top - $(this).parent().offset().top;
	
				swapToLevel($("#collectieHeader a.button"),1);
				swapToLevel($("#collectieHeader a.eerase"),2);
				swapToLevel($(this),3);
				swapToLevel($("#a" + $(this).attr("id")),4);
	
				isChecked("#p" + $(this).attr("id"));
				
				$(this).addClass("up");
	
				$("#p" + $(this).attr("id")).animate({opacity: 'toggle', height: 'toggle'}, 'fast', function(){}).css("top",nTop + "px");
			}
			else
			{
				if (isChecked("#p" + $(this).attr("id")) == true)
				{
					$(this).removeClass("up");	
					$(this).addClass("down").addClass("active");

					var nTop = $("#" +$(this).attr("id")).offset().top - $("#collectieHeader").offset().top;
					var nLeft = $("#" + $(this).attr("id")).offset().left - $("#collectieHeader").offset().left;

					setEraseButton(nTop, nLeft,$(this).attr("id"));
				}
				else
				{
					$(this).removeClass("up").removeClass("down").removeClass("active");	
					$("#a" + $(this).attr("id")).remove();
					
				}
				
				
				$("#p" + $(this).attr("id")).animate({opacity: 'toggle', height: 'toggle'}, 'fast', function(){});
				swapToLevel($("#collectieHeader a.button"),3);
				swapToLevel($("#collectieHeader a.eerase"),4);
			}
		});
		
	});
	
	$("#collectieHeader #frmFilters input:checkbox").each(function()
	{
		$(this).click(function()
		{
			getSelectionTotal();
		});
	});
	
	$("#collectieHeader a.erase").each(function()
	{
		$(this).click(function()
		{
			$(this).parent().find("input:checkbox").attr("checked","");
			$("#a" + $(this).parent().find("input:checkbox").attr("name")).remove();
			getSelectionTotal();
			getSelectionContent();
		});
	});

	if (_ss != "")
	{
		if (_ss == "page")
		{
			_ss = $("#frmFilters").serialize();
		}

		setActive();
	}
	
	$("#collectieHeader a.aselection").each(function()
	{
		$(this).click(function()
		{
			getSelectionContent();
			var sID = $(this).parents(".filterBox").attr("rel");
			$("#" + sID).trigger('click');	
		});
	});

	$("#globalNav ul li:first a").addClass('first');
	$("#localNav ul li:last").addClass('last');
	
	$(document).pngFix();
	
	$("#breadcrumbs a:last").css('textDecoration','none');
	
	$("#textSizeNav a").click(function() 
	{
		$(this).parent().find("a").css("textDecoration","none");
		$(this).css("textDecoration","underline");
   });
	
   jQuery('#newsCarousel').jcarousel(
   {
		scroll: 1,
        auto: 4,
        wrap: 'both',
        initCallback: mycarousel_initCallback
    });
 
 	var sQ = "Zoeken";
 	
	$("#q").focus(function()
	{
		if ($(this).attr("value") == sQ || $(this).attr("value") == "")
		{
			$(this).attr("value","");
		}
	});
	
	$("#q").blur(function()
	{
		if ($(this).attr("value") == sQ || $(this).attr("value") == "")
		{
			$(this).attr("value",sQ);
		}
	});
    
    doCycle("banner",2000,4000);
    doCycle("action",200,3000);
    initCollection();

});

function doCycle(elem,speed,timeout) 
{
	if (document.getElementById(elem)) 
	{
 		$("#"+elem).cycle({
			fx: 'fade',
			cleartype: true,
		    cleartypeNoBg: true,
			speed: speed,
			timeout: timeout
		});
	}
}

function initCollection()
{
	
	if (document.getElementById("collection")) {
		
		//if (document.getElementById("btn_arrow_leftcover"))
		//{
		//	document.getElementById("btn_arrow_leftcover").style.display = "none";
		//	document.getElementById("btn_arrow_rightcover").style.display = "none";
		//}
	
		//initSlideShow();
		
		doCollection();
		setColllectionImages();
	
	}
}

function showProgress(id)
{
	var s = "<div id='progress'><img src='" + _root + "images/loader.gif' width='32' height='32'><br><br>Bezig met laden...</div>";
	$(id).html(s);
}

function removeProgress()
{
	$("#progress").remove();
}

function showCollectionItem(id)
{

	var sURL = _root + "include/ajax/getItem.asp?id=" + id + "&path=" + _path;
	
	$.ajax({
		type: "GET",
		url: sURL,
		cache: false,
		async: true,
		beforeSend: function()
		{
			showProgress("#contentCollection");
		},
		success: function(data) 
		{
			$("#contentCollection").html(data);
			doCollection();
		}, 
		error: function(XMLHttpRequest, textStatus, errorThrown) 
		{
			alert("Foutmelding");
		}
	});		
}

function setColllectionImages()
{
	$("#theImages a").each(function()
	{
		var id = $(this).children("img").attr("id");
		
		$(this).click(function()
		{
			showCollectionItem(id);
			return false;
		});
	});
}


function loadCollectionImage(s)
{
	var img = new Image();
	$(img).load(function() 
	{
		$('#image').html("");
		$(this).hide();
		$('#image').removeClass('loading').append(this);
		
		$(this).fadeIn();
	}).error(function () 
	{
	}).attr('src', s);
}

function doCollection()
{
	if (document.getElementById("collection")) 
	{
		$("#collection #images a").each(function() {			
			$(this).click(function() {
				$('#image').addClass('loading')
				var s = $(this).children("img").attr("path");
				loadCollectionImage(s);
				return false;
			});
		});
		
	}
}

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();
    });
};


var bUseNavHover = false;

if (bUseNavHover == true)
{
	if (window.attachEvent)
	{
		window.attachEvent("onload", navHover);
	}
}

navHover = function() 
{
	var lis = document.getElementById("globalNav").getElementsByTagName("LI");
	
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}

function makeFlashObj(sID, sPath, sWidth, sHeight, sBG)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="' + sID + '" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + sWidth + '" height="' + sHeight + '">');
	document.write('<param name="movie" value="' + sPath + '">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="bgcolor" value="' + sBG + '">');
	document.write('<embed wmode="transparent" bgcolor="' + sBG + '" src="' + sPath + '" quality="high" id="' + sID + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + sWidth + '" height="' + sHeight + '"></embed>');
	document.write('</object>');
}

function setActiveStyleSheet(title) {
	var i, a, main;	
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

function getActiveStyleSheet() {
	var i, a;	
	for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}	
	return null;
}

function getPreferredStyleSheet() {	
	var i, a;	
	for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title")) return a.getAttribute("title");
	}	
	return null;
}

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;
}

window.onload = function(e) {
	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);
	
  	aLinks = document.getElementById('content').getElementsByTagName('a');
	
	for(i=0; i<aLinks.length; i++) {
		if(aLinks[i].className == "Woordenboekwoord") {
			var oLink = aLinks[i];
			var oSpan = document.createElement('span');
			var parent = oLink.parentNode;
			
			oSpan.className = "nowrap";
			oSpan.appendChild(oLink.cloneNode(true));
			parent.replaceChild(oSpan, oLink);
		}
	}
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

function frmStoreSubmit() 
{
	var d = document.frmStoreSearch;
	
	if (d.postcode.value == "" && d.plaats.value == "")
	{
		alert('U kunt een winkel vinden door uw postcode of plaats in te vullen. Probeer het opnieuw!');
		return false;
	}
	else
	{
		d.submit();	
	}
}


-->