
//====================================
// Main DHTML Utility Javascript functions
//
// Version: 2.02
//
// Author:   Dawson Cowals
// Created:  06-07-2002
// Modified: 11-05-2002
//
//====================================

//Tab variables
numberOfTabs      = 5;
tabActiveLayer    = new Array(numberOfTabs);
tabOffLayer       = new Array(numberOfTabs);

tabActiveLayer[0] = "tab0_active";
tabActiveLayer[1] = "tab1_active";
tabActiveLayer[2] = "tab2_active";
tabActiveLayer[3] = "tab3_active";
tabActiveLayer[4] = "tab4_active";

tabOffLayer[0]    = "tab0_off";
tabOffLayer[1]    = "tab1_off";
tabOffLayer[2]    = "tab2_off";
tabOffLayer[3]    = "tab3_off";
tabOffLayer[4]    = "tab4_off";


//function takes a layer name and a toggle value
//works in both NS and IE to hide layer or make it visible

function toggleLayer(layID,tog) {
   //if we want to hide the layer
   if (tog == 'hide') {
        //if this is new 6.0 Browser
        if (is_nav6up || is_ie6up || is_gecko || is_opera5up) {
           document.getElementById(layID).style.visibility = "hidden";

        //if this is an old Netscape 4.x browser
        }  else if (is_nav4up) {
           document.layers[layID].visibility='hide';

	//if this is an old IE 5.x browser
        } else if (is_ie5up) {
           document.all[layID].style.visibility='hidden';
        }

   //otherwise we want to show it
   } else {
        //if this is new 6.0 Browser
        if (is_nav6up || is_ie6up || is_gecko || is_opera5up) {
           document.getElementById(layID).style.visibility = "visible";

        //if this is an old Netscape 4.x browser
        }  else if (is_nav4up) {
           document.layers[layID].visibility='show';

	//if this is an old IE 5.x browser
        } else if (is_ie5up) {
           document.all[layID].style.visibility='visible';
        }
   }
}

function activateTab(tabIndex) {

	//show layer
	//var layID = tabActiveLayer[tabIndex];
	//alert(layID);
	toggleLayer(tabActiveLayer[tabIndex],'show');

	//hide other layers
	hideAllActiveTabsExcept(tabIndex);

}

function hideAllActiveTabsExcept(tabIndex) {
	var i = 0;
	for (i=0; i < numberOfTabs; i++) {
		if (tabActiveLayer[i] != tabActiveLayer[tabIndex]) {
			toggleLayer(tabActiveLayer[i], 'hide');
		}
	}
}

//call: hilit(this,true,true)   -- to hilit a field and select it's contents
//call: hilit(this,true,false)  -- to hilit a field without selecting it's contents
//call: hilit(this,false,false) -- to turn the hilit off
function hilit (source,doHilit,doSelect) {

    //aSource = event.srcElement;
    //aParent = aSource.parentElement;

    if (doHilit) {
      //hilit color
      cellColor  = "#996666";
      fieldcellColor = "#cc9999";

      if (doSelect) {
    	//if we are in a text input box, select it
        source.select();
      }
    } else {
      //original color
      cellColor  = "#669999";
      fieldcellColor = "#ffffff";
    }

    source.style.backgroundColor = fieldcellColor;
    //aParent.style.backgroundColor = cellColor;
}

function todaysDate(target) {
  var today    = new Date();
  var dateNow  = parseInt(today.getDate());
  var monthNow = parseInt(today.getMonth());
  var yearNow  = today.getYear();

  if (monthNow < 9) {
    monthString = "0" + (monthNow + 1) + "";
  } else {
    monthString = "" + (monthNow + 1) + "";
  }

  if (dateNow <= 9) {
    dayString = "0" + dateNow + "";
  } else {
    dayString = dateNow;
  }

  target.value = monthString + "/" + dayString + "/" + yearNow;

}

function getRandom(low,high) {

  var myRand = Math.floor(Math.random() * (high+1)) + low;
  return (myRand);

}

