/*
	-- LOGIN START PAGE FUNCTIONS --
*/
// Function that focuses the login form when entering the site
function focusElement(){
	document.loginform.login.focus();
}

// Function for checking the entire login form
function checkLoginForm(form){	
	if(isEmpty(form.login) && isEmpty(form.password)){
		alert("Please enter a valid loginname and password");
		form.login.focus();
		return false;
	}else if(isEmpty(form.login)  && !isEmpty(form.password)){
		alert("Please enter a valid loginname");
		form.login.focus();
		return false;
	}else if(!isEmpty(form.login) && isEmpty(form.password)){
		alert("Please enter a password");
		form.password.focus();
		return false;
	}
	return true;
}

// Simple verification function for textfields
function isEmpty(aTextField) {
   if ((aTextField.value.length==0) ||
   (aTextField.value==null)) {
      return true;
   }
   else { return false; }
}

// Simple verification function for e-mail
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

/*
	-- COMMONLY USED FUNCTIONS FOR THE SITE --
*/
function swt_Lang(lang) {
	if (!lang){
		lang = "en";
	}
	
	var url = new String(window.location);

	if (lang == "en"){
		newUrl = url.replace("/sv","/en");
	}else if (lang == "sv"){
		newUrl = url.replace("/en","/sv");
	}
	window.location.href = newUrl;
	return true;
}