/* Author: 1ontheweb */
/* File created: 22/02/2008 */
/* Last modified: 16-Apr-2008 03:32 PM */

/* Provides client side code for Ajax operations. */

	var xhr;
   var lastRecID = 0;

	function createXHR() {
      var xhr;
      try {
      	xhr = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
      	try {
      		xhr = new ActiveXObject("Microsoft.XMLHTTP");
      	} catch (E) {
      			xhr = false;
      		}
      }
      if (!xhr && typeof XMLHttpRequest != ' undefined' ) {
      	xhr = new XMLHttpRequest();
      }
      return xhr;
	}
   
   function showTestimonial() {
   	if (xhr.readyState == 4){
      	if (xhr.status == 200) {
         	var data = xhr.responseText;
            var testimonial = data.split('|');
            lastRecID = testimonial[0];
            document.getElementById('indexquote').innerHTML = testimonial[1];
            // setTimeout('setBackgroundHighlight()', 0);
            // setTimeout('setBackgroundNormal()', 2000);
            setTimeout('getTestimonial()', 12000);
         }
      }
   }
   
   function getTestimonial() {
   	xhr = createXHR();
      xhr.onreadystatechange = showTestimonial;
		xhr.open('GET', 'get-testimonial.php?recID=' + lastRecID);
      xhr.send(null);
   }
   
   function setBackgroundHighlight() {
   	document.getElementById('indexquote').style.backgroundColor = '#DECC06';
   }
   
   function setBackgroundNormal() {
   	document.getElementById('indexquote').style.backgroundColor = '#D2CEE6';
   }



