// <![CDATA[
/*
* Copyright: 2005 - 2007 SI Works Internet Solutions
* If you have come across this page, its cause you are snooping through code, and are generally a developer as such
* If you would like to use some of the code on this page, please simply email support@siworks.co.za and ask permission
* it would be much appreciated, as we have worked very hard on these func.tions() and scri.pts()
* 
* Note: All functions below are to make sure that we are sticking to standards and are mainly
* for visual effects and loading events and handlers.
*
* General functions to use accross all sites and use for loading events
* @page common.functions.js
* @version 2.3.0
* @author Greg Shiers, Jarratt Ingram (SI Works Internet)
* @copyright: SI Works Internet Solutions 2005 - 2007
*/

/*
* Function to grab one or more elements
* @usage $('element1','element2')
* @returns Array
* @version 1.1
*/
function $( ) {
	var elements = new Array( );
	for ( var i = 0; i < arguments.length; i++ ) {
		var element = arguments[i];
		if ( typeof element == 'string' )
			element = document.getElementById ( element );
		if ( arguments.length == 1 )
			return element;
		elements.push ( element );
	}
	return elements;
}
/**
* Function that creates an element
* @param element
* @version 1.2
* @returns string
* @author Greg Shiers
*/
function $_C ( element ){
	if ( typeof document.createElement != 'undefined' ) {
		return document.createElement(element);
	}
	else {
		alert('Your browser does not support document.createElement')
	}
}
/**
* Function to return the value of a form field
* @param element
* @version 1.2
* @returns string
* @author Greg Shiers
*/
function $_F( element ) {
	if (typeof element == 'string') {
		element = $( element );
	}
	return element.value;
}
/*
* Function to get the value of a cookie
* @usage GetCookie ( name )
* @param name
* @version 1.5
*/
function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
/*
* Function to set a new Cookie
* @usage setCookie ( name, value, expires, path, domain, secure )
* @param name
* @param value
* @param expires
* @param path
* @param domain
* @param secure
* @version 1.0
*/
function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}
/*
* Function to check all checkboxes within a table
* @usage selectCookie ( name , path , domain )
* @param name
* @param path
* @param domain
* @version 1.2
*/
function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) {
		document.cookie = name + '=' +
		( ( path ) ? ';path=' + path : '') +
		( ( domain ) ? ';domain=' + domain : '' ) +
		';expires=Thu, 01-Jan-1970 00:00:01 GMT';
	}
}
/*
* Function to open a new window
* @usage openWindow(name, url, width, height, scroll )
* @param (name, url, width, height, scroll ) name: window name, url: page to be opened, width: window width, height: window height, scroll: window scroll
* @version 1.0
*/
function openWindow ( name , url , width , height , scroll ) {
	// Set Variables to position screen in the middle of the page
	var left = (screen.width) ? (screen.width-width)/2 : 0;
	var top = (screen.height) ? (screen.height-height)/2 : 0;

	// Open the new window
	// Set all to 0 except status cuase we need to show this for usability
	window.open(url,name,'left='+left+',top='+top+',toolbar=0,location=0,directories=0,status=1, menubar=0,scrollbars='+scroll+',resizable=0,width='+width+',height='+height);
}

/*
* Function to count charactors on a text field
* @usage countText ( field, countfield, maxlimit )
* @param ( field, countfield, maxlimit ) field: textarea that we are counting, countfield: field that updates with the true left charactors, maxlimit: max charactors
* @version 1.5
*/
function countText ( field, countfield, maxlimit ) {
	if ( document.getElementById && document.createTextNode ){
		// Lets set come variables
		var fld = $( field );
		var count = $( countfield );
		// if too long...trim it!
		( fld.value.length > maxlimit ) ? fld.value = fld.value.substring( 0, maxlimit ) : count.innerHTML = ( maxlimit - fld.value.length )
	}
}

