 //GLOBAL VARIABLES AND ROUTINES FOR GENERAL PURPOSE AND MAIN INTERFACE

  var layerRef, styleSwitch, layerOpen, layerClose;
  var browserType = "old";

//Initialize variables that can be used to make functions cross browser.

	if (document.getElementById && !document.all) {
        layerRef="document.getElementById";
        styleSwitch=".style";
		layerOpen = "(";
		layerClose = ")";
		browserType = "NN5";
  
	} else if (parseInt(navigator.appVersion) >= 4) {
		if (navigator.appName == "Netscape") {
	        layerRef="document.layers";
	        styleSwitch="";
			layerOpen = "[";
			layerClose = "]";
	        browserType = "NN4";
	        document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP | Event.KEYPRESS);
		}else{
	        layerRef="document.all";
	        styleSwitch=".style";
			layerOpen = "[";
			layerClose = "]";
	        browserType = "IE4";
		}
	}
	

//GENERAL FUNCTIONS FOR SHOWING AND HIDING LAYERS

   //Accepts the layer name and shows it by setting its visibility property
   //to 'visible'

   function showLayer(layerName){
		eval(layerRef+layerOpen+'"'+layerName+'"'+layerClose+styleSwitch+'.visibility="visible"');
   }

   //Accepts the layer name and hides it by setting its visibility property
   //to 'hidden'

   function hideLayer(layerName){
		eval(layerRef+layerOpen+'"'+layerName+'"'+layerClose+styleSwitch+'.visibility="hidden"');
   }

   // Accepts the document ref (for cross=frame control)
   // AND layer name and shows it by setting its visibility property
   // to visible'

   function showXframeLayer(docRef, layerName){
		eval(docRef+layerRef+layerOpen+'"'+layerName+'"'+layerClose+styleSwitch+'.visibility="visible"');
   }

   // Accepts the document ref (for cross=frame control)
   // AND layer name and hides it by setting its visibility property
   // to 'hidden'

   function hideXframeLayer(docRef, layerName){
		eval(docRef+layerRef+layerOpen+'"'+layerName+'"'+layerClose+styleSwitch+'.visibility="hidden"');
   }


 // LOAD NEW IMAGE
 // This function receives
 //     the name of the layer where the image resides,
 //     the name of the image, and
 //     the url of the new image to be displayed
 // and replaces the current image with the new one.

 function loadImage(docRef,layerName,imageName,imgUrl) {
    //eval(docRef + layerRef+'[layerName].document.images[imageName].src=imgUrl');
	//alert(docRef + layerRef+layerOpen+"layerName"+layerClose+".document.images[imageName].src=imgUrl");
	if (browserType == "NN5") {
		document.images[imageName].src=imgUrl;
	} else {
		eval(docRef + layerRef+'[layerName].document.images[imageName].src=imgUrl');
	}
 }

 
// Dynamic DIV text content swapping

function swapHTML(docref,text,fieldName){

	if (browserType == "NN4") {
		eval(docref + "document.layers[fieldName].document.write(text)");
		eval(docref + "document.layers[fieldName].document.close()");
	} else if (browserType == "NN5") {
		rng = eval(docref + "document.createRange()");
		el = eval(docref + "document.getElementById(fieldName)");
		rng.setStartBefore(el);
		htmlFrag = rng.createContextualFragment(text);
		
		while (el.hasChildNodes()) {
			el.removeChild(el.lastChild);
		}
		el.appendChild(htmlFrag);

	} else {
		eval(docref + "document.all[fieldName].innerHTML=text");
	}
}

