var open_slide = "";
var action = true;

function slide(id, arg)
{
	if(action == true)
	{
		action = false;
		if(arg == 'close')
		{
			Effect.BlindUp(id,{duration: 0.5, afterFinish: function(){ action = true; }});
			open_slide = "";
		}
		else
		{
			if(open_slide != id)
			{
				if(open_slide == "")
				{
					Effect.BlindDown(id,{duration: 0.5, afterFinish: function(){ action = true; }});
					open_slide = id;
				}
				else
				{
					Effect.BlindUp(open_slide,{duration: 0.5});
					Effect.BlindDown(id,{delay: 0.5, duration: 0.5, afterFinish: function(){ action = true; }});
					open_slide = id;
				}
			}
			else
			{
				Effect.BlindUp(open_slide,{duration: 0.5, afterFinish: function(){ action = true; }});
				open_slide = "";
			}
		}
	}
}


function clearField()
{
	var inputs = new Array();
	var values = new Array();
	var elements = $$('#container input');
		
	for (var i=0; i < elements.length; i++){
		var element = elements[i];
		
		if (element.getAttribute('type') == 'text'){			
			inputs.push(element);
		}
	}
	
	inputs.each(function(el, i) {
		values[i] = el.value;
		$(el).observe('focus', function(e){
			if(values[i] == el.value)
			{
				$(el).value = '';
			}
		});
		$(el).observe('blur', function(e){
			if(el.value == '')
			{
				$(el).value = values[i];	
			}
		});
	});
}

Event.observe(window, 'load', clearField);

function LoadCategory(p_nCategory)
{
	url='request.php';
	new Ajax.Request(url, { 
		method:'post', 
		postBody: 'request=category&category='+p_nCategory,
		onSuccess: 
		function(response) {
			$('categories').innerHTML = response.responseText;
		}
		
	});	
}

function UpdateShoppingcart(pRequest, pArtikel, pData)
{
	if(pRequest == 'update')
	{
		url='request.php';
		new Ajax.Request(url, { 
			method:'post', 
			postBody: 'request=shoppingcart&action='+pRequest+'&product='+pArtikel+'&update=' + pData,
			onSuccess: 
			function(response) {				
				document.getElementById('shoppingcart').innerHTML = response.responseText;
			}
			
		});	
	}
	else if(pRequest == 'aantal')
	{
		if(pData == 'up')
		{
			if(pArtikel < 999)
			{
				$('aantal').value = parseInt(pArtikel) + 1;
			}
		}
		else if(pData == 'down')
		{
			if(pArtikel > 1)
			{
				$('aantal').value = parseInt(pArtikel) - 1;
			}
		}
	}
}

function loadPage(pageID) {  
	var url = 'http://www.webkey3.nl/cms3/index.php?menuid=' + pageID;
	try {
				var parent = window.top.topvenster;
	}
	catch(e) {
	}
	if(parent) {
				window.top.location.href = url;
	}
}

function pagina(paginaID, archief){
	
	url = "http://www.webkey3.nl/cms3/index.php?menuid=" + paginaID;
	url2 = "index.php?paginaID=" + paginaID;

	try {
		obj = window.top.topvenster;
	} 
	catch(e) {}
	if(obj) { 
		window.top.location.href = url;
	} else { 
		window.location.href = url2;
	}
	
}

function loadProduct(productID) {  
	var url = 'http://www.webkey3.nl/cms3/watersportline.php?id=' + productID;
	try {
				var parent = window.top.topvenster;
	}
	catch(e) {
	}
	if(parent) {
				window.top.location.href = url;
	}
}
