var total = 0;

function showHide(what,fr_num) {
	if(document.getElementById(what).innerHTML == '') {
				var so = new FlashObject("world_spin.swf", "flashmovie", "772", "345", "8", "#FFFFFF");
				so.addParam("quality", "high");
				so.addVariable("frame_num", fr_num);
				so.write("flash-content");
				setCookie('flash_state',"0",365)
				document.getElementById('flash-controller').innerHTML = '<img src="images/up_arrow.gif" alt="" /><a href="JAVASCRIPT://" onclick="showHide(\'flash-content\',\''+fr_num+'\');" title="" class="plain">Hide Flash Content</a>';
	} else {
		document.getElementById(what).innerHTML = '';
		document.getElementById('flash-controller').innerHTML = '<img src="images/down_arrow.gif" alt="" /><a href="JAVASCRIPT://" onclick="showHide(\'flash-content\',\''+fr_num+'\');" title="" class="plain">Show Flash Content</a>';
		setCookie('flash_state',"1",365)
	}
}
function setCookie(c_name,value,expiredays) {
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}
function checkCookie()
{
flash_state=getCookie('flash_state')
if (flash_state!=null && flash_state=="1") {
  document.getElementById('flash-content').innerHTML = '';
		document.getElementById('flash-controller').innerHTML = '<img src="images/down_arrow.gif" alt="" /><a href="JAVASCRIPT://" onclick="showHide(\'flash-content\');" title="" class="plain">Show Flash Content</a>';
}
else if(flash_state!=null && flash_state=="0") {
	//do nothing
}

else if(flash_state==null)
  {
  flash_state=1
  if (flash_state!=null && flash_state!="")
    {
    setCookie('flash_state',flash_state,365)
    }
  }
}
var counter = 1;
var total = 0;
var inc = 1;
var old_inc = 0;
function get_radio_value()
{
			if(inc == old_inc) {
				showQues(counter+1);
				counter++;
				inc++;
			} else {
				alert('Please select an answer');
			}
}
function showQues(which) {
	if(which == 2) {
		document.getElementById('questions').innerHTML = '							<p>Q2.Does washing at lower temperatures give good cleaning results?</p>';
		document.getElementById('questions').innerHTML += '							<p class="answers">';
		document.getElementById('questions').innerHTML += '								<form name="theForm">';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Yes<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />No<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="1" onclick="set(this);" />Yes, if you use an appropriate product<br /><br />';
		document.getElementById('questions').innerHTML += '							</form>';
		document.getElementById('questions').innerHTML += '							</p>';
		document.getElementById('questions').innerHTML += '							<img src="images/next.gif" onclick="get_radio_value(document.theForm.q1);">';
	}
	if(which == 3) {
		document.getElementById('questions').innerHTML = '							<p>Q3.Which one of the following is not a result of compaction?</p>';
		document.getElementById('questions').innerHTML += '							<p class="answers">';
		document.getElementById('questions').innerHTML += '								<form name="theForm">';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Fewer chemicals<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Lower emissions from transport<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Less packaging waste<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="1" onclick="set(this);" />Increased energy use in manufacturing<br /><br />';
		document.getElementById('questions').innerHTML += '							</form>';
		document.getElementById('questions').innerHTML += '							</p>';
		document.getElementById('questions').innerHTML += '							<img src="images/next.gif" onclick="get_radio_value();">';
	}
	if(which == 4) {
		document.getElementById('questions').innerHTML = '							<p>Q4.Which one of the following is an example of compaction at work in the detergent industry?</p>';
		document.getElementById('questions').innerHTML += '							<p class="answers">';
		document.getElementById('questions').innerHTML += '								<form name="theForm">';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Recycled packaging<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Cleaning wipes<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="1" onclick="set(this);" />Liquitabs<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Wind turbines<br /><br />';
		document.getElementById('questions').innerHTML += '							</form>';
		document.getElementById('questions').innerHTML += '							</p>';
		document.getElementById('questions').innerHTML += '							<img src="images/next.gif" onclick="get_radio_value();">';
	}
	if(which == 5) {
		document.getElementById('questions').innerHTML = '							<p>Q5.Why does excessive packaging have a negative impact on the environment?</p>';
		document.getElementById('questions').innerHTML += '							<p class="answers">';
		document.getElementById('questions').innerHTML += '								<form name="theForm">';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />It irritates shoppers<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="1" onclick="set(this);" />It results in more waste that has to be collected or will go to landfill<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />You can\'t recycle it<br /><br />';
		document.getElementById('questions').innerHTML += '							</form>';
		document.getElementById('questions').innerHTML += '							</p>';
		document.getElementById('questions').innerHTML += '							<img src="images/next.gif" onclick="get_radio_value();">';
	}
	if(which == 6) {
		document.getElementById('questions').innerHTML = '							<p>Q6.Which of the following is not a function of packaging?</p>';
		document.getElementById('questions').innerHTML += '							<p class="answers">';
		document.getElementById('questions').innerHTML += '								<form name="theForm">';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Protects the product<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Allows transportation<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="1" onclick="set(this);" />Improves product effectiveness<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Allows messages to reach the consumer<br /><br />';
		document.getElementById('questions').innerHTML += '							</form>';
		document.getElementById('questions').innerHTML += '							</p>';
		document.getElementById('questions').innerHTML += '							<img src="images/next.gif" onclick="get_radio_value();">';
	}
	if(which == 7) {
		document.getElementById('questions').innerHTML = '							<p>Q7. Which one of these tips will help you save water when washing?</p>';
		document.getElementById('questions').innerHTML += '							<p class="answers">';
		document.getElementById('questions').innerHTML += '								<form name="theForm">';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Washing at higher temperatures<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="1" onclick="set(this);" />Adding more laundry to each wash <br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Washing more, smaller loads.<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Using an older washing machine<br /><br />';
		document.getElementById('questions').innerHTML += '							</form>';
		document.getElementById('questions').innerHTML += '							</p>';
		document.getElementById('questions').innerHTML += '							<img src="images/next.gif" onclick="get_radio_value();">';
	}
	if(which == 8) {
		document.getElementById('questions').innerHTML = '							<p>Q8. In the past 20 years, by what percentage have washing machines reduced water consumption?</p>';
		document.getElementById('questions').innerHTML += '							<p class="answers">';
		document.getElementById('questions').innerHTML += '								<form name="theForm">';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />17%<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />45%<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="1" onclick="set(this);" />62%<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />80%<br /><br />';
		document.getElementById('questions').innerHTML += '							</form>';
		document.getElementById('questions').innerHTML += '							</p>';
		document.getElementById('questions').innerHTML += '							<img src="images/next.gif" onclick="get_radio_value();">';
	}
	if(which == 9) {
		document.getElementById('questions').innerHTML = '							<p>Q9. Who is responsible for caring for the environment?</p>';
		document.getElementById('questions').innerHTML += '							<p class="answers">';
		document.getElementById('questions').innerHTML += '								<form name="theForm">';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Consumers<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Companies<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />Authorities<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="1" onclick="set(this);" />Everyone<br /><br />';
		document.getElementById('questions').innerHTML += '							</form>';
		document.getElementById('questions').innerHTML += '							</p>';
		document.getElementById('questions').innerHTML += '							<img src="images/next.gif" onclick="get_radio_value();">';
	}
	if(which == 10) {
		document.getElementById('questions').innerHTML = '							<p>Q10. If the whole of the UK reduced their washing temperature by one click on the machine dial, how much electricity would be saved per year?</p>';
		document.getElementById('questions').innerHTML += '							<p class="answers">';
		document.getElementById('questions').innerHTML += '								<form name="theForm">';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />1 Megawatt hour <br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />4 Megawatt hours<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="1" onclick="set(this);" />2 Terawatt hours<br /><br />';
		document.getElementById('questions').innerHTML += '								<input type="radio" name="q1" value="0" onclick="set(this);" />3 Gigawatt hours<br /><br />';
		document.getElementById('questions').innerHTML += '							</form>';
		document.getElementById('questions').innerHTML += '							</p>';
		document.getElementById('questions').innerHTML += '							<img src="images/next.gif" onclick="chkScore(total);">';
	}
}
function set(what) {
	
	//alert(what.value);
	document.getElementById('score').value = what.value;
	total = parseInt(total) + parseInt(what.value);
	if(old_inc < inc) {
		old_inc++;
	}
	//alert(total);
}
function chkScore(total) {
	if(total <= 3) {
		document.getElementById('questions').innerHTML = '							<p>Oh dear! Don’t worry, we’ll make a sustainability expert out of you yet. Download <a href="docs/SIB_Quiz Results.pdf" target="new">the answers</a> to see where you went wrong.</p>';
	}
	else if(total <= 6) {
		document.getElementById('questions').innerHTML = '							<p>Pretty good but there’s definitely room for improvement. Download <a href="docs/SIB_Quiz Results.pdf" target="new">the answers</a> and see where you could have done better.</p>';
	}
	else if(total >= 7) {
		document.getElementById('questions').innerHTML = '							<p> Well done! You are a sustainability expert! Make sure that you put your expert knowledge to good use by following our <a href="docs/SIB Tips_final 13.12.07.pdf" target="new">top tips</a> for reducing your impact on the environment.<br />You can also download <a href="docs/SIB_Quiz Results.pdf" target="new">the answers here</a>.</p>';
	}
}