// JavaScript Document

// Function name: makeLinkTitles() - body onload - adds or appends title attribute for links that open in a new browser window

function makeLinkTitles() {
    if( !document.links )
    {
        document.links = document.getElementsByTagName("a");
    }
    for (var ti=0;ti<document.links.length;ti++) 
	{
        var lnk = document.links[ti];
		if (lnk.target=="_blank") 
		{
			lnk.title=lnk.title+" (opens in new window)";
		}
	}
}

// Macromedia popup script

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Function name: backButton() - sends you back to previous page

function backButton() {
  history.back();
}

// Function name: core(date) - rollover activity

function core(date) {
  if (date=="0") document.getElementById('coreText').firstChild.nodeValue="Today: By measuring carbon dioxide concentrations trapped in the ice, scientists now know carbon dioxide concentrations today are the highest for 650,000 years. Scientists have linked these higher concentrations with higher temperatures, suggesting global warming.";
  if (date=="2000") document.getElementById('coreText').firstChild.nodeValue="2000s: After an all-time high in the 1980s, samples of ice from recent years show a  drop in lead concentrations in the ice. This shows the impact of the worldwide introduction of lead-free petrol.";
  if (date=="1960") document.getElementById('coreText').firstChild.nodeValue="1960s: Ice layers show a drop in the amount of radioactive gases in the ice following the ban on testing atomic bombs in 1963.";
  if (date=="1800") document.getElementById('coreText').firstChild.nodeValue="1800s: Higher concentrations of carbon dioxide and nitrous oxides trapped in the ice  mark the beginning of the Industrial Revolution and the burning of fossil fuels in power stations, factories and cars.";
  if (date=="1400") document.getElementById('coreText').firstChild.nodeValue="1400s: The rise in sodium in the ice marks a time when seas were stormier, throwing up salt onto the ice. Some scientists think that these stormier times mark 'the Little Ice Age', a period of much cooler temperatures that lasted until the 1900s.";
  if (date=="12") document.getElementById('coreText').firstChild.nodeValue="12,000 years ago: Thinner layers of ice show that in just a few years, temperatures dropped dramatically. This chill then lasted for another thousand years! From this, scientists have worked out that climate changes can be quicker than previously thought.";
  if (date=="73") document.getElementById('coreText').firstChild.nodeValue="73,000 years ago: Dust and ash in the layers of ice show evidence of a huge volcanic eruption in Indonesia, the biggest of the last 500,000 years. As dust and ash blocked out the sun, the eruption probably cooled global temperatures for many years.";
  if (date=="740") document.getElementById('coreText').firstChild.nodeValue="740,000 years ago: From the deepest ice core samples ever extracted, scientists have confirmed that in the last 740,000 years, Earth has been through eight separate Ice Ages, when the climate was much colder than today.";
}

// Function name: quotes(pic) - rollover activity

function quotes(pic) {
	var thisface="f"+pic;
	var newface="img/activity_pics/9_face"+pic+"b.jpg";
	document.getElementById(thisface).src=newface;
  if (pic=="1") document.getElementById('quoteText').firstChild.nodeValue="It is ridiculous that countries think that they can lay claim to Antarctic territory. Antarctica has no king, no queen, no government, no leader of any kind. That's why countries should drop these territorial claims. Instead, members of the United Nations should own Antarctica collectively. That's the only fair solution";
  if (pic=="2") document.getElementById('quoteText').firstChild.nodeValue="The Antarctic Treaty System is a 'rich man's club' run by a small group of developed countries that use Antarctica for their own benefit. As a poor country that lies close to Antarctica we are much more likely to benefit if we actually owned a piece of Antarctica.";
  if (pic=="3") document.getElementById('quoteText').firstChild.nodeValue="We live in the country nearest to Antarctica. We even share some of the same problems as Antarctica, like the hole in the ozone layer. This gives us a very good case for owning a piece of the continent.";
  if (pic=="4") document.getElementById('quoteText').firstChild.nodeValue="Just because the British led the first expeditions here doesn't give them any claim to any territory in Antarctica today!";
  if (pic=="5") document.getElementById('quoteText').firstChild.nodeValue="Thanks to research carried out by British scientists we understand much more about Antarctica's climate and environment, and how this affects us all. We deserve some acknowledgement of this!";
  if (pic=="6") document.getElementById('quoteText').firstChild.nodeValue="As the richest country in the world only we can afford the technology to carry out groundbreaking experiments in Antarctica, like explorations into space. What's more, our scientists are the best in the world too.";
  if (pic=="7") document.getElementById('quoteText').firstChild.nodeValue="It was our Amundsen - not their Scott - who was the first to reach the South Pole. We deserve recognition for this achievement with a piece of the pie.";
  if (pic=="8") document.getElementById('quoteText').firstChild.nodeValue="Unless individual countries own pieces of Antarctica no-one will ever take responsibility for what happens there. You only need to look at the United Nations to see that decision-making that requires agreement from everybody leads to no decision at all. The protection of Antarctica in the future would be much more secure under the control of individual countries.";
}

// Function name: quotesoff(pic) - mouseout for rollover activity

function quotesoff(pic) {
document.getElementById('quoteText').firstChild.nodeValue="Hover over the faces to see what they think!";
var thisface="f"+pic;
var origface="img/activity_pics/9_face"+pic+".jpg";
document.getElementById(thisface).src=origface;
}

// Cookie functions for the make your own webpage activity - includes semicolon and comma check in saveIt

function saveIt(name,formnumber)
{
	var formnum = formnumber;
	var x = document.forms[formnum].cookievalue.value;
	var result=x;
	while (result.indexOf(";")>-1){
	var semicolonfix=result;
	result = semicolonfix.replace(';','zzz');
	}
	while (result.indexOf(",")>-1){
	var commafix=result;
	result = commafix.replace(',','xxx');
	}
	if(x) createCookie(name,result,1);
	else{
	alert('You have missed something out!');
	createCookie(name,'you missed this one!',1);}
}

function saveNumber(name,formnumber)
{
	var formnum = formnumber;
		var x = parseInt(document.forms[formnum].cookievalue.value);
	if(!document.forms[formnum].cookievalue.value)alert('You have not selected both your pictures!');
	else
	if(x>=1 && x<=6) createCookie(name,x,1);
	else
	{alert ('You entered something strange as one of your picture options!')
		createCookie(name,100,1);}
}

function readIt(name)
{
	alert('The value of the cookie is ' + readCookie(name));
}

// note - cookie creation is in styleswitcher js file