// Common Functions
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

function settext (objName, newText) { //v4.01 MM's fucntion had a fuckin long name
  if ((obj=findObj(objName))!=null) with (obj)
    if (ns4) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}

function displayLayers()
{ 
  var i, visStr, obj, args = displayLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr) visStr = 'inline';
        else visStr = 'none';
      }
      obj.display = visStr;
    }
  }
}

function openWindow(winname, URLStr, left, top, width, height, menubar)
{
  var newWindow = open(URLStr, winname, 'toolbar=no,location=no,directories=no,status=no,menubar='+(menubar?'yes':'no')+',scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  return true;
}
function randomNumber(limit){
  return Math.floor(Math.random()*limit);
}

// Browser Detection
var ie4 = document.all,
	ns4 = document.layers,
	ns6 = document.getElementById && !document.all,
	isdominant = (ie4 || ns4 || ns6),
	iswin98 = navigator.appVersion.indexOf("Win")!=-1 && navigator.appVersion.indexOf("98")!=-1;
