var petNames = new Array();
petNames["HM001"]="Frog";
petNames["HM002"]="Pig";
petNames["HM003"]="Cow";
petNames["HM004"]="Black Bear";
petNames["HM006"]="Lion";
petNames["HM007"]="Elephant";
petNames["HM008"]="Monkey";
petNames["HM009"]="Hippo";
petNames["HM010"]="Golden Retriever";
petNames["HM011"]="Cocker Spaniel";
petNames["HM012"]="St. Bernard";
petNames["HM013"]="Basset Hound";
petNames["HM014"]="Poodle";
petNames["HM015"]="Grey Cat";
petNames["HM016"]="Black & White Cat";
petNames["HM017"]="Orange Cat";
petNames["HM021"]="Googles";
petNames["HM023"]="Seal";
petNames["HM031"]="Leopard";
petNames["HM032"]="Tiger";
petNames["HM040"]="Gorilla";
petNames["HM042"]="Striped Alley Cat";
petNames["HM068"]="Pegasus";
petNames["HM069"]="Unicorn";
petNames["HM070"]="Yorkie";
petNames["HM078"]="Rabbit";
petNames["HM080"]="Cheeky Monkey";
petNames["HM103"]="Horse";
petNames["HM104"]="Chihuahua";
petNames["HM105"]="Pug";
petNames["HM106"]="White Terrier";
petNames["HM107"]="Pink Poodle";
petNames["HM109"]="Tree Frog";
petNames["HM110"]="White Persian";
petNames["HM111"]="Panda";
petNames["HM113"]="Koala";
petNames["HM114"]="Bull Frog";
petNames["HM116"]="Polar Bear";
petNames["HM117"]="Pink Pony";
petNames["HM120"]="Husky";
petNames["HM123"]="Dalmatian";
petNames["HM126"]="Bull Dog";
petNames["HM131"]="Love Puppy";
petNames["HM134"]="Sherbet Bunny";
petNames["HM135"]="Black Cat";
petNames["HM136"]="Black Lab";
petNames["HM138"]="Chocolate Lab";
petNames["HM139"]="Clydesdale";
petNames["HM141"]="Beagle";
petNames["HM142"]="Spotted Frog";
petNames["HM143"]="Raccoon";
petNames["HM145"]="Black Friesian";
petNames["HM146"]="German Shepherd";
// davidt added these new pets
petNames["HM137"]="Reindeer";
petNames["HM149"]="Collie";
petNames["HM152"]="Charcoal Cat";
petNames["HM153"]="Yellow Lab";
petNames["HM101"]="Brown Arabian";
petNames["HM150"]="Turtle";
petNames["HM144"]="Love Frog";
petNames["HM147"]="Pinto";
petNames["HM132"]="Penguin";
petNames["HM148"]="Duck";
petNames["HM162"]="Tie Dye Frog";
petNames["HM191"]="Black Poodle";
petNames["HM167"]="Velvety Elephant";
petNames["HM098"]="Grey Arabian";
petNames["HM192"]="Black and White Cheeky Dog";
petNames["HM189"]="Pink and White Cat";
petNames["HM180"]="Kangaroo";
petNames["HM165"]="Himalayan"; 
petNames["HM159"]="Schnauzer";
// Michael Szutu new pets added
petNames["HM154"]="Tiger Snake";
petNames["HM166"]="Bengal Tiger"; 
petNames["HM195"]="Brown Dog";
petNames["HM198"]="Leopard Lizard";
petNames["HM202"]="American Cocker";
petNames["HM205"]="Chicken";


