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);
}


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;
		});
});

function getMoney(value) {
	return replace(cent(roundNumber(value)),'.',',')
}

function cent(amount) {
    amount -= 0;
    return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function roundNumber(num) {
	var result = Math.round(num*Math.pow(10,2))/Math.pow(10,2);
	return result;
}

function replace(string,text,by) {
// Replaces text with by in string
	string += '';
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;

	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,txtLength))) return string;
	if (i == -1) return string;

	var newstr = string.substring(0,i) + by;

	if (i+txtLength < strLength)
	newstr += replace(string.substring(i+txtLength,strLength),text,by);
	
	return newstr;
}

