var empty = '';
function loadField(id, dbf) {
	var data = $(id).innerHTML;
	if(data == empty) {
		data = '';	
	}
	$(id + '_b').hide();
	$(id).innerHTML = '<input name="' + id + '" id="' + id + '_v" type="text" class="field" maxlength="24" value="' + data + '" onBlur="saveField(\'' + id + '\', \'' + dbf + '\');" />';
	$(id + '_v').focus();
}

function saveField(id, dbf) {
	url='request.php';
	new Ajax.Request(url, { 
		method:'post', 
		postBody: 'request=klant&dbf=' + dbf + '&value=' + $(id + '_v').value,
		onSuccess: 
		function(response) {
			if($(id + '_v').value == '') {
				$(id).innerHTML = empty;
			}
			else {	
				$(id).innerHTML = response.responseText;
			}
			$(id + '_b').show();
		}
	});
}

function setBetaalwijze(v) {
	url='request.php';
	new Ajax.Request(url, { 
		method: 'post', 
		postBody: 'request=betaalwijze&value=' + v,
		onSuccess: 
		function(response) {
			if(response.responseText == 'ideal') {
				$('ideal').innerHTML = '<img src="images/template/radio_active.gif" />';
				$('overboeking').innerHTML = '';
			}
			else if(response.responseText == 'overboeking') {
				$('ideal').innerHTML = '';
				$('overboeking').innerHTML = '<img src="images/template/radio_active.gif" />';
			}
		}
	});	
}

function loadMsg(id1, id2) {
	Effect.Appear(id2, {
		from: 1.0,
		to: 0.8,
		delay: 0.0,
		duration: 0.1
	});
}

function closeMsg(id1, id2, page) {
	Effect.Fade(id1, {
		from: 1.0,
		to: 0.0,
		delay: 0.0,
		duration: 0.5
	});
	if(id2 != '' || id2 != 'undefined') {
		Effect.Fade(id2, {
			from: 1.0,
			to: 0.0,
			delay: 0.0,
			duration: 0.5
		});
	}
	if(page != '') {
		location.href = page;	
	}
}

function submenu()
{
	var items = $$('#submenu .categorie');	
	items.each(function(el, i){
		var assortment = $(el).className.split(' ');
		el.observe('click', function(e){
			$(assortment[1]).style.display = 'block';	
			$('image_'+assortment[1]).src = "images/template/"+assortment[1]+"_small_active.jpg";
			items.each(function(other, j) {
				var active_assortment = $(other).className.split(' ');
				if(i != j) {
					$(active_assortment[1]).style.display = 'none';	
					$('image_'+active_assortment[1]).src = "images/template/"+active_assortment[1]+"_small.jpg";
				}
			});
		});
	});
}

var active_tab = 'information';
var active_zindex = '20';

function tab(id, zindex)
{
	if(active_tab != id)	
	{
		$(active_tab+'_tab').className = 'tab_detail';	
		$(active_tab).style.display = 'none';
		$(active_tab+'_tab').style.zIndex = active_zindex;	
		
		$(id+'_tab').className = 'tab_active';
		$(id).style.display = 'block';
		$(id+'_tab').style.zIndex = '25';
		
		active_zindex = zindex;		
		active_tab = id; 
	}	
}

function shoppingcart(pRequest, pArtikel, pData)
{
	
	if(parseInt(pData) < 1) {
		pRequest = 'delete';
	}
	if(pRequest == 'update' || pRequest == 'delete')
	{
		url='request.php';
		new Ajax.Request(url, { 
			method:'post', 
			postBody: 'request=shoppingcart&action='+pRequest+'&artikelID='+pArtikel+'&update=' + pData,
			onSuccess: 
			function(response) {
				document.getElementById('shoppingcart').innerHTML = response.responseText;
			}
			
		});	
	}
}

function setLanguage(pLanguage)
{
	if(pLanguage != '')
	{
		url='request.php';
		new Ajax.Request(url, { 
			method:'post', 
			postBody: 'request=language&language='+pLanguage,
			onSuccess: 
			function() {
				location.reload(true);
			}		
		});
	}
}

function page(paginaID) {  
	var url = 'http://www.mellowliving.nl/cms3/index.php?menuid=' + paginaID;
	try {
				var parent = window.top.topvenster;
	}
	catch(e) {
	}
	if(parent) {
				window.top.location.href = url;
	}
}
function taal(sitename){
	var url = "http://www.webkey3.nl/cms3/index.php?naamw=" + sitename;
	try{
		obj = window.top.topvenster;
	}
	catch(e){
	}
	if(obj){
		window.top.location.href=url;
	}
}
function form(formID) {  
	var url = 'http://www.webkey3.nl/cms3/form.php?action=wijzigen&formid=' + formID;
	try {
				var parent = window.top.topvenster;
	}
	catch(e) {
	}
	if(parent) {
				window.top.location.href = url;
	}
}
function product(artikelID) {  
	var url = 'http://www.webkey3.nl/cms3/mellowliving.php?id=' + artikelID;
	try {
				var parent = window.top.topvenster;
	}
	catch(e) {
	}
	if(parent) {
				window.top.location.href = url;
	}
}

