/*
 * Personality Test
 * Copyright 2000-... Natalie Witt
 * Email: theadmiral@farscapeaustralia.iwarp.com
 * Site: http://www.farscape-australia.com
 *
 * Please do not use this javascript without permission and acknowledgment
 */

var agt=navigator.userAgent.toLowerCase();

/*
 * "4 letter category code: character name<br>character personality description",
 *
 * I've provided the names of each letter in the 4-letter code to give you a brief idea.
 * Check the codes.html file for expanded descriptions of each letter in the code.
 */
var types = new Array(
"ISFP: Simulants<br>Simulants were created to kill in a war that never took place, and now search the galaxy looking for worthy foes. They are mostly made like mechanoids but have some biomechanical parts. They are crazy and bloodthirsty, they live to kill.",
"ESFP: Cat<br>You love your self and your clothes. You believe you're the most hansom creature in the entire universe and that every female loves you. You have the worst dress sense ever, but you think it is the coolest ever. Your favourite food is Fish and you love Milk. You're lazy and selfish and have never worked hard, except when you're doing your hair. And you also have six nipples!!",
"ISTP: Kryten<br>You're very fussy. You are obsessed with cleaning and you hate a messy and untidy room. You try to be a mother to all around you, which most take advantage of. You?re a good friend and loyal (like a dog!), your quick thinking gets you out of trouble and most of the time into more trouble!!",
"ESTP: Kochanski<br>Kochanski grew up in the Gorbals, the trendiest part of Glasgow, alongside her brother Moose and her pony, Trumper. She was educated in Cyberschool, but afterwards, having discovered that the world didn't actually revolve around her, she went off the rails and became a retropunk. She then went to Cadet School and enlisted in the Space Corps, then signed on to Red Dwarf. She loves cottage cheese with pineapple chunks and her teddy bear, Boo-Boo. She hates showers.",
"ISTJ: Rimmer<br>You're a nerd, a wuss and a brain box! You?re also very cunning and want power, you would do anything to get a promotion but it never gets you anywhere. You have very few friends and were bullied at school, and you still are bullied at work! You don?t like to fight or get hurt and would prefer to run. You common sense does help those around you in times of need.",
"ESTJ: Skutters<br>Skutters are the maintenance robots of Red Dwarf and have their cupboard piled high with Film Fun magazines. They love John Wayne movies and playing Cowboys and Indians. And insulting Rimmer with two-finger salutes! The only known named Skutters are Bob and Madge.",
"ISFJ: Duane Dibbley<br>Duane is Cats alter ego. And as you would expect he is the total opposite of Cat, he goofy and a nerd. And his dress sense is even worse than Cats!",
"ESFJ: Holly<br>You are very very bright and a little mad! Your also very relaxed, maybe a little too relaxed and witty in a situation. And you've read every book ever written!",
"INTP: The Talkie Toaster<br>This little ?19.99 toaster is bread-obsessed! After meeting him you'll want to smash it up, all he talks about is toast and other bread related food, and won't stop until you eat some!",
"ENTP: Psirens<br>Using telepathy to induce hallucinations, the Psirens lure space travellers onto the asteroids on which they resided and then suck their brains out with a small metal straw. Their neutral form is something like a seven-foot cockroach!",
"INTJ: Kill Crazy<br>He's the kind of prison inmate who thinks he can take on a T-Rex with his bare hands! He is psychotic, violent and has no sense for self-preservation. He did manage to reprogram Kryten to show shower footage of the women's wing but apart from that his skills seem best suited to killing things. Sadly his involvement with the Cassandra (Series 8, Episode 4) mission was cut short when he ran into a hatchway and knocked himself cold.",
"ENTJ: Captain Hollister<br>The Captain of the Red Dwarf, he put Lister in stasis for bringing an unquarantined animal aboard the ship (his pet cat).",
"INFP: The Inquisitor<br>A simulant whose ability to self-repair allowed him to survive to the end of time itself. Concluding that there is no god or afterlife, he constructed a time gauntlet and now roams history looking for those who have wasted their lives and replacing them with those who never got the chance to live.",
"ENFP: Lister<br>Like Cat, you don't like to work and love women. But what you do like is a curry and a beer, and your guitar. As a child you stole and vandalised anything and everything, you?re not too bright but in a situation you come up with good(ish) ideas that usually saves you and your mates.",
"INFJ: The Kinitawowi<br>A friendly GELF tribe. Not skinning you alive the minute you meet is one of their warmest greetings. Lister married the Kinitawowi chief's daughter who was called Ech-ech-ech-ech-ech-ech-ech-ech-ech!",
"ENFJ: Ace Rimmer<br>A Space Corps Marine, eventually ending up as a test pilot for the Corps. While testing a ship that crosses dimensions he met the real Rimmer."
);

