// Content generating code for Testimonials Widget
//Phred White - 2007-12-14

/*
// Requires this block to be inserted at the top of the HTML page
this.display_text = "";
*/

/* Requires this block to be inserted in the HTML page
var t=setTimeout("initTestimonials()",180000);
this.display_text="";
function initTestimonials() {
t=setTimeout("initTestimonials()",180000);
	upDate();
}
*/
//alert("testimonials.js");


function drawTestimonials() {
	//alert("drawTestimonials");
	var textBuff = "";
	textBuff = this.display_text;
	//alert("textBuff: "+textBuff);
	document.getElementById('widget_content').innerHTML = textBuff;
}
function upDate() {
	//AJAX to Perl connector
	survID=0;
	if (survID.length<1) {survID = 0;}
	var post_info = $H({ survID: survID}).toQueryString();
	
	//alert("post_info: " + post_info);
	
	var opt = {
		 method: 'post',
		 postBody: post_info,
		 onSuccess: function(t) {
			 var response = t.responseText;
			 //alert("t.responseText: " + t.responseText);
			 //alert("response: " + response);
			 
			 var jsonObj = eval("("+response+")");
			 //alert("jsonObj: " + jsonObj);
			 
			 display_text = jsonObj.display_text;
			 //alert("this.display_text: "+this.display_text);
			 drawTestimonials();
		 },
			  
	   // Handle 404
		on404: function(t) {
			 alert("t.responseText" + t.responseText);
			alert('Error 404: location "' + t.statusText + '" was not found.');
		},
		// Handle other errors
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
			 alert("t.responseText" + t.responseText);
		} 
		  
			   
	};	
	new Ajax.Request('/_components/Corp_Testimonial_Widget.perl', opt);
}