/*
* Function to show or hide an element based on mouse event
* @usage showHideElement ( element )
* @param ( element ) element that needs the function applied
* @version 1.5
*/
function showHideElement ( element ) {
	var div = document.getElementById( element );
	( div.style.display == "block" || div.style.display == "" ) ? div.style.display = "none" : div.style.display = "block" ;
}
/*
* Function to show or hide an element based on mouse event via a checkbox
* @usage showHideCheckbox ( element )
* @param ( element ) checkbox that needs the function applied
* @version 1.4
*/
function showHideCheckbox ( element , checkbox ) {
	// set the element variables
	var div = document.getElementById ( element ), chk = document.getElementById ( checkbox );
	( chk.checked ) ? div.style.display = "none" : div.style.display = "block";
}
/*
* Function to show or hide an element based on mouse event via a radio button
* @usage showHideRadioButton ( element, show )
* @param ( element, show ) radio button that needs the function applied, show: if you want to show the element or hide it
* @version 1.2
*/
function showHideRadioButton ( element , show ) {
	// set the element variables
	var div = document.getElementById ( element );
	( show ) ? div.style.display = "block" :  div.style.display = "none";
}
/*
* Function to show or hide an element based on mouse event via a radio button
* @usage showHideRadioButton ( element , selectbox , index )
* @param ( element , selectbox , index ) element: element effected, selectbox: the select box that needs to be validated, index: which index is the one to be selected
* @version 1.5
*/
function showHideSelectBox ( element , selectbox , index ) {
	// set the element variables
	var element = document.getElementById ( effected ), sel = document.getElementById ( selectbox );
	( sel.selectedIndex != index ) ? element.style.display = "none" : element.style.display = "block";
}

/*
* Function to show or hide an element based on mouse event via a radio button
* @usage showHideHomePageFileInputs ( )
* @param element
* @param element
* @version 1.5
*/
function showHideHomePageFileInputs ( element , alternative ) {
	$(element).style.display = "block";
	$(alternative).style.display = "none";
}

