// getObj
//   Cross-browser element selection.
function getObj(name)
{
  if (document.getElementById)
  {
  	return document.getElementById(name);
  }
  else if (document.all)
  {
	  return document.all[name];
  }
  else if (document.layers)
  {
    var e, i;
    e = getObjNN4(document,name);
    if (e == undefined) {
      e = getFormEl(name);
    }
    return e;
  }
}

// getObjNN4
//   Special element selection to work with Netscape 4
function getObjNN4(obj, name)
{
	var l = obj.layers;
	var foundLayer;
	for (var i=0; i < l.length; i++)
	{
		if (l[i].id == name)
		 	foundLayer = l[i];
		else if (l[i].layers.length)
			var tmp = getObjNN4(l[i],name);
		if (tmp)
		  return tmp;
	}
	return foundLayer;
}

// getFormEl
function getFormEl(name) {
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i][name] != undefined) {
      return document.forms[i][name];
    }
  }
}


// focusField
function focusField(id) {
  var e;
  e = getObj(id);
  if (e)
    e.focus();
}

// openImageWindow
//   Opens a new window with the specified image and resizes the window to hold the image.
function openCCVWindow() {
  var w;
  newWindow = window.open('CCVCode.htm','LargeImageWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=480,height=440');
  /*
  newWindow.document.write("<html><head>\n");
  newWindow.document.write("<s");
  newWindow.document.write("cript language='JavaScript'>\n");
  newWindow.document.write(" var ie5, nn4, nn6;\n");
  newWindow.document.write(" ie5=nn4=nn6=false;\n");
  newWindow.document.write(" if(document.all) ie5=true;\n");
  newWindow.document.write(" else if(document.getElementById) nn6=true;\n");
  newWindow.document.write(" else if(document.layers) nn4=true;\n");
  newWindow.document.write(" function autoResize() {\n");
  newWindow.document.write("  if(ie5) self.resizeTo((document.images[0].width+10>screen.width) ? screen.width-10 : document.images[0].width+10, (document.images[0].height+20+30>screen.height) ? screen.height-10 : document.images[0].height+20+30);\n");
  newWindow.document.write("  else if(nn6) {\n");
  newWindow.document.write("    if() self.sizeToContent();\n");
  newWindow.document.write("  }\n");
  newWindow.document.write("  else top.window.resizeTo(document.images[0].width,document.images[0].height+20+30);\n");
  newWindow.document.write("  self.focus();\n");
  newWindow.document.write(" }\n");
  newWindow.document.write("</s");
  newWindow.document.write("cript><link rel='stylesheet' href='" + css + "' type='text/css' />");  	
  newWindow.document.write("</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onload='javascript:autoResize();'><img src='" + img + "' border='0' /><br /><center>[<a href='javascript:window.close();'>Close Window</a>]</center></body></html>");
  newWindow.document.close();
  newWindow.focus();
  */
}

