function ContentRepository(){
this.dataset=new DatasetDefinition();
this.recordSet=new Collection();
this.resultSet=new Collection();
this.htmlTables=new Collection();
this.xmlLoader=new XMLloader();
window.existingOnloadHandler=window.onload;
window.onload=this.init;
window.ContentRepositoryReference=this;
}
ContentRepository.prototype.buildTable=CR_buildTable;
ContentRepository.prototype.init=CR_init;
ContentRepository.prototype.parseXML=CR_parseXML;
function CR_buildTable(){
var _1=this.htmlTables.iterator();
while(_1.hasNext()){
var _2=_1.next();
_2.resultSet=this.resultSet;
_2.buildTable();
}
}

function CR_init(){
  if(window.existingOnloadHandler!=null){
    window.existingOnloadHandler();
  }
  var _3=window.ContentRepositoryReference;
  _3.xmlLoader.load("events",_3.dataset.XMLsource,_3,"parseXML");
}

function CR_parseXML(_4){
docRoot=_4.getElementsByTagName(this.dataset.XMLsourceRootElement);
docRoot=docRoot[0];
for(var i=0;i<docRoot.childNodes.length;i++){
if(docRoot.childNodes[i].nodeType!=1){
continue;
}
var _6=this.dataset.createNewDataRecord(docRoot.childNodes[i]);
this.resultSet.add(_6);
}
this.buildTable();
doNext(); //call the load paging function
return;
}

