var Testimonials = new Array();

OH_testimonials = {
	
	request : function(Id){
		Obj = {
			Method: "Get",
			Class : "Object",
			Query : {
				Type : Id
			}
		}
		Obj.Query = $.toJSON(Obj.Query);
		
		$.post(OH_config.jsonPath, Obj, function(json) {
			Testimonials = json;
			OH_testimonials.Length = Testimonials.Results.length - 1;
			OH_testimonials.Current = Math.floor(Math.random()*Testimonials.Results.length);
			OH_testimonials.display();
		}, "json");
	},
	
	display : function(){
		O = Testimonials.Results[OH_testimonials.Current].Properties;
		txt = "<p>" + O.testimonial +"<br /><br />";
		txt += O.name + "<br />";
		txt += "<a target=\"_blank\" href=\""+O.website+"\">"+O.organization+"</a></p>"
		$("#text").html(txt)
	},
	
	next : function(){
		OH_testimonials.Current++;
		
		if(OH_testimonials.Current>OH_testimonials.Length)
			OH_testimonials.Current = 0;
			
		OH_testimonials.display();
	},
	
	prev : function(){
		OH_testimonials.Current--;

		if(OH_testimonials.Current<0)
			OH_testimonials.Current = OH_testimonials.Length;
			
		OH_testimonials.display();
	}
	
}