var browser_internet_explorer = (document.all) ? true : false;
var browser_mozilla = (document.getElementById && !document.all) ? true : false;
var boxes = new Array();
var myrequest = makeRequest();
var idtag;

function editTarget(target, content) 
{
  document.getElementById(target).innerHTML = ""+content;
}

function editStyle(target, color, background)
{
  document.getElementById(target).style.color = color;
  document.getElementById(target).style.background = background;
}

function changeStyle(target, color, background)
{
  document.getElementById(target).style.color = color;
  document.getElementById(target+"a").style.color = color;
  document.getElementById(target+"b").style.color = color;
  document.getElementById(target).style.background = background;
}

function makeRequest()
{
  var myrequest;
  if (browser_internet_explorer)
      myrequest= new ActiveXObject("Microsoft.XMLHTTP");
  else
      myrequest= new XMLHttpRequest()
  return myrequest;
}

function getFormFields(myform, myfield)
{
  var field_string = "";
  var field_array = myfield.split(":");
  
  for (i = 0; i < field_array.length; i++)
  {
    field_value = document.forms[myform].elements[field_array[i]].value;
    
    if (field_string)
      field_string += "&";
    field_string += ""+field_array[i]+"="+field_value;
  }
  return field_string;
}

function getPage(method, myaction, id, myform, myfield)
{
  idtag=id;

  //myrequest.abort;
  myrequest.open(method, myaction);
  myrequest.onreadystatechange = getContent;
  
  if (method == "post")
  {
    myrequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    //myrequest.setRequestHeader("Content-length", parameters.length);
    //myrequest.setRequestHeader("Connection", "close");
    myrequest.send(getFormFields(myform, myfield));    
  }
  else
    myrequest.send(null);
}

function getContent()
{
  if (myrequest.readyState==4)
  {
      myresponse = myrequest.responseText;
      document.getElementById(idtag).innerHTML = myresponse;
  }
}

function hideBox(box)
{
  if (browser_mozilla) 
    document.getElementById(["box"+box]).style.display = "none";
  if (browser_internet_explorer) 
    document.all["box"+box].style.display = "none";   
}

function showBox(box)
{ 
  if (browser_mozilla) 
    document.getElementById(["box"+box]).style.display = "block";
  if (browser_internet_explorer) 
    document.all["box"+box].style.display = "block"; 
}

function hideBoxes()
{
  for (i = 0; i < boxes.length; i++)
  {
    hideBox(i)
  }
}

function setDisplay(box)
{
  hideBoxes();
  showBox(box);
}

function hideCombo(combo)
{
  if (combox == 1)
  {
    //if (browser_mozilla) 
      //document.getElementById(["combo"+combo]).style.visibility = "hidden";
    if (browser_internet_explorer) 
      document.all["combo"+combo].style.visibility = "hidden"; 
  }
}

function showCombo(combo)
{
  if (combox == 1)
  {
    //if (browser_mozilla) 
      //document.getElementById(["combo"+combo]).style.visibility = "visible";
    if (browser_internet_explorer) 
      document.all["combo"+combo].style.visibility = "visible"; 
  }
}

function preloadImages(path, files)
{
  file_array = files.split(",");
  
  for (i = 0; i < file_array.length; i++)
  {
    eval("image"+ i +" = new Image()");
    eval("image"+ i +".src = '"+ path + file_array[i] +"'");
  }
}

function rollOver(name, src)
{
  document[name].src = src;
}

function changeBkg(name, src)
{
  if (browser_internet_explorer)
  {
    document.all[name].style.background = "url("+ src +")";
  }
  if (browser_mozilla)
  {
    document.getElementById([name]).style.background = "url("+ src +")";
  }
}