// Confidential - not to be disclosed without written permission of Acute Technology Limited
// Copyright Acute Technology Limited info@acutetechnology.com

// *****************************************************************************
// common.js - support routines 
// *****************************************************************************

// Support for Consensus dynamic loading: 
// when this script is loaded, decrement the counter 
if (window.scriptsToLoad){
  scriptsToLoad--;
}

// *****************************************************************************
// Functions
// *****************************************************************************

function doNothing() {
  // useful when we need to call a function, but have nothing to do
}

// *****************************************************************************
// Code to support the navigation tabs, plus support for scrollable checklists
// *****************************************************************************

// the tabs idea comes from here: http://www.builderau.com.au/program/css/
function switchSub(object){
	if(object.getElementsByTagName('ul').length > 0){
		fUl = object.getElementsByTagName('ul')[0];
		if(fUl.style['visibility'] != 'visible'){
			fUl.style['visibility'] = 'visible'
		}else{
			fUl.style['visibility'] = 'hidden'
		}
	}
}
		
// initChecklist: Add :hover functionality on labels for IE for scrollable checkboxes
// See: http://c82.net/article.php?ID=25
		
function initChecklist() {
	if (document.all && document.getElementById) {
		// Get all unordered lists
		var lists = document.getElementsByTagName("ul");
		
		for (i = 0; i < lists.length; i++) {
			var theList = lists[i];
			
			// Only work with those having the class "checklist"
			if (theList.className.indexOf("checklists") > -1) {
				var labels = theList.getElementsByTagName("label");
				
				// Assign event handlers to labels within
				for (var j = 0; j < labels.length; j++) {
					var theLabel = labels[j];
					theLabel.onmouseover = function() { this.className += " hover"; };
					theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
				}
			}
		}
	}
}

// uses moofx.jx and moofx.utils.js to toggle a div, by varying its height

function mooToggle(el){
  // toggle the visibility of a div
  var faq_a = $(el);
  if (Element.visible(faq_a)){
    // Use moofx to hide the element 
    var myEffect = new Fx.Height(el, {duration: 1000, onComplete: function(){
        Element.hide(el); 
      } 
    });
    myEffect.toggle();
    }
  else {
  // Use moofx to show the element 
  var myEffect = new Fx.Height(el, {duration: 1000});
  Element.show(el);
  myEffect.hide();
  myEffect.toggle();  }
}


