
function checkInputText(oThis,doShow,text)
{
	if(doShow)
	{
		//Removing spaces to reduce the text to nothing is there is only spaces and no letters
		var currentVal = oThis.value.replace(/ /g,'');
		
		//Text has to be shown if nothing has been entered
		if(currentVal == '')
		{
			oThis.value = text;
			oThis.style.color = 'gray';
		}
	
	} else {
		//Text has to be hidden if default text is there
		if(oThis.value == text)
		{
			oThis.value = '';
			oThis.style.color = 'black';
		}
	}
}

function cleanFields(oForm,text1,text2,text3)
{
	var valid = true;
	var currentVal = '';
	for(i = 0; i < oForm.elements.length; i++)
	{
		currentVal = oForm.elements[i].value;
		if(currentVal == text1 || currentVal == text2 || currentVal == text3 )
		{
			oForm.elements[i].value = '';
			oForm.elements[i].style.color = 'black';
		}
		if(oForm.elements[i].name.indexOf("email") > -1 && oForm.elements[i].type == 'text')
		{
			valid = validateEmail(currentVal);
			if(!valid)
				alert("Angiv venligst en gyldig e-mail-adresse.");
		} 
	}
	
	return valid;
}

function validateEmail(mail)

{

    validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;



   // search email text for regular exp matches

    if (mail.search(validRegExp) == -1) 

    {

        return false;

    } 

    return true; 

}

