function movetonextselection(arrParentChildLink,arrParentOptions,arrChildOptions,strParentNoun,strChildNoun,strMode,parentControlId,childControlId){var strActionText='';var iCurrSource=0;var aOptions;var sortIndex;var arrChildOptionsOutput;var intItemToSelect=0;var optionKey='';var optionValue='';var topOptionText;if(strMode=='search'){if(strChildNoun=='sub category'){strActionText='Any sub category';}else{strActionText='Select '+strChildNoun;}}else{strActionText='Choose a '+strParentNoun+' first';}
var ctlParent=$("#"+parentControlId)[0];var ctlChild=$("#"+childControlId)[0];var ctlSelectedChild=$("#selected"+childControlId)[0];if(ctlParent.value===''||ctlParent.text===''){if(!ctlChild.disabled){ctlChild.disabled=true;}
ctlChild.options.length=0;ctlChild.options[0]=new Option(strActionText,'',false,false);}
else{iCurrSource=ctlParent.options[ctlParent.selectedIndex].value;if(arrParentChildLink[iCurrSource]===null||arrParentChildLink[iCurrSource].length===0){var strNoChildrenMsg='';if(strChildNoun=='sub category'){strNoChildrenMsg='No sub categories';}else{strNoChildrenMsg='No '+strChildNoun+'s';}
if(ctlChild.options[0].text!=strNoChildrenMsg){ctlChild.options.length=0;ctlChild.options[0]=new Option(strNoChildrenMsg,'',false,false);if(!ctlChild.disabled){ctlChild.disabled=true;}}}
else{if(ctlChild.disabled){ctlChild.disabled=false;}
aOptions=new Array();var index=0;for(i=0;i<arrParentChildLink[iCurrSource].length;i++){if(arrParentChildLink[iCurrSource][i]==1){aOptions[index]=i;index++;}}
arrChildOptionsOutput=new Array(aOptions);for(i=0;i<aOptions.length;i++){arrChildOptionsOutput[i]=new Array(1);arrChildOptionsOutput[i]=[aOptions[i],arrChildOptions[aOptions[i]]];}
arrChildOptionsOutput.sort(function(a,b){if(a[1]=='Other'){return 1;}
else if(b[1]=='Other'){return-1;}
else if(a[1].indexOf('Other ')>-1){return 1;}
else if(b[1].indexOf('Other ')>-1){return-1;}
else if(a[1]==b[1]){return 0;}
else{return a[1]>b[1]?1:-1;}});ctlChild.options.length=0;topOptionText='';if(strMode=='search'){if(strChildNoun=='sub category'){topOptionText='Any sub category';}
else{topOptionText='Select '+strChildNoun;}}
else{topOptionText='Choose...';}
ctlChild.options[0]=new Option(topOptionText,'',false,false);ctlChild.options[1]=new Option('','',false,false);
for(i=0;i<arrChildOptionsOutput.length;i++){if(ctlSelectedChild&&ctlSelectedChild.value!==''&&arrChildOptionsOutput[i][0]==ctlSelectedChild.value){intItemToSelect=i+2;}
optionKey=arrChildOptionsOutput[i][0];optionValue=arrChildOptionsOutput[i][1];
ctlChild.options[i+2]=new Option(optionValue,optionKey,false,false);}
ctlChild.options[intItemToSelect].selected=true;}}
var districtDropDown="district";var $suburbDropDown=$("select#suburb");if(ctlParent.id===districtDropDown){var $propertyTypeDropDown=$("#29");}
if(ctlChild.onchange){ctlChild.onchange();}}
function validateMulti(multi,cbo){var anySelected;var allSelected;if(multi.options.length===0){anySelected=false;allSelected=false;}
else{anySelected=false;allSelected=true;for(iLoop=0;iLoop<multi.options.length;iLoop++){if(multi.options[iLoop].selected){anySelected=true;}
else{allSelected=false;}}}
if(allSelected&&!cbo.checked){cbo.checked=true;}
else if(!allSelected&&cbo.checked){cbo.checked=false;}}
function g(arrIn){var arrOut=new Array();for(iLoop=0;iLoop<arrIn.length;iLoop++){arrOut[arrIn[iLoop]]=1;}
return(arrOut);}
