 
   var xmlObj = null; 
   var id=null;
     
   function getrandom() 
   {    
    var elArr = xmlObj.responseXML.getElementsByTagName('testimonial');
        
    var min_random = 0;    
    var max_random = elArr.length;

    //max_random++;

    var range = max_random - min_random;
    var n=Math.floor(Math.random()*range) + min_random;

    return n;
    }
  
    function ReadFullTestimonial(file)
    {
        xmlObj=GetXmlHttpReqObj();
        if (xmlObj!=null)
      {
        xmlObj.onreadystatechange = function()
        {
         if(xmlObj.readyState == 4)
         { 	
	       var tt=xmlObj.responseXML.getElementsByTagName('testimonial'); 
	       var dataF = null;
	       try
	       { 	            
	           dataF = xmlObj.responseXML.getElementsByTagName('testimonial')[id].getElementsByTagName('first')[0].firstChild.nodeValue;
	       }
	       catch(e)
	       {
	           dataF = "";
	       }
	       var dataS = null;
	       try
	       { 	            
	           dataS = xmlObj.responseXML.getElementsByTagName('testimonial')[id].getElementsByTagName('second')[0].firstChild.nodeValue;
	       }
	       catch(e)
	       {
	           dataS = "";
	       }
	       var dataL = null;
	       try
	       { 	            
	           dataL = xmlObj.responseXML.getElementsByTagName('testimonial')[id].getElementsByTagName('last')[0].firstChild.nodeValue;
	       }
	       catch(e)
	       {
	           dataL = "";
	       }	
	              
           updateObj("xmlData", dataF + dataS + dataL);
           
           try
           {
              updateObj("xmlName", xmlObj.responseXML.getElementsByTagName('testimonial')[id].getElementsByTagName('name')[0].firstChild.nodeValue);
           }
           catch (e)
           {
              updateObj("xmlName","");
           }
           try
           {
              updateObj("xmlPos", xmlObj.responseXML.getElementsByTagName('testimonial')[id].getElementsByTagName('position')[0].firstChild.nodeValue);
           }
           catch (e)
           {
              updateObj("xmlPos","");
           }
         }
        }
        xmlObj.open ('GET', file, true);
        xmlObj.send ('');
        
        document.getElementById("moreTestim").style.display="none";
      }       
    }
    
    function ReadTestim(file)
    {      
      xmlObj=GetXmlHttpReqObj();
      
      if (xmlObj!=null)
      {
        xmlObj.onreadystatechange = function()
        {
         if(xmlObj.readyState == 4)
         {
	       id=getrandom();	
	       var tt=xmlObj.responseXML.getElementsByTagName('testimonial'); 
	       try
	       {
              updateObj("xmlData", xmlObj.responseXML.getElementsByTagName('testimonial')[id].getElementsByTagName('first')[0].firstChild.nodeValue);
           } 
           catch (e)
           {
              updateObj("xmlData", "");
           }
           try
           {
              updateObj("xmlName", xmlObj.responseXML.getElementsByTagName('testimonial')[id].getElementsByTagName('name')[0].firstChild.nodeValue);
           }
           catch (e)
           {
              updateObj("xmlName","");
           }
           try
           {
              updateObj("xmlPos", xmlObj.responseXML.getElementsByTagName('testimonial')[id].getElementsByTagName('position')[0].firstChild.nodeValue);
           }
           catch (e)
           {
              updateObj("xmlPos","");
           }
         }
        }
        xmlObj.open ('GET', file, true);
        xmlObj.send ('');
      }
    }
      
    function updateObj(obj, data)
    {
       var pObj = document.getElementById(obj);
       
       while (pObj.hasChildNodes())
       {
          pObj.removeChild(pObj.lastChild);
       }
       
       pObj.appendChild(document.createTextNode(data));
    }
    
    function GetXmlHttpReqObj()
    {
      var req=null;
      
      if(window.XMLHttpRequest)
      {
          req = new XMLHttpRequest();
      } else if(window.ActiveXObject)
      {
        try 
        {
                req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) 
            {
                try 
                {
                    req = new ActiveXObject("Microsoft.XMLHTTP");
                } catch(e)
                {
                     req = null;
                }
            }         
      } else 
      {
         req = null;
      }
      
      return req;
    }
    
    function ReadAllTestimonials(file)
    {
      xmlObj=GetXmlHttpReqObj();
      if (xmlObj!=null)
      {
          xmlObj.onreadystatechange = function()
          {
            if(xmlObj.readyState == 4)
            {
                var tab=document.getElementById("testimTable");
                
                var ts = xmlObj.responseXML.getElementsByTagName('testimonial');    	       
    	        
	            for (var i=0; i<ts.length; i++)
	            {
	                var testim = ts.item(i);   
	                var dataF = null;
	                try
	                { 	            
	                    dataF = testim.getElementsByTagName('first')[0].firstChild.nodeValue;
	                }
	                catch(e)
	                {
	                    dataF = "";
	                }
	                var dataS = null;
	                try
	                { 	            
	                    dataS = testim.getElementsByTagName('second')[0].firstChild.nodeValue;
	                }
	                catch(e)
	                {
	                    dataS = "";
	                }
	                var dataL = null;
	                try
	                { 	            
	                    dataL = testim.getElementsByTagName('last')[0].firstChild.nodeValue;
	                }
	                catch(e)
	                {
	                    dataL = "";
	                }
	                var name = '';
	                try
	                {
	                    name = testim.getElementsByTagName('name')[0].firstChild.nodeValue; 
	                }
	                catch (e)
	                {
	                    name="";
	                }    	            
	                var position = '';
	                
	                try
	                {
	                    position = testim.getElementsByTagName('position')[0].firstChild.nodeValue; 
	                }
	                catch (e)
	                {
	                    position = '';
	                }
    	            
	                var dataTr = document.createElement("tr");        
                    var dataTD = document.createElement("td");
                    dataTD.align="left";
                    dataTD.innerHTML="<br /> <p id='xmlData' style='padding: 10px 90px 0 90px;text-align:justify;' >"+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + dataF + "<br/>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + dataS + "<br/>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + dataL + "</p>";               
                    dataTr.appendChild(dataTD);
                    tab.appendChild(dataTr);
                    
                    var nameTr = document.createElement("tr");        
                    var nameTD = document.createElement("td");
                    nameTD.align="right";
                    nameTD.innerHTML="<p id='xmlName' style='padding: 20px 90px 0 0;'>"+name+"</p>";               
                    nameTr.appendChild(nameTD);
                    tab.appendChild(nameTr);
                    
                    var posTr = document.createElement("tr");        
                    var posTD = document.createElement("td");
                    posTD.align="right";
                    posTD.innerHTML="<p id='xmlPos' style='padding: 10px 90px 0 0;'>"+position+"</p>";
                    posTr.appendChild(posTD);
                    tab.appendChild(posTr);
	            }           
             }
            }
            xmlObj.open ('GET', file, true);
            xmlObj.send ('');
      }
    }
 