var clothingNames = new Array();
clothingNames["WE000052"]="Blue Ball Cap";
clothingNames["WE000053"]="Dude Cap";
clothingNames["WE000054"]="Khaki Cargo Pants";
clothingNames["WE000055"]="Camo Cargo Pants";
clothingNames["WE000056"]="Cuffed Jeans";
clothingNames["WE000057"]="Maroon Hoody";
clothingNames["WE000058"]="Bubble Vest";
clothingNames["WE000059"]="Blue & Pink Striped Polo Shirt";
clothingNames["WE000060"]="Wheel of Wow Tee";
clothingNames["WE000061"]="Layered Tee";
clothingNames["WE000062"]="Cute Cropped Jacket";
clothingNames["WE000063"]="Yellow Raincoat & Hat";
clothingNames["WE000064"]="Polka Dot PJ Top";
clothingNames["WE000065"]="Polka Dot PJ Bottom";
clothingNames["WE000066"]="Pink Baggy Jeans";
clothingNames["WE000067"]="Red Football Jersey";
clothingNames["WE000068"]="Red Sport Pants";
clothingNames["WE000069"]="Pink & Purple Fleece Top";
clothingNames["WE000070"]="Webkinz Pet Coat";
clothingNames["WE000071"]="Love Diva Pet Coat";
clothingNames["WE000072"]="Hand Knit Sweater";
clothingNames["WE000073"]="Leopard Tank";
clothingNames["WE000074"]="Cute Blouse";
clothingNames["WE000075"]="Shorts";
clothingNames["WE000076"]="Angel Dress w/Wings";
clothingNames["WE000077"]="Ballerina Costume";
clothingNames["WE000078"]="Terry Robe";
clothingNames["WE000079"]="Jean Jacket";
clothingNames["WE000080"]="Pink Knit Capelet";
clothingNames["WE000081"]="Polka Dot Hoody";
clothingNames["WE000082"]="Pink Striped Polo";
clothingNames["WE000083"]="Blue Floral Dress";
clothingNames["WE000084"]="Pumpkin Costume";
clothingNames["WE000085"]="Camo Tank Top";
clothingNames["WE000086"]="Rhinestone Jeans";
clothingNames["WE000087"]="Witch Costume";
clothingNames["WE000292"]="Santa Outfit";
// Michael Szutu added new clothing
clothingNames["WE000297"]="Chalk Flower Top";
clothingNames["WE000298"]="Smocked Sundress";
clothingNames["WE000299"]="Big Funky Hat";
clothingNames["WE000300"]="Swimming Trunks";
clothingNames["WE000301"]="Wildflower Swimsuit";
clothingNames["WE000302"]="Smart Sweater Vest";
clothingNames["WE000303"]="Turquoise Blouse";
clothingNames["WE000304"]="Blue Football Jersey";
clothingNames["WE000305"]="Stone Wash Jeans";
clothingNames["WE000306"]="Brown Cards";
clothingNames["WE000307"]="Star Fly Pants";
clothingNames["WE000308"]="Tuxedo";
clothingNames["WE000309"]="Warm up Set";
clothingNames["WE000310"]="Candy Capri Set";
clothingNames["WE000311"]="Webkinz Hoody";
clothingNames["WE000312"]="Cherry Tank";
clothingNames["WE000313"]="Cupcake Tee w/Skirt";
clothingNames["WE000314"]="Lilac Sparkle Party Dress";
clothingNames["WE000315"]="Cheerleader Outfit";
clothingNames["WE000316"]="Basketball Outfit";
clothingNames["WE000317"]="Gathered Top and Pant Set";
clothingNames["WE000318"]="Kaleidoscope Skirt Set";
clothingNames["WE000319"]="Pink Poodle PJ Set";
clothingNames["WE000320"]="Wedding Dress";

var clothingExceptions = new Array();

clothingExceptions["WE000052"] = new Object();
clothingExceptions["WE000052"].dontfit = new Array("HM001","HM109","HM114","HM142");

clothingExceptions["WE000053"] = new Object();
clothingExceptions["WE000053"].dontfit = new Array("HM001","HM109","HM114","HM142");
clothingExceptions["WE000053"].loose = new Array("HM068");

clothingExceptions["WE000054"] = new Object();
clothingExceptions["WE000054"].dontfit = new Array("HM021","HM078","HM110","HM134","HM142");
clothingExceptions["WE000054"].loose = new Array("HM068","HM070");

clothingExceptions["WE000055"] = new Object();
clothingExceptions["WE000055"].dontfit = new Array("HM021","HM078","HM110","HM134","HM142");
clothingExceptions["WE000055"].loose = new Array("HM068","HM070");

clothingExceptions["WE000056"] = new Object();
clothingExceptions["WE000056"].dontfit = new Array("HM021","HM078","HM109","HM110","HM134","HM142");

clothingExceptions["WE000057"] = new Object();
clothingExceptions["WE000057"].dontfit = new Array("HM021","HM110");
clothingExceptions["WE000057"].loose = new Array("HM068");
clothingExceptions["WE000057"].tight = new Array("HM139");

clothingExceptions["WE000058"] = new Object();
clothingExceptions["WE000058"].dontfit = new Array("HM021","HM070","HM114","HM126","HM139");
clothingExceptions["WE000058"].tight = new Array("HM040","HM142");

