// Copyright(c) 2007 The Australian National University

function DDIUtil(){}
DDIUtil.deleteCookie=function(cookieName){var expiry=new Date();expiry.setTime(expiry.getTime()-(1000*60*60*24));document.cookie=cookieName+"=; expires="+expiry.toGMTString();};DDIUtil.getQueryStringParam=function(queryInfo,property){var re=new RegExp(property+":\\[(.+?[^\\\\]?)\\]","i");var matches=re.exec(queryInfo);if(matches==null){return"";}else{return matches[1];}};DDIUtil.setQueryStringParam=function(queryInfo,property,value){var re=new RegExp(property+":\\[.*?[^\\\\]?\\]","i");if(re.test(queryInfo)){return queryInfo.replace(re,property+":["+value+"]");}else if(queryInfo==""){return property+":["+value+"]";}else{return queryInfo+" "+property+":["+value+"]";}};DDIUtil.updateQueryStringParam=function(queryInfo,property,value){var current=DDIUtil.getQueryStringParam(queryInfo,property);if(current==""){queryInfo=DDIUtil.setQueryStringParam(queryInfo,property,value);}else{queryInfo=DDIUtil.setQueryStringParam(queryInfo,property,current+" "+value);}
return queryInfo;};DDIUtil.addCommasToNumber=function(nStr){nStr+='';x=nStr.split('.');x1=x[0];x2=x.length>1?'.'+x[1]:'';var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2');}
return x1+x2;};DDIUtil.getHitCaption=function(hit){var caption;if(hit.hitType=="dataset"){caption=hit.name;}else{if(hit.label==null){caption=hit.name;}else{caption=hit.name+" ("+hit.label+")";}}
return caption;};DDIUtil.changeSearchInURLs=function(parentNode,oldName,newName){var href;var labelEl;var nodes=parentNode.children;var hrefRE=new RegExp();hrefRE.compile("search="+oldName+"&");for(var i=0;i<nodes.length;i++){href=nodes[i].href;href=href.replace(hrefRE,"search="+newName+"&");nodes[i].href=href;var labelEl=nodes[i].getLabelEl();if(labelEl!=null){labelEl.href=href;}}};Array.prototype.ddiiContains=function(searchFor){var found=false;searchFor=searchFor.toLowerCase();for(var i=0;i<this.length;i++){if(searchFor===this[i].toLowerCase()){found=true;break;}}
return found;};