
// Purpose:			NetAssociates Client(IE5+) GUI/Page functions
// Author:			Kieran O'Toole - NetAssociates Limited. 03/2002
// Note:			Custom made for Netassoc.com

var IE4 = (document.all) ? 1 : 0;									// IE4+	
//var IE5 = (navigator.appVersion.indexOf("MSIE 5.")!=-1) ? 1 : 0;	// IE5+
var IE6 = (navigator.appVersion.indexOf("MSIE 5.")!=-1) ? 1 : 0;	// IE6+
var IE6 = (navigator.appVersion.indexOf("MSIE 6.")!=-1) ? 1 : 0;	// IE6+
var IE7 = (navigator.appVersion.indexOf("MSIE 7.")!=-1) ? 1 : 0;	// IE7+
var mbIE6 = (IE6 || IE7) ? 1 : 0;									// IE6+
var NS4 = (document.layers) ? 1 : 0;								// Netscape ver 4-6
var NS5 = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= 5) ? 1 : 0; 
var bOK = (NS5 || document.getElementById) ? 1 : 0;			// Must be true to use this DHTML page
var isMac = (navigator.appVersion.indexOf("Mac") != -1);
var isWin = (navigator.userAgent.indexOf("Windows") != -1);

// ----------------------------------------------------------------------------- GUI
// Purpose:			hides or shows the DIV & 
//					toggles the '+' and '-' signs indicator images &
// Scope:			cross browser
function doClick(item) {
	if (item.className.toUpperCase()=="LEVEL1" || item.className.toUpperCase()=="PLUS1") {
		var sID = item.id.substr(0,item.id.length-1);
		var eTarget = getE(sID+"s");
		var eIcon = getE(sID+"i");
	  	if (eTarget.style.display=="none") {
			fnPageSecClick(eTarget,eIcon,1);		
		} else {
			fnPageSecClick(eTarget,eIcon,0);
	    }
	}
}

// Scope:			cross browser
function fnPageSecClick(eTarget,eIcon,iValue) {
	var srcID=eIcon.id.substr(0,eIcon.id.length-1);		// remove the last 2 chars
	if (iValue==null) return null;
	if (!iValue) {
		setV(eTarget,'hidden');
		if (eIcon.className.toUpperCase()=="LEVEL1") eIcon.src="/imgs/tit/butHide01.gif";
		if (eIcon.className.toUpperCase()=="PLUS1") eIcon.src="/imgs/dng/dngPlus.gif";
		fnSave(srcID,0);
	} else {
		setV(eTarget,'visible');
		if (eIcon.className.toUpperCase()=="LEVEL1") eIcon.src="/imgs/tit/butShow01.gif";
		if (eIcon.className.toUpperCase()=="PLUS1") eIcon.src="/imgs/dng/dngMinus.gif";
		fnSave(srcID,1);
	}
}

// Purpose:			load HTML into content div etc.
// Scope:			cross browser
function doRowClick(item,sTargetID) {
	var sID=item.id;
	var eTarget=getE(sTargetID);
	var oXML=getXMLHttp();
//alert("URI: "+sID+"\n\nTarget: "+sTargetID);	
	if (sTargetID=="_top") document.location.href = item.id;
	if (oXML && eTarget) {
		var sURL=sID;
		oXML.open('GET',sURL,true);
		//oXML.onreadystatechange = function() {fnHandleHTTP(oXML);}
		oXML.onreadystatechange = function() {if(oXML.readyState==4) getE(sTargetID).innerHTML=oXML.responseText;}
		oXML.send('');
	} else {
		var sURL = item.id;
		sURL=sURL.replace("&view=divbox","");
		document.location.href = sURL;							// Bounce Down browser to the ful URI
	}
}

function fnHandleHTTP(oXML) {
alert("ReadyState: "+oXML.readyState);
	if(oXML.readyState!=4) return; 				// our request is not done
	//var strDocText = oXML.responseText;
alert(strDocText);
	//eTarget.innerHTML = oXML.ResponseText;
}

// Purpose:			Opens a standard User Help window
// Scope:			cross browser function
function doHelpClick(strWord) {
	winH=window.open ("/about/technojargon/aye.asp?whatsthat="+strWord,"winWord","status=no,toolbar=no,scrollbars=yes,width=480,height=370,resizable=yes");
}

// Purpose:			Swaps one image for another.. usually from user click!
// Scope:			IE6+ only
function doSwapImage(sID,sImgURL) {
	if (sImgURL==null || sID==null || !bOK) return null; 
	if (IE4 || IE5 || IE6 || IE7 || bOK || NS4) {					// capatability
		if (sID) {
			var el = getE(sID);
			if (el) el.src = sImgURL;
		}
	}
}

