<!--
var errors = "";

function _gel(id){return document.getElementById(id);}

function checkmailerror(myObj){
	mail = myObj.value;
	fel = new Array("hotmial","hotmal.com","@homail.com","hotmaill","hottmail","hotmail.se","hotmail.som","@otmail","hotmil","@gotmail","hotail","htomail","hotamil","@htamil","@htmail","hormail","hotnail","hotmsil","homtil.com","hotmale.com","homtail","hotmaiil","hotmaail","hotmai.com","hotmaik","hotmaul","hotmall"); 
	for(x=0;x<fel.length;x++){
		chk = eval("/"+fel[x]+"/");
		if(chk.test(mail)){
			alert("Din e-postadress innehåller \""+fel[x]+"\" som verkar vara en felskrivning eller ogiltig adress, vänligen korrigera detta innan du fortsätter.");
			myObj.focus();
		}
	}
}

function menu(obj) {
	option=obj.options[obj.selectedIndex].value;
	if (option != '')
		window.location=option;
}

/**
 * Validate e-mail
 */
function validEmail(email) {
	var res = false;
	var atIndex = email.indexOf("@");
	if (atIndex > 0 && email.length > 5) {
		var pIndex = email.indexOf(".",atIndex);
		if ((pIndex > atIndex+1) && (email.length > pIndex+2))
			res = true;
	}
	return res;
}


/**
 * Validate login-form-phone
 */
function checkLoginPhone(form){

	result = false;
	if(!/^\d{10,10}$/.test(form.phone.value)){
		alert("Fyll i ditt mobilnummer med endast siffror (ex: 0701234567 | 10 siffror, ej landskod).");
		form.phone.focus();

	}else{
		result = true;
	}
	return result;
}


/**
 * Validate activate-form-phone
 */
function checkActivatePhone(form){

	result = false;
	if(!/^\d{10,10}$/.test(form.phone.value)){
		alert("Fyll i ditt mobilnummer med endast siffror (ex: 0701234567 | 10 siffror, ej landskod).");
		form.phone.focus();

	}else{
		result = true;
	}
	return result;
}
	
	
/**
 * Validate login-form
 */
function checkLogin() {
	var ret = false;

	// Email
	if (document.loginForm.phone.value == "")
		alert ('Du måste fylla i ditt mobilnummer');

	// Password
	else if (document.loginForm.password.value == "")
		alert ('Du måste fylla i lösenord');

	else
		ret = true;

	if (!ret) {
		window.event.returnValue=false;
		return;
	}
	return true;
}


/**
 * Trim a string (remove spaces before and after)
 */
function trim(str) {
	while (str.substring(0,1) == " ") {
		str = str.substring(1,str.length);
	}
	while (str.substring(str.length-1,str.length) == " ") {
		str = str.substring(0,str.length-1);
	}
	return str;
}

/**
 * Validate name in Registration form
 */
function validateName() {
	var str = trim(document.registerForm.name.value);

	if (str.length < 2 || !str.match(" ") || !(str.search(" ") <= str.length-2)) {
		document.pic_name.src = "images/arrow_left_orange.gif";
		errors = errors + "Du måste ange för- och efternamn.\n";
	}
	else
		document.pic_name.src = "images/check_green.gif";
}

/**
 * Validate email in Registration form
 */
function validateEmail() {
	var str = trim(document.registerForm.email.value);

	if (!validEmail(str)) {
		document.pic_email.src = "images/arrow_left_orange.gif";
		errors = errors + "Du måste ange en korrekt e-postadress.\n";
	}
	else
		document.pic_email.src = "images/check_green.gif";
}

/**
 * Return true if str is numeric, false otherwise
 */
function isNumeric(str) {
	var vChars = "0123456789";
	var isNum = true;
	var c;
	
	for (i = 0; i < str.length && isNum == true; i++) {
		c = str.charAt(i);
		if (vChars.indexOf(c) == -1)
			isNum = false;
	}
	
	return isNum;
}

/**
 * Validate mobile phone number in Registration form
 */
