/********************************************/
/*   Handcode Toolkit v1.1                  */
/*   Copyright 2004 Incus Web Works         */
/********************************************/

/********************************************/
/*   Add these styles to your stylesheet:   */
/*      B = Main Menu Button 'Out'          */
/*      S = Sub Menu Button 'Out'           */
/*                                          */
/*                                          */
/*   Menu-building function definitions:    */
/*                                          */
/*   _D('ID', 'class')                      */
/*     Opens a div                          */
/*   _C()                                   */
/*     Closes a div                         */
/*   _B('Text', 'Link')                     */
/*    Creates a main menu button            */
/*   _SM('Text', 'ID')                      */
/*    Creates a sub-menu                    */ 
/*   _S('Text', 'Link', 'Parent-ID')        */
/*    Creates a sub-menu button             */
/********************************************/



/* Other Functions */
// Uses some functions from "Layout Functions"

function _warnSubmit (form, text) {
 if (confirm('Are you sure you want to delete this item? \nClick "OK" to delete it.')) _getRef(form).submit();
}

/* Menu Functions */
// Uses some functions from "Layout Functions"

function _B (text, Link, Frame) {
 _button (text, Link, Frame, 'B', '', '', '');
}
function _SM (text, subID) {
 _subMenuButton (text, subID, 'B', '', '', '');
}
function _S (text, Link, Frame, subID) {
 _subMenuLink (text, Link, Frame, subID, 'S', '');
}
//writes div
function _D (ID, C, S){ document.write("<div id="+ID+" class=\""+C+"\" style=\""+S+"\">"); }
//closes div
function _C (){ document.write("</div>"); }
//writes menu button 
function _button (text, Link, Frame, Class, Style, Over, Out){ document.write("<div class=\""+Class+"\" style=\""+Style+"\" onMouseOver=\"_BOver(this, '"+Over+"')\" onMouseOut=\"_BOut(this, '"+Out+"')\" onMouseDown=\"_go('"+Link+"', '"+Frame+"')\">"+text+"</div>"); }
function _subMenuButton (text, subID, Class, Style, Over, Out){ document.write("<div class=\""+Class+"\" style=\""+Style+"\" onMouseOut=\"_hideWait('"+subID+"'); _SMOut(this, '"+Out+"')\" onMouseOver=\"_show('"+subID+"'); _SMOver(this, '"+Over+"')\">"+text+"</div>"); }
function _subMenuLink (text, Link, Frame, parentID, Class, Style){ document.write("<div class=\""+Class+"\" style=\""+Style+"\" onMouseOut=\"_hideWait('"+parentID+"'); _SOut(this)\" onMouseOver=\"_show('"+parentID+"'); _SOver(this)\" onMouseDown=\"_go('"+Link+"', '"+Frame+"')\">"+text+"</div>"); }
//goes to a locaiton
function _go(Link, Frame){
 if (Frame) _getRef(Frame).src=Link;
 else window.location = Link; }
//shows object
tID=0;
OpenID=0;
function _show(ID){
	if (tID || OpenID) _clearHide();
	_getSty(ID).display="block";
	OpenID=ID;
}
//hides object after T milliseconds
T=500;
function _hideWait(ID){
	tID = setTimeout('_hide("'+ID+'")', T);
}
function _hide(ID){
	_getSty(ID).display="none";
	OpenID=0;
}
function _clearHide(){
	if (tID) clearTimeout (tID);
	if (OpenID) _hide(OpenID);
}


/* Layout Functions */

//These variables define the minimum size of the browser window
MinWidth = 818;
MinHeight = 625;
//compatability code
var isDOM=document.getElementById?1:0;
var isIE=document.all?1:0;
var isNS4=navigator.appName=='Netscape'&&!isDOM?1:0;
var isIE4=isIE&&!isDOM?1:0;
var isOp=window.opera?1:0;
var isWin=navigator.platform.indexOf('Win')!=-1?1:0;
var isDyn=isDOM||isIE||isNS4;
var px=isNS4||isOp?0:"px"; 
var CSSmode=document.compatMode;
CSSmode=(CSSmode&&CSSmode.indexOf('CSS')!=-1)||isDOM&&!isIE||isOp?1:0;
function _getRef(id, par) {
 par=!par?document:(par.navigator?par.document:par);
 return isIE ? par.all[id] :
  (isDOM ? (par.getElementById?par:par.ownerDocument).getElementById(id) :
  (isNS4 ? par.layers[id] : null));
}
function _getSty(id, par){
 var r=_getRef(id, par);
 return r?(isNS4?r:r.style):(isNS4?id:id.style);
}
//object positioning, width & height functions
function _top(id, value, par){
 var sty=_getSty(id, par);
 sty.top=(value?value:0)+px;
}
function _left(id, value, par){
 var sty=_getSty(id, par);
 sty.left=(value?value:0)+px;
}
function _width(id, value, par){
 var sty=_getSty(id, par);
 sty.width=(value?value:0)+px;
}
function _height(id, value, par){
 var sty=_getSty(id, par);
 sty.height=(value?value:0)+px;
}
//page object constructor
if (!window.page) var page = { win: window, minW: MinWidth, minH: MinHeight, MS: isIE&&!isOp, db: CSSmode?'documentElement':'body' }
//function returns window width
page.winW=function() { with (this) return Math.max(minW, MS?win.document[db].clientWidth:win.innerWidth-15) }
//function returns window height
page.winH=function() { with (this) return Math.max(minH, MS?win.document[db].clientHeight:win.innerHeight) }
//onLoad and onResize functions
window.onload = function() { _position(); }
window.onresize = function() { _position(); }
//array to hold all div objects
var divs = Array();
//div object constructor
function div (id, x, y, w, h){ this.id = id; this.x = x; this.y = y; this.w = w; this.h = h; }
//function creates div object
divCount = 0;
function _locate (id, x, y, w, h){
 divs[divCount] = new div(id, x, y, w, h);
 //this line allows reference to div properties directly via id: e.g. div.{divID}.x
 eval ('div.'+id+' = new div(id, x, y, w, h)');
 ++divCount;
}
//function creates div object
function _build (id, x, y, w, h, c, s, t){
 _D(id, c, s);
 document.write(t);
 _C();
 _locate (id, x, y, w, h);
}
//function positions div objects
function _position() {
//only run these functions once
 winW = page.winW();    //no max width
 //widthMax = 950;  winW = page.winW()<widthMax ? page.winW() : widthMax;   //set max width as "widthMax" 
 winH = page.winH();    //no max height
 //heightMax = 720;  winH = page.winH()<heightMax ? page.winH() : heightMax;   //set max height as "heightMax"
 for (var i = 0; i < divs.length; i++) {
  //'if statement' prevents error if div does not exist in page
  if (_getRef(divs[i].id)) {
   _left(divs[i].id, eval(divs[i].x)); 
   _top(divs[i].id, eval(divs[i].y)); 
   // Don't let the width and height get below 0.    
   if (divs[i].w) _width(divs[i].id, Math.max(0,eval(divs[i].w)));
   if (divs[i].h) _height(divs[i].id, Math.max(0,eval(divs[i].h)));
   _getSty(divs[i].id).visibility="visible";
  }
 }
}