/*
* Function document.getElementsByClassName to find all element with a certain className
* @usage element.getElementsByClassName ( clsName )
* @param ( clsName ) the class you want to find
* @version 1.5
* @author 
*/
document.getElementsByClassName = function( clsName ){
	// Make the return value into a new arry
	var retVal = new Array();
	// Go through ALL Elements in the DOM by using the *
    var elements = document.getElementsByTagName("*");
	// Loop through ALL elements as defined
    for( var i = 0;i < elements.length;i++ ) {
		// Find all elements with a className
        if( elements[i].className.indexOf(" ") >= 0 ){
            var classes = elements[i].className.split( " " );
            for( var j = 0; j < classes.length; j++ ){
                if( classes[j] == clsName )
					// Return all elements by using the push() method which adds the next
					// element to the array of elements with the same classname
                    retVal.push( elements[i] );
            }
        }
        else if(elements[i].className == clsName)
            retVal.push ( elements[i] );
    }
	// Return the value
    return retVal;
}
/*
* Function to add a load event to the page when it loads
* to load a function with parameters we need to use addLoadListener ( function () { loadfunction ( parameters ) })
* @usage addLoadListener ( func )
* @param ( func ) the function you want to load
* @version 1.4
* @author 
*/
function addLoadListener( func ) { 
	if (typeof window.addEventListener != 'undefined') { //Check for window.addEventListener (FireFox)
    	window.addEventListener('load', func, false); // Set for FF
  	}
  	else if (typeof document.addEventListener != 'undefined') { // Check for document.addEventListener (FireFox)
    	document.addEventListener('load', func, false);
  	}
  	else if (typeof window.attachEvent != 'undefined') { // Check for window.attachEvent (IE)
    	window.attachEvent('onload', func);
  	}
  	else {
    var oldfn = window.onload;
    	if (typeof window.onload != 'function') {
      		window.onload = func;
    	}
    	else {
      		window.onload = function() {
        		oldfn();
        		func();
      		};
    	}
  	}
}
/*
* Function to add a event to a certain element
* to load a event with parameters we need to use attachEventListener ( function () { loadfunction ( parameters ) })
* @usage attachEventListener (  target, eventType, functionRef, capture  ) target: which element, eventType: which event, functionRef: which function, capture: true / false;
* @param ( func ) the function you want to load
* @version 1.1
* @returns Boolean
* @author 
*/
function attachEventListener( target, eventType, functionRef, capture ) {
	if (typeof target.addEventListener != "undefined") { //Check for target.addEventListener (FireFox)
		target.addEventListener(eventType, functionRef, capture); // Set the listener
	}
	else if (typeof target.attachEvent != "undefined") { // Check for target.attachEvent (IE)
		target.attachEvent("on" + eventType, functionRef);
	}
	else {
		eventType = "on" + eventType;

		if (typeof target[eventType] == "function") {
			var oldListener = target[eventType];

			target[eventType] = function() {
				oldListener();
				return functionRef();
			}
		}
		else {
			target[eventType] = functionRef;
		}
	}
	return true;
}
/*
* Function to remove an event to a certain element
* to load a event with parameters we need to use attachEventListener ( function () { loadfunction ( parameters ) })
* @usage detachEventListener (  target, eventType, functionRef, capture  ) target: which element, eventType: which event, functionRef: which function, capture: true / false;
* @param ( func ) the function you want to load
* @version 1.2
* @author 
*/
function detachEventListener( target, eventType, functionRef, capture ) {
	if (typeof target.removeEventListener != "undefined") {
		target.removeEventListener(eventType, functionRef, capture);
	}
	else if (typeof target.detachEvent != "undefined") {
		target.detachEvent("on" + eventType, functionRef);
	}
	else {
		target["on" + eventType] = null;
	}
	return true;
}
/*
* Function to stop the default action of a element
* @usage stopDefaultAction ( event ) which event we want to stop
* @param ( event ) the event we want to stop
* @version 1.1
* @returns Boolean
* @author 
*/
function stopDefaultAction ( event ) {
	event.returnValue = false;
	if (typeof event.preventDefault != "undefined") {
	    event.preventDefault();
  	}
  return true;
}
/*
* Function to scroll to the top of the page
* @usage scrollToPagetop ( event ) which event we want to stop
* @version 1.0
* @returns Boolean
* @author greg shiers
*/
function scrollToPagetop ( ) {
	scroll(0,0);
}
/*
* Function to clear the innerHTML of an element
* @usage clearInnerHtml ( event ) which event we want to stop
* @params element
* @params focus_element
* @version 1.0
* @returns Boolean
* @author Greg Shiers
*/
function clearInnerHtml ( element , focus_element ) {
	if ( typeof element != "undefined" ) { 
		$( element ).innerHTML = '';
	}
}
// Array.prototype.inArray
// inArray Prototype Array object by EmbiMedia
Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
}
/**
* Function that inserts and element after a certain one
* @param parent
* @param node
* @param referenceNode
* @version 1.6
* @author Greg Shiers
*/
function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}
/**
* Function to get the target of an Event
* @param event 
* @version 1.2
* @returns String
* @author Greg Shiers
*/
function getEventTarget( event ) {
	var targetElement = null;
	if (typeof event.target != "undefined") {
		targetElement = event.target;
	}
	else {
		targetElement = event.srcElement;
	}
	while (targetElement.nodeType == 3 && targetElement.parentNode != null) {
		targetElement = targetElement.parentNode;
	}
	return targetElement;
}
/**
* Fucntion to find the scroll position of an element
* @version 1.4
* @returns Array
* @author Greg Shiers
*/
function getScrollingPosition( ) {
	//array for X and Y scroll position
	var position = [0, 0];
	//if the window.pageYOffset property is supported
	if( typeof window.pageYOffset != 'undefined' ) {
		//store position values
		position = [
		window.pageXOffset,
		window.pageYOffset
		];
	}
	//if the documentElement.scrollTop property is supported
	//and the value is greater than zero
	if(typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0) {
		//store position values
		position = [
		document.documentElement.scrollLeft,
		document.documentElement.scrollTop
		];
	}
	//if the body.scrollTop property is supported
	else if(typeof document.body.scrollTop != 'undefined') {
		//store position values
		position = [
		document.body.scrollLeft,
		document.body.scrollTop
		];
	}
//return the array
return position;
}
/**
* Fucntion to find the position of the mouse
* @version 1.0
* @returns Array
* @author Greg Shiers
*/
function getMousePosition(event)
{
	var mouse = [0,0];
	if (typeof event == "undefined") {
		var event = window.event;
	}
	if (event.pageX || event.pageY) {
		mouse[0] = event.pageX;
		mouse[1] = event.pageY;
	}
	else if (event.clientX || event.clientY)
	{
		mouse[0] = event.clientX;
		mouse[1] = event.clientY;
	}
	return mouse;
}
/*
* Function to stop the default action of a element
* @usage findFocus ( ) loads on pageload
* @version 2.0
* @author Greg Shiers
*/
function findFocus() {
	var form, elements;
	if ( document.forms[0] != 'undefined' || document.forms[1] != 'undefined' ) { // Check that there is a form
		// find the form
		if ( document.forms[0] && document.forms[0].getAttribute('id') != "login" ) {
			form = document.forms[0];
			elements = form.elements[1]; // We select elements[1] because the elements[0] is the fieldset
			if ( elements ) { // If there is an element lets focus onto it
				if (elements.type=="text" || elements.type=="textarea" || elements.type=="password" ) {
					elements.focus();
				}
			}
		}
		else if ( document.forms[1] ) { 
			form = document.forms[1];
			elements = form.elements[1]
			if ( elements ) { // If there is an element lets focus onto it
				if (elements.type=="text" || elements.type=="textarea" || elements.type=="password" ) {
					elements.focus();
				}
			}
		}
		else { return false; } // return false if there is no element for either
	}
	else { return false; }
}
// Add the load listener to the find the focus ;)
addLoadListener( findFocus );

