/*****************************************************************************/

/* 					Controls Global Navigation for IE						 */

/*****************************************************************************/

// Nav Toggle
function navOn(id){document.getElementById(id).style.display='block';}
function navOff(id){document.getElementById(id).style.display='none';}

function NavWidget(debug,defer,allowFocus) {
  // debug (true/false): enables debugging mode
  // defer (true/false): defers init() call (will have to be called manually)
  // noNetscapeBlur (true/false): allows buttons to get and keep focus (annoying inner border shown - workaround for Netscape 7.0 when buttons in <fieldset> tags, ie. demo page)
  var self = this;
  this.debugEnabled = (debug?1:0);
  this.defer = (defer?1:0);
  this.noFocus = (allowFocus?0:1);
  this.b = document.getElementById('main-nav').getElementsByTagName("li");
  this.init = function() {
 // alert('scriiiiiipt');
    // Main loop (assigns nav event handlers etc.)
    for (var i=0; i<this.b.length; i++) {
		if(this.b[i].className=='nav-section'){
		 // alert(this.b[i].id);

		 // alert(this.myid);
		  this.b[i].htmlMouseDownHandler = (this.b[i].onmouseover?this.b[i].onmouseover:function(){});
		  this.b[i].htmlMouseUpHandler = (this.b[i].onmouseup?this.b[i].onmouseup:function(){});
		  this.b[i].htmlMouseOutHandler = (this.b[i].onmouseout?this.b[i].onmouseout:function(){});
		  this.b[i].onmouseover = function() {
		    //alert(this.id);
		    this.className = this.className+'-over';
			if(this.id.indexOf('-over')==-1) this.id = this.id+'-over';
		    if (self.debugEnabled) this.debug();
		    this.htmlMouseDownHandler();
		  }
	      this.b[i].onmouseup = function() {
		 // 	alert(this.myid);
		    this.id = this.id.replace(/\-over/,'');
	  	    this.className = this.className.replace(/\-over/,'');
		    if (self.debugEnabled) this.debug();
		    this.htmlMouseUpHandler();
		  }
		  if (this.noFocus) {
		    this.b[i].onfocus = function() {
		      this.blur();
		    }
		  }
		  this.b[i].onmouseout = function() {
		    //alert(this.id);
		    this.id = this.id.replace(/\-over/,'');
	  	    this.className = this.className.replace(/\-over/,'');
			if (self.debugEnabled) this.debug();
			this.htmlMouseOutHandler();
		  }
		  if (self.debugEnabled) {
		    this.b[i].onmouseover = function() {
			  this.debug();
			}
		  }
	      this.b[i].debug = function() {
		    window.status = 'NavWidget(): '+this.className;
		  }
		}
    }
  }
  if (!this.defer) {
    this.init();
  }
}

var navWidget = null;

//onloadHandlers[onloadHandlers.length] = 'navWidget = new NavWidget()';

onloadLib.addEvent('var navWidget = new NavWidget();');