
/* - dccompaniesdirectory.js - */
// http://www.valetforet.org/portal_javascripts/dccompaniesdirectory.js?original=1
var queryTarget="dccompaniesdirectory_getindustrysubbranches?industry_branch=";var IndustrySubBranchReq=null;
function clearSelectOptions(selectObject){while(selectObject.length>0){selectObject.remove(0)}}
function appendOptionToSelect(select,value,content){var opt;opt=document.createElement("option");opt.value=value;opt.appendChild(document.createTextNode(content));select.appendChild(opt)}
function getElementTextNS(prefix,local,parentElem,index){var result="";if(prefix&&isIE){result=parentElem.getElementsByTagName(prefix+":"+local)[index]} else{result=parentElem.getElementsByTagName(local)[index]}
if(result){if(result.childNodes.length>1){return result.childNodes[1].nodeValue} else{return result.firstChild.nodeValue}} else{return "n/a"}}
function IndustrySubBranchProcessReqChange(){if(IndustrySubBranchReq.readyState==4){if(IndustrySubBranchReq.status>299||IndustrySubBranchReq.status<200) return;var industrySubBranchSelect=document.getElementById("industrySubBranch");var items=IndustrySubBranchReq.responseXML.getElementsByTagName("item");clearSelectOptions(industrySubBranchSelect);appendOptionToSelect(industrySubBranchSelect,""," ");for(var i=0;i<items.length;i++){appendOptionToSelect(industrySubBranchSelect,getElementTextNS("","value",items[i],0),getElementTextNS("","title",items[i],0))}}}
function updateIndustrySubBranchSelect(event){if(!event) var event=window.event;IndustrySubBranchReq=new XMLHttpRequest();IndustrySubBranchReq.onreadystatechange=IndustrySubBranchProcessReqChange;IndustrySubBranchReq.open("GET",queryTarget+encodeURIComponent(this.value),true);IndustrySubBranchReq.send(null)}
function initialiseCompaniesDirectorySearchForm(){var industryBranchSelect=document.getElementById("industryBranch");var industrySubBranchSelectContainer=document.getElementById("fieldname-industrySubBranch");if(industryBranchSelect&&industrySubBranchSelectContainer){industryBranchSelect.onchange=updateIndustrySubBranchSelect;replaceClassName(industrySubBranchSelectContainer,"hiddenStructure","")}}
registerPloneFunction(initialiseCompaniesDirectorySearchForm);