/*
* Opens a rel="external" in a new window, to validate in XHTML strict
* This code was found on http://www.sitepoint.com/article/standards-compliant-world in order to be able to validate a page with 
* opening a new link in a new window without target="_blank"
* @usage addLoadListener ( externalLinks );
* @version 1.0
* @author www.sitepoint.com
*/
function externalLinks(){
	if (!document.getElementsByTagName) return; // Check for DOM / Browser compatability
	var anchors = document.getElementsByTagName("a"); // Set var, which will narrow down all the a elements in the document
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";
	}
}
// Load this function on page load
addLoadListener ( externalLinks );

/*
* Function to preload any icons / images that we might use for dynamic content
* @usage preloadImages (  ) 
* @version 1.5.2
* @author 
*/
function preloadImages () {
	// This is not a function, but will load images on the fly as we moive along parsing the page
	var names = ['progress'];
	// Create an object to pass the above array through the for loop below
	var objects = [];
	
	// Loop through all the images if there are more than 1
	for (var i = 0; i < names.length; i++) {
		objects[i] = new Image(); // Create the image
		objects[i].src = '/images/icons/'+names[i] + '.gif'; // Give it a src
	}
}
// Load this function on page load
addLoadListener ( preloadImages );

/**
* Swaps the main image on the products page
* @param targetID
* @param imageSRC
* @param imageID
* @param hintID
* @param productID
* @version 
* @returns 
* @type 
* @author Greg Shiers
*/
function swapImage( targetID , imageSRC , imageID , hintID , productID ){
	// Try and see if we've found the relevant images and divs
	try {
	// We make sure that the flower care box is hidden
	
		if( $( targetID ) ) {
			$( targetID ).setAttribute('src', imageSRC );
			if( $(hintID) ){
				$(hintID).setAttribute('href', '/hint/'+productID+'/'+imageID);
			}		
		}
	}
	catch ( error ) {
		return null;
	}
}

/**
* Swaps the main image on the products page
* @param elements
* @version 
* @returns 
* @type 
* @author Greg Shiers
*/

