//********************************************************
// MiscFunctions.js
// Version 2.0
// Modified 10/08/01
// Added the ShowInfoBox function
// Version 1.0
// created 5/06/01
//********************************************************

// This file contains

// function PopupWindow(itemNo, maxItems) - Show the Pop Up layer and hides all others
// function Reveal() - Reveals the bottom frame when it is hidden

// variable and function naming standard
  // global variable  - gClassnamePropertyName
  // local variable   - lowerCase
  // function         - StartsWithUpperCase


//********************************************************
// Dependancies
//********************************************************
 
// The function PopupWindow requires the style sheet miscStyle.css

//********************************************************
// Global Variables
//********************************************************

//none

//********************************************************
// function ShowInfoBox
//********************************************************

function ShowInfoBox(itemNo)
{
  //itemNo is the item that was selected, = 0 if none selected
  //maxItems is the number of possible items
  
  //local variables
  var i
  gSelectedInfoBox = itemNo
  
  if (itemNo == 0)
  {
    infoWindow.className = "infoWindowSelected"
	info1.className = "infoWindowTitle"
	info2.className = "infoWindowScreenTitle"
	for(i=3; i <= gInfoWindowMaxItems; i++)
  	{
	   //Show window associated with selected link
	     eval('info' + i + '.className = " infoWindowContent"')
    }
  }
  else
  {
    infoWindow.className = "infoWindowNotSelected"
	info1.className = "infoWindowTitleFade"
	info2.className = "infoWindowScreenTitleFade"
	for(i=3; i <= gInfoWindowMaxItems; i++)
  	{
	   //Show window associated with selected link
	     eval('info' + i + '.className = " infoWindowContentFade"')
    }
  }
  
  for(i=1; i <= gNoShowInfoMaxItems; i++)
  {
     if(i == itemNo)
     {
       //change the selected icon 
	     eval('document.i' + i + '.src="' + gImageOn.src + '"')
	   //Show window associated with selected link
	     eval('showInfoBox' + i + '.className = " showInfoBoxSelected"')
      }
	  else
      {
       //change the not selected icon
	     eval('document.i' + i + '.src="' + gImageOff.src + '"')
	   //Hide windows not associated with selected link
	     eval('showInfoBox' + i + '.className = " showInfoBoxNotSelected"')
      }
   }
}

//********************************************************
// function ShowPopLayer
//********************************************************

function PopupWindow(itemNo, maxItems)
{
  //itemNo is the item that was selected
  //maxItems is the number of possible items
  
  //local variables
  var i
  
  for(i=1; i <= maxItems; i++)
  {
     if(i == itemNo)
     {
       //change selected link style
	     eval('popupLink' + i + '.className = " popupLinkSelected"')
	   //Show window associated with selected link
	     eval('popupWindow' + i + '.className = " popupWindowSelected"')
      }
	  else
      {
       //change not selected link style
	     eval('popupLink' + i + '.className = " popupLinkNotSelected"')
	   //Hide windows not associated with selected link
	     eval('popupWindow' + i + '.className = " popupWindowNotSelected"')
      }
   }
}

//********************************************************
// function Reveal
//********************************************************

function Reveal()
{
  //local variables
  var i=1
  var bottomHeight

  for(i=1; i<40; i+=5)
  {
  	bottomHeight = i
  	top.document.all.myFrames.rows = "*, " + bottomHeight + "%"
  }
}

//********************************************************
// function openPopUp
//********************************************************
// opens new browser window

function openPopUp (htmlFile, windowName, width, height)    
{  
	windowOptions  = "status=no, toolbar=no, location=no, menubar=no, resizable=no, scrollbars=yes, width="
	windowOptions += width + ", height = " + height	
	
	winPopUp = window.open (htmlFile, windowName, windowOptions)
}

//********************************************************
// functions  getPos and show
// based on the code from http://www.siteexperts.com/tips/jperry/ts02/page1.asp
//********************************************************
//required for show funciton and making only one popup layer visible at a time
var gPreviousSpan=null;

// code to close a popup layer by clicking anywhere on the page.
//document.onclick = new Function("show(null)")
function getPos(el,sProp) {
	var iPos = 0
	while (el!=null) {
		iPos+=el["offset" + sProp]
		el = el.offsetParent
	}
	return iPos
}

function show(clickSpan,popupSpan) {
	if (popupSpan) {
	    popupSpan.style.display='';
		popupSpan.style.pixelLeft = getPos(clickSpan,"Left")
		popupSpan.style.pixelTop = getPos(clickSpan,"Top") + clickSpan.offsetHeight
	}
	//Makes sure only one popup layer is shown at a time
	if ((popupSpan!=gPreviousSpan) && (gPreviousSpan)) gPreviousSpan.style.display='none'
	gPreviousSpan=popupSpan
}

function showCourseOutline(clickSpan,popupSpan) {
	if (popupSpan) {
	    popupSpan.style.display='';
		popupSpan.style.pixelLeft = 0
		//popupSpan.style.pixelLeft = getPos(clickSpan,"Left")
		popupSpan.style.pixelTop = getPos(clickSpan,"Top")
	}
	//Makes sure only one popup layer is shown at a time
	if ((popupSpan!=gPreviousSpan) && (gPreviousSpan)) gPreviousSpan.style.display='none'
	gPreviousSpan=popupSpan
}

function showHere(clickSpan,popupSpan) {
	if (popupSpan) {
	    popupSpan.style.display='';
		popupSpan.style.pixelLeft = getPos(clickSpan,"Left")
		popupSpan.style.pixelTop = getPos(clickSpan,"Top") + clickSpan.offsetHeight
	}
	//Makes sure only one popup layer is shown at a time
	if ((popupSpan!=gPreviousSpan) && (gPreviousSpan)) gPreviousSpan.style.display='none'
	gPreviousSpan=popupSpan
}

function showOverImage(popupSpan) {
	if (popupSpan) {
	    popupSpan.style.display='';
	}
	//Makes sure only one popup layer is shown at a time
	if ((popupSpan!=gPreviousSpan) && (gPreviousSpan)) gPreviousSpan.style.display='none'
	gPreviousSpan=popupSpan
}

//********************************************************
// functions  ClosePopUpDefinition
//********************************************************
function ClosePopUpDefinition(obj){
  obj.style.display = 'none'
}