function xmlhttpConnection () {
  var xmlhttpObj;
  if (window.XMLHttpRequest) {
    xmlhttpObj = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    xmlhttpObj = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (!xmlhttpObj) return null;
  this.connect = function(requestUrl, requestMethod, queryString, doneFunction) {
    if (!xmlhttpObj) return false;
    requestMethod = requestMethod.toUpperCase();
    if (requestMethod == "GET") {
      if (queryString != "") { queryString = "?" + queryString; }
      xmlhttpObj.open(requestMethod, requestUrl + queryString, true);
      queryString = "";
    } else {
      xmlhttpObj.open(requestMethod, requestUrl, true);
      xmlhttpObj.setRequestHeader("Method", "POST " + requestUrl + " HTTP/1.1");
      xmlhttpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    }
    xmlhttpObj.onreadystatechange = function() {
      if (xmlhttpObj.readyState == 4) { doneFunction(xmlhttpObj); }
    }
    xmlhttpObj.send(queryString);
  }
}

function loadissue(issueurl, objectId) {
  var loader = new xmlhttpConnection();
  if (!loader || !document.getElementById) { return true; }
  var loaderDone = function (oXML) {
    var text = oXML.responseText;
    var foreground = document.getElementById(objectId);
    foreground.innerHTML = oXML.responseText;
  }
  loader.connect(issueurl,'GET','',loaderDone);
  return false;
}

//Opacity and Fade in script.
function SetOpacity(object,opacityPct)
{
  // IE.
  object.style.filter = 'alpha(opacity=' + opacityPct + ')';
  // Old mozilla and firefox
  object.style.MozOpacity = opacityPct/100;
  // Everything else.
  object.style.opacity = opacityPct/100;
}
function ChangeOpacity(id,msDuration,msStart,fromO,toO)
{
  var element=document.getElementById(id);
  var opacity = element.style.opacity * 100;
  var msNow = (new Date()).getTime();
  opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;
  if (opacity<0) 
    SetOpacity(element,0)
  else if (opacity>100)
    SetOpacity(element,100)
  else
  {
    SetOpacity(element,opacity);
    element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",1);
  }
}
function FadeIn(id)
{
  var element=document.getElementById(id);
  if (element.timer) window.clearTimeout(element.timer); 
  var startMS = (new Date()).getTime();
  element.timer = window.setTimeout("ChangeOpacity('" + id + "',1000," + startMS + ",0,100)",1);
}
function FadeOut(id)
{
  var element=document.getElementById(id);
  if (element.timer) window.clearTimeout(element.timer); 
  var startMS = (new Date()).getTime();
  element.timer = window.setTimeout("ChangeOpacity('" + id + "',1000," + startMS + ",100,0)",1);
}

function FadeInImage(foregroundID,newImage)
{
  var foreground=document.getElementById(foregroundID);
  SetOpacity(foreground,0);
  var newElement=document.getElementById('text2');
  foreground.innerHTML = newElement.innerHTML;
  if (foreground.timer) window.clearTimeout(foreground.timer); 
  var startMS = (new Date()).getTime();
  foreground.timer = window.setTimeout("ChangeOpacity('" + foregroundID + "',1000," + startMS + ",0,100)",10);
}
