
var tA = {
  // initialisation function, call with load
  init: function() {
    if (!document.getElementById) return;  
    
    tA.range_bandings = document.getElementById('range_bandings');    
    if (!document.getElementById('range_bandings')) return;  
    
    tA.tickall = document.getElementById('tickall');
    if (tA.tickall) {
			tA.addEvent(tA.tickall, 'click', tA.tickAll, false);
			tA.addEvent(tA.tickall, 'keypress', tA.tickAll, false);
		}
    
  },
  
  
  tickAll: function() {
  	
  	var newstatus = true;
  	
  	if (tA.tickall.checked == false) {
  		newstatus = false;
  	}
  
    // get inputs in this container
    var list = tA.range_bandings.getElementsByTagName('input');
		// loop though list
		for (var k = 0; k < list.length; k++) {
			// get the row element
			var elem = list[k];
			if ((elem.id.search('banding_') != -1)) {
				//alert(elem.checked);
				elem.checked = newstatus;
			}
				
    }
    
  
  },
  
  
  
	// function to add event listener, also caches events so they can be removed when the
	// page unloads to avoid memory leaks in IE
  addEvent: function(elm, evType, fn, useCapture) {
		// for W3C DOM complience
    if (elm.addEventListener) {
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } 
		// for IE...
		else if (elm.attachEvent) {
      var r = elm.attachEvent('on' + evType, fn);
      //EventCache.add(elm, evType, fn);
      return r;
    } else {
			// for anyone else not IE or Moz... Safari etc
      elm['on' + evType] = fn;
    }
  },
	
	// cross-browser get target
	find_target: function(e) 	{
		var target; 	
		// for IE, target is held in window.event array
		if (window.event && window.event.srcElement) 
			target = window.event.srcElement;
		else if (e && e.target)
			target = e.target;
		if (!target)
			return null;
			
		return target;
	}
	
	
}


tA.addEvent(window, 'load', tA.init, false);