function clearForm ( form ){
	var form = document.forms[0];
	// Loop through all elements in the form
	for ( var i = 0; i < form.length; i++ ) {
		var inputs = form[i]; // Set inputs as each of the form[i]
		switch ( inputs.type ) {
			// Check for input
			case 'text' :
				inputs.value = '';
			break;
			// Check for radio box or checkbox
			case 'radio' :
			case 'checkbox' :
				inputs.checked = false;
			break;
			// Check for select boxes
			case 'select-one' :
			case 'select-multiple' :
				inputs.selectedIndex = 0;
			break;
		}
	}
}
/**
* Function that created the colour picker display
* @param event
* @version 1.8
* @author Greg Shiers
*/
function displayPicker(event){
	if(typeof event=="undefined"){
		event = window.event;
	}
	if($('pick_tbl')){
		if($('pick_tbl').innerHTML !=''){
			$('pick_tbl').innerHTML = '';
		}
	}
	var html;
	var column_count=1;
	var td_across=8;
	var scrollingPosition = getScrollingPosition();
	var cursorPosition=[0, 0];
	
	if(typeof event.pageX != "undefined" && typeof event.x != "undefined"){
		cursorPosition[0]=event.pageX;
		cursorPosition[1]=event.pageY;
	}
	else{
		cursorPosition[0]=event.clientX+scrollingPosition[0];
		cursorPosition[1]=event.clientY+scrollingPosition[1];
	}
	var coloursArray  = ['000000','993300','333300','003300','003366','000080','333399','333333','800000','FF6600','808000','008000','008080','0000FF','666699','808080','FF0000','FF9900','99CC00','339966','33CCCC','3366FF','800080','999999','FF00FF','FFCC00','FFFF00','00FF00','00FFFF','00CCFF','993366','C0C0C0','FF99CC','FFCC99','FFFF99','CCFFCC','CCFFFF','99CCFF','CC99FF','FFFFFF'];
	var x_axis = cursorPosition[0]+20;
	var y_axis = cursorPosition[1]-5;
	html='<table id="picker" cellpadding="0" cellspacing="0" style="z-index:1000;positon: absolute; left:'+x_axis+'px;top:'+y_axis+'px'+';">\n<tr>\n';
	html+='<tr><td colspan="8" style="text-align: right;"><a href="/" onclick="$(\'pick_tbl\').innerHTML=\'\';return false;" style="width: auto; height: auto; border: 0;font-size: 90%; color: #f00; text-decoration: none;">Close<img src="/images/icons/close.gif" width="10" height="10" alt="Close this picker" title="Close this picker" class="icol" /></a></td></tr>';
	for ( var i=0; i<coloursArray.length; i++){
		if(column_count>td_across){
			html+='<tr>';
			column_count=1;
		}
		html += '<td><a href="/" style="background-color:#'+coloursArray[i]+'" class="'+coloursArray[i]+'" onclick="setInputColour(this);return false;"></a></td>\n';
		column_count++;
		
		if(column_count>td_across){
			html+='</tr>';
		}
	}
	if(column_count>td_across){
		html+="</table>";
	}
	else{
		html+="</tr></table>";
	}
	var div=document.createElement('div');
	div.id='pick_tbl';
	$('container').appendChild(div);
	$('pick_tbl').innerHTML=html;
}
/**
* Function that sets the input field valiable
* @param element
* @version 1.4
* @author Greg Shiers
*/
function setInputField(element){
	target_input = element;
}
/**
* Function that sets the input colour
* @param element
* @version 1.5
* @author Greg Shiers
*/
function setInputColour(element){
	$(target_input).style.backgroundColor='#'+element.className;
	$(target_input).value = element.className;
	$('picker').style.display='none';
}
/**
* Function to initialize all the picker block if more than 1
* @version 1.4
* @author Greg Shiers
*/
function initPickerBlocks(){
	var pickers=['pickit'];
	if($('pickit')){
		for(var i=0;i<pickers.length;i++){
			attachEventListener($(pickers[i]),"click",displayPicker,false);
		}
	}
}
addLoadListener(initPickerBlocks);
/**
* Function that moves facilitators from the select box and creates a table
* @param from
* @param to
* @version 1.5
* @author Greg Shiers
*/
function moveSelected (from, to) {
	var i, j, error = 0;
	var f = $(from);
	var t = $(to).getElementsByTagName('tr');
	for ( i = 0; i < f.length; i++ ) {
		error = 0;
		if ( f[i].selected ) {
			for ( j = 0; j < t.length; j++ ) {
				if (f[i].value == t[j].getElementsByTagName('td')[0].innerHTML) {
					error = 1;
				} 
			}
			if (!error) {
				addTableRow(f[i].text, f[i].value);
			}
		} 
	} 
}
/**
* Function that adds a new table row to the populated table
* @param value
* @param select
* @version 1.5
* @author Greg Shiers
*/
var count = 70;
function addTableRow(value,selected) {	
	var html;
	count++;
	var c_td1 = document.createElement('td');
		c_td1.style.display="none";
	var c_td2 = document.createElement('td');
	var c_td3 = document.createElement('td');
	var c_td4 = document.createElement('td');

	var tr = document.createElement('tr');
		tr.id = "row"+count;
	var target = $("to").getElementsByTagName('tbody')[0];
	
	var new_row = target.appendChild(tr);
	var theNode = document.createTextNode(value);
	
	var td1 = new_row.appendChild(c_td1);
		td1.appendChild(document.createTextNode(selected));
	var td2 = new_row.appendChild(c_td2);
		td2.innerHTML = value;
	var td3 = new_row.appendChild(c_td3);
		td3.innerHTML = generateFacilitatorLevels();
	var td4 = new_row.appendChild(c_td4);
		td4.innerHTML = createDeleteButton("row"+count)+'<input type="checkbox" name="checkbox_'+count+'" id="checkbox_'+count+'" value="'+count+'" />';
}
/**
* Function that updates the hidden field with comma separated values of facilitator ID's
* @version 1.6
* @author Greg Shiers
*/
function saveSelected () {
	var f = $("to").getElementsByTagName('tbody')[0].getElementsByTagName('tr');
	var t_value = '';
	for (i = 0; i < f.length; i++) {
		if (i < f.length-1) {
			t_value += f[i].getElementsByTagName('td')[0].innerHTML + ',';
		}
		else {
			t_value += f[i].getElementsByTagName('td')[0].innerHTML;
		}
	}
	$('facilitators_values').value = t_value;
}
/**
* Function that creates the dropdown menu with facilitator levels
* @version 1.6
* @returns string
* @author Greg Shiers
*/
var counter = 70;
function generateFacilitatorLevels(){	
	counter++;
	var levels = ["Main facilitator","Co facilitator","Observer"];
	var html;
	html = "<select name=\"facilitator_"+count+"\">\t\t";
	html += "<option value=\"0\">Not Assigned</option>\n\t\t\t\t";
	for ( var i=0;i<levels.length;i++ ) {
		html += "<option value=\""+(i+1)+"\">"+levels[i]+"</option>\n\t\t\t\t";
	}
	html +="</select>";
	return html;
}
/**
* Function that creates the delete button
* @param ID
* @version 1.3
* @returns string
* @author Greg Shiers
*/
function createDeleteButton(ID) {	
	var img = "<img src=\"/images/icons/delete.gif\" />";
	var href = '<a href="/" title="" onclick="removeFacilitatorRow(\''+ID+'\');return false;">'+img+'</a>';
	return href;
}
/**
* Function that removes a row from the falicatators table
* @param ID
* @version 1.2
* @author Greg Shiers
*/
function removeFacilitatorRow(ID) {	
	var parent = $("to").getElementsByTagName('tbody')[0];
		parent.removeChild($(ID));
}

