

function markLabel(id)
{
	$('label_'+id).addClassName('boersen-error');
}

function unmarkLabel(id)
{
	$('label_'+id).removeClassName('boersen-error');
}

function enableElement(id)
{
	$(id).enable();
}

function disableElement(id)
{
	$(id).disable();
}


function checkMoney(id)
{	ret = true;
	unmarkLabel(id);
	val = $(id).value;
	if(val.lastIndexOf(",") == -1)
	{
		parsed = parseFloat(val,10);
		if(isNaN(parsed))
		{	ret = false;
		}
	}
	else
	{
		parts = val.split(',')
		if(parts.length > 2)
		{	ret = false;
		}
		if(isNaN(Number(parts[0])) || isNaN(Number(parts[1])))
		{	ret = false;
		}
	}
	
	if(ret == false)
	{	markLabel(id);
	}
	
	return ret;
}

function checkTime(id)
{
	unmarkLabel(id);
	val = $(id).value;
	
	timereq = /^([0-1][0-9]|[2][0-4]):[0-5][0-9]$/;
	
	if(val.match(timereq))
	{	return true;
	}
	
	markLabel(id);
	return false;
}

function checkDate(id)
{
	unmarkLabel(id);
	val = $(id).value;

	datereq = /([0][1-9]|[1-2][0-9]|[3][0-1])\.([0]?[1-9]|[1][0-2])\.[2][0-9][0-9][0-9]/;
	
	if(val.match(datereq))
	{	return true;
	}
	
	markLabel(id);
	return false;
}

function checkMietKauf(id,mietid, kaufid)
{
	unmarkLabel(id);
	if($(mietid).checked == false && $(kaufid).checked == false)
	{
		markLabel(id);
		return false;
	}
	return true;
}

function checkEmail(id)
{
	unmarkLabel(id);
	val = $(id).value;
	
	mailreq = /^([\D]+[\S])+@([\D][\S]+\.)*?[\D][\S]+\.[\w][\w]+/;
	
	if(val.match(mailreq))
	{	return true;		
	}
	
	markLabel(id);
	return false;
}

function checkNumeric(id)
{
	unmarkLabel(id);
	val = $(id).value;
	if(val.length == 0 || isNaN(Number(val)))
	{	markLabel(id);
		return false;
	}
	
	return true;
}

function checkEmpty(id)
{
	unmarkLabel(id);
	val = $(id).value;
	if(val.length == 0)
	{
		markLabel(id);
		return false;
	}
	return true;
}

function checkSelect(id)
{
	unmarkLabel(id);
	val = $(id).value;
	if(val == -1)
	{
		markLabel(id);
		return false;
	}
	return true;
}
