// =============================================================
// pop-up box javascript functions



// -----------------------------------------------------------
// Show the pop-up box

function popbox(category,topic) {
  
  // the url to load
  var url = '/util/popbox/' + category + '/' + topic + '.phtml';
  
  // size the box
  setCSSProperty('popbox','width','300px');
  setCSSProperty('popbox','height','200px');
  
  // move the box
  if( (circle_mouseX - 300) < 0 ) { gotoX = circle_mouseX; } else { gotoX = circle_mouseX - 300; }
  setCSSProperty('popbox','top',(circle_mouseY - 200) + 'px');
  setCSSProperty('popbox','left',gotoX + 'px');

  // show the box
  setCSSProperty('popbox','display','block');
  
  // load the page
  fillElement('popbox',url);
  
}


// -----------------------------------------------------------
// hide the box

function popbox_close() {
  
  // close the box
  setCSSProperty('popbox','display','none');
  
}


// -----------------------------------------------------------
// fill box based on a base url and a form name

function popbox_fill(url,formid,controls) {

  // if there is a form passed in, grab the inputs
  if(formid != '') {
  
    // start an array of parameters
    var params = new Array();

    // get the inputs for the given form
    inputs = document.getElementById(formid).getElementsByTagName('input');
    for(var i = 0; i < inputs.length; i++) {
      params.push( inputs[i].name + '=' + inputs[i].value );
    }
  
    // fill the box
    fillElement('popbox',url + '?' + params.join('&'));
    
  } else {

    // fill the box with the url, no form element
    fillElement('popbox',url);

  }
  
}