function DatasetDefinition(){
this.allFields=new Collection();
this.XMLsource;
this.XMLsourceRootElement;
return true;
}
DatasetDefinition.prototype.add_Field=DD_add_Field;
DatasetDefinition.prototype.createNewDataRecord=DD_createNewDataRecord;
DatasetDefinition.prototype.getAllFieldNames=DD_getAllFieldNames;
DatasetDefinition.prototype.useXMLsource=function(_7){
this.XMLsource=_7;
};
DatasetDefinition.prototype.XMLrootElement=function(_8){
this.XMLsourceRootElement=_8;
};
function DD_createNewDataRecord(_9){
var _a=new Object();
var _b=this.allFields.iterator();
while(_b.hasNext()){
var _c=_b.next();
_a[_c.name]=new Object();
_a[_c.name].name=_c.name;
_a[_c.name].type=_c.type;
_a[_c.name].value=_c.defaultValue();
}
var _d=new String();
for(var i=0;i<_9.childNodes.length;i++){
var _f=_9.childNodes[i];
if(_f.nodeType!=1){
continue;
}
if(_f.childNodes.length<1){
continue;
}
for(var _10 in _a){
var _11=_a[_10];
if(_11.name!=_f.nodeName){
continue;
}
var _12=unescape(_f.childNodes[0].nodeValue);
var _13=trim(_12);
switch(_11.type){
case "string":
_11.value=_13;
break;
case "date":
var RE=/\d{4}-\d{2}-\d{2}/;
if(RE.test(_13)){
_11.value=createDateObj(_13);
}
break;
case "pipe":
var _15=_13.split("|");
for(var k=0;k<_15.length;k++){
var _17=trim(_15[k]);
_11.value.add(_17);
}
break;
}
}
}
return _a;
}
function DD_add_Field(_18,_19){
_18=_18.toLowerCase();
var _1a;
switch(_18){
case "date":
_1a=function(){
var _1b=createDateObj("today");
return _1b;
};
break;
case "pipe":
_1a=function(){
return new Collection();
};
break;
case "string":
_1a=function(){
return "";
};
break;
default:
return;
break;
}
var _1c=new Object();
_1c.name=_19;
_1c.type=_18;
_1c.defaultValue=_1a;
this.allFields.add(_1c);
}
function DD_getAllFieldNames(){
var _1d=new Collection();
var _1e=this.allFields.iterator();
while(_1e.hasNext()){
var _1f=_1e.next();
_1d.add(_1f.name);
}
return _1d;
}
function CustomSort(){
this.lc=false;
this.scopeChain=[];
var _20=this;
this.sortCodeDescending=function CS_sortCode(_21,_22){
var _23=new Object();
var _24=new Object();
_23.value=_21;
_24.value=_22;
var _25=_20.scopeChain;
switch(_25.length){
case 1:
_23.value=_21[_25[0]];
_24.value=_22[_25[0]];
break;
case 2:
_23.value=_21[_25[0]][_25[1]];
_24.value=_22[_25[0]][_25[1]];
break;
case 3:
_23.value=_21[_25[0]][_25[1]][_25[2]];
_24.value=_22[_25[0]][_25[1]][_25[2]];
break;
}
if(typeof _23.value=="object"){
if(_23.value.toArray){
_23.value=_23.value.toArray().toString();
}
}
if(typeof _24.value=="object"){
if(_24.value.toArray){
_24.value=_24.value.toArray().toString();
}
}
if(_20.lc){
_23.value=_23.value.toLowerCase();
_24.value=_24.value.toLowerCase();
}
if(_23.value<_24.value){
return -1;
}else{
if(_23.value>_24.value){
return 1;
}else{
return 0;
}
}
};
this.sortCodeAscending=function CS_sortCode(_26,_27){
var _28=new Object();
var _29=new Object();
_28.value=_26;
_29.value=_27;
var _2a=_20.scopeChain;
switch(_2a.length){
case 1:
_28.value=_26[_2a[0]];
_29.value=_27[_2a[0]];
break;
case 2:
_28.value=_26[_2a[0]][_2a[1]];
_29.value=_27[_2a[0]][_2a[1]];
break;
case 3:
_28.value=_26[_2a[0]][_2a[1]][_2a[2]];
_29.value=_27[_2a[0]][_2a[1]][_2a[2]];
break;
}
if(typeof _28.value=="object"){
if(_28.value.toArray){
_28.value=_28.value.toArray().toString();
}
}
if(typeof _29.value=="object"){
if(_29.value.toArray){
_29.value=_29.value.toArray().toString();
}
}
if(_20.lc){
_28.value=_28.value.toLowerCase();
_29.value=_29.value.toLowerCase();
}
if(_28.value>_29.value){
return -1;
}else{
if(_28.value<_29.value){
return 1;
}else{
return 0;
}
}
};
}
CustomSort.prototype.lowercase=CS_lowercase;
CustomSort.prototype.sortWith=CS_sortWith;
CustomSort.prototype.sortFunction=CS_sortFunction;
function CS_lowercase(){
this.lc=true;
}
function CS_sortWith(){
for(var i=0;i<arguments.length;i++){
this.scopeChain=this.scopeChain.concat(arguments[i]);
}
}
function CS_sortFunction(_2c){
if(_2c.toLowerCase()=="asc"){
return this.sortCodeAscending;
}else{
return this.sortCodeDescending;
}
}
function createDateObj(_2d){
if(_2d=="today"){
var _2e=new Date();
var _2f=_2e.getFullYear();
var _30=_2e.getMonth()+1;
var _31=_2e.getDate();
_2d=_2f+"-"+_30+"-"+_31;
}
var _32=_2d.split("-");
var _33=parseInt(_32[0],10);
var _34=parseInt(_32[1],10)-1;
var _35=parseInt(_32[2],10);
var _36=new Date(_33,_34,_35);
return _36;
}
function getDateString(_37){
var _38=_37.getMonth();
var day=_37.getDate();
var _3a=_37.getFullYear();
var _3b=new String();
_3b+=getDateString.monthNamesShort[_38]+" ";
_3b+=day+", ";
_3b+=_3a;
return _3b;
}
getDateString.monthNamesShort=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
getDateString.monthNamesLong=["January","February","March","April","May","June","July","August","September","October","November","December",];
function trim(str){
return str.replace(/^\s*|\s*$/g,"");
}
function XMLloader(){
this.XMLdocs=new Collection();
this.loadMethod=this.getLoadMethod();
window.XMLloaderIntervalID=null;
window.XMLloaderIntervalObject=null;
window.XMLloaderIntervalMethod=null;
}
XMLloader.prototype.load=Xl_load;
XMLloader.prototype.getLoadMethod=Xl_getLoadMethod;
function Xl_load(_3d,URL,_3f,_40){
(URL.indexOf("?")!=-1)?(URL+="&"):(URL+="?");
URL+=new Date().getTime();
var _41=new XMLdocObj();
_41.name=_3d;
_41.URL=URL;
var _42=false;
var _43=this;
switch(this.loadMethod){
case "XMLHttpRequest":
var _44=new XMLHttpRequest();
_44.onreadystatechange=function(){
if((_44.readyState==4)&&(_44.status<300)){
_41.doc=_44.responseXML;
_43.XMLdocs.add(_41);
_3f[_40](_41.doc);
return true;
}
};
_44.open("GET",_41.URL,true);
_44.send(null);
return true;
break;
case "ActiveXObject":
var _45;
try{
_45=new ActiveXObject("Microsoft.XMLDOM");
}
catch(e){
_45=new ActiveXObject("Msxml2.XMLHTTP");
}
_45.onreadystatechange=function(){
if(_45.readyState==4){
_41.doc=_45;
_43.XMLdocs.add(_41);
_3f[_40](_41.doc);
return true;
}
};
_45.load(_41.URL);
return true;
break;
case "iFrame":
var _46=document.createElement("DIV");
_46.style.visibility="hidden";
_46.style.position="absolute";
_46.style.top="0px";
_46.style.left="0px";
_46.innerHTML="<iframe src=\""+_41.URL+"\" name=\"XML_loader_"+_41.name+"\" height=\"0\" width=\"0\"></iframe>";
document.body.appendChild(_46);
var _47="checkiFrameLoad('"+_41.name+"');";
window.XMLloaderIntervalObject=_3f;
window.XMLloaderIntervalMethod=_40;
window.XMLloaderIntervalID=setInterval(_47,100);
_41.doc="XML_loader_"+_41.name;
_43.XMLdocs.add(_41);
return true;
break;
default:
return false;
break;
}
}
function Xl_getLoadMethod(){
if(window.XMLHttpRequest){
return "XMLHttpRequest";
}
if(window.ActiveXObject){
try{
var AXO=new ActiveXObject("Microsoft.XMLDOM");
return "ActiveXObject";
}
catch(e){
}
}
if(document.createElement&&document.childNodes){
return "iFrame";
}
return false;
}
function checkiFrameLoad(_49){
var _4a="XML_loader_"+_49;
if(window.frames[_4a]){
window.XMLloaderIntervalObject[window.XMLloaderIntervalMethod](window.frames[_4a].window.document);
window.clearInterval(window.XMLloaderIntervalID);
}
}
function XMLdocObj(){
this.name;
this.URL;
this.doc;
this.functionName;
}
var HTMLtemplates=new Object();
HTMLtemplates.displayTable=new String();

