
var color_logoff_text_over = '#FFFFFF';
var color_logoff_text_out = '#FFFFFF';
var color_logoff_border_over = '#a84c51';
var color_logoff_border_out = '#a84c51';
var color_logoff_background_over = '#a84c51';
var color_logoff_background_out = '#a84c51';

var color_menu_text_on = '#CC6600';
var color_menu_text_off = '#333333';


function validateForm() {	
	
	var x = document.forms[0].elements; 
	for (var i=0;i<x.length;i++) {		
		// check for required attribute
		if (x[i].getAttribute('required') && !x[i].value) {
			// notify user of error
			filloutAlert(x[i]);			
			return false;
		}
		// check for email attribute
		if (x[i].getAttribute('email')) {
			if(!validateEmail(x[i].value)) {
				// notify user of error
				emailAlert(x[i]);			
				return false;
			}			
		}		
		// check for emailconfirm attribute
		if (x[i].getAttribute('emailconfirm')) {
			// get email value
			email = x['email'].value;
			if(!confirmEmail(email,x[i].value)) {
				// notify user of error
				emailConfirmAlert(x[i]);			
				return false;
			}			
		}	
		// check for minlength attribute
		if (x[i].getAttribute('minlength')) {
			var minlen = x[i].getAttribute('minlength');
			if(x[i].value.length!=minlen) {
				// notify user of error
				lengthAlert(x[i]);			
				return false;
			}			
		}		
	}

	var x = document.getElementsByTagName('textarea');
	for (var i=0;i<x.length;i++)	{
		if (x[i].getAttribute('maxlength')) {
	  	x[i].onkeypress = checkLength;
		}
	}
	return true;
}

function checkLength() {
 var max = this.getAttribute('maxlength');
 if (this.value.length > max) {
 	  // notify user of error
 }
}

function validateEmail(email) {
	if(email.length>0)	{	
		if(email.indexOf("@")<0 || email.indexOf(".")<0) {					
			return false;
		}				
	}
	return true;
}

function confirmEmail(email,email2) {
	if(email!=email2)  {
		return false;
	}
	return true;
}


function filloutAlert(obj) {
	obj.focus();
	obj.style.backgroundColor="#FFFF99";
	alert("Udfyld venligst det markeret felt.");			
}

function emailAlert(obj) {
	obj.focus();
	obj.style.backgroundColor="#FFFF99";
	alert("Email adressen er ikke korrekt");				
}


function emailConfirmAlert(obj) {
	obj.focus();
	obj.style.backgroundColor="#FFFF99";
	alert("Email adresserne er ikke ens");				
}

function lengthAlert(obj) {
	obj.focus();
	obj.style.backgroundColor="#FFFF99";
	var minlen = obj.getAttribute('minlength');
	alert("Feltet skal være mindst "+minlen+" karaktere langt");				
}

