try{SC.addVersion('0110', '1.0.000', 'Randomly Displayed Testimonials');}catch(err){};
function scRandomTestimonials(showtotal){
	var testArr = [];
	
	this.add = function( testi ) {
		/*
			add - Public - Adds a testimonial to the set
			PARAMETERS:	testi - the testimonial html as a string
			RETURN:	none
		*/
		testArr.push(testi);
	}
	
	function forceInt( num ) {
		/*
			forceInt - Private - Forces data of an undefined type into an integer value
			PARAMETERS:	num - should be an integer value, but may be of a different type
			RETURN:	an integer value
		*/
		return (isNaN(num = parseInt((typeof num === Number)? num : num.toString().replace(/^.*?([\+\-]?[\d\.]+).*?$/, "$1"))))? 0 : num;
	}
	
	function randArr( iArr, num ) {
		/*
			randArr - Private - Chooses a random set of from an array
			PARAMETERS:	iArr - the set of items (as an array) to randomly select from
						num - the number of random items to choose as an integer
			RETURN:	the set of randomized items as an array
		*/
		var len = iArr.length;
		if (len > num) {
			if ((len / 2) > num) {  // Determines which algorithm to use
				var oArr = iArr;
				iArr = [];
				for (var i = 0, j = num; i < j; i++) {
					var ran = Math.floor(Math.random() * oArr.length);
					iArr.push(oArr[ran]);
					oArr.splice(ran,1);
				}
				delete oArr;
			} else {
				for (var i = 0, j = (len - num); i < j; i++) {
					var ran = Math.floor(Math.random() * iArr.length);
					iArr.splice(ran,1);
				}
			}
		}
		return iArr;
	}
	
	this.display = function( num, objId ) {
		/*
			display - Public - Outputs the testimonials to the page
			PARAMETERS:	num - the number of random testimonials to display
						objId - the id of an HTML object to display the testimonials within; if nothing is passed, document.write will be used.
			RETURN:	none
		*/
		var tmpArr = randArr(testArr, forceInt(num));
		var tConts = "";
		if (tmpArr) {
			tConts = "<ul>";
			for(var i = 0, j = tmpArr.length; i < j; i++){
				tConts += "<li>";
				tConts += tmpArr[i];
				tConts += "</li>";
			}
			tConts += "</ul>";
		}
		if (objId) {
			var obj = obj = document.getElementById(objId);
			if (obj) {
				obj.innerHTML = tConts;
			}
		} else {
			document.write(tConts);
		}
	};
}