function validatePhone() {
	var str = trim(document.registerForm.phone.value);
	
	if (str.substring(0,1) == "0" && str.length > 7 && isNumeric(str)) {
		document.pic_phone.src = "images/check_green.gif";
	}
	else {
		document.pic_phone.src = "images/arrow_left_orange.gif";
		errors = errors + "Felaktigt mobilnummer.\n";
	}
}

/**
 * Validate age in Registration form
 */
function validateAge() {
	var str = trim(document.registerForm.age.value);
	
	if (str.length > 3) {
		document.pic_age.src = "images/check_green.gif";
	}
	else {
		document.pic_age.src = "images/arrow_left_orange.gif";
		errors = errors + "Du måste ange när du är född.\n";
	}
}

/**
 * Validate password in Registration form
 */
function validatePassword() {
	var str = trim(document.registerForm.password.value);
	var str2 = trim(document.registerForm.password2.value);

	if (str.length > 2) {
		document.pic_password.src = "images/check_green.gif";
		if (str != str2) {
			document.pic_password2.src = "images/arrow_left_orange.gif";
			errors = errors + "Lösenordet måste repeteras korrekt.\n";
		}
		else
			document.pic_password2.src = "images/check_green.gif";
	}
	else {
		document.pic_password.src = "images/arrow_left_orange.gif";
		document.pic_password2.src = "images/arrow_left_orange.gif";
		errors = errors + "Lösenordet måste vara minst 3 bokstäver långt.\n";
	}
}

/**
 * Validate city in Registration form
 */
function validateCity() {
	var str = trim(document.registerForm.city.value);

	if (str.length < 1) {
		document.pic_city.src = "images/arrow_left_orange.gif";
		errors = errors + "Du måste ange din bostads ort.\n";
	}
	else
		document.pic_city.src = "images/check_green.gif";
}

/**
 * Validate old password in Setup form
 */
function validateOldPassword() {
	var str = trim(document.registerForm.oldpassword.value);

	if (str.length < 3) {
		document.pic_oldpassword.src = "images/arrow_left_orange.gif";
		errors = errors + "Lösenordet måste vara minst 3 bokstäver långt.\n";
	}
	else
		document.pic_oldpassword.src = "images/check_green.gif";
}

/**
 * Validate Accept rules
 */
function validateAcceptrules() {
	if (!document.registerForm.acceptrules.checked) {
		errors = errors + "Du måste godkänna våra villkor.\n";
		document.getElementById('rulestext').style.color="#AA0000";
	}
	else
		document.getElementById('rulestext').style.color="#007E00";
}

/**
 * Validate all fields in registration
 */
function validateAll() {
	validateAcceptrules();
	validateName();
	validatePhone();
	validateEmail();
	validateAge();
	validatePassword();
	validateCity();
}

/**
 * Validate all fields in user setup
 */
function validateAllSetup() {
	validateName();
	validatePhone();
	validateEmail();
	validateAge();
	validateCity();
	if ((trim(document.registerForm.password.value)).length > 0)
		validatePassword();
	validateOldPassword();
}

/**
 * Validate Registration form
 */
function checkRegistrationForm() {
	errors = "";
	validateAll();
	if (errors != "") {
		alert(errors);
		window.event.returnValue=false;
		return;
	}
	return true;
}

/**
 * Validate Registration form
 */
function checkSetupForm() {
	errors = "";
	validateAllSetup();
	if (errors != "") {
		alert(errors);
		window.event.returnValue=false;
		return;
	}
	return true;
}

/**
 * Validate a email-box
 */
function checkEmail(obj) {
	if (validEmail(obj.value))
		document.images("pic_"+obj.name).src = "images/check_green.gif";
	else
		document.images("pic_"+obj.name).src = "images/arrow_right_orange.gif";
}

/**
 * Check that value length is > 0
 */
function notEmpty(val,errmess) {
	if (val <= 0) {
		alert(errmess);
		window.event.returnValue=false;
		return;
	}
	return true;
}
-->
