function FormErrorDisplay(f, errorInfo)
{
	// disabled all errors by default
	for (var i=0; i<registerRules.length; i++)
	{
		var parts = registerRules[i].split(",");
		var fieldName = parts[1];
	
		if($(fieldName+'_label')) $(fieldName+'_label').style.color = "#fff";	
		if($(fieldName)) $(fieldName).style.color = "#fff";
		if($(fieldName)) $(fieldName).style.borderColor = "#b2b6ab";
		
		if($('captcha')) $('captcha').style.color = "#fff";
		if($('captcha')) $('captcha').style.borderColor = "#b2b6ab";
		
	}
	
	
	for (var i=0; i<errorInfo.length; i++)
	{
		var fieldName;
		
		// radio button
		if (errorInfo[i][0].type == undefined)
			fieldName = errorInfo[i][0][0].name;
		else
			fieldName = errorInfo[i][0].name;
		
		// display the error
		if(errorInfo[i][0].type == 'checkbox') {
			$(fieldName+'_label').style.color = "#900";	
		}
		$(fieldName).style.color = "#900";
		$(fieldName).style.border = "1px solid #900";
	}
	
	return (errorInfo.length == 0) ? true : false;
	
	return false;
}

function checkCaptcha() {
	if($F('captcha').hex_md5() != $F('captchaSol')) {
		var field = $("captcha");
		return [[field, "doe het"]];
	}
	else return true;
}


function checkInput(inputfield,initvalue,comparevalue){
	if(comparevalue){
		if(inputfield.value == ''){
			if(comparevalue != 'Wachtwoord') inputfield.value = comparevalue;
		}
	}
	else{
		if(inputfield.value == 'Wachtwoord'){
			inputfield.value = '';
			replaceT(inputfield);
		}
		else if(inputfield.value == initvalue){
			inputfield.value = '';
		}
	}
}
function replaceT(obj){
	var newO=document.createElement('input');
	newO.setAttribute('type','password');
	newO.setAttribute('id',obj.getAttribute('id'));
	newO.setAttribute('name',obj.getAttribute('name'));
	obj.parentNode.replaceChild(newO,obj);
	setTimeout("document.getElementById('"+obj.getAttribute('id')+"').focus();",10);
}

function updateCard(intCardId){
	var blnCard = 0;
	if($('card_text'+intCardId).visible()) blnCard = 1;
		
	new Ajax.Request('/includes/ajax/update_cardtext.php', {
		method: 'post',
		parameters: {cartId: intCardId, card: blnCard, cardTxt:''},
		onSuccess: function(transport) {
		}
	});

}
function updateCardTxt(objCardText){
	
	new Ajax.Request('/includes/ajax/update_cardtext.php', {
		method: 'post',
		parameters: {cartId: objCardText.title, card:1, cardTxt: $F(objCardText)},
		onSuccess: function(transport) {
		}
	});

}
function updateVoucherTxt(objVoucherText){
	
	new Ajax.Request('/includes/ajax/update_vouchertext.php', {
		method: 'post',
		parameters: {cartId: objVoucherText.title, voucherTxt: $F(objVoucherText)},
		onSuccess: function(transport) {
		}
	});

}


Event.observe(window, "load", function() {

$$('input.replace_input')
		.invoke('observe', 'focus', function(event){
			if(Event.element(event).id == 'passphrase') {
				if(Event.element(event).value == Event.element(event).title) {
					Event.element(event).value = '';
					replaceT(Event.element(event));
				}
			}
			else if(Event.element(event).value == Event.element(event).title)
				Event.element(event).value = '';
		})
		.invoke('observe', 'blur', function(event){
			if(Event.element(event).value == '')
				Event.element(event).value = Event.element(event).title;
		});
});


