/* global variables */
var section;

/* just a bit of browser sniffing is necessary. */

var ie = (document.all) ? true: false; 
var isWin = (navigator.platform.indexOf("Win") != -1) ? true : false;

var ieWin = (ie && isWin) ? true : false;

var ieWin50 = (isWin && navigator.appVersion.indexOf('MSIE 5.0') != -1) ? true : false;


/* the menu open/close function. */

function togglemenu(num) { 

/* set local variables. */
var submenu = "sub"+num;
var square = "sq"+num;

/* Set the display style to "none" if the value is null */
if (document.getElementById(submenu).style.display == null) {
 document.getElementById(submenu).style.display = "none";
 }
 
/* The toggle section. 
If the value of the submenu element's display is "none", 
then it's set to "block"; if the value is "block", it's set to "none".
The plus/minus GIF is also reset accordingly.
*/

if (document.getElementById(submenu).style.display == "none") {
document.getElementById(submenu).style.display = "block";
document.getElementById(square).src = "../../images/minus.gif";
}
else {
document.getElementById(submenu).style.display = "none";
document.getElementById(square).src = "../../images/plus.gif";
 }
}


/* Get all the elements with a given class name */

function getElementsByClassName(tagname, classname) {
 
 /* only execute in 5+ browsers. */
 if (!document.getElementById) return false;

 /* get all elements with the tag name tagname. */

 var TagElements = document.getElementsByTagName(tagname);

 /* define an array which will hold the elements with the class name classname. */
 var elementsByClassName = new Array();

 /* Look at all the elements in TagElements, and find the ones with the class name classname. */

 for (i=0; i<TagElements.length; i++) {
  if (TagElements[i].className == classname) {
    elementsByClassName[elementsByClassName.length] = TagElements[i];
    }
 }
  return elementsByClassName;
}


function changeclassstyle(tagname,classname,styleproperty,newstyle) {
 var tochange = getElementsByClassName(tagname,classname);
  for (k=0; k < tochange.length; k++) {
    eval("tochange[k].style." + styleproperty + " = " + "'" + newstyle + "'");
  }
}

/* change the cursor style */
function changecursor(num) {
var square = "sq" + num;

if (ieWin50) {
 var cursorstyle = 'hand'; }
else {
 var cursorstyle = 'pointer';
 }
document.getElementById(square).style.cursor = cursorstyle;
}

var section;
function init() 
{
	if (document.getElementById) 
	{
		changeclassstyle('div','sublevel','display','none');
		changeclassstyle('td','pic','display','none');

		if (section > 0) 
		{ 
			togglemenu(section); 
		}
	 }
}

function openwindow(url,name,properties,width, height)
{
		winleft = Math.round((screen.width - width)/2);
		wintop = Math.round((screen.height - height)/2);

		window.open(url, name, properties + ",left="+winleft+",top="+wintop+",width="+width+",height="+height);
}