//---------------------------------------------
//     Quick browser detect v0.01 Kirk Bentley [kbentley@datalink.net.au]  
//---------------------------------------------
//     Copyright 2004 Datalink.net.au  
//---------------------------------------------  
findBrowserFn = function(){  
     var browser;  
     if(navigator.userAgent.indexOf('Gecko') >= 0){  
          browser = 'gecko';  
     }else if(navigator.userAgent.indexOf('Safari') >= 0){  
          browser = 'safari';  
	}else if(navigator.userAgent.indexOf('MSIE') >= 0  && navigator.userAgent.indexOf('MSIE 5.') >= 0  && navigator.userAgent.indexOf('Win') >= 0){
		browser = 'ie5';
	}else if(navigator.userAgent.indexOf('MSIE') >= 0 && navigator.userAgent.indexOf('Win') >= 0){
		browser = 'iePc';
	}else if(navigator.userAgent.indexOf('MSIE') >= 0 && navigator.userAgent.indexOf('Mac') >= 0){
		browser = 'ieMac';
     }  
     return browser;  
}  
  
var browser     = findBrowserFn();  
  
//---------------------------------------------  
//     Drop Down Navigation v0.01 Kirk Bentley [kbentley@datalink.net.au]  
//---------------------------------------------  
//     Copyright 2004 Datalink.net.au  
//---------------------------------------------  
function dropDownNav(){  
     //->     Find parent container.  
	var dropDown	= document.getElementById('dropDown');
     //->>     Find triggers.  
	var pAr	= dropDown.getElementsByTagName('dl');
       
     function initFn(){  
          //-->     Loop through triggers and assign events.  
          for(x = 0; x < pAr.length; x++){  
               var pTrigger     = pAr[x];  
               //-->     Find correct child node to display.  
               for(i = 0; i < pTrigger.childNodes.length; i++){  
                    pTrigger.cNode     = pTrigger.childNodes[i];  
                    if(pTrigger.cNode.tagName == 'DD'){  
                         break;  
                    }
               }
               //-->     Mouse over events  
               pTrigger.onmouseover     = function(){  
				this.cNode ? this.cNode.className = 'show':null;
				this.cNode && browser == 'iePc' ? this.cNode.style.top = '-0.1em':null;  //<-- Dodgey... add this style rule to the ie only css hack.
				this.cNode && browser == 'ie5' ? this.cNode.style.top = '-0.35em':null;  //<-- Dodgey... add this style rule to the ie only css hack.
                    }
               //-->     Mouse out events  
	               pTrigger.onmouseout     = function(){  
	                    this.cNode ? this.cNode.className = '':null;  
	               }
	        }
          }  
	//-->	Init drop down menu.
	browser == 'iePc' || browser == 'ie5' ? initFn():null;

} 

//--------------------------------------------------------------------------
//	Swap divs v0.01 Kirk Bentley [kbentley@datalink.net.au]
//--------------------------------------------------------------------------
//	Copyright 2004 Datalink.net.au
//--------------------------------------------------------------------------
//	Arguments:		container	| id of element containing triggers.
//						  Note: Triggers are normaly anchors.
//
//	Instructions:		Make sure all triggers have a name attribute set
//				to the ID of the element you wish to show.
//--------------------------------------------------------------------------
function swapDivsFn(container){
	function initFn(){
		//-->	Find parent container.
		var m		= document.getElementById(container);
		//-->	Find triggers.
		var aAr	= m.getElementsByTagName('A');
		
		for(x = 0; x < aAr.length; x++){
			var trigger	= aAr[x];	//<-- Find triggers.
			trigger.show	= document.getElementById(aAr[x].name);	//<-- Create reference to div to show / hide.
			trigger.on	= 0;	//<--	Default state.
			
			//-->	Mouse over events.
			trigger.onmouseover	= function(){
				this.on	= 1;	//<-- Make this trigger active.
				//-->	Hide / Show div's depending on trigger active state.
				for(i = 0; i < aAr.length; i++){
					!aAr[i].on ? document.getElementById(aAr[i].name).style.display = 'none':this.show.style.display = 'block';
				}
			}
			//-->	Mouse out events
			trigger.onmouseout	= function(){
				this.on	= 0;	//<-- Return active state to default.
			}
			
		}
     }  
	//-->	Init div swap.
     initFn();
}  


/* 
	opens a print page dialogue box on the client
*/

function printIt(){
	if (window.print) {
		window.print() ;
	} else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box  WebBrowser1.outerHTML = "";
	}
}


/* 
	provides functionality for the image gallery template
*/

function DOMCall(name) {
	if (document.layers) 
		return document.layers[name];
	else if (document.all)
		return document.all[name];
	else if (document.getElementById)
		return document.getElementById(name);
}

function showPic (whichpic) {
	DOMCall('placeholder').src = whichpic.href;
	if (whichpic.title) {
		DOMCall('imageCaption').innerHTML = whichpic.title;
		DOMCall('imageCaption').className = "";
	} else {
		DOMCall('imageCaption').className = "hidden";
	}
 	return false;
}

var popCalActive;
!popCalActive ? popCalActive = 0:'';

window.onload	= function(){

	document.getElementById('flowChart') ? swapDivsFn('flowChart',1):null;

	popCalActive ? initPopCal():'';
	dropDownNav();  
}