/**
* Function that selects a column of checkboxes
* @param trig
* @param tbl
* @param column
* @version 1.2
* @author Greg Shiers
*/

function checkAllCheckboxesInTableColumn( trig, tbl , column ) {	
	var trigger = $(trig);
	var table = $(tbl);
	var rows  = table.getElementsByTagName('tbody')[0].getElementsByTagName('tr');
		for ( var i = 0; i < rows.length; i++ ) {	
			var row = rows[i].getElementsByTagName('td')[column].getElementsByTagName('input')[0];
			(trigger.checked) ? row.checked = true : row.checked = false;
		}
}

/**
* Function the checks the "Check all" checkbox is all the checkboxes in the column is checked
* @param trigger
* @param target
* @param column
* @version 1.2
* @author Greg Shiers
*/

function setCheckAllStatus ( trigger , target , column ) { 
	if ( $(trigger) ) {
		var checked = $(trigger).getElementsByTagName('tbody')[0].getElementsByTagName('tr');
		var count = 0;
		for ( var i = 0; i < checked.length; i++) {	
			var chk = checked[i].getElementsByTagName('input')[column];
			count += (chk.checked) ? 1 : 0;
		}
		return ( count == checked.length ) ? $(target).checked = true : $(target).checked = false;
	}
	else {
		return false;
	}
}


if ($('tbl')) {
addLoadListener( function () {	
	setCheckAllStatus('tbl','check_all',0)
});
}

/**
* Suckerfish menu loader
* @param 
* @version 
* @returns 
* @type 
* @author Greg Shiers
*/
if ($('nav_left')) {
sfHover2 = function() {
	var sfEls2 = document.getElementById("nav_left").getElementsByTagName("LI");
	for (var j=0; j<sfEls2.length; j++) {
		sfEls2[j].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls2[j].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover2);
}
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


// ]]>