//the 4 letter codes
names1 = new Array("ISFP", "ESFP", "ISTP", "ESTP", "ISTJ", "ESTJ", "ISFJ", "ESFJ", "INTP", "ENTP", "INTJ", "ENTJ", "INFP", "ENFP", "INFJ", "ENFJ");

//character names - short version, using for anchor name
names2 = new Array("Simulants", "Cat", "Kryten", "Kochanski", "Rimmer", "Skutters", "DuaneDibbley", "Holly", "TalkieToaster", "Psirens", "KillCrazy", "CptnHollister", "Inquisitor", "Lister", "Kinitawowi", "AceRimmer");

//character names - long version (same as in the descriptions)
names3 = new Array("Simulants", "Cat", "Kryten", "Kochanski", "Rimmer", "Skutters", "Duane Dibbley", "Holly", "The Talkie Toaster", "Psirens", "Kill Crazy", "Captain Hollister", "The Inquisitor", "Lister", "The Kinitawowi", "Ace Rimmer");

function displayAllTypes() {
var page = "";
page += "<center><table border=0><tr><td valign=top>";
for(var j=0; j<8; j++) {
  page += names1[j] + ":<br>\n";
}
page += "</td><td valign=top width=135>";
for(var j=0; j<8; j++) {
  page += "<a href='#" + names2[j] + "'>" + names3[j] + "</a><br>\n";
}
page += "</td><td valign=top>";
for(var j=8; j<16; j++) {
  page += names1[j] + ":<br>\n";
}
page += "</td><td valign=top width=135>";
for(var j=8; j<16; j++) {
  page += "<a href='#" + names2[j] + "'>" + names3[j] + "</a><br>\n";
}
page += "</td></tr></table></center><p><blockquote><ul>";
for(var i=0; i<types.length;i++)
  page += "<li><a name='" + names2[i] + "'></a>" + types[i] + "<br><br></li>\n";
page += "</ul></blockquote>\n";
return page;
} //end function

function isTrue(Val) {
  return document.extest[Val].checked ? 1 : 0;
} //end fn isTrue

/*
 * If you want more than 1 character for a category do something like this:
 *
 * else if(ETyp == "INTJ") {
 *   if(E<1) typNum=10;               //Name 10, Scientist
 *   else if(S<1) typNum=11;          //Name 11, Scientist
 *   else if(T>5) typNum=12;          //Name 12, Scientist
 *   else typNum=13;                  //Name 13, Scientist
 * }
 *
 * Remember to make sure to change the numbers so they're sequential
 */
