//jokestate 0 = joke active, 1 = answer active
var jokestate = 0
var currentjoke = -1

var jokes = new Array(
      "What did the cat say when he lost all his money?"
    , "What is yellow on the outside and grey on the inside?"
    , "What do you get if you cross an elephant and a kangaroo?"
    , "What is grey, beautiful and wears glass slippers?"
	, "Why do mother kangaroos hate rainy days?"
	, "How do snails get their shells so shiny?"
	, "How do hens stay fit?"
	, "What do you get when two giraffes collide?"
	, "What do tigers wear in bed? "
	, "How do you get 4 elephants in a mini?"
	, "What kind of ant is good at maths?"
	, "What is the insect's favourite game?"
	, "How does a bird with a broken wing manage to land safely? "
	, "Why was the camel standing in the corner ignoring his camel pals? "
	, "What do you get if you cross a fish with an elephant?"
	, "Why is the sky so high?"
	, "What do Wildlife animals sing at Christmas?"
	, "Why do elephants have trunks?"
	, "What do you call an elephant in a phone box?"
	, "What brush do you use to groom a rabbit?"
	, "What snake do you find on a car?"
	, "What did the pig say at the beach on a hot summer's day?"
	, "What is the difference between a bird and a fly?"
	, "How do you start a teddy bear race?"
	, "Why do bears have fur coats?"
	, "What do you call an elephant at the North Pole?"
	, "What is a parrot's favourite game?"
	, "Where do the sick bees go?"
	, "Why is a polar bear cheap to have as a pet?"
	, "What is a teddy bear’s favourite pasta?"
	, "What do you call a bee that can't make up his mind?"
	, "What do you get if you cross a monkey with an ocean?"
	, "Where do North Polar bears vote?"
	, "How do elephants talk to each other?"
	, "What is a snake’s favourite subject?"
	, "Why wouldn't the leopard take a bath?"
	, "What do you call a well-dressed lion?"
	, "Why did the leopard go to a cleaner?"
	, "What is green and can jump a mile in a minute?"
	, "What is big, grey and flies straight up?"
	, "Where do cows go on a Saturday night?"
	, "What do cats read in the morning?"
	, "Which animal should you never play cards with?"
	, "What is the difference between an Indian & an African elephant?"
	, "What do you get if you cross a cat with Father Christmas?"
	, "Where do bees go to catch the bus?"
	, "Why do tigers eat raw meat?"
);
  
  var answers = new Array(
      "I'm paw!"
    , "An elephant disguised as a banana!"
    , "Big holes all over Australia!"
    , "Cinderelephant!"
	, "Because the kids have to play indoors."
	, "They use snail varnish."
	, "They eggs-ercise."
	, "A giraffic jam."
	, "Stripy pyjamas!"
	, "2 in the front, 2 in the back."
	, "An account-ant!"
	, "Cricket!"
	, "With its sparrowchute!"
	, "Because he had the hump."
	, "Swimming trunks!"
	, "So birds won't bump their heads"
	, "Jungle bells, jungle bells."
	, "Because they would look silly with suitcases."
	, "Stuck."
	, "A Harebrush."
	, "A Windscreen Viper."
	, "I'm bacon!"
	, "A bird can fly but a fly can't bird."
	, "Ready, teddy, go!"
	, "Because they would look stupid in anoraks!"
	, "Lost!"
	, "Hide and Speak!"
	, "Waspital!"
	, "It lives on ice!"
	, "Tagliateddy!"
	, "A maybee."
	, "A Chimpansea."
	, "The North Pole."
	, "By 'elephone!"
	, "Hissstory."
	, "He didn't want to get spotlessly clean."
	, "A dandy lion (dandelion)."
	, "To have its spots removed!"
	, "A grasshopper with hiccups!"
	, "An elecopter."
	, "To the mooooovies."
	, "Mewspapers."
	, "A cheetah."
	, "About 3000 miles."
	, "Santa claws."
	, "The buzz stop!"
	, "Because they can't cook!"		
);  

    
  
function generateJoke() {
    var jokenumber = Math.random() * jokes.length;
    jokeindex = Math.floor(jokenumber)
	
	if (jokestate == "0") {
		
		if (jokeindex == currentjoke) {
			jokeindex = Math.floor(jokenumber)
			generateJoke()
		} else {
			document.getElementById('jokeoutput').innerHTML = jokes[jokeindex];
			document.getElementById('joketitle').innerHTML = 'Wildlife jokes ... Click to see the answer'
			jokestate = 1
			currentjoke = jokeindex
		}

	} else {
		document.getElementById('jokeoutput').innerHTML = answers[currentjoke];
		document.getElementById('joketitle').innerHTML = 'Wildlife jokes ... Click for a new joke'
		jokestate = 0	
	} 
	

}
