var nameForm;

var girl = new Array("Girl","Angel","Babe","Baby","Chick","Cutie","Daisy","Doll","Fairy","Gal","Girl","Gurl","Kitten","Kitty","Lady","Miss","Queen","Sugar","Sweetie","Tomboy");

var boy = new Array("Boy","Boi","Bro","Bubba","Chief","Daddy","Dude","Duke","Fellow","Guy","Jack","King","Knight","Man","Master","Mister","Mr","Prince");

var all = new Array("Boss","Brat","Buddy","Bug","Bum","Cat","Child","Dog","Freak","Friend","Junior","Kid","Pal","Punk","Star","Teen");

var fire = new Array("Fire","Bold","Energy","Fast","Hot","Jumpy","Peppy","Quick","Speedy","Spicy","Witty","Zesty");

var water = new Array("Water","Aqua","Dark","Deep","Dreamy","Mind","Moody","Moon","Psycho","Quiet","Secret","Shy");

var air = new Array("Air","Bossy","Brave","Charm","Ego","Flip","Flirty","Funny","Puppy","Social","Warm","Wild");

var earth = new Array("Earth","Brain","Cold","Fair","Harsh","Honest","Ideal","Simple","Smarty","Solid","Strong","Think");

var loco = new Array("Animal","Beast","Blast","Comedy","Comic","Crazy","Freak","Fool","Goof","Hoodoo","Howdy","Hype","Hyper","Joker","Local","Loco","Loon","Loony","Nutty","Pants","Salty","Slap","Sneak","Sushi","Voodoo","Wit","Yoyo","Zombie");

var pop = new Array("Best","Better","Big","Black","Blast","Candy","Cash","Cool","Dig","Fab","Fan","Flirt","Giant","Glam","Groovy","Hot","Hype","Live","Metal","Mini","Minx","Nice","Pink","Power","Rock","Rok","Slam","Slinky","Tight","Trip","Vibe");

var skate = new Array("180","360","Action","Ahoy","Air","Aloha","Amp","Beach","Blue","Board","Giant","Hangin","Hodad","Kickin","Mellow","Rad","Rider","Rip","Ripper","Ryder","Salty","Sea","Sick","Sk8","Sk8er","Sky","Snow","Solid","Sport","Surf","Surfer","Wave");

var fantasy = new Array("Beam","Black","Castle","Creep","Dark","Devil","Dragon","Elf","Evil","Fog","Foggy","Giant","Goth","Gray","Ice","Jewel","Light","Mean","Mist","Misty","Mystic","Myth","Planet","Pony","Pure","Sky","Star","Sun","Sword","White");

var alien = new Array("Alpha","Blog","Brain","Bright","Cold","Cyber","Data","Dot","E","Gamma","Geek","Genius","Loner","Mega","Mondo","Mutant","Net","New","Ray","Spider","Spy","Talk","Techno","Test","Time","Uber","Ultra","Wise","Wizard","X","Xray");

var street = new Array("411","Bad","Betta","Big","Bling","Booty","Booyah","Chill","Da","Dawg","Dialed","Fly","Fresh","Funky","Hip","Homie","Hood","Hop","Hott","Ice","Kewl","Nu","Phat","Phatty","Rap","Smooth","Tha","Wack","Yo");





function startNamegame() {
	nameForm = document.getElementById("nameform");
    nameForm.reset();
    document.getElementById("namebutton").onclick = doName;
}


function doName() {
	// concatenate all arrays matching checked boxes
	var hasCheck = false; 
	var nameArray = new Array();
	var allInput = document.getElementsByTagName("input");
		for (var i=0; i<allInput.length; i++) {
			if (allInput[i].checked) {
				nameArray = nameArray.concat(eval(allInput[i].value));
				hasCheck = true;
			}
		}
	// make sure at least one box has been checked
	if (!hasCheck) {
		document.getElementById("yourname").firstChild.nodeValue = "Please answer at least one question!";
		return false;
	}
	// randomly select three words from concatenated array (repeats allowed)
    var randomNum1 = Math.floor((Math.random() * nameArray.length));
    var randomNum2 = Math.floor((Math.random() * nameArray.length));
    var randomNum3 = Math.floor((Math.random() * nameArray.length));
    var thisName = nameArray[randomNum1] + nameArray[randomNum2] + nameArray[randomNum3];
    document.getElementById("yourname").firstChild.nodeValue = thisName;
    nameForm.getElementsByTagName("a")[0].href = "signup.html" + "?" + thisName;
    // change the words on the button, including a custom echo
    var echo = nameArray[randomNum1];
    var buttonArray = new Array("show me another","do i look like a "+echo+"?","you can do better","oh come on now","keep them coming","are you nuts?","please get a life","you must be joking","let's try again","i'll let that slide","i love it...NOT","not quite there","not even close","again, only better","lather, rinse, repeat");
    var randomNum4 = Math.floor((Math.random() * buttonArray.length));
    document.getElementById("namebutton").value = buttonArray[randomNum4];
    return true;
}

