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 getElementsByTagAndName(tag, name) {
    
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute("name");
          if(att == name) {
               arr[iarr] = elem[i];
               iarr++;
          }
     }
     return arr;
}

function invertVisibilityLayers()
{
  var i, visStr,disStr, obj, args = invertVisibilityLayers.arguments;
  for (i=0; i<(args.length); i++)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = "hide";
	  if (obj.style)
      {
        obj = obj.style;
        if(obj.visibility == 'visible') 
		{
			visStr = 'hidden';
			disStr = 'none';
		}
        else 
		{
			if(obj.visibility == 'hidden')
			{
				visStr = 'visible';
				disStr = 'block';
			}
	  	}
      }
      obj.visibility = visStr;
      obj.display = disStr;
    }
  }
  return visStr == 'visible';
}

function toggle(id)
{
	invertVisibilityLayers(id)
}

function functionExists(functionName)
{
  var exists = true;
  try{
    exists = typeof(eval(functionName))=="function";
  }catch(e){
    exists = false;
  }
  return exists;
}