// JavaScript Document

// let reader choose style sheet

function lrgTxt() {
  var ActiceSS;
  
  ActiceSS = getActiveStyleSheet();
 
  
  if (ActiceSS == null)
  	{
  		setActiveStyleSheet("standard_large");
		return;
	}
	 
  // Each colour scheme has its own font size CSSs
  
  //Change size CSS for HIGH
  if (ActiceSS.search("high") != -1 )
		{
			if (ActiceSS == "high")
				{
					setActiveStyleSheet("high_large");
				}
			else
			{
				if (ActiceSS == "high_small")
					{
						setActiveStyleSheet("high");	
					}
				else
					{						
						alert("Large text is already selected. To make further changes, open the View menu in your browser and select Text Size (Microsoft Internet Explorer) or Increase Font (Netscape Navigator).");						
					}
			}
		return;
		}
	
	  //Change size CSS for low
	if (ActiceSS.search("low") != -1 )
		{
			if (ActiceSS == "low")
				{
					setActiveStyleSheet("low_large");
					return;
				}
			if (ActiceSS == "low_small")
				{
					setActiveStyleSheet("low");
					return;
				}
			if (ActiceSS == "low_large")
				{
					alert("Large text is already selected. To make further changes, open the View menu in your browser and select Text Size (Microsoft Internet Explorer) or Increase Font (Netscape Navigator). You can also check the User Guide for more information about controlling text sizes.");
					return;
				}
			return;
		}
	else
		{
			if (ActiceSS == "standard_small")
				{
					setActiveStyleSheet("standard");
				}
			if (ActiceSS == "standard_large")
				{
					alert("Large text is already selected. To make further changes, open the View menu in your browser and select Text Size (Microsoft Internet Explorer) or Increase Font (Netscape Navigator). You can also check the User Guide for more information about controlling text sizes.");
				}
		}  
}

function smlTxt() {
  var ActiceSS;
  
  ActiceSS = getActiveStyleSheet();
  
  if (ActiceSS == null)
  	{
  		setActiveStyleSheet("standard_small");
		return;
	}
	 
  // Each colour scheme has its own font size CSSs
  
  //Change size CSS for HIGH
  if (ActiceSS.search("high") != -1 )
		{
			if (ActiceSS == "high")
				{
					setActiveStyleSheet("high_small");
					return;
				}
			if (ActiceSS == "high_large")
				{
					setActiveStyleSheet("high");
					return;
				}
			if (ActiceSS == "high_small")
				{
					alert("Small text is already selected. To make further changes, open the View menu in your browser and select Text Size (Microsoft Internet Explorer) or Decrease Font (Netscape Navigator). You can also check the User Guide for more information about controlling text sizes.");
					return;
				}
		return;
		}
	
	  //Change size CSS for low
	if (ActiceSS.search("low") != -1 )
		{
			
			if (ActiceSS == "low")
				{
					setActiveStyleSheet("low_small");
					return;
				}
			if (ActiceSS == "low_large")
				{
					setActiveStyleSheet("low");
					return;
				}
			if (ActiceSS == "low_small")
				{
					alert("Small text is already selected. To make further changes, open the View menu in your browser and select Text Size (Microsoft Internet Explorer) or Decrease Font (Netscape Navigator). You can also check the User Guide for more information about controlling text sizes.");
					return;
				}
			return;
		}
	
  
  if ((ActiceSS == null) || (ActiceSS == "standard"))
  	{
  		setActiveStyleSheet("standard_small");
	}
  
  if (ActiceSS == "standard_large")
  	{
  		setActiveStyleSheet("standard");
	}
  
  if (ActiceSS == "standard_small")
  	{
  		alert("Small text is already selected. To make further changes, open the View menu in your browser and select Text Size (Microsoft Internet Explorer) or Decrease Font (Netscape Navigator). You can also check the User Guide for more information about controlling text sizes.");
	}
  
}

function setPrintStyleSheet(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 setDefaultStyleSheet(title) {
 var cookie = readCookie("style");
 var title = cookie ? cookie : getPreferredStyleSheet();
 setActiveStyleSheet(title);
}

	
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();
  	if (title == "printer")
		{  
			return true;
		} 
	else 
		{  
    		createCookie("style", title, 365);
		}
 }



// toggle visibility 

function toggle( targetId ){
  if (document.getElementById){
  		target = document.getElementById( targetId );
  			if (target.style.display == "none"){
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
  	}
}

// Set the current text size Larger



// Set the current text size Smaller



