var domObj=new Array();

/*------------------------------------------------------------------------------------
ba_dom overview;   	
	.purpose == changes styles of any DOHM object that has been assigned an 'id' attribute within its tag
	.call origin == MULTIPLE as follows:
baDomObjArry(); is placed in the documents onload attribute of the body tag. This establishes the domObj Array on document load;

Place one of the following in an object's behavior(i.e., onmouseover,onload,onkeydown,etc.) that will recieve the focus:
domObj['sub_menu'].setV('visible');  ~ USE TO CHANGE 1 STYLE ATTRIBUTE FOR 1 OBJECT    -------OR--------
domAcs('setV','sub_menu','visible','setBkgdColor','sub_menu','#000000','setColor','main_menu','#000000'); 
~ USE domAcs() TO CHANGE MULTIPLE -OR- 1 STYLE ATTRIBUTE(S) FOR MULTIPLE -OR- 1 OBJECT(S). See .notes below for additional information;
	
	.notes == be sure to include a 
<script language="javascript" src="/DIRECTORY OF JS FILE/ba_dom.js" type="text/javascript"></script>
tag in the <head> of your *.html document in which this function is invoked.

domAcs() syntax (see .call origin above for additional information):
domAcs("1. function", "2. object's id", "3. reqrd function var", Repeat 1, 2, & 3 for each object style you want to change)
Multiple objects AND multiple styles can be changed utilizing one function call. Ex:
	   
	<a href="/js/index.html" onmouseover="
	domAcs('setBkgdImage','m-menu','img/pretty.jpg','setBrdrColor','main_menu','#666666','setColor','s-menu','#000000');">
	this a text link in the body</a>
	
The example above changes the background image and the border color of the m-menu AND the text color of the s-menu via onmouseover behavior assigned to a text link in the body. domAcs() can be invoked from any object that can execute a JS behavior and applied to any object that has been assigned an 'id' attribute in its tag;

------------------------------------------------------------------------------------*/

function domAcs(){
	//entry script to access all domObj methods/functions in this file.
	//dAa[0] must == the name of the function to be implemented.
	var dAa=domAcs.arguments, i;
	for(i=1;i<dAa.length;i+=2){
		eval("domObj['"+dAa[i]+"']."+dAa[0]+"('"+dAa[i+1]+"')");
		//above is equiv to: domObj[obj ID name].function(function variable);
	}
}

//------------------------------------------------------------------------------------

function baDomObjArry(){
	var i,j,a,k,tV,obj,objcss,objid;
	if(document.getElementById){
		a='document.getElementsByTagName';
		k=3;
	}else if(document.all){
		a='document.all.tags';
		k=3;
	}else if(document.layers){
		a='document.layers';
		k=1;
	}else{
		return;
	}
	for(j=0;j<k;j++){
		if(k==3){
			if(j==0){
				tV=eval(a+'("div")');
			}else if(j==1){
				tV=eval(a+'("span")');
			}else if(j==2){
				tV=eval(a+'("p")');
			}
		}else{
			tV=eval(a);
		}
		for(i=0;i<tV.length;i++) {
			obj=tV[i];
			if(k==3){
				objcss=obj.style;
			}else{
				objcss=obj;
			}
			objid=obj.id;
			
			if(objid){
				domObj[objid] = new domObjProp(obj, objcss, objid);
			}
		}
	}	
}
//------------------------------------------------------------------------------------
function domObjProp(obj,css,id){
	this.obj=obj;
	this.css=css;
	this.id=id;
	this.setBkgdColor=setBkgdColor;
	this.setBkgdImage=setBkgdImage;
	this.setBrdrColor=setBrdrColor;
	this.setBorderWidth=setBorderWidth;
	this.setColor=setColor;
	this.visibility=getV;
	this.setV=setV;
	this.zIndex=getZI;
	this.setzIndex=setZI;
	this.moveabove=mveAbove;
	this.movebelow=mveBelow;
	this.sethtml=setHTML;
}

//------------------------------------------------------------------------------------
function setBkgdColor(nC){
	//sets obj background color. nC=new color.
	if(!document.layers){
		this.css.backgroundColor=nC;
	}else{
		this.css.bgColor=nC;
	}
}

//------------------------------------------------------------------------------------
function setBkgdImage(nI){
	//sets obj background image. nI=new image file name, file path or full URL.
	if(!document.layers){
		this.css.backgroundImage="url("+nI+")";
	}else{
		this.css.background.src=nI;
	}
}

//------------------------------------------------------------------------------------
function setBrdrColor(nC){
	//sets obj border color. nC=new color.
	if(!document.layers){
		this.css.borderColor=nC;
	}else{
		this.css.borderColor=nC;
	}
}

//------------------------------------------------------------------------------------

function setBorderWidth(nW){
	//sets obj border width. nW=new width.
	if(!document.layers){
		this.css.borderWidth=nW;
	}else{
		this.css.borderWidth=nW;
	}
}

//------------------------------------------------------------------------------------

function setColor(nC){
	//sets obj color. nC=new color.
	if(!document.layers){
		this.css.color=nC;
	}else{
		this.css.color=nC;
	}
}

//------------------------------------------------------------------------------------

function setBkgdTxtColors(objID,bC,tC){
		var myObj=window.document.getElementById(objID);
		myObj.style.backgroundColor=(bC); //background color
		myObj.style.color=(tC); //text color
}

//------------------------------------------------------------------------------------

function getV(){
	//returns the visibility status of the object.
	if(!document.layers){
		if(this.css.visibility){
			return this.css.visibility;
		}
	}else{
		if(this.css.visibility=="show"){
			return "visible";
		}
		if(this.css.visibility=="hide"){
			return "hidden";
		}
	}
	return "inherit";
}
//------------------------------------------------------------------------------------

function setV(nV){
	//sets the visibility status to nV.
	if(!document.layers){
		this.css.visibility=nV;
	}else{
		if(nV=="visible"){
			this.css.visibility="show";
		}else if(nV=="hidden"){
			this.css.visibility="hide";
		}else{
			this.css.visibility="inherit";
		}
	}
}

//------------------------------------------------------------------------------------

function getZI(){
	//returns the stacking order of layers. by making all the same num. the layers cannot overlap.
	return this.css.zIndex;
}
//------------------------------------------------------------------------------------

function setZI(nZ){
	//sets the obj zIndex (see getZI() for addit. notes).
	if(nZ>0){
		this.css.zIndex=nZ;
	}else{
		this.css.zIndex=0;
	}
}

//------------------------------------------------------------------------------------

function mveAbove(rO){
	//moves the obj above specified obj in z-order. rO==specified object
	this.css.zIndex=domObj[rO].css.zIndex+1;
}

//------------------------------------------------------------------------------------

function mveBelow(rO){
	//moves the obj below specified obj in z-order. rO==specified object
	var rOz=domObj[rO].css.zIndex;
	if(rOz>0){
		this.css.zIndex=rOz-1;
	}else{
		rO.css.zIndex=1;
		this.css.zIndex=0;
	}
}

//------------------------------------------------------------------------------------

function setHTML(nHTML){
	//sets the tag and text (i.e.,HTML) to appear in the obj. NOTE innerHTML is not part of the W3C stand. but both NN6 and IE support this technique.
	if(!document.layers){
		this.obj.innerHTML=nHTML;
	}else{
		with (this.obj.document){
			open();
			write(nHTML);
			close();
		}
	}
}