var sq_answers = new Array();

var sq_cur, sq_i;



 for (sq_i = 0; sq_i < 10; sq_i++)

  sq_answers[sq_i] = "b";

 sq_cur = 0;



function sq_whichgreatest(a, b, c)

{

 if ((a > 5) || ((a > b) && (a > c)))

  return('a');

 if ((b > 5) || ((b > c) && (b > a)))

  return('b');

 if ((c > 5) || ((c > a) && (c > b)))

  return('c');

 return('b'); 

}



function sq_countanswers(x)

{

var r = 0;

 

 for (sq_i = 0; sq_i < 10; sq_i++)

 {

  if (sq_answers[sq_i] == x)

   r++;

 }

 return(r);

}



function sq_onsubmit()

{

var gotanswer = '';

var sqc = document.getElementById("sqc");

var h = '';

var na, nb, nc;

var ts = '</strong></p><table width="100%" border="0" cellspacing="5" cellpadding="0">';

var te = '<tr><td>&nbsp;</td><td>&nbsp;</td></tr></table>'

var ra = '<tr><td width="17%" align="right" valign="top"><input type="radio" name="sqa" value="a" /></td><td width="83%">';

var rb = '<tr><td width="17%" align="right" valign="top"><input type="radio" name="sqa" value="b" /></td><td width="83%">';

var rc = '<tr><td width="17%" align="right" valign="top"><input type="radio" name="sqa" value="c" /></td><td width="83%">';



 if ((sq_cur < 0) || (sq_cur > 9))

 {

  alert('Invalid Question')

  window.location.href = 'starquiz.html';

  return(false);

 }

 for (sq_i = 0; sq_i < 3; sq_i++)

 {

  if (document.sqf.sqa[sq_i].checked == true)

  {

   gotanswer = document.sqf.sqa[sq_i].value;

   sq_answers[sq_cur] = gotanswer;

   break;

  }

 }

 if (gotanswer == '')

 {

  alert('Please Pick an Answer!');

  return(false);

 }

 sq_i = sq_cur + 2;

 if (sq_i <= 10)

 {

  document.sqi.src = 'images/q' + sq_i + '.jpg'; 

  h = '<h1>Question ' + sq_i + ' of 10</h1><p><strong>';

 }

 switch(sq_cur++)

 {

  case 0:  /* Q2 */

   h += 'What would you most like to do?' + ts;

   h += rb + 'Sky dive in Taupo, New Zealand</td></tr>';

   h += ra + 'Go fly fishing in Denmark</td></tr>';

   h += rc + 'Take a long beach walk in the Bahamas</td></tr>';

   h += te + '<div align="right"><input type="submit" value="Next Question" /></div>';

   break;

  case 1:  /* Q3 */

   h += 'Which capital city would you most like to live in?' + ts;

   h += rc + 'Wellington in New Zealand</td></tr>';

   h += rb + 'Moscow in Russia</td></tr>';

   h += ra + 'Paris in France</td></tr>';

   h += te + '<div align="right"><input type="submit" value="Next Question" /></div>';

   break;

  case 2:  /* Q4 */

   h += 'Which of the following careers would suit you the most?' + ts;

   h += rb + 'Musician</td></tr>';

   h += rc + 'Singer and songwriter</td></tr>';

   h += ra + 'Actress</td></tr>';

   h += te + '<div align="right"><input type="submit" value="Next Question" /></div>';

   break;

  case 3:  /* Q5 */

   h += 'What&#39;s your favourite food?' + ts;

   h += ra + 'Italian food</td></tr>';

   h += rc + 'Fresh fish from Bermuda</td></tr>';

   h += rb + 'Ajaruli hachapuri: baked bread with cheese and an egg in the middle (a traditional Georgian dish)</td></tr>';

   h += te + '<div align="right"><input type="submit" value="Next Question" /></div>';

   break;

  case 4:  /* Q6 */

   h += 'Which languages would you most like to speak?' + ts;

   h += rb + 'German</td></tr>';

   h += rc + 'Spanish</td></tr>';

   h += ra + 'Italian</td></tr>';

   h += te + '<div align="right"><input type="submit" value="Next Question" /></div>';

   break;

  case 5:  /* Q7 */

   h += 'Who would you most like to date?' + ts;

   h += rc + 'Ian Thorpe (Australian swimmer)</td></tr>';

   h += rb + 'Luke Pritchard (The Kooks)</td></tr>';

   h += ra + 'Johnny Borrell (Razorlight)</td></tr>';

   h += te + '<div align="right"><input type="submit" value="Next Question" /></div>';

   break;

  case 6:  /* Q8 */

   h += 'Who do you most admire?' + ts;

   h += ra + 'French linguist and actor, Johnny Depp</td></tr>';

   h += rb + 'Multilingual singer and songwriter, Paul McCartney</td></tr>';

   h += rc + 'French linguist and actor, Orlando Bloom</td></tr>';

   h += te + '<div align="right"><input type="submit" value="Next Question" /></div>';

   break;

  case 7:  /* Q9 */

   h += 'Which song do you have on your ipod?' + ts;

   h += rc + 'Pink &#39;Get this party started&#39;</td></tr>';

   h += ra + 'Jamie Cullum&#39;s &#39;Catching the French Tales&#39;</td></tr>';

   h += rb + 'Bj&ouml;rk&#39;s &#39;The Pleasure Is All Mine&#39;</td></tr>';

   h += te + '<div align="right"><input type="submit" value="Next Question" /></div>';

   break;

  case 8:  /* Q10 */

   h += 'What&#39;s your favourite pastime?' + ts;

   h += rb + 'Adrenaline activities e.g. paragliding, hang gliding and roller coasters</td></tr>';

   h += ra + 'Playing hockey</td></tr>';

   h += rc + 'Travelling in new countries</td></tr>';

   h += te + '<div align="right"><input type="submit" value="Finish Quiz" /></div>';

   break;

  default:  /* Results */

   na = sq_countanswers('a');

   nb = sq_countanswers('b');

   nc = sq_countanswers('c');

   gotanswer = sq_whichgreatest(na, nb, nc);

   document.sqi.src = 'images/q' + gotanswer + '.jpg';

   h = '<h1>Your Star Quiz Results</h1><p>';

   if (gotanswer == 'a')

    h += 'Chic and elegant but with a bit of a wild-side, you are most like <strong>Emma Watson</strong> who rose to fame playing Hermione Granger in Harry Potter.  Emma speaks three languages (French, German and Italian) and is the UK&#39;s 55th highest earning Briton under 30.';

   else if (gotanswer == 'b')

    h += 'You&#39;re most like <strong>Katie Melua</strong>, adventurous, creative and an adrenaline junkie. Katie attended the BRIT school with Leona Lewis and Amy Winehouse and has released three platinum selling albums, making her Britain&#39;s 29th richest young person.';

   else

    h += 'You&#39;re an ultra-chilled out glamour girl like singer-songwriter <strong>Natasha Bedingfield</strong>, who has had global success with her debut album <em>Unwritten</em>. Natasha speaks French, German and Spanish. She is Britain&#39;s 77th highest-earning young person under 30.';

   h += '</p>';

   h += '<p><a href="starquiz.html" title="Take Quiz Again">Take Quiz Again</a></p>';

   break;

 }

 sqc.innerHTML = h;

 return(false);

}