// JavaScript Document

//the showsection function is used on the product information pages. It displays only the section of information that the user selects from the right-hand navigation. 

//The first thing that it does is to set the display style of all of the divs inside the containing div 'product_main_content' to none, effectively hiding them all (including the 'back to top' links for people with javascript disabled). The function then redisplays the right-hand navigation (which has just been set to display:none because it is inside 'product_main_content') by setting the style of its containing div ('product_page_navigation') to block.

//The function then identifies the link that has been clicked, identifies the corresponding div by its id, then sets the style of only that div to display:block, effectively un-hiding it.

function showsection(id){
	var divs = document.getElementById("product_main_content").getElementsByTagName("div");
		for(i = 0; i < divs.length; i++)
			{
			divs[i].style.display = "none";
			}
	document.getElementById("product_page_navigation").style.display = "block"	
    if(!document.getElementById) return false;
    var div = document.getElementById("section"+id);
    var curDiv = document.getElementById("section"+current);
    curDiv.style.display = "none";
    div.style.display = "block";
    current = id;
}

// show_about_section works in pretty much the same way as showsection, seen above. It's used exclusively on the about page to hide / display the relevant sections.

function show_about_section(id){
	var divs = document.getElementById("about_main_content").getElementsByTagName("div");
		for(i = 0; i < divs.length; i++)
			{
			divs[i].style.display = "none";
			}
	document.getElementById("about_navigation").style.display = "block"	
    if(!document.getElementById) return false;
    var div = document.getElementById("section"+id);
    var curDiv = document.getElementById("section"+current);
    curDiv.style.display = "none";
    div.style.display = "block";
    current = id;
}

// same again, but for A-Z

function show_a2z_section(id){
	var divs = document.getElementById("about_main_content").getElementsByTagName("div");
		for(i = 0; i < divs.length; i++)
			{
			divs[i].style.display = "none";
			}
	document.getElementById("a2zNavigation").style.display = "block"	
    if(!document.getElementById) return false;
    var div = document.getElementById("section"+id);
    var curDiv = document.getElementById("section"+current);
    curDiv.style.display = "none";
    div.style.display = "block";
    current = id;
}


// the gup function grabs the options after a "?" in a URL, e.g. bett_rota.html?resource=eig&name=dave&foo=bar and returns the value of "name". 
// so in the example, gup("resource") would return "eig".

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
//the reloadpageforsection function is used only in three places on the oxford schools package page. the point of this function is twofold, one: to show the selection that the user choses on the left-hand navigation, and two: create a page url containing the variables for the browsers history. the point is that if the clicks forward to, for example, the oro page from the subscriber services section, and then clicks back on their browser, they will be back in the subscriber section of the osp page. 

//this function simply adds the variable to the url, of this (the osp) page, and then reloads the page. the work of showing the selected section is done by the onpage javascript upon the loading of the page.

function reloadpageforsection(id){}

