function fetch_object(idname, forcefetch)
{
	var browser = '';
	if (document.getElementById)
	{
		browser = "std";
	}
	else if (document.all)
	{
		browser = "ie4";
	}
	else if (document.layers)
	{
		browser = "ns4";
	}

	var siteobject = new Array();
	switch (browser)
	{
		case "std":
		{
			siteobject[idname] = document.getElementById(idname);
		}
		break;

		case "ie4":
		{
			siteobject[idname] = document.all[idname];
		}
		break;

		case "ns4":
		{
			siteobject[idname] = document.layers[idname];
		}
		break;
	}
	return siteobject[idname];
}

function open_close(object)
{
	data = fetch_object(object);
	pdata = fetch_object(object + '_parent');
	var table = pdata.parentNode.parentNode.parentNode.parentNode;

	if (data.style.display == "none")
	{
		data.style.display = "";
		pdata.innerHTML = '<a href="#top"  onclick="return open_close(\'' + object + '\'); return false" title="Minimise Recent Tutorials">Minimise Recent Tutorials</a>';

		var appendage = fetch_object(object + '_appendage');
		table.removeChild(appendage);
	}
	else if (data.style.display == "")
	{
		data.style.display = "none";
		pdata.innerHTML = '<a href="#top" onclick="open_close(\'' + object + '\'); return false" title="Maximise Recent Tutorials">Maximise Recent Tutorials</a>';

		var thebody = document.createElement('tbody');
		var theappendage = document.createElement('tr');
		thebody.appendChild(theappendage);
		var appendage = document.createElement('td');
		theappendage.appendChild(appendage);
		appendage.colSpan = 3;

		thebody.id = object + '_appendage';
		appendage.onclick = function()
		{
			open_close(object);
		}
		appendage.innerHTML = 'Click Here to Maximise the Banner.';

		if (data.nextSibling == null || table.lastChild.previousSibling.id == object)
		{
			appendage.className = 'alt1_footer';
			table.appendChild(thebody);
		}
		else
		{
			appendage.className = 'alt1_padding';
		 	table.insertBefore(thebody, data.nextSibling);
		}
	}

	return false;
}








function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);