/****************************************************************************************************************************
API.JS
   Author: 	Eric Cly
   Date:	August 11, 2003
nested api

   Function Index 

	Oject Manipulation functions **************

	fnObjShow(objectID,state)	// set objects visibility [state = visibility, 0=hidden, 1=visible]
	fnSetObjZ(objectID,z)           // **** Use this to set z-index of objects w/ the onLoad attribute of the body tag
					// **** its the only way to use the functions fnGetObjZ() and fnSwapObjZ()
	fnSwapObjZ(objectID)		// *** you must set the z-index with fnSetObjZ() for this function to work
					// *** Swaps the z-index of objects

******************************************************************************************************************************/


	var headerImg	= '';
	var menu 	= new Array();		//array to hold link and src for menu hyperlinks

	var menuKtr	= 0;			//ktr used to grow array for hyperlinks
	var kontentStr  = '';
	var isDHTML	=0;			//DHTML 	compatibility
	var isLayers	=0;			//Netscape4 	compatibility
	var isAll	=0;			//IE		compatibility
	var isID	=0;			//W3C		compatibility
	var prevZ	=0;			//DHTML 	compatibility
	var prevZObjID	=null;			//DHTML 	compatibility
	
	if(document.getElementById) {isID =1; isDHTML =1;}		//if true we are using a W2C compatible browser: IE6:5:4 & NS6:7
	else {
		if(document.all) {isAll=1; isDHTML=1; }			//if true then we are using IE4
		else {
		   browserVersion = parseInt(navigator.appVersion);	//if neither IE4:5:6 & NS6:7 check browser Version

		  //if Browser is Netscape and its version is 4 then we are using netscape4
		if((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers=1; isDHTML=1;}	
       }}


/* function fnGetDom *********************************************************************************************************

	Purpose:	Get proper syntax for manipulating objects or returning object id for Netscape4-7, and IE
	Parameters:	ObjectID =used for netscape4 way of accessing nested elements -> document.object1.object2
			ObjectID2=used for the targeted element to manipulate
			withStyle=used to either manipulate targeted object 1; return targeted object 0 *********************/


	function fnGetDom(objectID,objectID2,withStyle) {							//get the proper DOM model

		if(withStyle==1) {

			if(isID) {return (document.getElementById(objectID2).style);}
			else {
				if(isAll) {return (document.all[objectID2].style);}
			else {
				if(isLayers) {
					if(objectID1) {return (document.layers[objectID].layers[objectID2]);}
				else {
					return (document.layers[objectID2]);}
				}
			};}
		}
		else {
			if(isID){return(document.getElementById(objectID2));}
			else {
				if(isAll){return (document.all[objectID2]);}
			else {
				if (isLayers) {
					if(objectID1) {return (document.layers[objectID].layers[objectID2]);}
				else {
					return (document.layers[objectID2]);}
				}
			};}
		}
	}


/* end Detection of DOM types *********************************************************************************************/


 /* Start addMenu() ******************************************************************************

	Purpose:    Add menu items
	
	Parameters: link     = hyperlink
		    src	     = hyperlink src
		    imgSrc   = background image of cell
		    height   = height of cell
		    width    = width of cell
		    event    = events ex:[ onClick,onMouseOver,etc ]
		    method   = function event should run when activated ex:[dispMenu()]
		    clss     = class attribute

	Requires:   Global variables
		    menu    = new Array();
		    menuKtr ='';				
	
  ************************************************************************************************/

function addMenu(link,src,imgSrc,height,width,event,method,clss,fontSz){

	

	menu[menuKtr] = new Array("link","src");	//Simulate two dimentional array to hold link and src
	menuKtr=menuKtr+1;				//Grow array with new menu item with each function call
	var a	     ='';
	var td	     ='';				//temp var to concat with td Attributes
	var tdAttrib ='';				//td attribute result
	var aAttrib  ='';				//<a href> attribute result
	var menuStr	= '';				//string used to concat row and columns for table and hyperlinks
	
	if(clss   !=''){a = ' class='+clss;}				 //if a class is supplied apply class to <a href>
	if(imgSrc !=''){td= ' background=' +imgSrc; tdAttrib=td;}	 //if img Src is supplied apply background to cell
	if(width  !=''){td= ' width='+width; tdAttrib=tdAttrib+td;}	 //if width is supplied apply cell width
	if(height !=''){td= ' height='+height; tdAttrib=tdAttrib+td;}	 //if height is supplied apply cell height
	if(event  !=''){td=   event +'='+ method; tdAttrib=tdAttrib+td;} //if method and method is supplied apply cell event and method
	if(event!='' && method=='' || event=='' && method!=''){		 //if only the method or only the event is supplied give error message
		alert('Message from addMenu(): Event and Method parameter both need values!'); //display error message
		return;										//exit function
	}

	Str= '<tr><td '+ tdAttrib + '><font size="'+fontSz+'"><a href=' +src+ a +'>'+link+'</a></font></td></tr>'; 		//get cell  

	menuStr= menuStr + Str;						//update menuString with added menu item
	return menuStr;
	
}
/* End addMenu() **********************************************************************************/


function writeMenu(inStr){

	document.write('<table border=0>'+ inStr +'</table>');	//Write menu within <table> tags, menuStr is written out as: "<tr><td><a href="">menu</td></tr>"
}									//End function writeMenu()
/* End writeMenu() ********************************************************************************/

function skipLine(x){							//Skip x amount of lines
	for(a=0;a<x;a++){						//Loop through as many times as we want to skip lines

		kontentStr=kontentStr+'<br>';				//SkipLine
	}								//End loop
}									//End function skipLine()

function addSpace(x){
	for(a=0;a<x;a++){
		if(a<x-1){kontentStr=kontentStr+ '&nbsp';}
		else{kontentStr=kontentStr+ '&nbsp ';}
	}
}

function addText(inText){
	kontentStr=kontentStr+inText;
}

function addImg(inImage,border,height,width,event,method,clss,name){
	
	var im    ='';
	var imgAt ='';
	

	if(name != ''){im= ' name=' + name;imgAt=imgAt+im;}
	if(border>0)  {im= ' border=' + border;imgAt=imgAt+im;}
	if(height>0)  {im= ' height=' + height;imgAt=imgAt+im;}
	if(width>0)   {im= ' width=' + width;imgAt=imgAt+im;}
	if(clss != ''){im= ' class=' +clss;imgAt=imgAt+im;}
	if(event!='' && method=='' || event=='' && method!=''){		 
		alert('Message from addImg(): Event and Method parameter both need values!'); //display error message
		return;										//exit function
	}else{imgAt=imgAt + ' ' + event+'='+method;}
	
	kontentStr=kontentStr+'<img src='+inImage+ imgAt+'>';
}

function addLink(link,src,event,method,clss){

	var tmp='';
	var str='';

	if(clss   !=''){tmp = ' class='+clss;str=str+tmp;}
	if(event!='' && method=='' || event=='' && method!=''){		 
		alert('Message from addImg(): Event and Method parameter both need values!'); //display error message
		return;										//exit function
	}else{str=str+tmp + ' ' + event+'='+method;}

	kontentStr= kontentStr+ '<a href='+src+ str +'>' + link + '</a>';
}

function addTag(inTag){b
	kontentStr=kontentStr+inTag;
}

function fontSize(inSize){
	kontentStr=kontentStr+'<font size=' +inSize+'>';
}

function fontEndSize(inSize){
	kontentStr=kontentStr+'</font>';
}

function b(){			
	kontentStr=kontentStr+'<b>';	
}

function i(){
	kontentStr=kontentStr+'<i>';	
}

function u(){
	kontentStr=kontentStr+'<u>';	
}

function bEnd(){
	kontentStr=kontentStr+'</b>';		
}

function iEnd(){
	kontentStr=kontentStr+'</i>';		
}

function uEnd(){
	kontentStr=kontentStr+'</u>';		
}

function center(){
	kontentStr=kontentStr+'<center>';
}

function centerEnd(){
	kontentStr=kontentStr+'</center>';
}

function kly(){
	alert('hey this works');
}

function drawWaterMrk(){

	var bName;

	bName= navigator.appName;

	if(bName=='Netscape'){

			addTag ('<div id="watermark" style="position: absolute; left: 10px; top: 10px">');
			addTag ('<img src="./images/other/gear1.png" >');
			addTag ('</div>');	


	
	}else{

			addTag ('<div id="watermark">');
			addTag ('<img src="./images/other/gear1a.png" style="filter: Alpha(style=0,opacity=40)">');
			addTag ('</div>');

	}

}

/*** Object Manipulations *************************************************************************************************/



  //set the Z index of the object  
function  fnSetObjZ(objectID,objectID2,z) {

	var dom = fnGetDom(objectID,objectID2,1);
	dom.zIndex = z;

}

function fnGetObjZ(objectID,objectID2) {

	var dom = fnGetDom(objectID,objectID2,1);
	
	if(dom.zIndex != null)
		return dom.zIndex;
	return (null);
}


  //Swap the z-index of objects
function fnSwapObjZ(objectID,objectID2) {
	
	if(prevZObjID !=null)
		fnSetObjZ(prevZObjID,prevZObjID2,prevZ);



	prevZ = fnGetObjZ(objectID,objectID2);

	prevZObjID = objectID;
	prevZObjID2= objectID2; 

	fnSetObjZ(objectID,objectID2,1000);

	
}

