//took this from http://www.thedevproject.com/2006/05/08/randomizing-javascript-arrays/
Array.prototype.shuffle = function() {
  for (var i = 0; i < this.length; i++) {
    // Random item in this array.
    var r = parseInt(Math.random() * this.length);
    var obj = this[r];
 
    // Swap.
    this[r] = this[i];
    this[i] = obj;
  }
}

function randomize(tableID) {
	var myTable = document.getElementById(tableID);
	var myRows = new Array();
	for (i=myTable.rows.length-1; i>=0; i--) {
		var theRow = myTable.rows[i];
		myRows.push(theRow);
		theRow.parentNode.removeChild(theRow);
	}
	myRows.shuffle();
	for (j=0; j<myRows.length; j++) {
		var newTbody = document.createElement("tbody");
		newTbody.appendChild(myRows[j]);
		myTable.appendChild(newTbody);
	}
}
window.onload = function() {
	randomize("randomtable");
}