function showType(ETyp,E,S,T,J) {
  if(ETyp == "ISFP") typNum=0;       //Name 0, Artist
  else if(ETyp == "ESFP") typNum=1;  //Name 1, Entertainer
  else if(ETyp == "ISTP") typNum=2;  //Name 2, Artisan
  else if(ETyp == "ESTP") typNum=3;  //Name 3, Promotor
  else if(ETyp == "ISTJ") typNum=4;  //Name 4, Trustee
  else if(ETyp == "ESTJ") typNum=5;  //Name 5, Administrator
  else if(ETyp == "ISFJ") typNum=6;  //Name 6, Conservator
  else if(ETyp == "ESFJ") typNum=7;  //Name 7, Seller
  else if(ETyp == "INTP") typNum=8;  //Name 8, Architect
  else if(ETyp == "ENTP") typNum=9;  //Name 9, Inventor
  else if(ETyp == "INTJ") typNum=10; //Name 10, Scientist
  else if(ETyp == "ENTJ") typNum=11; //Name 11, Field Marshall
  else if(ETyp == "INFP") typNum=12; //Name 12, Questor
  else if(ETyp == "ENFP") typNum=13; //Name 13, Journalist
  else if(ETyp == "INFJ") typNum=14; //Name 14, Author
  else if(ETyp == "ENFJ") typNum=15; //Name 15, Pedagogue
  else typNum=-1; //Error

  var yourType = "";
  yourType += "<html><head><title>Your Red Dwarf Personality Type<\/title>\n";
  if((parseInt(navigator.appVersion)>=4) && (agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) ) {
    yourType += "<LINK REL=STYLESHEET TYPE='text/css' HREF='perstestns.css'>";
  } //end if NS
  else if((parseInt(navigator.appVersion)>=4) && (agt.indexOf('msie') != -1) ) {
    yourType += "<STYLE TYPE='text/css' SRC='perstest.css'><\/STYLE>";
  } //end if IE
  yourType += "\n<\/head>";
  yourType += "<body bgcolor='black' link='cornflowerblue' text='silver' vlink='cornflowerblue'>\n";
  yourType += "<center><span id=title class=title>Your Red Dwarf Personality Type</span><br>\n";
  yourType += "<p id=small class=small><a href=fsperstest.html>Take the Test</a>&nbsp\;&nbsp\;|";
  yourType += "&nbsp\;&nbsp\;";
  yourType += "<a href=types.html>Display All Types</a>&nbsp\;&nbsp\;|&nbsp\;&nbsp\;";
  yourType += "<a href=codes.html>The Codes</a></p></center>\n<p><blockquote><blockquote><p>\n";

  (typNum!=-1) ? yourType += "You are most like " + names3[typNum] + "<p>" + types[typNum] : alert("Either you don't have a personality or there's a problem with this script. \n\nPlease inform the webmaster at dantheman_180@hotmail.com");

  yourType += "\n</blockquote></blockquote><center>\n";
  yourType += "<p id=small class=small><a href=http://reddwarf.iwarp.com/>Red Dwarf Home</a></p>\n";
  yourType += "<p>Personality Test &copy; 2001";

  var date = new Date();
  var d = date.getFullYear();
  if(date.getFullYear() != '2001')
    yourType += "-" + d;
  yourType += " <a href=http://numbatcreations.scriptmania.com/>Numbat Creations</a></p>";
  yourType += "</center></body></html>";
  document.open();
  document.writeln(yourType);
  document.close();
} //end fn showType

function isVal(P, S1, S2, I) {
  var Val1 = "";
  var Val2 = "";
  for(var ii = 1; ii <= I; ii++) {
	   Val1 = P + ii + S1;
	   Val2 = P + ii + S2;
   	if((document.extest[Val1].checked == false) && (document.extest[Val2].checked == false)) {
      return false;
    }
	 }
  return true;
} //end fn isVal

function scoreTest() {
  var E = 0;
  var S = 0;
  var T = 0;
  var J = 0;
  var Type = "";
  var isValid;

  // validation
  (isVal("EI","e","i",6) == false) ? isValid = "f" : isValid = "t";
  (isVal("SN","s","n",6) == false) ? isValid = "f" : isValid = "t";
  (isVal("TF","t","f",6) == false) ? isValid = "f" : isValid = "t";
  (isVal("JP","j","p",6) == false) ? isValid = "f" : isValid = "t";
  if(isValid == "f") {
    alert("You must answer all of the questions!");
    return false;
  }

  E = isTrue("EI1e") + isTrue("EI2e") + isTrue("EI3e") + isTrue("EI4e") + isTrue("EI5e") + isTrue("EI6e");
  S = isTrue("SN1s") + isTrue("SN2s") + isTrue("SN3s") + isTrue("SN4s") + isTrue("SN5s") + isTrue("SN6s");
  T = isTrue("TF1t") + isTrue("TF2t") + isTrue("TF3t") + isTrue("TF4t") + isTrue("TF5t") + isTrue("TF6t");
  J = isTrue("JP1j") + isTrue("JP2j") + isTrue("JP3j") + isTrue("JP4j") + isTrue("JP5j") + isTrue("JP6j");

  (E>3) ? Type = "E" : Type = "I";
  (S>3) ? Type += "S" : Type += "N";
  (T>3) ? Type += "T" : Type += "F";
  (J>3) ? Type += "J" : Type += "P";

  showType(Type,E,S,T,J);
  return false;
} //end fn scoreTest

function resetChecked(FuncName) {
  document.extest[FuncName].checked = false;
} //end fn resetChecked
