/****************************************************/
/*	Javascipt Secure loginform script				*/
/*													*/
/*	Shows a normal login form but will not directly	*/
/*	send filled in information, password will be	*/
/*	encryptred first, and send to server via a		*/
/*	new form. This way if user wants to remember	*/
/*	password, the plaintext password will be		*/
/*	stored in the browser, not the encrypted one	*/
/*	The encrypted one will never be the same hash	*/
/*													*/
/*	Usage: secureForm(targetpage,checkkey)			*/
/*	Created by: J.Versteege							*/
/*	Date: 17 - 11 - 2005							*/
/*													*/
/****************************************************/

function setForm(){
	document.secured.password.value = hex_md5(hex_md5("Encrypt this thing: "+document.slogin.pwd.value)+document.slogin.key.value);
	document.secured.loginname.value = document.slogin.usr.value;
	document.secured.newlanguage.value = document.slogin.lang.options[document.slogin.lang.selectedIndex].value;
	}

function secureForm(action,key,logintext,passwordtext,langtext,langlist,buttontext,lostpassurl,lostpasstext){
	var loginform = "<div class='sloginform' id='sloginform'>"+
				"<form name='slogin' id='slogin' method='post' action='javascript:document.secured.submit()' onSubmit='setForm();'>"+
				"<div id='usrtext'>"+[logintext]+"<\/div>"+
				"<div id='usrbox'><input type='text' id='usr' name='usr' value='guest'/><\/div><br/>"+
				"<div id='pwdtext'>"+[passwordtext]+"<\/div>"+
				"<div id='pwdbox'><input type='password' id='pwd' name='pwd' value='guest123'/><\/div><br/>"+
				"<div id='langtext'>"+[langtext]+"<\/div>"+
				"<div id='langbox'><select id='lang' border='0' name='lang' onChange='window.location=\"?newlanguage=\"+this.value'>"+[langlist]+"</select><\/div>"+
				"<input type='hidden' name='key' value='"+[key]+"'/>"+
				"<input type='submit' id='go' name='go' value='"+[buttontext]+"'/>"+
				"<\/form>"+
				"<form name='secured' method='post' action='"+[action]+"'>"+
				"<input name='loginname' type='hidden'/>"+
				"<input name='password' type='hidden'/>"+
				"<input name='newlanguage' type='hidden'/>"+
				"<\/form>"+
				"<\/div>"+
				"<div id='lostpass'><a class='lostpass' href='"+[lostpassurl]+"'>"+[lostpasstext]+"<\/a><\/div>";
	return loginform;
	}

