var xmlhttp1;
var fullname;
var comment;

function ajax_view_replies_response(xmlhttp1,id)
{
    
        document.getElementById(id).innerHTML = xmlhttp1.responseText;
    

}

function loadXMLDoc(id)
{ 
 
   if((document.getElementById(id).style.display=='') ||(document.getElementById(id).style.display=='none'))
    {
        document.getElementById(id).style.display = 'block';
         document.getElementById(id).innerHTML ='<img src="eorder/images/icons/greenajaxloading.gif">';
  
      xmlhttp1=new XMLHttpRequest();    
    xmlhttp1.onreadystatechange=function() 
    { 
        if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
            ajax_view_replies_response(xmlhttp1, id);
    }
    
    
var url1="eorder/comments/test.php?q="+id+"&sid="+Math.random();
xmlhttp1.open("GET",url1,true);
xmlhttp1.send(null);
  }
     else
    {
        document.getElementById(id).innerHTML ='';
       document.getElementById(id).style.display = '';
      
    }     
  

}













function ajax_view_form_response(xmlhttp1,id)
{

    if((document.getElementById(id).style.display=='') ||(document.getElementById(id).style.display=='none'))
    {
        document.getElementById(id).style.display = 'block';
        document.getElementById(id).innerHTML = xmlhttp1.responseText;
        
    }
    else
    {
        document.getElementById(id).innerHTML = '';
       document.getElementById(id).style.display = '';
    }
}
function new_comm(id)
{
     xmlhttp1=new XMLHttpRequest();    
    xmlhttp1.onreadystatechange=function() 
    { 
        if (xmlhttp1.readyState===4 && xmlhttp1.status===200)
            ajax_view_form_response(xmlhttp1, id);
    }
var url1="eorder/comments/add_comment.php?q="+id+"&sid="+Math.random();
xmlhttp1.open("GET",url1,true);
xmlhttp1.send(null);
}

function ajax_apply_response(xmlhttp1,id)
{
    //alert(xmlhttp1.responseText);
     var form = id+"_add_new_comm";
     //alert(form);
    document.getElementById(form).innerHTML = xmlhttp1.responseText;
    eval(document.getElementById(form).innerHTML);
    //function clear_div(form)
    //{
      //alert(form);
    //   document.getElementById(form).style.display = 'none'; 
   // }
  //  setTimeout(clear_div(form),5000);
    
}







function insert_new_comm(fullname,id,comment)
{
    
     xmlhttp1=new XMLHttpRequest();    
    xmlhttp1.onreadystatechange=function() 
    { 
        if (xmlhttp1.readyState===4 && xmlhttp1.status===200)
           ajax_apply_response(xmlhttp1, id);
    }
 var params = 'name='+fullname+'&id='+id+'&text='+comment;

var url1="eorder/comments/insert.php"
/*document.getElementById('debug').innerHTML='call:'+url1;*/
xmlhttp1.open("POST",url1,true);
xmlhttp1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp1.setRequestHeader("Content-length", params.length);
xmlhttp1.setRequestHeader("Connection", "close");


xmlhttp1.send(params);
}


function change(id,color)
{
		document.getElementById(id).style.color = color;
}