clothingExceptions["WE000059"] = new Object();
clothingExceptions["WE000059"].dontfit = new Array("HM021","HM110","HM114");
clothingExceptions["WE000059"].tight = new Array("HM126","HM142");

clothingExceptions["WE000060"] = new Object();
clothingExceptions["WE000060"].dontfit = new Array("HM001","HM021","HM109","HM110","HM114","HM126","HM142");
clothingExceptions["WE000060"].tight = new Array("HM002","HM003","HM007","HM009","HM040","HM116");

clothingExceptions["WE000061"] = new Object();
clothingExceptions["WE000061"].dontfit = new Array("HM021","HM110","HM114");
clothingExceptions["WE000061"].tight = new Array("HM070","HM126","HM139","HM142");

clothingExceptions["WE000062"] = new Object();
clothingExceptions["WE000062"].dontfit = new Array("HM001","HM021","HM040","HM070","HM109","HM110","HM114","HM126","HM142");
clothingExceptions["WE000062"].tight = new Array("HM002","HM003","HM007","HM009","HM116","HM139");

clothingExceptions["WE000063"] = new Object();
clothingExceptions["WE000063"].dontfit = new Array("HM021","HM069","HM070","HM103","HM114","HM117","HM142","HM145");
clothingExceptions["WE000063"].tight = new Array("HM040","HM110","HM126","HM139");

clothingExceptions["WE000064"] = new Object();
clothingExceptions["WE000064"].dontfit = new Array("HM021","HM114");
clothingExceptions["WE000064"].loose = new Array("HM068");

clothingExceptions["WE000065"] = new Object();
clothingExceptions["WE000065"].dontfit = new Array("HM021","HM110");
clothingExceptions["WE000065"].loose = new Array("HM068");
clothingExceptions["WE000065"].tight = new Array("HM142");

clothingExceptions["WE000066"] = new Object();
clothingExceptions["WE000066"].dontfit = new Array("HM021","HM078","HM110","HM134","HM142");
clothingExceptions["WE000066"].loose = new Array("HM068","HM070");

clothingExceptions["WE000067"] = new Object();
clothingExceptions["WE000067"].dontfit = new Array("HM021");
clothingExceptions["WE000067"].tight = new Array("HM070","HM110","HM114","HM126","HM142");

clothingExceptions["WE000068"] = new Object();
clothingExceptions["WE000068"].dontfit = new Array("HM021","HM078","HM110","HM134");
clothingExceptions["WE000068"].tight = new Array("HM142");

clothingExceptions["WE000069"] = new Object();
clothingExceptions["WE000069"].dontfit = new Array("HM002","HM003","HM007","HM009","HM021","HM070","HM110","HM114","HM116","HM139");
clothingExceptions["WE000069"].tight = new Array("HM006","HM078","HM126","HM142");

clothingExceptions["WE000070"] = new Object();
clothingExceptions["WE000070"].dontfit = new Array("HM021","HM040","HM114");
clothingExceptions["WE000070"].tight = new Array("HM126","HM142");

clothingExceptions["WE000071"] = new Object();
clothingExceptions["WE000071"].dontfit = new Array("HM021","HM040","HM114");
clothingExceptions["WE000071"].tight = new Array("HM126","HM142");

clothingExceptions["WE000072"] = new Object();
clothingExceptions["WE000072"].dontfit = new Array("HM021","HM040");

clothingExceptions["WE000073"] = new Object();
clothingExceptions["WE000073"].dontfit = new Array("HM021","HM114","HM142");
clothingExceptions["WE000073"].tight = new Array("HM040","HM126","HM139");

clothingExceptions["WE000074"] = new Object();
clothingExceptions["WE000074"].dontfit = new Array("HM021","HM069","HM103","HM114","HM117","HM126","HM139","HM145");
clothingExceptions["WE000074"].tight = new Array("HM142");

clothingExceptions["WE000075"] = new Object();
clothingExceptions["WE000075"].dontfit = new Array("HM021","HM069","HM078","HM103","HM110","HM117","HM120","HM134","HM145");
clothingExceptions["WE000075"].tight = new Array("HM139");

clothingExceptions["WE000076"] = new Object();
clothingExceptions["WE000076"].dontfit = new Array("HM021","HM040","HM070","HM104","HM109","HM110","HM114","HM126","HM142");

clothingExceptions["WE000077"] = new Object();
clothingExceptions["WE000077"].dontfit = new Array("HM021","HM069","HM070","HM103","HM109","HM110","HM114","HM117","HM126","HM134","HM139","HM142","HM145");
clothingExceptions["WE000077"].tight = new Array("HM002","HM003","HM006","HM007","HM009","HM078","HM116");

