",{value:i.Value,text:i.Text,selected:i.Selected}))});t.change()}})}function GotoAction(n,t,i){$("#lbl_Error").text("");$("#lbl_Error").hide();t>0?$.ajax({type:"POST",url:"/Catalog/GetRules/",data:$("#formCreate").serialize()+"&AttributeId="+t,accept:"application/json",error:function(n){ShowErrorMessage("error: "+n.responseText)},success:function(r){var e=!1,u=0,f=0,o=0,s=$.parseJSON(r);$.each(s,function(n,t){$("#ddValue_"+n+" option").removeAttr("disabled");$("#ddDesc_"+n+" option").removeAttr("disabled");$("#dd_"+n+" option").removeAttr("disabled");$("#ddparent_"+n+" option").removeAttr("disabled");$("#dd_child"+n+" option").removeAttr("disabled");var r=!1,i="",s;$.each(t,function(t,e){e.CascadingParentId>0?(option="option[value='"+e.Id+","+e.CascadingParentId+"']",i="option[value='"+e.CascadingParentId+"']"):option="option[value='"+e.Id+"']";DropdownValue=$("#ddValue_"+n);DropdownDesc=$("#ddDesc_"+n);Dropdown=$("#dd_"+n);DropdownParent=$("#ddparent_"+n);DropdownChild=$("#dd_child"+n);e.Selected&&!e.Disable&&(Dropdown.val(e.Id),DropdownDesc.val(e.Id),DropdownValue.val(e.Id));e.Disable?(DropdownValue.find(option).attr("disabled","disabled"),DropdownDesc.find(option).attr("disabled","disabled"),Dropdown.find(option).attr("disabled","disabled"),s!=i&&DropdownParent.find(i).attr("disabled","disabled"),DropdownChild.find(option).attr("disabled","disabled")):(r||(u=e.Id,e.CascadingParentId>0&&(f=e.CascadingParentId,o=n),r=!0),s=i,DropdownValue.find(option).removeAttr("disabled"),DropdownDesc.find(option).removeAttr("disabled"),Dropdown.find(option).removeAttr("disabled"),DropdownParent.find(i).removeAttr("disabled"),DropdownChild.find(option).removeAttr("disabled"))});$("#ddValue_"+n+" option").each(function(){this.selected&&this.disabled&&(this.selected=!1,f>0?$("#ddValue_"+n).val(u+","+f):$("#ddValue_"+n).val(u))});$("#ddparent_"+n+" option").each(function(){this.selected&&this.disabled&&(this.selected=!1,$("#ddparent_"+n).val(f),e=!0)});$("#dd_child"+n+" option").each(function(){this.selected&&this.disabled&&(this.selected=!1,$("#dd_child"+n).val(u+","+f))});$("#ddDesc_"+n+" option").each(function(){this.selected&&this.disabled&&(this.selected=!1,$("#ddDesc_"+n).val(u))});$("#dd_"+n+" option").each(function(){this.selected&&this.disabled&&(this.selected=!1,$("#dd_"+n).val(u))});$("#dd_"+n).val()==null&&$("#dd_"+n).val(u);$("#ddDesc_"+n).val()==null&&$("#ddDesc_"+n).val(u);$("#dd_child"+n).val()==null&&$("#dd_child"+n).val(u);$("#ddparent_"+n).val()==null&&$("#ddparent_"+n).val(u)});e&&FindCascadeDropDown(f,o,u);i?onchangeGet(n):GotoAction(n,t,1)}}):i||onchangeGet(n)}function FindCascadeDropDown(n,t,i){if(n==""){$("#ddValue_"+t).val("");$("#ddparent_"+t).val("");var r=$("#dd_child"+t);r.empty();r.append($("",{value:"",text:"-- select an item --",selected:!0}))}else $.ajax({type:"POST",url:"/Catalog/GetCascadingAttribueItem/",data:{ParentId:""+n+"",ItmId:""+i+""},accept:"application/json",error:function(n){ShowErrorMessage("error: "+n.responseText)},success:function(i){var u=$("#dd_child"+t),r;u.empty();$.each(i,function(n,t){u.append($("",{value:t.Value,text:t.Text,selected:t.Selected}));t.Selected&&(r=t.Value)});r!=null&&($("#ddValue_"+t).val(r),$("#ddparent_"+t).val(n));GotoAction(0,t,0)}})}function MatchDescriptionValues(n,t,i,r){if(t=="V")if(r)if(n=="")FindCascadeDropDown("",i,"");else{var u=n.split(",");u.length>1&&FindCascadeDropDown(u[1],i,u[0])}else $("#ddDesc_"+i).val(n);else t=="D"&&(n!=""?$("#ddValue_"+i).val(n):$("#ddValue_"+i).val(""));GotoAction(0,i,0)}