<!--  // Default Scripts - itsmephill@yahoo.co.uk - 8 Apr 05
//capture screen size
if (document.layers)
{
	origWidth = window.innerWidth;
	origHeight = window.innerHeight;
}
else
{
	var origWidth, origHeight;
	origWidth = window.screen.availWidth;
	origHeight = window.screen.availHeight;
}

function screenSizeSetup()//show and hide objects based on screen size
{
	var largeScrSizeVis = new Array("accOptionsId","logoId","mainMenuId","myMenuId");
	var smallScrSizeVis = new Array("titleId","tgMenuId");
	var i;
	if (origWidth > 1500) //show and hide objects based on large screen size
	{
		for (i=0; largeScrSizeVis[i]; i++) //loops thru large screen show items
		{    
			displayOn(largeScrSizeVis[i]);  // call func to turn display of span on
		}
		for (i=0; smallScrSizeVis[i]; i++) //loops thru small screen show items
		{    
			displayOff(smallScrSizeVis[i]);  // call func to turn display of span off
		}
	}
}
//netscape css bug fix
function reloadPage() {
	if (innerWidth != origWidth || innerHeight != origHeight) 
	location.reload();
	}
if (document.layers) onresize = reloadPage;

function findDOM(objectID, withStyle) //get document object model for current users browser
{
	if (withStyle) {
		if (document.getElementById) return (document.getElementById(objectID).style) ; 
		else if (document.all) return (document.all[objectID].style); 
		else if ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) == 4)) return (document.layers[objectID]); 
	}
	else {
		if (document.getElementById) return (document.getElementById(objectID)) ; 
		else if (document.all) return (document.all[objectID]); 
		else if ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) == 4)) return (document.layers[objectID]); 
	}
}
function lastModStr() //get document last modified date
{
	var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var dateObj = new Date(document.lastModified);
	var wday = days[dateObj.getDay()]
	var lmonth = months[dateObj.getMonth()]
	var date = dateObj.getDate()
	var fyear = dateObj.getFullYear()
	if (fyear < 2000) 
		fyear = fyear + 1900;
	return(lmonth + " " + date + ", " + fyear); //return(wday + ", " + lmonth + " " + date + ", " + fyear);
}
function readCookie(name) //Read cookie value
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue; //returns title of css sheet from cookie
}
function writeCookie(name,value) // Write style sheet title to cookie
{
  var expire;
    expire = new Date(); //Get current date
	expire.setMonth(expire.getMonth()+6); //set cookie expires to 6 months from now
	expire = "; expires=" + expire.toGMTString(); //convert expires date to GMT format
  	document.cookie = name + "=" + escape(value) + expire +";path=/;"; //write cookie
  //cookie available for all directories on domain
}
window.onload = function(e) //Read values from cookie, set style sheets and indicate menus
{	
	var title, elementIndex;
	var sheets = new Array("col","siz"); //types of style sheets to set
	for (elementIndex=0; elementIndex < sheets.length; elementIndex++)
	{ //loop through array and set active style sheets
		title = readCookie(sheets[elementIndex]);//get type from array and read cookie
		if (title.length > 0) //don't run if no title returned from cookie
		{
			setActiveStyleSheet(title); //call to set active sheet
		}
		else
		{	//if no style set in cookie set defaults
			/*if (sheets[elementIndex]=="col")
			{
				setActiveStyleSheet("colour1"); //call to set active sheet to default colour
			}
			else
			{
				setActiveStyleSheet("size1"); //call to set active sheet to default size
			}*/
		}
	}
	//screenSizeSetup(); // sets up object visibility based on screen size (pda vs pc)
	//setSection(); // sets location indication on main menu
	}