clothingExceptions["WE000078"] = new Object();
clothingExceptions["WE000078"].dontfit = new Array("HM021");
clothingExceptions["WE000078"].tight = new Array("HM114");

clothingExceptions["WE000079"] = new Object();
clothingExceptions["WE000079"].dontfit = new Array("HM002","HM003","HM007","HM009","HM021","HM070","HM109","HM114","HM116","HM126","HM139","HM142");
clothingExceptions["WE000079"].tight = new Array("HM006","HM110");


clothingExceptions["WE000081"] = new Object();
clothingExceptions["WE000081"].dontfit = new Array("HM021","HM110");
clothingExceptions["WE000081"].loose = new Array("HM068");
clothingExceptions["WE000081"].tight = new Array("HM139");

clothingExceptions["WE000082"] = new Object();
clothingExceptions["WE000082"].dontfit = new Array("HM021","HM110","HM114");
clothingExceptions["WE000082"].tight = new Array("HM126","HM142");

clothingExceptions["WE000083"] = new Object();
clothingExceptions["WE000083"].dontfit = new Array("HM021","HM110","HM114");
clothingExceptions["WE000083"].tight = new Array("HM070","HM126","HM142");

clothingExceptions["WE000084"] = new Object();
clothingExceptions["WE000084"].dontfit = new Array("HM021","HM040","HM068","HM070","HM109","HM114","HM126","HM139","HM142");
clothingExceptions["WE000084"].tight = new Array("HM002","HM003","HM007","HM009","HM069","HM103","HM110","HM116","HM117","HM145");

clothingExceptions["WE000085"] = new Object();
clothingExceptions["WE000085"].dontfit = new Array("HM021","HM114");
clothingExceptions["WE000085"].tight = new Array("HM126","HM142");

clothingExceptions["WE000086"] = new Object();
clothingExceptions["WE000086"].dontfit = new Array("HM021","HM078","HM109","HM110","HM134","HM142");

clothingExceptions["WE000087"] = new Object();
clothingExceptions["WE000087"].dontfit = new Array("HM021","HM114");
clothingExceptions["WE000087"].loose = new Array("HM068");
clothingExceptions["WE000087"].tight = new Array("HM126","HM142");

clothingExceptions["WE000292"] = new Object();
clothingExceptions["WE000292"].dontfit = new Array("HM021","HM070","HM110","HM114","HM134");
clothingExceptions["WE000292"].tight = new Array("HM126","HM142");

clothingExceptions["WE000297"] = new Object();
clothingExceptions["WE000297"].dontfit = new Array("HM021", "HM132", "HM148", "HM150", "HM154");
clothingExceptions["WE000297"].tight = new Array("HM040", "HM070", "HM110", "HM126", "HM142", "HM144", "HM149", "HM165");

// Add new exceptions - Michael Szutu

clothingExceptions["WE000298"] = new Object();
clothingExceptions["WE000298"].dontfit = new Array("HM021", "HM150");

clothingExceptions["WE000299"] = new Object();
clothingExceptions["WE000299"].dontfit = new Array("HM150", "HM154");
clothingExceptions["WE000299"].loose = new Array("HM002", "HM003", "HM007", "HM009", "HM012", "HM013", "HM021", "HM023", "HM068", "HM069", "HM098", "HM101", "HM103", "HM106", "HM117", "HM137", "HM139", "HM145", "HM147", "HM198", "HM205");

clothingExceptions["WE000300"] = new Object();
clothingExceptions["WE000300"].dontfit = new Array("HM021", "HM023", "HM070", "HM078", "HM110", "HM132", "HM134", "HM144", "HM148", "HM150", "HM154", "HM165", "HM180", "HM198", "HM205");
clothingExceptions["WE000300"].tight = new Array("HM069", "HM098", "HM101", "HM103", "HM117", "HM139", "HM145", "HM147");

clothingExceptions["WE000301"] = new Object();
clothingExceptions["WE000301"].dontfit = new Array("HM021", "HM023", "HM110", "HM114", "HM132", "HM134", "HM144", "HM148", "HM150", "HM154", "HM165", "HM180", "HM198", "HM205");
clothingExceptions["WE000301"].tight = new Array("HM040", "HM070", "HM078", "HM126", "HM142", "HM149");

