/***********************************************
* DOM Random Content Order script- © John Davenport Scheuer
* adapted from Random Content Order script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
* as first seen in http://www.dynamicdrive.com/forums
* username:jscheuer1
***********************************************/

function randomizeContent(classname){
if(typeof document.cloneNode!=='undefined'){
var contents=randomizeContent.collectElementbyClass(classname);
contents.ref.sort(function() {return 0.5 - Math.random();});
for (var i=0; i<contents.ref.length; i++){
contents.par[i].replaceChild(contents.ref[i],contents.theNodes[i]);
contents.ref[i].style.visibility="visible";
}
}
}

randomizeContent.collectElementbyClass=function(classname){ //return three arrays containing elements with specified classname, plus a clone of themselves, plus a list of their parentNodes
var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)", "i"); //regular expression to screen for classname within element
var contentobj=new Object();
contentobj.ref=new Array(); //array containing clones of the participating nodes
contentobj.par=new Array(); //array containing participating contents' parentNodes
contentobj.theNodes=[]; //array containing the participating nodes
var alltags=document.all? document.all : document.getElementsByTagName("*");
for (var i_tem = 0; i_tem < alltags.length; i_tem++)
if (typeof alltags[i_tem].className=="string" && alltags[i_tem].className.search(classnameRE)!=-1)
contentobj.theNodes[contentobj.theNodes.length]=alltags[i_tem];
for (var i=0; i<contentobj.theNodes.length; i++){
contentobj.par[contentobj.par.length]=contentobj.theNodes[i].parentNode;
contentobj.ref[contentobj.ref.length]=contentobj.theNodes[i].cloneNode(true);
}
return contentobj
}