//Detect if NS4 or IE
var ns = (document.layers) ? true : false;
var ie = (document.all) ? true : false;

//Detect if NS6
//var ns6 = (navigator.userAgent.indexOf('Netscape6') != -1) ? true : false;
var ns6 = (!document.all && document.getElementById) ? true : false;

//Variables for IE DOM
var coll;
var styleObj;

//Create objects for NS DOM & IE DOM
if(document.layers){     
  	 coll = "";
	 styleObj = "";
}else{
     coll = "all.";
     styleObj = ".style";
}



//Generates a random number between 1 & the number of entries.  Creates an object based on the number generated and shows it.
function randomText(){
	var randNum = Math.round(Math.random() * (numEntries - 1)) + 1;
	var randObj = "entry" + randNum;
	show(randObj);
}

//Function that writes the DHTML style sheets
function writeStyle(){
     document.write('<style type="text/css">\n');
     
     for(var i=1; i<=numEntries; i++){
          document.write('#entry' + i + ' {position: absolute; left:' + leftPos +'; top:' + topPos +'; visibility: hidden;}\n');     
     }
     
     document.write('</style>')
     document.write('\n');
}

//Function that writes the layers.
function writeLayers(){
for(var i=1; i<=numEntries; i++){
	document.write('<div id="entry' + i +'">\n');
	document.write('<table border="0" cellpadding="0" cellspacing="0">\n');
	document.write('<tr>\n');
	document.write('	<td width="158">\n');
	<!--document.write('   <img src="images/spacer.gif" width="1" height="5"><br>\n');-->
	document.write('   <span id="graycontent">\n');
    document.write(eval('entry' + i));     
	document.write('</span>');
	<!--document.write('   <img src="images/spacer.gif" width="1" height="9"><br>\n');-->
	document.write('   <table cellpadding="0" cellspacing="0" border="0" width="158">\n');
	document.write('   <tr>\n');
	document.write('    <td align="right">\n');
	document.write('   	<span id="italicblack">\n');
	document.write('<br>');
	document.write(eval('title' + i));
	document.write('<br>');
	document.write(eval('company' + i));
	document.write('  	</span>\n');
	document.write('    </td>\n');
	document.write('   </tr>\n');
	document.write('   </table>\n');
	document.write('	</td>\n');
	document.write('</tr>\n');
	document.write('</table>\n');
	document.write('</div>\n');
     }
     document.write('</div>');
}
//Function that makes an object visible
function show(obj){
   if(ns6){
   		document.getElementById(obj).style.visibility = "visible";
		document.getElementById(obj).style.display = "";
   }
   else{
   		var theObj = getObject(obj);
   		theObj.visibility = "visible";
   }
}

//Function that hides an object
function hide(obj){ 
	if(ns6){
   		document.getElementById(obj).style.display = "none";
		document.getElementById(obj).style.visibility = "hidden";
   	}
	else{
   		var theObj = getObject(obj);
   		theObj.visibility = "hidden";
  	}
}

//Function that takes an object name as an argument and creates the appropriate DOM reference.
function getObject(obj){
     var theObj;
     if(typeof obj == "string"){
          theObj = eval("document." + coll + obj + styleObj);
     }
     else{
          theObj = obj;
     }
     return theObj;
} 