// Purpose:			Saves a named pair to page specific client-side XML store
// Scope:			IE6+ only
function fnSave(sID,vValue){
	if (mbIE6 && isWin) {
		var ePersist = getE("oPersistDiv");
		if (ePersist) {
			ePersist.setAttribute(sID,vValue);									// persist object.
			ePersist.save("nxGUIPrefs");											// save into an XML Store.
		}
	}
}

// Purpose:			Retreives a named pair from a page specific client-side XML store
// Scope:			IE6+ only
function fnLoad(sID){
	if (mbIE6 && isWin) {
		var ePersist = getE("oPersistDiv");
		if (ePersist) {
			ePersist.load("nxGUIPrefs");										// The XML Store is loaded.
			var vValue=ePersist.getAttribute(sID);								// retrieve the persistent object
			return vValue; 
		}
	}
}

// Purpose:			Configures the Page sections has specified
// Scope:			IE6+ on Windows only
function fnLoadPgSections(arySec) {
var sID;
var iSec;
	if (mbIE6 && isWin) {
		for (iSec in arySec) {
			sID=arySec[iSec];
			var eTarget = getE(sID+"s");
			var eSource = getE(sID+"i");
			if (eTarget && eSource) {
				if (fnLoad(sID)==1) fnPageSecClick(eTarget,eSource,1);
				if (fnLoad(sID)==0) fnPageSecClick(eTarget,eSource,0);
			}
		}
	}
}

function setVisibility(e1,s1) {setV(e1,s1);}				// depreciated to setV

// Purpose:			Change the visibility of a positioned element.
// Scope:			cross browser function
function setV(el, val) {
 	if (bOK || IE4) {
		if (el.constructor==String) el=getE(el);
		if (!el) return;
	  	if (null==el.style) return;
	    switch (val) {
	    case "hidden":
		  el.style.visibility = "hidden";
		  el.style.display = "none";
	      break;
	    case "visible":
		  el.style.visibility = "visible";
		  el.style.display = "";
	      break; 
	    default:
		  el.style.visibility = "visible";
		  el.style.display = ""; 
		}
		return;		
	} 
	if (NS4) {      
	    switch (val) {
	    case "hidden":
	      el.NSLayer.visibility = "hide"; break;
	    case "visible":
	      el.NSLayer.visibility = "show"; break; 
	    case "inherit":
	      el.NSLayer.visibility = "inherit"; break;
	    default:
	      el.NSLayer.visibility = "";
		}
  	}
}

// purpose:			returns an HTML DOM element by ID
// Scope:			cross browser function
function getE(sID) {
	if (bOK) return document.getElementById(sID);
	if (IE4) return document.all(sID);
	if (NS4) return document.layers(sID);
}

// purpose:			legacy
function getElement(strID) {return getE(strID);}

// purpose:			toggles the visibility of an element by ID
function doShowHide(sID) {
	var eX=getE(sID);
	if (eX) {
		if (eX.style.visibility!="visible") {
			setV(eX,"visible");
		} else {
			setV(eX,"hidden");
		}
	}
}

// ----------------------------------------------------------------------------- GUI
// Purpose:			toggles a DIV between visible and hidden, and updates a img
// Note:			tested with MSIE & Gekco
function doOpenClose(strID,strImgID,intClass) {
	var eX = getE(strID);
	var eImg = getE(strImgID);
	if (eX) {
		if (eX.style.visibility == "hidden") {
			setV(eX,"visible");
			if ((eImg) && (intClass == 0)) {
				eImg.src = "/imgs/dng/dngMinus.gif";
			}
			if ((eImg) && (intClass == 1)) {
				eImg.src = "/imgs/tit/butHide01.gif";
			}
		} else {
			setV(eX,"hidden");
			if ((eImg) && (intClass == 0)) {
				eImg.src = "/imgs/dng/dngPlus.gif";
			}
			if ((eImg) && (intClass == 1)) {
				eImg.src = "/imgs/tit/butShow01.gif";
			}
		}
	}
}

// AJAX stuff
if (typeof(XMLHttpRequest)!='undefined'){    
	var getXMLHttp = function() {return new XMLHttpRequest();}
} else {
    var getXMLHttp = function(){
		var aXMLObjects=['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'];
		for(i=0; i<aXMLObjects.length; i++){ 
			try{
				return new ActiveXObject(oHTTP[i]);  
			}catch(err){}
		}   
	}
}




