/* SVN: $Id: ajax_client.js 1702 2008-02-19 19:05:42Z dukemaster $ */
//var xmlHttp;

function doSave(theelement,value)
{
    var xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request")
        return false;
    }
    document.getElementById('span'+theelement).style.MozOpacity=0.50;
    var url="/comments/ajax_comments.php"
    var str;
    str = "version=0.3";
    str=str+'&elid='+theelement;
    str=str+'&value='+value;
    str=str+"&sid="+Math.random()
    xmlHttp.onreadystatechange=function () 
    {
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
        { 
            document.getElementById('span'+theelement).innerHTML = xmlHttp.responseText;
            document.getElementById('span'+theelement).style.MozOpacity=1;
        }
    }
    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xmlHttp.send(str);
}

function GetXmlHttpObject()
{ 
    //XMLhttp variable will hold the XMLHttpRequest object
    var xmlhttp = false;            
    // If the user is using Mozilla/Firefox/Safari/etc
    if (window.XMLHttpRequest) {
        //Intiate the object
        xmlhttp = new XMLHttpRequest();
        //Set the mime type
	if (typeof xmlhttp.overrideMimeType != "undefined") {
	    xmlhttp.overrideMimeType('text');
	}
    } else if (window.ActiveXObject) {
        //Intiate the object
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xmlhttp
}

function trim(str)
{
   str = str.replace(/^\s*|\s*$/g,"");
   str = str.replace(/\n/g,"");
   return str;
}
