/**
 *	Check that all values has been filled out properly
 */
function checkLogin(f) {
	var username = f.username.value;
	var passw = f.password.value;

	if (username.length < 4 || username == "e-postadress") {
		alert("Du måste ange ett användarnamn!");
		f.username.focus();
		return false;
	}

	if (passw.length < 5 || passw == "Lösenord") {
		alert("Du måste ange ett lösenord på minst 5 tecken!");
		f.password.focus();
		return false;
	}
	
	return true;
}

var forgottPassWin;
function openForgottPass() {
	forgottPassWin = new Window({width: 450, height: 200,url: "/forgottpass.jsp", zIndex: 99999999, minimizable: false, maximizable: false, resizable: false, title: "Glömt lösenord", draggable: true, wiredDrag: true, showEffectOptions: {duration:null}, hideEffectOptions: {duration:null}});
	forgottPassWin.show();
}

function openRegisterCode() {
	var registerCodeWin = new Window({width: 450, height: 200,url: "/register_code.jsp", zIndex: 99999999, minimizable: false, maximizable: false, resizable: false, title: "Glömt lösenord", draggable: true, wiredDrag: true, showEffectOptions: {duration:null}, hideEffectOptions: {duration:null}});
	registerCodeWin.show();
	
	myObserver = { 
			onClose: function(eventName, win) {
				if (win == registerCodeWin) {
					window.location.reload();
					Windows.removeObserver(this); 
				}
			} 
	}
	
	Windows.addObserver(myObserver); 
}

function openRegisterPPCode() {
	var registerPPCodeWin = new Window({width: 450, height: 440,url: "/webacl/regcoderegister.jsp", zIndex: 99999999, minimizable: false, maximizable: false, resizable: false, title: "Prova onlinetjänster gratis!", draggable: true, wiredDrag: true, showEffectOptions: {duration:null}, hideEffectOptions: {duration:null}});
	registerPPCodeWin.show();
}

function deleteCode() {
	new Ajax.Request("/register_code.jsp?remove=true",
		  	{
		    	method:'get',
		    	onSuccess: function(transport){
					window.location.reload();
				}
		   });

}

