//-----------------------------------------------------------------------------------
// 
// scripts.js
//
// Copyright ©2006 Intervisual Software Ltd.
// (Parts copyright Macromedia, Inc.)
//
// This file contains various common scripts used within the site.  They are
// brought out into a separate file to avoid duplication in the page files.
// Also, by using client-side include, the loading of pages is made more
// efficient by allowing the client browser to cache this file.
//
//-----------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------
//
// MM_findObj
//
// Macromedia library function for finding an item on the page given its name.
//
//-----------------------------------------------------------------------------------

function MM_findObj(n, d) 
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//-----------------------------------------------------------------------------------
//
// hilite & lolite
//
// These functions provide rollover effects for the top menu bar.  When the 
// mouse is moved over a menu item, it is underlined, turned blue, and the
// cursor is changed to a hand (signifying a link).
//
//-----------------------------------------------------------------------------------

function hilite(thing)
{
  thing.style.cursor = "hand";
  thing.style.textDecoration="underline";
}

function lolite(thing) 
{
  thing.style.cursor = "default";
	thing.style.textDecoration="none";
}

//-----------------------------------------------------------------------------------
//
// showhide
//
// Expands or contracts the given menu item.
//
//-----------------------------------------------------------------------------------

function showhide(id)
{
	var thing, icon;
  thing = document.getElementById("item"+id);
  icon = document.getElementById("icon"+id);
	if (thing.style.display=="")
	{
		thing.style.display="none";
		if (icon) icon.src="/images/closed.gif";
	}
	else
	{
		thing.style.display="";
		if (icon) icon.src="/images/open.gif";
	}
}

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers


function resizeCaller() 
{
	if (document.getElementById)
	{
		resizeIframe("mainframe")
		resizeIframe("latestframe")
	}
}

function sizeCaller() 
{
/*
if (navigator.userAgent.indexOf("MSIE")>-1 && navigator.userAgent.indexOf("Opera")==-1)
    document.getElementById("printpage").style.display = "";
*/	
	resizeCaller ();
}

function resizeIframe(frameid)
{
	var currentfr=document.getElementById(frameid)
	if (currentfr)
	{
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
			currentfr.height = currentfr.Document.body.scrollHeight;
		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent)
		{
			currentfr.detachEvent("onload", readjustIframe) // Bug fix line
			currentfr.attachEvent("onload", readjustIframe)
		}
	}
}

function readjustIframe(loadevt) 
{
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
	if (iframeroot)
		resizeIframe(iframeroot.id);
}

function loadpage(url)
{
	if (document.getElementById)
		document.getElementById("mainframe").src=url;
}

if (window.addEventListener)
{
	window.addEventListener("load", sizeCaller, false);
	window.addEventListener("resize", resizeCaller, false);
}
else if (window.attachEvent)
{
	window.attachEvent("onload", sizeCaller);
	window.attachEvent("onresize", resizeCaller);
}
else
{
	window.onload=sizeCaller;
  window.onresize=resizeCaller;
}

//-----------------------------------------------------------------------------------
//
// printpage
//
// Prints the content of the main frame for the page
//
//-----------------------------------------------------------------------------------

function printpage ()
{
  mainframe.focus(); 
	mainframe.print();
}


