//insideout wales  - How welsh are you quiz (c) Designblender & Gawain Davies 2009

$(document).ready(function(){
			//Set the variables and reset all forms
			curPoints = 0;
			qCounter = 0;			
			for(var i = 1 ; i < 11; i++)
			{
				if($("input[name=q"+i+"]:checked").val()){document.getElementById("question"+i).reset();}
			}			
										
			$(".next").click(function(){				
			    $("#qContainer").animate({"left": "-=800px"}, "normal");					
					if($("input[name=q"+qCounter+"]:checked").val())
					{
						curPoints += parseInt($("input[name=q"+qCounter+"]:checked").val());
						//alert(curPoints + " : " + qCounter);
						qCounter++;
					}	
					else if(!$("input[name=q"+qCounter+"]:checked").val())
					{
						qCounter++;
					}
					
					
					if(qCounter == "11")
					{
						showResults();
					}										
			});		
		 }); //end of ready function
		 	
			function showResults()
			{
				//Create the results text
				if (curPoints == "100"){ 
					title = "<h2>"+curPoints+"% the Red Dragon itself!!!</h2>" ;
					mainImg = '<img src="images/dragon.png" width="150" height="234" title="dragon" />';
					mainPara = "<p>Well done! You're passionately Welsh through and through! There's no doubting where your loyalties lie.</p>";
					ioText = '<h3>Inside Out Match</h3><p><img src="images/Highlights_Welsh_His2.jpg" width="200" height="282" alt="Highlights" class="left" />You probably know it all anyway, but sit back and enjoy this entertaining reminder of your beloved nation\'s past.<br /><a href="http://www.gomer.co.uk/gomer/en/gomer.ViewBook/isbn/1843238500" title="Buy Now">Buy Highlights of Welsh history!</a></p>';					
				}
				
				else if (curPoints > "74" && curPoints < "100")
				{
					title = "<h2>"+curPoints+"% a woolly Welsh sheep</h2>" ;
					mainImg = '<img src="images/sheep-res01.png" width="150" height="143" alt="Sheep" />';
					mainPara = '<p>Not quite 100% but close enough! You\'re proud to be Welsh, even if your Welsh general knowledge isn\'t quite up to scratch!</p>';
					ioText = '<h3>Inside Out Match</h3><p><img src="images/Telling_The_Story_Welsh.jpg" width="200" height="283" alt="Story" class="left" />A brief tour through the history of our native language – an ideal starting point to brush up on your facts! <br /><a href="http://www.gomer.co.uk/gomer/en/gomer.ViewBook/isbn/9781848510494" title="Buy Now">Buy Telling the Story of Welsh!</a></p>';
				}
				
				else if (curPoints > "50" && curPoints < "75")
				{
					title = "<h2>"+curPoints+"% a week old leek</h2>" ;
					mainImg = '<img src="images/leek.png" width="150" height="359" alt="leek" />';
					mainPara = '<p>You\'re well on the way to fully fledged Welshness! Keep up the good work.</p>';
					ioText = '<h3>Inside Out Match</h3><p><img src="images/Great_Welsh_Festivals.jpg" width="200" height="282" alt="Festivals" style="float:left;" />This guide will get you out and about to experience the true taste of Wales at a host of entertaining events. Guaranteed to up your Welshness levels! <br /><a href="http://www.gomer.co.uk/gomer/en/gomer.ViewBook/isbn/1843238519" title="Buy Now">Buy Great Welsh Festivals</a></p>';
				}
				
				else if (curPoints > "24" && curPoints < "50")
				{
					title = "<h2>"+curPoints+"% a wilted daffodil</h2>" ;
					mainImg = '<img src="images/wilted_daff.png" width="150" height="216" alt="daffodil" />';
					mainPara = '<p>Could do better. Your Welshness needs some work!</p>';
					ioText = '<h3>Inside Out Match</h3><p><img src="images/Welsh_Icons.jpg" width="200" height="282" alt="Icons" style="float:left;" />Let\'s start with the basics! This guide to the iconic symbols of Wales and Welsh life will put you on the right track. <br /><a href="http://www.gomer.co.uk/gomer/en/gomer.ViewBook/isbn/1843237873" title="Buy Now">Buy Welsh Icons</a></p>';
				}
				
				else if (curPoints > "-1" && curPoints < "25")
				{
					title = "<h2>"+curPoints+"% the Prince of Wales</h2>" ;
					mainImg = '<img src="images/charles.png" width="150" height="169" alt="Charles" />';
					mainPara = '<p>Oh dear, there must be a tiny bit of Welshness in there somewhere, all you need is something to tease it out...</p>';
					ioText = '<h3>Inside Out Match</h3><p><img src="images/Welsh_Traditions2.jpg" width="200" height="282" alt="Traditions" style="float:left;" />Let\'s start right at the beginning. A comprehensive yet brief guide to all things uniquely Welsh, this is the book to start teasing out your inner Welshness.<br /><a href="http://www.gomer.co.uk/gomer/en/gomer.ViewBook/isbn/1843237679" title="Buy Now">Buy Welsh Traditions and Traits</a></p>';
				}
				
				tryAgain = '<a href="javascript:window.location.reload()" title="Try again!"><img src="images/reset_button.png" width="150" height="40" /></a>';
				rLayout = '<div class="rLeft">'+mainImg+'</div><div class="rRight">'+title+mainPara+ioText+tryAgain+'</div>';
				
				$("div#results").replaceWith(rLayout);
			}