HTMLtemplates.displayTable+="<span style='font-size: 12px; line-height: 14px;'>%__tableDescription__%</span>";
HTMLtemplates.displayTable+="<table border='0' id='results'>";
HTMLtemplates.displayTable+="<tr id='test' style='background-color: #F0F0F0; text-align: center;'>%__columnHeaders__%</tr>";
HTMLtemplates.displayTable+="%__tableRows__%";
HTMLtemplates.displayTable+="</table><br>";
HTMLtemplates.displayRow=new String();
HTMLtemplates.displayRow+="<tr>%__tableCells__%</tr>";
HTMLtemplates.displayCell=new String();
HTMLtemplates.displayCell+="<td valign=\"top\" class=\"smtext\">%__columnData__%</td>";



function HtmlTable(_4b){
this.divID=_4b;
this.resultSet=new Collection();
this.tableColumns=new Collection();
this.mouseOverBGColor="transparent";
this.mouseOutBGColor="transparent";
this.tableBGColor="transparent";
this.cachedColumnHeadersHTML=new String();
this.tableDescription="";
this.displayTableHeader=true;
this.initialSort="";
this.dataset=new DatasetDefinition();
this.rowFilter=null;
this.sortColumn="";
this.sortOrder="descending";
this.sortRules=new Collection();
this.title="";
}
HtmlTable.prototype.buildTable=HT_buildTable;
HtmlTable.prototype.displayColumn=HT_displayColumn;
HtmlTable.prototype.addBuildRule=HT_addBuildRule;
HtmlTable.prototype.addRowFilterRule=HT_addRowFilterRule;
HtmlTable.prototype.sortTable=HT_sortTable;
function HT_sortTable(_4c,_4d){
var _4e=new CustomSort();
_4e.lowercase();
_4e.sortWith(_4c,"value");
this.resultSet.sort(_4e.sortFunction(_4d));
return;
}
function HT_addRowFilterRule(_4f){
if(typeof _4f!="function"){
return;
}
this.rowFilter=_4f;
}
function HT_addBuildRule(_50,_51){
var _52=this.dataset.getAllFieldNames();
if(!_52.contains(_50)){
return;
}
if(typeof _51!="function"){
return;
}
var _53=this.tableColumns.iterator();
while(_53.hasNext()){
var _54=_53.next();
if(_54.name==_50){
_54.buildRule=_51;
}
}
}
function HT_displayColumn(_55,_56){
var _57=this.dataset.getAllFieldNames();
if(!_57.contains(_55)){
return;
}
var _58=null;
if(arguments.length>2){
_58=arguments[2];
}
var _59=new Object();
_59.name=_55;
_59.width=_56;
_59.alias=_58;
_59.linkField=null;
_59.linkTarget=null;
_59.buildRule=null;
this.tableColumns.add(_59);
return;
}
function HT_buildTable(){
if(this.resultSet.size()<1){
document.getElementById(this.divID).innerHTML="<br><br>No results were found that match your criteria.<br>";
return;
}
this.sortTable(this.sortColumn,this.sortOrder);
var _5a=new String();
var _5b=false;
var _5c=this.resultSet.iterator();
while(_5c.hasNext()){
var _5d=_5c.next();
var _5e=true;
if(this.rowFilter!=null){
_5e=this.rowFilter(_5d);
}
if(_5e){
if(!_5b){
_5b=true;
}
var _5f=new String();
var _60=this.tableColumns.iterator();
while(_60.hasNext()){
var _61="";
var _62="";
var _63=_60.next();
var _64=HTMLtemplates.displayCell;
if(_63.buildRule!=null){
_61=_63.buildRule(_5d);
}else{
switch(_5d[_63.name].type){
case "string":
_61=_5d[_63.name].value;
break;
case "date":
_61=getDateString(_5d[_63.name].value);
break;
}
}
if(_63.linkField!=null){
var _65="_self";
if(_63.linkTarget!=null){
_65=_63.linkTarget;
}
_62="<a href=\""+_5d[_63.linkField].value+"\" target=\""+_65+"\">";
_62+=_61+"</a>";
}else{
_62=_61;
}
_5f+=_64.replace("%__columnData__%",_62);
}
var _66=HTMLtemplates.displayRow.replace("%__tableCells__%",_5f);
_66=_66.replace("%__mouseOverBGColor__%",this.mouseOverBGColor);
_66=_66.replace("%__mouseOutBGColor__%",this.mouseOutBGColor);
_5a+=_66;
}
}
var _67=new String();
if(_5b){
_67=this.title;
}
_67+=HTMLtemplates.displayTable.replace("%__tableDescription__%",this.tableDescription);
_67=_67.replace("%__tableBGColor__%",this.tableBGColor);
_67=_67.replace("%__columnHeaders__%",this.cachedColumnHeadersHTML);
_67=_67.replace("%__tableRows__%",_5a);
if(document.getElementById(this.divID)!=null){
  document.getElementById(this.divID).innerHTML=_67;
}
}
function Collection(){
this.collectionArray=[];
}
Collection.prototype.add=collectionAdd;
Collection.prototype.addAll=collectionAddAll;
Collection.prototype.clear=collectionClear;
Collection.prototype.contains=collectionContains;
Collection.prototype.containsAll=collectionContainsAll;
Collection.prototype.equals=collectionEquals;
Collection.prototype.isEmpty=collectionIsEmpty;
Collection.prototype.iterator=collectionIterator;
Collection.prototype.remove=collectionRemove;
Collection.prototype.removeAll=collectionRemoveAll;
Collection.prototype.retainAll=collectionRetainAll;
Collection.prototype.size=collectionSize;
Collection.prototype.sort=collectionSort;
Collection.prototype.toArray=collectionToArray;
function collectionAdd(_68){
this.collectionArray=this.collectionArray.concat(_68);
return true;
}
function collectionAddAll(){
for(var i=0;i<arguments.length;i++){
this.collectionArray=this.collectionArray.concat(arguments[i]);
}

return true;
}
function collectionClear(){
this.collectionArray.length=0;
return true;
}
function collectionContains(_6a){
var _6b=false;
for(var i=0;i<this.size();i++){
if(this.collectionArray[i]==_6a){
_6b=true;
}
}
return _6b;
}
function collectionContainsAll(_6d){
if(_6d.constructor!=Collection){
return null;
}
var _6e=_6d.toArray();
var _6f=_6e.length;
var _70=0;
for(var i=0;i<_6e.length;i++){
var _72=_6e[i];
var _73=false;
for(var j=0;j<this.size();j++){
if(this.collectionArray[j]==_72){
_70++;
}
}
}
if(_70==_6f){
return true;
}else{
return false;
}
}
function collectionEquals(_75){
if(_75.constructor!=Collection){
return null;
}
return (this.collectionArray.toString()==_75.collectionArray.toString());
}
function collectionIsEmpty(){
if(this.size()<1){
return true;
}else{
return false;
}
}
function collectionIterator(){
return new IteratorObject(this);
}
function collectionRemove(_76){
var iT=this.iterator();
while(iT.hasNext()){
if(iT.next()==_76){
iT.remove();
return true;
}
}
return false;
}
function collectionRemoveAll(_78){
if(_78.constructor!=Collection){
return null;
}
var _79=false;
var _7a=_78.iterator();
while(_7a.hasNext()){
rmIteratorObj=_7a.next();
var _7b=this.iterator();
while(_7b.hasNext()){
var _7c=_7b.next();
if(_7c==rmIteratorObj){
_7b.remove();
_79=true;
}
}
}
return _79;
}
function collectionRetainAll(_7d){
if(_7d.constructor!=Collection){
return null;
}
var _7e=false;
var _7f=this.iterator();
while(_7f.hasNext()){
var _80=_7f.next();
var _81=false;
var _82=_7d.iterator();
while(_82.hasNext()){
var _83=_82.next();
if(_80==_83){
_81=true;
}
}
if(!_81){
_7f.remove();
_7e=true;
}
}
return _7e;
}
function collectionSize(){
return this.collectionArray.length;
}
function collectionSort(){
var _84=null;
if(arguments.length==1){
if(typeof arguments[0]=="function"){
_84=arguments[0];
}
}
if(_84==null){
this.collectionArray.sort();
return true;
}else{
this.collectionArray.sort(_84);
return true;
}
return false;
}
function collectionToArray(){
return this.collectionArray;
}
function IteratorObject(_85){
this.arrIndex=0;
this.collection=_85;
return;
}
IteratorObject.prototype.hasNext=IteratorObjectHasNext;
IteratorObject.prototype.next=IteratorObjectNext;
IteratorObject.prototype.remove=IteratorObjectRemove;
function IteratorObjectHasNext(){
var _86=this.collection.toArray();
if(this.arrIndex==_86.length){
return false;
}else{
return true;
}
}
function IteratorObjectNext(){
var _87=this.collection.toArray();
this.arrIndex++;
return _87[(this.arrIndex-1)];
}
function IteratorObjectRemove(){
var _88=this.collection.toArray();
var _89=[];
_89=_89.concat(_88.slice(0,this.arrIndex-1));
_89=_89.concat(_88.slice(this.arrIndex));
this.collection.collectionArray=_89;
this.arrIndex=this.arrIndex-1;
}


