/* All source code is (c) Evogame.org. Unauthorized use/reverse engineering/copying is prohibited. */
var login={status:0,init:null};var lastHash;login.init=function(){login.status=1;var a=$("mainBody");a.style.backgroundImage='url("images/background.jpg")';var b=window.location.hash;if(b){b=b.substring(1);b=b.split(":");lastHash=b;setPage(b[0]);return}else{lastHash=new Array()}setPage("main")};function page(){this.content=document.createElement("div")}page.prototype.title="";page.prototype.content=document.createElement("div");page.prototype.setActive=function(){var a=$("mainBody");a.innerHTML="";var d;var c;var b;d=document.createElement("div");d.id="window";c=document.createElement("div");c.id="windowTitle";b=document.createElement("div");b.id="windowLeftTop";c.appendChild(b);b=document.createElement("div");b.id="windowRightTop";c.appendChild(b);b=document.createElement("div");b.id="windowTitleContent";b.appendChild(document.createTextNode(this.title));c.appendChild(b);d.appendChild(c);c=document.createElement("div");c.id="windowMiddle";b=document.createElement("div");b.id="windowBorderLeft";c.appendChild(b);b=document.createElement("div");b.id="windowBorderRight";c.appendChild(b);b=document.createElement("div");b.id="windowContent";b.appendChild(this.content);c.appendChild(b);b=document.createElement("div");b.style.clear="both";c.appendChild(b);d.appendChild(c);c=document.createElement("div");c.id="windowFooter";b=document.createElement("div");b.id="windowLeftBottom";c.appendChild(b);b=document.createElement("div");b.id="windowRightBottom";c.appendChild(b);b=document.createElement("div");b.id="windowBorderBottom";c.appendChild(b);d.appendChild(c);a.appendChild(d)};var setPage=function(m){var l;switch(m){case"login":var j;var p;var c;var q;var n;var h;var k;var g;var f;if(lastHash&&lastHash[0]=="login"){window.location.hash="#"+lastHash.join(":")}else{window.location.hash="#login"}l=new page();l.title="Light of Evolution - Login";j=document.createElement("a");j.style.cursor="pointer";j.onclick=function(){setPage("main")};j.appendChild(document.createTextNode("Back"));l.content.appendChild(j);c=document.createElement("form");c.action="";c.method="post";c.onsubmit=function(){return doLogin($("form"))};c.id="form";p=document.createElement("table");p.style.width="50%";p.style.textAlign="center";p.cellPadding=0;p.cellSpacing=10;h=document.createElement("tbody");if(lastHash&&lastHash.length>=5){if(lastHash[4]=="1"){q=document.createElement("tr");n=document.createElement("td");n.colSpan=2;n.appendChild(document.createTextNode("Error: Username/Password not found."));q.appendChild(n);h.appendChild(q)}}q=document.createElement("tr");n=document.createElement("td");n.style.width="50%";n.appendChild(document.createTextNode("Universe"));q.appendChild(n);n=document.createElement("td");n.style.width="50%";k=document.createElement("select");k.id="universe";k.style.width="100%";for(f=0;f<universes.length;f++){g=document.createElement("option");g.id="universe";g.value=f;if(lastHash&&lastHash.length>=2){if(parseInt(lastHash[1])==f){g.selected=true}}g.appendChild(document.createTextNode(uniNames[f]));k.appendChild(g)}n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("Username"));q.appendChild(n);n=document.createElement("td");k=document.createElement("input");k.type="text";k.name="username";k.value="";k.style.width="100%";if(lastHash&&lastHash.length>=3){k.value=lastHash[2]}n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("Password"));q.appendChild(n);n=document.createElement("td");k=document.createElement("input");k.type="password";k.name="password";k.value="";k.style.width="100%";n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("Remember me"));q.appendChild(n);n=document.createElement("td");k=document.createElement("input");k.type="checkbox";k.name="rememberme";k.value="1";if(lastHash&&lastHash.length>=4){if(lastHash[3]=="1"){k.checked=true}}n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.colSpan=2;k=document.createElement("input");k.type="submit";k.value="Login";n.appendChild(k);q.appendChild(n);h.appendChild(q);p.appendChild(h);c.appendChild(p);l.content.appendChild(c);l.setActive();break;case"register":if(lastHash&&lastHash[0]=="register"){window.location.hash="#"+lastHash.join(":")}else{window.location.hash="#register"}l=new page();l.title="Light of Evolution - Register";var j;var p;var q;var n;var f;var k;var g;j=document.createElement("a");j.style.cursor="pointer";j.onclick=function(){setPage("main")};j.appendChild(document.createTextNode("Back"));l.content.appendChild(j);c=document.createElement("form");c.action="post";c.onsubmit=doRegister(c);p=document.createElement("table");p.style.width="50%";p.style.textAlign="center";p.cellPadding=0;p.cellSpacing=10;h=document.createElement("tbody");q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("Universe"));n.style.width="50%";q.appendChild(n);n=document.createElement("td");k=document.createElement("select");k.style.width="100%";k.id="universe";for(f=0;f<universes.length;f++){g=document.createElement("option");g.value=f;g.appendChild(document.createTextNode(uniNames[f]));k.appendChild(g);if(lastHash.length>=2){if(parseInt(lastHash[1])==f){g.selected=true}}}k.onchange=function(){$("playerSideSelector").style.display=sidesUnis[this.value]?"table-row":"none"};n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("Username"));q.appendChild(n);n=document.createElement("td");k=document.createElement("input");k.type="text";k.name="username";k.id="username";k.style.width="100%";if(lastHash.length>=4){k.value=lastHash[3]}n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("Password"));q.appendChild(n);n=document.createElement("td");k=document.createElement("input");k.type="password";k.name="password";k.id="password";k.style.width="100%";n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("Repeat password"));q.appendChild(n);n=document.createElement("td");k=document.createElement("input");k.type="password";k.id="password2";k.style.width="100%";n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("E-Mail address"));q.appendChild(n);n=document.createElement("td");k=document.createElement("input");k.type="text";k.name="email";if(lastHash.length>=5){k.value=lastHash[4]}k.style.width="100%";n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("Gender"));q.appendChild(n);n=document.createElement("td");k=document.createElement("select");k.name="gender";k.id="gender";k.style.width="100%";g=document.createElement("option");g.appendChild(document.createTextNode(""));g.value="";k.appendChild(g);g=document.createElement("option");g.appendChild(document.createTextNode("Male"));g.value="M";if(lastHash.length>=6&&lastHash[5]=="M"){g.selected=true}k.appendChild(g);g=document.createElement("option");g.appendChild(document.createTextNode("Female"));g.value="F";if(lastHash.length>=6&&lastHash[5]=="F"){g.selected=true}k.appendChild(g);n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("Name of your planet"));q.appendChild(n);n=document.createElement("td");k=document.createElement("input");k.name="planet";k.type="text";if(lastHash.length>=7){k.value=lastHash[6]}k.style.width="100%";n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");q.style.display="none";q.id="playerSideSelector";n=document.createElement("td");n.appendChild(document.createTextNode("Universe side"));q.appendChild(n);n=document.createElement("td");k=document.createElement("select");k.name="side";k.style.width="100%";g=document.createElement("option");g.appendChild(document.createTextNode(""));g.value=0;k.appendChild(g);g=document.createElement("option");g.appendChild(document.createTextNode("Side 1"));g.value=1;k.appendChild(g);g=document.createElement("option");g.appendChild(document.createTextNode("Side 2"));g.value=2;k.appendChild(g);n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.appendChild(document.createTextNode("I agree with the rules"));q.appendChild(n);n=document.createElement("td");k=document.createElement("input");k.id="agree";k.name="agree";k.type="checkbox";if(lastHash.length>=8){if(parseInt(lastHash[7])==1){k.checked=true}}n.appendChild(k);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.colSpan=2;k=document.createElement("input");k.value="Create account";k.type="submit";n.appendChild(k);q.appendChild(n);h.appendChild(q);p.appendChild(h);c.appendChild(p);if(lastHash.length>=3&&lastHash[2]!="0"&&lastHash[2]!=""){k=document.createElement("input");k.name="ref";k.value=lastHash[2];k.type="hidden";c.appendChild(k)}l.content.appendChild(c);if(lastHash.length>=9&&lastHash[8]!=""){alert(Base64.decode(lastHash[8]))}l.setActive();break;case"screenshots":if(lastHash&&lastHash[0]=="screenshots"){window.location.hash="#"+lastHash.join(":")}else{window.location.hash="#screenshots"}l=new page();l.title="Light of Evolution - Screenshots";var j;j=document.createElement("a");j.style.cursor="pointer";j.onclick=function(){setPage("main")};j.appendChild(document.createTextNode("Back"));l.content.appendChild(j);l.setActive();break;case"regdone":if(lastHash&&lastHash[0]=="regdone"){window.location.hash="#"+lastHash.join(":")}else{window.location.hash="#regdone"}l=new page();l.title="Light of Evolution - Registration complete";var j;j=document.createElement("a");j.style.cursor="pointer";j.onclick=function(){setPage("main")};j.appendChild(document.createTextNode("Back"));l.content.appendChild(j);var b=document.createElement("center");b.appendChild(document.createTextNode("Registration is complete. An e-mail was sent to your e-mail address, with a link to confirm your e-mail address."));l.content.appendChild(b);l.setActive();break;default:window.location.hash="#front";l=new page();l.title="Light of Evolution - Main";var p;var h;var q;var n;var d;var a;var o;var e;var f;var j;p=document.createElement("table");p.style.width="100%";p.cellPadding=0;p.cellSpacing=10;l.content.appendChild(p);h=document.createElement("tbody");q=document.createElement("tr");q.style.height="60px";n=document.createElement("td");n.colSpan=2;n.style.textAlign="center";n.style.verticalAlign="top";a=document.createElement("div");a.style.width="75%";a.style.margin="auto";a.appendChild(document.createTextNode("Light of Evolution is a text-based and online game. Because it is text-based it is playable on every computer that has access to this website. The fact you can read this means you can play too!"));n.appendChild(a);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.style.textAlign="center";n.style.verticalAlign="top";n.style.width="50%";d=document.createElement("img");d.src="images/loginImage.png";d.style.width="335px";d.style.height="100px";d.style.opacity=0.7;d.style.cursor="pointer";d.onclick=function(){setPage("login")};d.onmouseover=function(){this.style.opacity=1};d.onmouseout=function(){this.style.opacity=0.7};n.appendChild(d);q.appendChild(n);n=document.createElement("td");n.style.textAlign="center";n.style.verticalAlign="top";n.style.width="50%";d=document.createElement("img");d.src="images/registerImage.png";d.style.width="335px";d.style.height="100px";d.style.opacity=0.7;d.style.cursor="pointer";d.onclick=function(){setPage("register")};d.onmouseover=function(){this.style.opacity=1};d.onmouseout=function(){this.style.opacity=0.7};n.appendChild(d);q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.style.textAlign="center";n.style.verticalAlign="top";d=document.createElement("img");d.src="images/screenshotImage.png";d.style.width="335px";d.style.height="100px";d.style.opacity=0.7;d.style.cursor="pointer";d.onclick=function(){setPage("screenshots")};d.onmouseover=function(){this.style.opacity=1};d.onmouseout=function(){this.style.opacity=0.7};n.appendChild(d);q.appendChild(n);n=document.createElement("td");n.style.textAlign="center";n.style.verticalAlign="top";o=["http://support.evogame.org/","http://forum.evogame.org/","http://wiki.evogame.org/","http://wiki.evogame.org/index.php/Rules","http://wiki.evogame.org/index.php/TOS","contact.php"];e=["Support","Forum","Wiki","Rules","TOS","Contact"];for(f=0;f<o.length;f++){j=document.createElement("a");j.target="_blank";j.href=o[f];j.appendChild(document.createTextNode(e[f]));n.appendChild(j);n.appendChild(document.createElement("br"))}q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("th");n.style.textAlign="center";n.style.verticalAlign="top";n.colSpan=2;n.appendChild(document.createTextNode("Quick jump"));q.appendChild(n);h.appendChild(q);q=document.createElement("tr");n=document.createElement("td");n.style.textAlign="center";n.style.verticalAlign="top";n.colSpan=2;for(f=0;f<universes.length;f++){if(!universes[f]){continue}j=document.createElement("a");j.href="http://"+universes[f]+"/game.php";j.appendChild(document.createTextNode("Universe "+f));n.appendChild(j);n.appendChild(document.createTextNode(" - "))}j=document.createElement("a");j.href="http://forum.evogame.org/";j.appendChild(document.createTextNode("Forum"));n.appendChild(j);q.appendChild(n);h.appendChild(q);p.appendChild(h);l.setActive();break}};var doLogin=function(a){if($("universe").value==0){alert("No universe specified.");return false}a.action="http://"+universes[$("universe").value]+"/login.php";a.submit();return true};var doRegister=function(a){return function(){if($("universe").value==0){alert("No universe specified.");return false}a.method="post";a.action="http://"+universes[$("universe").value]+"/reg.php";if($("password").value!=$("password2").value){alert("The passwords you entered do not match.");return false}if($("password").value.length<6){alert("Your password is not strong enough. (6 characters minimum)");return false}if($("username").value.length<4){alert("Your username must have at least 4 characters.");return false}if($("gender").value!="M"&&$("gender").value!="F"){alert("No gender selected."+$("gender").value);return false}if(!$("agree").checked){alert("You have to agree with the rules.");return false}return true}};var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(c){var a="";var k,h,f,j,g,e,d;var b=0;c=Base64._utf8_encode(c);while(b<c.length){k=c.charCodeAt(b++);h=c.charCodeAt(b++);f=c.charCodeAt(b++);j=k>>2;g=((k&3)<<4)|(h>>4);e=((h&15)<<2)|(f>>6);d=f&63;if(isNaN(h)){e=d=64}else{if(isNaN(f)){d=64}}a=a+this._keyStr.charAt(j)+this._keyStr.charAt(g)+this._keyStr.charAt(e)+this._keyStr.charAt(d)}return a},decode:function(c){var a="";var k,h,f;var j,g,e,d;var b=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(b<c.length){j=this._keyStr.indexOf(c.charAt(b++));g=this._keyStr.indexOf(c.charAt(b++));e=this._keyStr.indexOf(c.charAt(b++));d=this._keyStr.indexOf(c.charAt(b++));k=(j<<2)|(g>>4);h=((g&15)<<4)|(e>>2);f=((e&3)<<6)|d;a=a+String.fromCharCode(k);if(e!=64){a=a+String.fromCharCode(h)}if(d!=64){a=a+String.fromCharCode(f)}}a=Base64._utf8_decode(a);return a},_utf8_encode:function(b){b=b.replace(/\r\n/g,"\n");var a="";for(var e=0;e<b.length;e++){var d=b.charCodeAt(e);if(d<128){a+=String.fromCharCode(d)}else{if((d>127)&&(d<2048)){a+=String.fromCharCode((d>>6)|192);a+=String.fromCharCode((d&63)|128)}else{a+=String.fromCharCode((d>>12)|224);a+=String.fromCharCode(((d>>6)&63)|128);a+=String.fromCharCode((d&63)|128)}}}return a},_utf8_decode:function(a){var b="";var d=0;var e=c1=c2=0;while(d<a.length){e=a.charCodeAt(d);if(e<128){b+=String.fromCharCode(e);d++}else{if((e>191)&&(e<224)){c2=a.charCodeAt(d+1);b+=String.fromCharCode(((e&31)<<6)|(c2&63));d+=2}else{c2=a.charCodeAt(d+1);c3=a.charCodeAt(d+2);b+=String.fromCharCode(((e&15)<<12)|((c2&63)<<6)|(c3&63));d+=3}}}return b}};