/* <SCRIPT> */
// All global Client-Side JavaScript functions go here

// Creates a popup window with the image filename $fname
// x and y are the pixel dimensions of the image (use PHP function image_size())
function imagePopup(fname, x, y, caption)
{
  if (caption == null)
    caption = "";
  if (x == null || x > 1024)
    x = 1024;
  else
    x += 60;
  if (y == null || y > 768)
    y = 768;
  else
    y += 135;

  w = window.open("", "imgPopup", "resizable,scrollbars, width=" + x + ", height=" + y);
  w.resizeTo(x, y)
  w.document.write("<HTML><HEAD>" +
    "<LINK rel=\"stylesheet\" type=\"text/css\" href=\"../css/master.css\">" +
    "</HEAD><BODY bgcolor=\"white\" class=\"imgPopup\">");
  if (caption != "")
  w.document.write("<TABLE>");
  w.document.write("<TR>");
  w.document.write("<TD>");
  w.document.write("<IMG src=\"" + fname + "\" height=450>");
  w.document.write("</TD>");
  w.document.write("<TD>&nbsp");
  w.document.write("</TD>");
  w.document.write("<TD valign=\"top\">");
  w.document.write("<H4>" + caption + "</H4>\n");
  w.document.write("<INPUT type=\"button\" class=\"buttons\" value=\"Close\" onclick=\"self.close()\"></INPUT>");
  w.document.write("</TD>");
  w.document.write("</TR>");
  w.document.write("</TABLE>");
  w.document.write("</BODY></HTML>");
  w.document.close();
  w.document.title = caption ? caption : fname;
  w.focus();
  w.moveTo(10, 10);
}

function popup(url, width, height)
{
  if (width == null) width = 800;
  if (height == null) height = 600;
  w = window.open(url, "popup", "resizable,scrollbars, width=" + width + ", height=" + height);
  w.moveTo(10, 10);
}

// Set the focus to named field in a form. Pass 'form.field' string as parameter.
function SetFocus(focusTo)
{
  field = eval("document." + focusTo); // Refer to field object
  if (field) // Only set focus to field if it exists in the current doc
    field.focus(); 
}

// Close current window - great for OnClick buttons
function CloseMe()
{
  window.close();
}

// Close current window and refresh the parent - useful where
// the child causes changes to the parent (what children don't?)
function CloseMeRefresh()
{
  if (opener)
    opener.location.href = opener.location;
  window.close();
}

// Resets a form - polymorphic: if formName not specified, clears first form 
// on page. This is the method to use when a page has only one form.
// The form name is specified in HTML as <FORM name="xxxx"....
function ClearForm(formName)
{
  if (formName == null)
    document.forms[0].reset();
  else
    eval("document." + formName + ".reset()");
}

/*</SCRIPT>*/