clothingExceptions["WE000302"] = new Object();
clothingExceptions["WE000302"].dontfit = new Array("HM021", "HM023", "HM114", "HM126", "HM132", "HM142", "HM148", "HM150", "HM154");
clothingExceptions["WE000302"].tight = new Array("HM144");

clothingExceptions["WE000303"] = new Object();
clothingExceptions["WE000303"].dontfit = new Array("HM021", "HM150", "HM154"); 
clothingExceptions["WE000303"].tight = new Array("HM126", "HM132", "HM142", "HM144", "HM148");

clothingExceptions["WE000304"] = new Object();
clothingExceptions["WE000304"].dontfit = new Array("HM021", "HM110", "HM114", "HM126", "HM132", "HM142", "HM144", "HM149", "HM148", "HM150", "HM154", "HM165");
clothingExceptions["WE000304"].tight = new Array("HM040");

clothingExceptions["WE000305"] = new Object();
clothingExceptions["WE000305"].dontfit = new Array("HM021", "HM023", "HM078", "HM110", "HM132", "HM134", "HM144", "HM148", "HM150", "HM154", "HM165", "HM180", "HM198", "HM205");
clothingExceptions["WE000305"].tight = new Array("HM068", "HM120", "HM142", "HM149");

clothingExceptions["WE000306"] = new Object();
clothingExceptions["WE000306"].dontfit = new Array("HM021", "HM023", "HM078", "HM110", "HM114", "HM132", "HM134", "HM142", "HM144", "HM149", "HM148", "HM150", "HM154", "HM165", "HM180", "HM198", "HM205");

clothingExceptions["WE000307"] = new Object();
clothingExceptions["WE000307"].dontfit = new Array("HM021", "HM023", "HM078", "HM110", "HM132", "HM134", "HM144", "HM148", "HM150", "HM154", "HM165", "HM180", "HM198", "HM205");
clothingExceptions["WE000307"].tight = new Array("HM142", "HM149");

clothingExceptions["WE000308"] = new Object();
clothingExceptions["WE000308"].dontfit = new Array("HM021", "HM023", "HM078", "HM110", "HM114", "HM132", "HM134", "HM143", "HM144", "HM148", "HM150", "HM154", "HM165", "HM180", "HM198", "HM205");
clothingExceptions["WE000308"].tight = new Array("HM069", "HM116", "HM126", "HM139", "HM142", "HM145", "HM147", "HM149", "HM120", "HM117", "HM103", "HM098", "HM101");

clothingExceptions["WE000309"] = new Object();
clothingExceptions["WE000309"].dontfit = new Array("HM021", "HM023", "HM078", "HM110", "HM132", "HM134", "HM144", "HM148", "HM150", "HM154", "HM165", "HM180", "HM198", "HM205");
clothingExceptions["WE000309"].tight = new Array("HM114", "HM126", "HM142");

clothingExceptions["WE000310"] = new Object();
clothingExceptions["WE000310"].dontfit = new Array("HM021", "HM023", "HM078", "HM126", "HM132", "HM134", "HM144", "HM148", "HM150", "HM154", "HM180", "HM198", "HM205", "HM110");
clothingExceptions["WE000310"].tight = new Array("HM068", "HM114", "HM142", "HM149");

clothingExceptions["WE000311"] = new Object();
clothingExceptions["WE000311"].dontfit = new Array("HM021", "HM150", "HM154");
clothingExceptions["WE000311"].tight = new Array("HM132", "HM144", "HM148");

clothingExceptions["WE000312"] = new Object();
clothingExceptions["WE000312"].dontfit = new Array("HM021", "HM150", "HM154");
clothingExceptions["WE000312"].tight = new Array("HM114", "HM126", "HM132", "HM142", "HM144", "HM148");

clothingExceptions["WE000313"] = new Object();
clothingExceptions["WE000313"].dontfit = new Array("HM021", "HM150", "HM154");
clothingExceptions["WE000313"].tight = new Array("HM114", "HM126", "HM132", "HM142", "HM144", "HM148", "HM180", "HM205");

clothingExceptions["WE000314"] = new Object();
clothingExceptions["WE000314"].dontfit = new Array("HM021", "HM040", "HM110", "HM114", "HM126", "HM132", "HM142", "HM144", "HM149", "HM148", "HM150", "HM154", "HM165");
clothingExceptions["WE000314"].tight = new Array("HM113", "HM116");

