/* just a bit of browser sniffing is necessary. */
var ie = (document.all) ? true: false; 
var win_width=700, win_height=500;
var init;

/* dimensions */
function dimensions() {
	if (ie) {
		win_width=document.body.clientWidth; 
		win_height=document.body.clientHeight;
	}
	else {
		win_width=innerWidth;
		win_height=innerHeight;
	}
}

/* this function preloads the button images */

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/* the menu open/close function. */

function togglemenu(num) { 
	
	/* set local variables. */
	var submenu = "sub"+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".
	*/
	if (document.getElementById(submenu).style.display != "block") {
		changeclassstyle('div','sublevel','display','none');
		document.getElementById(submenu).style.display = "block";
	}
	else {
		document.getElementById(submenu).style.display = "none";
	}
}


/* 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 + "'");
  }
}

