/* AUTHOR     : Dale Bechtel, Bechtel Consulting
   DESCRIPTION: Generic Sitewide JavaScript Functions
   Copyright (c)2001-2005. All Rights Reserved
----------------------------------------------------------------------------------------------------
                                 G L O B A L   V A R I A B L E S
----------------------------------------------------------------------------------------------------*/
var winTop      = (screen.height-600)/2;                         // Window Centering Calculations
var winLeft     = (screen.width-800)/2;
var layerRef    = 'document.all';
var styleSwitch = '.style';
var viewSwitch  = '"visible"';
var hideSwitch  = '"hidden"';
var isNS = isIE = false;
var d           = new Date();
var oPopup = window.createPopup();
var rWin = null;

/*////////////////////////////////////////////////////////////////////////////////////////////////////
//                          S H A R E D   F U N C T I O N A L I T Y
//////////////////////////////////////////////////////////////////////////////////////////////////////
      Function: siteInit( )
  Description: Initialize all website stuff.
       Syntax: [SCRIPT]siteInit( statStr );[/SCRIPT]
----------------------------------------------------------------------------------------------------*/
function siteInit( statStr ) {

   if (document.layers) {
      document.captureEvents(Event.KEYDOWN);
      layerRef    = 'document.layers';
      styleSwitch = '';
      viewSwitch  = '"show"';
      hideSwitch  = '"hide"';
      isNS        = true;
   }
   else if ((document.getElementByID) || (document.all)) {
      layerRef    = 'document.all';
      styleSwitch = '.style';
      viewSwitch  = '"visible"';
      isIE        = true;
   }

   if ( isIE==false) { 
	   alert('This Application Requires Microsoft Internet Explorer Version 5.5 or Higher!');
   }

   document.onmousedown = NoRightClick;
   document.onkeydown   = getKeycode;
}
/*--------------------------------------------------------------------------------------------------
|                              I N P U T   E V E N T   H A N D L E R S
|---------------------------------------------------------------------------------------------------*/
function NoRightClick(b)
{ if (((isIE)&&(event.button > 1))||((isNS)&&(b.which > 1))) {alert('Use the left button');return false;} }
/*--------------------------------------------------------------------------------------------------*/
function getKeycode(e) {
var theKey;

   theKey = (isNS==true) ? e.which : event.keyCode; //alert('Keycode= '+theKey);
   if (theKey==18) {return false;}  // Disable ALT key
}
/*----------------------------------------------------------------------------------------------------
					Dynamic Hilite for input fields - changes background color
---------------------------------------------------------------------------------------------------- */
function hilite( what, action ) {
var tgl = (!action) ? 'none' : action;

   for (i=1; i < (n+1); i++) {eval('document.all.f'+i+'.style.backgroundColor = "transparent"');}

   if (what != '0' && what != '99') {
	  eval('document.all.f'+what+'.style.backgroundColor = "#FFFFCC"');
   }
}
/*---------------------------------------------------------------------------------------------------
						Dynamic Hilite for Borders - changes border color
-------------------------------------------------------------------------------------------------- */
function hiliteB( what, action ) {
var tgl = (!action) ? 'none' : action;
var nhl = '"3px solid #ffcc00"';

   if (parent.nav) {if (parent.nav.lmode == 'T' || parent.nav.lmode == 'X') {nhl = '"none"';}}
	if (tgl == 'off') {
		eval('document.all.f'+what+'.style.border = "none"');  	
	}else {
		eval('document.all.f'+what+'.style.border = '+nhl);
	}
}
/*////////////////////////////////////////////////////////////////////////////////////////////////////
//                          M E T A   -   F U N C T I O N S
////////////////////////////////////////////////////////////////////////////////////////////////////*/
/*------------------------------------------------------------------------------------------------
 			Show/Hide Layers Routines
-------------------------------------------------------------------------------------------------*/
function showLayer(layerID) {eval(layerRef+'["' + layerID + '"]' + styleSwitch + '.visibility= "visible"');}
function hideLayer(layerID) {eval(layerRef+'["' + layerID + '"]' + styleSwitch + '.visibility= "hidden"');}
/*--------------------------------------------------------------------------------------------------*/
function ClearError() {return true; }
/*--------------------------------------------------------------------------------------------------
      O N L I N E   G L O S S A R Y   /   P O P U P   D I S P L A Y
      -------------------------------------------------------------

      Displays a popup description box. Can be used in 2 modes.
      mode 1 (default): Looks up the word passed in glossary and displays definition.
      mode 2: Displays the passed text string directly.

      USAGE mode 1: <span onmouseover="glossary(this,'word2Lookup')">word2Lookup</span>
      USAGE mode 2: <span onmouseover="glossary(this,"Here is some text to display',2)">Whatever we are spanning</span>
-----------------------------------------------------------------------------------------------------*/
function glossary(current, theword, mde) {
var foundIt = 0;

   mde = (!mde) ? 1 : 2;                                   // Default to mode 1

   for (i=0; i<(words.length); i++) {                        // Search for word in glossary list

	  if (theword.indexOf(words[i].item) != -1) {
	     foundIt = i;
	  }
   }

   if ((foundIt > 0) && (mde==1)) {                          // If found send it to display function
      glossary2(current, words[foundIt].desc,theword);
   }      
   else if (mde==2) {                                        // Else if mode 2 send entire string
      var txt = 'aplaceholder';
      glossary2(current, theword,txt);
   }
}
/*--------------------------------------------------------------------------------------------------*/
function glossary2(current,txt,theword) {
var w  = 300;                                                    // Width of popup
var o  = (theword.length)*7;                                     // Creative math to center popup under word
var l  = ((w/2)*-1)+(o/2);
var t  = (event.y + 25);
var tp = t;
var h  = document.body.scrollHeight;

   current.onmouseout = oPopup.hide;
   oPopup.document.body.innerHTML = txt;
   oPopup.document.body.style.backgroundColor = "lightyellow";
   oPopup.document.body.style.border = "groove black 2px";
   oPopup.document.body.style.padding = "10px";

   oPopup.show(0,0,w,0);                                        // The next 3 lines calculate the height of the 
   var realHeight = oPopup.document.body.scrollHeight;          // popup, and redisplay it correctly
   oPopup.hide();

   if (h < (t+realHeight)) {tp = ((t-50)-realHeight);}          // Display over or under?  
   if (l < 10) {l = 10}
   //oPopup.show(l,tp,w,realHeight,event.srcElement);//alert(tp);
   oPopup.show(l,tp,w,realHeight);

}
/*--------------------------------------------------------------------------------------------------
     Function: word()
  Description: Creates glossery entry objects
--------------------------------------------------------------------------------------------------*/
function word(item, desc) {
   this.item  = (!item) ? 'No Words Passed' : item;
   this.desc  = (!desc) ? 'No Description'  : desc;
}
/*////////////////////////////////////////////////////////////////////////////////////////////////////
//                               S T A S H E D   S T U F F
////////////////////////////////////////////////////////////////////////////////////////////////////*/
/*---------------------------------------------------------------------------------------------------
                              O P E N   W I N D O W
----------------------------------------------------------------------------------------------------*/
function openWindow(url) {
var wTop      = winTop+130;
var wLeft     = winLeft+120;
var theURL    = ( (url == null) ? 'menu.asp' : url);
var winOption = 'height=600,width=800,titlebar=no,resizeable=no,left='+wLeft+',top='+wTop+',screenX='+wLeft+',screenY='+wTop;

   if ((rWin!=null) && (rWin.open)){ rWin.close(); }
   rWin = window.open(theURL,"rWin", winOption);
   rWin.focus();
}
/*--------------------------------------------------------------------------------------------------
      Function: loadData()
  Description: Dynamically load redundant html.
--------------------------------------------------------------------------------------------------*/
function loadData( laData, param ) {
var s = "";                                                                                               

   switch (laData) {
   case "footer" :
      s +=  '<hr>&COPY;2003-2005 by Gault Nursery Corporation. All rights reserved.<br>';
      s += 'Portions &copy;2000-2005 <a href="http://www.qumulous.com">Bechtel Consulting.</a>';
      s += ' All rights reserved.<br><br>';
      footer.innerHTML = s;   
      break;

   case "buttons" :
      s += '<a href="gault_catalog.htm"><img src="images/catalogbtn.gif" name="catalog" width="202" height="184" border="0" onmouseover="this.src=\'images/catalogbtn_down.gif\';" onmouseout="this.src=\'images/catalogbtn.gif\';"></a>';
      buttons.innerHTML = s;
      break;

	case "menu" :
      s += '&nbsp;&nbsp;<a href="http://www.gaultnurserycorp.com">Home</a> |&nbsp;'; 
 	   s += '<a href="http://www.gaultnurserycorp.com/gault_contact.htm">Contact Us</a> |&nbsp;';
      s += '<a href="http://www.gaultnurserycorp.com/gault_about.htm">About Us</a>';
      menu.innerHTML = s;   
      break;

   }

return s;
}
/*////////////////////////////////////////////////////////////////////////////////////////////////////
///				                       E N D   O F   C O D E
////////////////////////////////////////////////////////////////////////////////////////////////////*/
