/***************************************************/
/** Form validation funktions                     **/
/***************************************************/

function ResetForm (_fields)
{
	var fields = _fields.split("|");
	for (var i=0; i < fields.length-1; i++)
	{
		var _currId   = fields[i].substring(0,fields[i].indexOf("="));
		gElm(_currId + "_text").className = gElm(_currId + "_text").className.replace(/ textBC7/g, "");
	}
	document.forms[0].reset();
}

function ValidateForm (_fields)
{
	var errors = 0;
	var fields = _fields.split("|");
	for (var i=0; i < fields.length-1; i++)
	{
		var _currId   = fields[i].substring(0,fields[i].indexOf("="));
		var _currType = fields[i].substring(fields[i].indexOf("=")+1);
		errors += checkField(_currId, _currType);
	}
	
	if (!errors)
		document.forms[0].submit();
}

function FormShowPart(_id)
{
	gElm(_id).style.display = "block";
}

function checkField (_id, _type)
{
	var _currContent = _currContent = gElm(_id).value.replace(/ /g, "");
	
	switch(_type)
	{
		case "email":
			_currContent = checkEmail(_currContent);
			break;
	}
	
	if (_currContent=="")
	{
		if (gElm(_id + "_text").className.indexOf("textBC7")==-1)
			gElm(_id + "_text").className += " textBC7";
		return (1);
	}
	else
	{
		gElm(_id+"_text").className = gElm(_id+"_text").className.replace(/ textBC7/g, "");
		return (0);
	}
}

function checkEmail (_string)
{
	if (_string.indexOf("@")==-1) return ("");
	if (_string.indexOf(".")==-1) return ("");
	if (_string.length < 7) return ("");
	return ("x");
}