function setActiveStyleSheet(title) //Set active style sheet 
{ 
	var i, a, main, type;
	type = getStyleSheetType(title);
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) //loop through link elements
  {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && getStyleSheetType(a.getAttribute("title")) == type) 
	{//if link element has title and of matching sheet type
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
	writeCookie(type, title); //call write cookie function
		var targetId = title + "actv";
		setStyleIndicators(targetId);	//call active style indicators for access page
}
function getStyleSheetType(title) //Get style sheet type from title 
{
	var type = title.substr(0,3); //extract first 3 characters from title
	return type;
}
function setSection()  //set section indication on main menu
{
	var sectionId = "";
	var targetId = "";
	sectionId = findDOM('section',false); //call func to get section id to use for target
	targetId = sectionId.value;
	if (targetId != "")
	{
	displayOn(targetId);		//call func to turn display of div on
	}
}
function sectionMenuHover(targetId,hoverOnOff)
{
	var targetElement = findDOM(targetId,false);
	if (hoverOnOff=="on")
	{
		targetElement.className="mmhideTblBlue2Bg"
	}
	else
	{
		targetElement.className="mmhideTblBlueBg"
	}
	/*if (targetElement.className=="mmhoveron")
	{
		targetElement.className="mmhoveroff";
	}
	else
	{
		targetElement.className="mmhoveron";
	}*/
}
function setStyleIndicators(targetId) //sets active style indication on access page
{
	var docTitle = document.title;
	if (docTitle=="Accessibility Options" && targetId != "")
	{
		var sizStylInd = new Array("size1actv","size2actv","size3actv");
		var colStylInd = new Array("colour1actv","colour2actv");
		var stylInd = new Array;
		var i;
		var type = targetId.substr(0,3); //extract first 3 characters from targetId - col or siz
		if (type == "siz")
		{
			stylInd = sizStylInd;  //selects size indicators
		}
		else
		{
			stylInd = colStylInd;  //selects colour indicators
		}
		for (i=0; stylInd[i]; i++) //loops thru selected style indicators colour/size
		{
			//var targetElement = findDOM(stylInd[i],true);
			//targetElement.display="None";    
			displayOff(stylInd[i]);  // call func to turn display of span off
		}
		displayOn(targetId); // call func to turn display of span on
	}
}
function displayOn(targetId) //turns div or span visibility on 
{
	var targetElement = findDOM(targetId,true);
	targetElement.display="";		//turns display on
}

function displayOff(targetId) //turns div or span visibility off 
{
	var targetElement = findDOM(targetId,true);
	targetElement.display="None";    //turns display off
}
function printThis(targetId)
{ 
	var sourceId = "";
	var destinationId = "";
	var bodyText = "";

	 //call func to get div id to use for source, destination and non print content
	sourceId = findDOM(targetId,false); //source
	destinationId = findDOM("prtDest",false); //destination
	
	if (sourceId != "" && destinationId != "")
	{
		bodyText = sourceId.innerHTML; //get print content from source div
		destinationId.innerHTML = bodyText; //copy content to destination div
	
		displayOff("noPrint"); // turn rest of page off (non print content)
		print(); // call browser print function
		displayOn("noPrint"); // turn rest of page on
		destinationId.innerHTML = ""; //clear content from destination div
	}
}
function setText(targetId,textNo)
{
	var destinationId = "";
	txtArray = new Array();
	txtArray[0] = "&nbsp;";
	txtArray[1] = "text 1 test";
	txtArray[2] = "text 2 test";
	destinationId = findDOM("pictDisc",false); //destination
	destinationId.innerHTML = txtArray[textNo]; //copy content to destination div
}
function siteMenuOptions()
{
	//write site menu options into page
	document.write("<option value=http://tgweb/index.htm>Home Page</option>");
    document.write('<option value=http://tgweb/site_help/index.htm>Site Help</option>');
}
function othisMenuOptions()
{
	//write OTHIS menu options into page
	document.write("<option value=http://othis/utilities.htm>IT Support</option>");
    document.write('<option value=http://othis/etd/etd.htm>Education, Training &amp; Development</option>');
    //document.write('<option value=""#"">Information Analysis</option>');
    document.write('<option value=http://othis/library/welcome_to.htm>Library</option>');
    document.write('<option value=http://nww.oldham.nhs.uk/ig>Information Governance</option>');
    //document.write('<option value=""#"">Projects</option>');
    document.write('<option value=http://helpdesk.othis.nhs.uk/users/>Helpdesk</option>');
}
function dropDownMenuPageOpen(targetMenuName,targetDestination)
{
	var targetElement = findDOM(targetMenuName,false);//get reference to menu
	var targetURL = targetElement.options[targetElement.selectedIndex].value;//get selected menu item value
	//alert(othisTarget);
	if (targetDestination=="new")//check destination
	{
		window.open(targetURL,"","resizable,toolbar,scrollbars,status");//open target URL in new window
	}
	else
	{
		window.location.href = targetURL;//open target URL in current window
	}
}
//-->