clothingExceptions["WE000315"] = new Object();
clothingExceptions["WE000315"].dontfit = new Array("HM021", "HM126", "HM132", "HM144", "HM148", "HM150", "HM154", "HM180", "HM205");
clothingExceptions["WE000315"].tight = new Array("HM114", "HM142", "HM149");

clothingExceptions["WE000316"] = new Object();
clothingExceptions["WE000316"].dontfit = new Array("HM021", "HM023", "HM078", "HM110", "HM132", "HM134", "HM142", "HM144", "HM148", "HM150", "HM154", "HM165", "HM180", "HM198", "HM205");
clothingExceptions["WE000316"].tight = new Array("HM126");

clothingExceptions["WE000317"] = new Object();
clothingExceptions["WE000317"].dontfit = new Array("HM021", "HM023", "HM069", "HM070", "HM078", "HM098", "HM101", "HM103", "HM110", "HM117", "HM126", "HM132", "HM134", "HM139", "HM144", "HM145", "HM147", "HM148", "HM150", "HM154", "HM165", "HM180", "HM198", "HM205");
clothingExceptions["WE000317"].loose = new Array("HM068");

clothingExceptions["WE000318"] = new Object();
clothingExceptions["WE000318"].dontfit = new Array("HM021", "HM132", "HM144", "HM148", "HM150", "HM154", "HM180", "HM205");
clothingExceptions["WE000318"].tight = new Array("HM114", "HM126", "HM142", "HM149");

clothingExceptions["WE000319"] = new Object();
clothingExceptions["WE000319"].dontfit = new Array("HM021", "HM023", "HM078", "HM114", "HM132", "HM134", "HM144", "HM148", "HM150", "HM154", "HM180", "HM198", "HM205");
clothingExceptions["WE000319"].tight = new Array("HM126", "HM142", "HM149");

clothingExceptions["WE000320"] = new Object();
clothingExceptions["WE000320"].dontfit = new Array("HM021", "HM126", "HM150", "HM154");
clothingExceptions["WE000320"].tight = new Array("HM114", "HM142", "HM144");
clothingExceptions["WE000320"].loose = new Array("HM137");

function initClothingTool() {
	initPetMenu();
	initClothingMenu();
	openAnchor();
}

function openAnchor() {
	var pageURL = document.URL;
	
	var anchorPos = pageURL.indexOf('#')
	
	if (anchorPos > -1) {
		var anchorName = pageURL.substr(anchorPos+1);
		
		if (anchorName.length == 5) { //if we have a pet code
			setMenu("petMenu", anchorName);
		} else if (anchorName.length == 8) { //if we have a clothing code
			setMenu("clothingMenu", anchorName);
		}
		
		
	}
}

function setMenu(givenMenu, givenCode) {
	var menu = document.getElementById(givenMenu);
	
	for (var i=1; i <= menu.length; i++) {
		if (menu.options[i].value == givenCode) {
			menu.selectedIndex = i;
			if (givenMenu == "petMenu") {
				beforePetSelected();
			} else if (givenMenu == "clothingMenu") {
				beforeClothingSelected();
			}
			break;
		}
	}
	
}

function initClothingMenu() {
	var menu = document.getElementById("clothingMenu");
	var sortedClothing = new Array();
	var sortCount = 0;
	
	menu.innerHTML = "";
	
	for (var i in clothingNames) {
		if (typeof(clothingNames[i]) != "function") {
			sortedClothing[sortCount++] = clothingNames[i] + i;
		}
	}
	
	sortedClothing.sort();
	
	addMenuItem(menu, "Choose a clothing item...", 0, true);

	for (var i = 0; i < sortedClothing.length; i++) {
		
		addMenuItem(menu, sortedClothing[i].substring(0,sortedClothing[i].length-8), sortedClothing[i].substring(sortedClothing[i].length-8,sortedClothing[i].length), false);
		
	}
	
	menu.selectedIndex = 0;
	
	/*
	for (var i in clothingNames) {
		if (typeof(clothingNames[i]) != "function") {
			var opt = document.createElement('option');
			opt.text = clothingNames[i];
			opt.value = i;
			
			try {
				menu.add(opt, null);
			} catch(ex) {
				menu.add(opt);
			}
		}
	}*/
	
	
	menu.disabled = false;
	
	//beforeClothingSelected();
}

