// used in the most popular ajax widget in the front page


var bgHighlight = "#e9eef3";
var bgNoHighlight = "#93b9d8";

var colorHighlight = "#666";
var colorNoHighlight = "#fff";

var xmlhttp

function getAjaxList(content_id, link_id, q, c, n, w)
{
    if (q.length==0) // if something fails
      {
      document.getElementById(content_id).innerHTML="";
      return;
      }

    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
      {
      alert ("Your browser does not support XMLHTTP!");
      return;
      }


      var tabListItems = document.getElementById(link_id).parentNode.parentNode.childNodes;
      for ( var i = 0; i < tabListItems.length; i++ ) {
        if (tabListItems[i].nodeName == "LI" ) {
            var jee = getFirstChildWithTagName(tabListItems[i], 'A');
            jee.style.backgroundColor = bgNoHighlight;
            jee.style.color = colorNoHighlight;
        }
      }


/*
    var ulElem = document.getElementById(link_id).parentNode.parentNode;
    for (var i=0; i<4; i++) {
        var aElem = ulElem.childNodes[i].childNodes[0];
        aElem.style.backgroundColor = bgNoHighlight;
        aElem.style.color = colorNoHighlight;
    }
*/
    document.getElementById(link_id).style.backgroundColor = bgHighlight;
    document.getElementById(link_id).style.color = colorHighlight;


    var url="ajax_list.php";
    url=url+"?q="+q+"&c="+c+"&n="+n+"&w="+w;
    //url=url+"&sid="+Math.random();
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4)
            if (xmlhttp.status==200)
                document.getElementById(content_id).innerHTML=xmlhttp.responseText;
    }
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}


function GetXmlHttpObject()
{
    if (window.XMLHttpRequest)
      {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      return new XMLHttpRequest();
      }
    if (window.ActiveXObject)
      {
      // code for IE6, IE5
      return new ActiveXObject("Microsoft.XMLHTTP");
      }
    return null;
}

    function getFirstChildWithTagName( element, tagName ) {
      for ( var i = 0; i < element.childNodes.length; i++ ) {
        if ( element.childNodes[i].nodeName == tagName ) return element.childNodes[i];
      }
    }

