// Script for default status message
function defStatus()
{
	window.defaultStatus = 'Applied Ocean Systems Laboratory'
}

// Script for changing status message
function winStatus(msg)
{
	window.status = msg
}

// Create image objects
function newImage(arg)
{
     if (document.images)
	 {
          rslt = new Image()
          rslt.src = arg
          return rslt
     }
}

// Main Menu Rollovers
function MMenuFlip(id)
{
	var arrow = document.getElementById(id + "arrow")
	var item = document.getElementById(id + "item")
	var dirOn = "http://" + document.domain + "/images/mainmenuOn/"
	var dirOff = "http://" + document.domain + "/images/mainmenuOff/"
	var arrowSrc =  id + "arrow.jpg"
	var itemSrc = id + "item.jpg"
	
	if (arrow.src == dirOn + arrowSrc)
	{
		arrow.src = dirOff + arrowSrc
		item.src = dirOff + itemSrc
	}
	else if (arrow.src == dirOff + arrowSrc)
	{
		arrow.src = dirOn + arrowSrc
		item.src = dirOn + itemSrc
	}
	winStatus(' ')
}

// Top Menu Rollovers
function TMenu(id)
{
	var arrow = document.getElementById(id + "horiz")
	var dir = "http://" + document.domain + "/images/"
	var arrowSrc = id + "horizOn.gif"
	arrow.src = dir + arrowSrc
	winStatus(' ')
}

// Tool for footer locator function
function DL_GetElementTop(eElement)
{
   if (!eElement && this)                    // if argument is invalid
   {                                         // (not specified, is null or is 0)
      eElement = this;                       // and function is a method
   }                                         // identify the element as the method owner

   var DL_bIE = document.all ? true : false; // initialize var to identify IE

   var nTopPos = eElement.offsetTop;         // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element

   while (eParElement != null)
   {                                         // move up through element hierarchy
      if(DL_bIE)                             // if browser is IE, then...
      {
         if(eParElement.tagName == "TD")     // if parent a table cell, then...
         {
            nTopPos += eParElement.clientTop; // append cell border width to calcs
         }
      }
      else                                   // if browser is Gecko, then...
      {
         if(eParElement.tagName == "TABLE")  // if parent is a table, then...
         {                                   // get its border as a number
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder))            // if no valid border attribute, then...
            {                                // check the table's frame attribute
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null)         // if frame has ANY value, then...
               {
                  nTopPos += 1;              // append one pixel to counter
               }
            }
            else if(nParBorder > 0)          // if a border width is specified, then...
            {
               nTopPos += nParBorder;        // append the border width to counter
            }
         }
      }

      nTopPos += eParElement.offsetTop;      // append top offset of parent
      eParElement = eParElement.offsetParent; // and move up the element hierarchy
   }                                         // until no more offset parents exist
   return nTopPos;                           // return the number calculated
}

// Function to adjust body height and footer position
function BodyHeight()
{
	var BottomAnchor = "BottomAnchor"
	var BottomAnchor2 = "BottomAnchor2"
	var BodyDiv = "PageBodyArea"
	//var BodyContent = "PageContent"
	var FooterDiv = "Footer"
	if ( document.getElementById && document.getElementById(''+BottomAnchor+'') )
	{
		// Get Y position of anchor image(s)
		document.getElementById(''+BottomAnchor+'').getTrueYPosition = DL_GetElementTop
		var nMyElementsTrueYPosition = document.getElementById(''+BottomAnchor+'').getTrueYPosition()
		if ( document.getElementById(''+BottomAnchor2+'') )
		{
			document.getElementById(''+BottomAnchor2+'').getTrueYPosition = DL_GetElementTop
			var trueBottomAnchor2YPosition = document.getElementById(''+BottomAnchor2+'').getTrueYPosition()
		}
		// Decide whether to use value or set to default height for shorter pages
		if ( trueBottomAnchor2YPosition > nMyElementsTrueYPosition ) nMyElementsTrueYPosition = trueBottomAnchor2YPosition
		if ( nMyElementsTrueYPosition < 290 )
		{
			var NewBottom =  430
			var NewFooter =  450
		}
		else
		{
			var NewBottom =  ( nMyElementsTrueYPosition - 0 )
			var NewFooter =  ( nMyElementsTrueYPosition + 40  )
		}
		NewBottom = NewBottom + "px"
		NewFooter = NewFooter + "px"
		// Set heights and locations of divs
		//document.getElementById(''+BodyContent+'').style.height = NewBottom
		document.getElementById(''+FooterDiv+'').style.top = NewFooter
		if ( document.getElementById(''+BodyDiv+'') ) document.getElementById(''+BodyDiv+'').style.height = NewBottom
		document.getElementById(''+FooterDiv+'').style.visibility = 'visible'
	}
}







// Script to popup fullsize illustrations
function popFull(id,fileName)
{
	//fullPic = null
	//fullPic = newImage("full/" + fileName + ".jpg")
	//var picWidth = fullPic.width
	//var picHeight = fullPic.height
	var loc = "fullsize.asp?img=" + id
	var winHeight = 600
	var winWidth = 800
	var winName = fileName
	//if ( picWidth < 760 ) winWidth = picWidth + 40
	//else winWidth = 800
	//if (picHeight < 590 ) winHeight = picHeight + 10
	//else winHeight = 600
	windowprops = "height=" + winHeight + ",width=" + winWidth + ",location=no," + "scrollbars=yes,menubars=no,toolbars=no,resizable=yes"
	window.open(loc, winName, windowprops)
}