// NOTE: The default cells are 21 pixels high using this scheme
//var winwidth=document.all?document.body.clientwidth:window.innerwidth;
//winHeight=document.all?document.body.clientheight:window.innerHeight; 

function GetWidth()
{
	var x = 0;
	
	if( self.innerWidth )
	{
		x = self.innerWidth;
	}
	else if( document.documentElement && document.documentElement.clientWidth )
	{
		x = document.documentElement.clientWidth;
	}
	else if ( document.body )
	{
		x = document.body.clientWidth;
	}
	
	return x;
}

function GetHeight()
{
	var x = 0;
	
	if( self.innerHeight )
	{
		x = 180;
	}
	else if( document.documentElement )
	{
		x = 180;
	}
	else if ( document.body )
	{
		x = 180;
	}
	
	return x;
}

/** get_scrollbar_sizes()
*
* This function calculates window.scrollbarWidth and window.scrollbarHeight.
*/
function get_scrollbar_sizes()
{
	var i = document.createElement( "p" );
	
	i.style.width = "200px";
	i.style.height = "200px";
	var o = document.createElement( "div" );
	o.style.position = "absolute";
	o.style.top = "0px";
	o.style.left = "0px";
	o.style.visibility = "hidden";
	o.style.width = "150px";
	o.style.height = "150px";
	o.style.overflow = "hidden";
	o.appendChild( i );
	document.body.appendChild( o );
	
	var w1 = i.offsetWidth;
	var h1 = i.offsetHeight;
	o.style.overflow = "scroll";
	var w2 = i.offsetWidth;
	var h2 = i.offsetHeight;
	
	if ( w1 == w2 ) 
	{
		w2 = o.clientWidth;
	}
	
	if ( h1 == h2 )
	{
		h2 = o.clientHeight;
	}
	
	document.body.removeChild( o );
	
	window.scrollbarWidth = w1 - w2 - 50;
	window.scrollbarHeight = h1 - h2 - 50;

}



/** change_ypmenu_xposition()
	*
	* This function will move a menu after a window resize event.
	* It is called in the update() function
	*/
function change_ypmenu_xposition( id, xposition )
{
	element = document.getElementById( id + "Container" );
	
	var myWidth = GetWidth();
	var myHeight = GetHeight();
	if( element )
	{	var xPosition = ( myWidth / 2 ) - 325;
		
/*		if( typeof( window.innerWidth ) == 'number' )
		{	
			//Non-IE
			var myWidth = window.innerWidth;
		}
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
		{	
			//IE 6+ in 'standards compliant mode'
			var myWidth = document.documentElement.clientWidth;
			
		}*/
		if(myWidth>990)
		{
			xPosition = ( myWidth / 2 ) - 325;
		}
		else
		{
			xPosition = 179;
		}
			
		element.style.left = xPosition + "px";
			
	}
}

function update()
{		
	var myWidth = GetWidth();
	var myHeight = GetHeight();
	
	//alert( "x = " + myWidth + ", y = " + myHeight );
	var xPosition = ( myWidth / 2 ) - 325;
	//alert("here");
	if( document.documentElement && document.title!='Natural Heritage New Mexico - Home')
	{	
		myHeight=myHeight+3;
		xPosition = xPosition + 5;
		
	}
	else if( document.documentElement && document.title=='Natural Heritage New Mexico - Home')
	{	
		myHeight=myHeight+2;	
	
	}
		
	
	var yPosition = myHeight;
	if( window.ypSlideOutMenu_menu1 )
	{		
		change_ypmenu_xposition( "menu1", xPosition );
		change_ypmenu_xposition( "menu2", xPosition );
		change_ypmenu_xposition( "menu3", xPosition );
		change_ypmenu_xposition( "menu4", xPosition );
		change_ypmenu_xposition( "menu5", xPosition );
		change_ypmenu_xposition( "menu6", xPosition );
		change_ypmenu_xposition( "menu61", xPosition );
		change_ypmenu_xposition( "menu62", xPosition );		
	}
	else
	{	
		// DO NOT PREPEND with "var" keyword, because these have to be GLOBAL
		//new ypSlideOutMenu("number menu", "slide position", left, top, width, height)
		new ypSlideOutMenu("menu1", "right", xPosition, yPosition + 0, 175, 42)	;	
		new ypSlideOutMenu("menu2", "right", xPosition, yPosition + 30, 175, 126);
		new ypSlideOutMenu("menu3", "right", xPosition, yPosition + 61, 175, 126);
		new ypSlideOutMenu("menu4", "right", xPosition, yPosition + 91, 175, 189);
		new ypSlideOutMenu("menu5", "right", xPosition, yPosition + 121, 175, 42);		
		new ypSlideOutMenu("menu6", "right", xPosition, yPosition + 179, 175, 300);
		/*new ypSlideOutMenu("menu61", "right", xPosition + 175, yPosition + 179, 175, 205);
		new ypSlideOutMenu("menu62", "right", xPosition + 175, yPosition + 179 + ( 3 * 21 ), 175, 205);*/

	}
}

document.onload = update();


  	  