function initPetMenu() {
	var menu = document.getElementById("petMenu");
	var sortedPets = new Array();
	var sortCount = 0;
	
	menu.innerHTML = "";
	
	for (var i in petNames) {
		if (typeof(petNames[i]) != "function") {
			sortedPets[sortCount++] = petNames[i] + i;
		}
	}
	
	sortedPets.sort();
	
	addMenuItem(menu, "Choose a pet...", 0, true);
	
	for (var i = 0; i < sortedPets.length; i++) {
		addMenuItem(menu, sortedPets[i].substring(0,sortedPets[i].length-5), sortedPets[i].substring(sortedPets[i].length-5,sortedPets[i].length), false);
	}
	
	menu.selectedIndex = 0;
	
	menu.disabled = false;
	
}

function beforePetSelected() {
	document.getElementById("clothingMenu").selectedIndex = 0;
	
	new Effect.Fade('fitsPets', {duration: 0.1});
	new Effect.Fade('listLoose', {duration: 0.1});
	new Effect.Fade('listTight', {duration: 0.1});
	new Effect.Fade('listDontFit', {duration: 0.1, afterFinish: petSelected});

	//petSelected();
}

function beforeClothingSelected() {
	document.getElementById("petMenu").selectedIndex = 0;
	
	new Effect.Fade('listLoose', {duration: 0.1});
	new Effect.Fade('listTight', {duration: 0.1});
	new Effect.Fade('listDontFit', {duration: 0.1, afterFinish: clothingSelected});
	
}

function clothingSelected() {
	var menu = document.getElementById("clothingMenu");
	var fitsPets = document.getElementById("fitsPets");
	var listLoose = document.getElementById("listLoose");
	var listTight = document.getElementById("listTight");
	var listDontFit = document.getElementById("listDontFit");
	var clothingCode = menu.options[menu.selectedIndex].value;
	
	var errLoose = null;
	var errTight = null;
	var errDontFit = null;
	
	listLoose.innerHTML = listTight.innerHTML = listDontFit.innerHTML = "";
	
	//listLoose.style.display = listTight.style.display = listDontFit.style.display = "none";
	
	try {
		if (clothingExceptions[clothingCode].loose) {
			listLoose.innerHTML = outputPetList(clothingExceptions[clothingCode].loose, "Loose Fitting", "loose");
			//listLoose.style.display = "block";
			new Effect.Appear('listLoose', {duration: 0.2});
		}
	} catch(errLoose) {
		listLoose.innerHTML = "";
	}
	
	try {
		if (clothingExceptions[clothingCode].tight) {
			listTight.innerHTML = outputPetList(clothingExceptions[clothingCode].tight, "Tight Fitting", "tight");
			//listTight.style.display = "block";
			new Effect.Appear('listTight', {duration: 0.2});
		}
	} catch(errTight) {
		listTight.innerHTML = "";
	}
	
	try {
		if (clothingExceptions[clothingCode].dontfit) {
			listDontFit.innerHTML = outputPetList(clothingExceptions[clothingCode].dontfit, "Doesn't Fit", "dontfit");
			//listDontFit.style.display = "block";
			new Effect.Appear('listDontFit', {duration: 0.2});
		}
	} catch(errDontFit) {
		listDontFit.innerHTML = "";
	}
	
	if (listLoose.innerHTML == "" && listTight.innerHTML == "" && listDontFit.innerHTML == "") {
		
		//var fitMsg = clothingNames[clothingCode];
		
		if (clothingNames[clothingCode] != null)
		{
			var fitMsg = '<div class="petList fits"><div class="title">' + "Fits all pets!" + '</div>';
		}
		else
		{
			var fitMsg = '';
		}
	} else {
		var fitMsg = '<div class="petList fits"><div class="title">' + "Fits most pets, with the following exceptions:" + '</div>';
	}
	
	fitsPets.innerHTML = fitMsg;
	
	
	//clothingNames.sort();
	//fitsPets.innerHTML += clothingNames.length;
	
	//document.write();
	//menu.disabled = false;
	//menu.focus();

	//listLoose.style.display = listTight.style.display = listDontFit.style.display = "block";
	
	//afterClothingSelected();
}

