function opacity( id, opacStart, opacEnd, millisec )
{
  // Determine the speed for each animated frame
  var speed = Math.round(millisec / 100);
  var timer = 0;

  // Determine the direction of the fading (either in or out)
  if( opacStart > opacEnd )
  {
    // Fade the object out
    for( i = opacStart; i >= opacEnd; i-- )
    {
      setTimeout( "changeOpac(" + i + ",'" + id + "')", (timer * speed) );
      timer++;
    }
  }
  else if( opacStart < opacEnd )
  {
    // Fade the object in
    for( i = opacStart; i <= opacEnd; i++ )
    {
      setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
      timer++;
    }
  }
  else
  {
    // This fork is intentionally left blank for the time being
    // If we are neither fading in nor out, the function does nothing
  }

} // end function opacity()

//change the opacity for different browsers
function changeOpac( opacity, id )
{
  // Grab the DOM Object we are working with
  var object = document.getElementById(id).style;

  // Set the various opacity levels for the different
  // types of browsers
  object.opacity = (opacity / 100);
  object.MozOpacity = (opacity / 100);
  object.KhtmlOpacity = (opacity / 100);
  object.filter = "alpha(opacity=" + opacity + ")";
} 

function shiftOpacity(id, millisec)
{
  // If the element is currently not visible, we will make it visible
  // The idea is simply to shift from one transparency to another
  // without the developer needing to define this
  if( document.getElementById( id ).style.opacity == 0 )
    opacity( id, 0, 100, millisec );
  else
    opacity( id, 100, 0, millisec );
} 

function QS_Focus( fixed, element )
{
  document.getElementById( fixed ).style.display = 'none';
  document.getElementById( element ).style.display = 'block';
}

function QS_Blur( fixed, element )
{
  document.getElementById( element ).style.display = 'none';
  document.getElementById( fixed ).style.display = 'block';
}


function AV_Dropdown_Open( filename, updateDiv, tableWidth, extraParams, update )
{
  // Update the div layer first if requested
  if( update == true )
    dropdown_update_div( filename, updateDiv, tableWidth, extraParams );

  // Display the div layer
  document.getElementById( updateDiv ).style.display = 'block';

  // Display the close button layer
  document.getElementById( updateDiv + '_close' ).style.display = 'block';

} // end function AV_Dropdown()


function AV_Dropdown_Close( updateDiv )
{
  // Hide the div layer
  document.getElementById( updateDiv ).style.display = 'none';
  document.getElementById( updateDiv + '_close' ).style.display = 'none';

} // end function AV_Dropdown_Close()


function AV_Dropdown_Update( filename, updateDiv, tableWidth, extraParams )
{
  // Create a loading table
  var loadTable = '<table cellpadding="0" cellspacing="0" style="background-color: #ffffff; width: ' + tableWidth + 'px; min-height: 100px;">'
                + '<tr>'
                + '  <td style="padding-top: 20px; text-align: center; font-size: 14px; color: #333333;">'
                + '    <img src="themes/Default/images/ajax/ajax_loader.gif" /> ...loading</img>'
                + '  </td>'
                + '</tr>'
                + '</table>';

  // Set the loading animation before we do anything
  document.getElementById( updateDiv ).innerHTML = loadTable;

  // Create the parameter list
  var params = "tableWidth=" + tableWidth + extraParams;

  // Process the AJAX POST request
  AJAX_POST( filename, params );

  // Update the form when the AJAX process finishes
  xmlhttp.onreadystatechange = function()
  {
    if( (xmlhttp.readyState == 4) && (xmlhttp.status == 200) )
    {
      // Update the Message Box
      document.getElementById( updateDiv ).innerHTML = xmlhttp.responseText;
    }
  }

} // end function AV_Dropdown_Update()


function AV_Update_Input( hiddenField, hiddenValue, inputField, inputValue, updateDiv )
{
  // Update the hidden field with the foreign ID
  document.getElementById( hiddenField ).value = hiddenValue;

  // Update the form field with the text
  document.getElementById( inputField ).value = inputValue;

  // Once the elements have been updated, we need to close the div
  document.getElementById( updateDiv ).style.display = 'none';
  document.getElementById( updateDiv + '_close' ).style.display = 'none';

} // end function AV_Update_Input()