function petSelected() {
	var menu = document.getElementById("petMenu");
	var fitsPets = document.getElementById("fitsPets");
	var listLoose = document.getElementById("listLoose");
	var listTight = document.getElementById("listTight");
	var listDontFit = document.getElementById("listDontFit");
	var petCode = menu.options[menu.selectedIndex].value;
	
	var errLoose = null;
	var errTight = null;
	var errDontFit = null;
	


	fitsPets.innerHTML = listLoose.innerHTML = listTight.innerHTML = listDontFit.innerHTML = "";
	
	var arrFits = new Array();
	var arrLoose = new Array();
	var arrTight = new Array();
	var arrDontFit = new Array();
	
	for (var clothingCode in clothingExceptions) { //for every clothing exception
		if (typeof(clothingExceptions[clothingCode]) != "function") { //if it's an actual value
			if(clothingExceptions[clothingCode].dontfit) { //and it has don't fit values
				for (var i in clothingExceptions[clothingCode].dontfit) { //go through each pet code
					if (clothingExceptions[clothingCode].dontfit[i] == petCode) {;
						arrDontFit[clothingCode] = clothingNames[clothingCode];
					}
				}
			}
		}
	}
	
	for (var clothingCode in clothingExceptions) { //for every clothing exception
		if (typeof(clothingExceptions[clothingCode]) != "function") { //if it's an actual value
			if(clothingExceptions[clothingCode].loose) { //and it has don't fit values
				for (var i in clothingExceptions[clothingCode].loose) { //go through each pet code
					if (clothingExceptions[clothingCode].loose[i] == petCode) {;
						arrLoose[clothingCode] = clothingNames[clothingCode];
					}
				}
			}
		}
	}
	
		for (var clothingCode in clothingExceptions) { //for every clothing exception
		if (typeof(clothingExceptions[clothingCode]) != "function") { //if it's an actual value
			if(clothingExceptions[clothingCode].tight) { //and it has don't fit values
				for (var i in clothingExceptions[clothingCode].tight) { //go through each pet code
					if (clothingExceptions[clothingCode].tight[i] == petCode) {;
						arrTight[clothingCode] = clothingNames[clothingCode];
					}
				}
			}
		}
	}


	
	for (var clothingCode in clothingNames) {
		if (typeof(clothingNames[clothingCode]) != "function" && !arrTight[clothingCode] && !arrLoose[clothingCode] && !arrDontFit[clothingCode]) {
			arrFits[clothingCode] = clothingNames[clothingCode];
		}
	}
	
	var fitCount = 0;
	var dontfitCount = 0;
	
	if (petNames[petCode] != null)
	{
		var outFits = outputClothingList(arrFits, "These clothing items fit the " + petNames[petCode] , "fits");
		var	outLoose = outputClothingList(arrLoose, "The " + petNames[petCode] + " fits loosely in these items: ", "loose");
		var outTight = outputClothingList(arrTight, "The " + petNames[petCode] + " fits tightly in these items: ", "tight");
		var outDontFit = outputClothingList(arrDontFit, "Clothing items that <em>do not</em> fit the " + petNames[petCode] + ":" , "dontfit");
	
	if (outFits) {
		fitsPets.innerHTML += outFits;
		new Effect.Appear('fitsPets', {duration: 0.2});
	}
	
	if (outLoose) {
		listLoose.innerHTML += outLoose;
		new Effect.Appear('listLoose', {duration: 0.2});
	}
	
	if (outTight) {
		listTight.innerHTML += outTight;
		new Effect.Appear('listTight', {duration: 0.2});
	}
	
	if (outDontFit) {
		listDontFit.innerHTML += outDontFit;
		new Effect.Appear('listDontFit', {duration: 0.2});
	}
	
	}
	
	



}

function addMenuItem(givenMenu, givenText, givenValue, givenDisabled) {
	var opt = document.createElement('option');
	opt.text = givenText;
	opt.value = givenValue;
	opt.disabled = givenDisabled;
	
	try {
		givenMenu.add(opt, null);
	} catch(ex) {
		givenMenu.add(opt);
	}
}


function afterClothingSelected() {
	
	//alert("afterClothingSelected");
}

function outputPetList(givenList, givenLabel, givenClass) {
	var out = '<div class="petList ' + givenClass + '"><div class="title">' + givenLabel + '</div>';
	
	for (var i in givenList) {
		if (typeof(givenList[i]) != "function") {
			out += "<div>" + givenList[i] + " - " + petNames[givenList[i]] + "</div>"
		}
	}
	
	out += "</div>";
	
	return out;
}

function outputClothingList(givenList, givenLabel, givenClass) {
	var out = "";
	var count = 0;
	
	for (var i in givenList) {
		if (typeof(givenList[i]) != "function") {
			out += "<div>" + i + " - " + givenList[i] + "</div>"
			count++;
		}
	}
	
	if (count > 0) {
		out = '<div class="petList ' + givenClass + '"><div class="title">' + givenLabel + '</div>' + out + '</div>'
	}
		
	return out;
}

