";htmlToDraw+="
"+lng(options.humanName)+"
";}
else{htmlToDraw="
";htmlToDraw+="
"+lng(options.humanName)+":
";}
htmlToDraw+="
";htmlToDraw+="
";htmlToDraw+="
";var child=this.getChild(0);if(child instanceof jsCSideView){child.options.viewBoxSel=options.childBoxSel;child.inputId=this.inputId;}
$(options.viewBoxSel).html(htmlToDraw);jsRadio2SlotView.superclass.drawView.call(this);}
jsRadio2SlotView.prototype.disable=function(view){this.setOption("disabled",true);$(this.options.viewBoxSel).addClass("radio2Disabled");this.getChild(0).disable();}
jsRadio2SlotView.prototype.enable=function(view){this.setOption("disabled",false);$(this.options.viewBoxSel).removeClass("radio2Disabled");this.getChild(0).enable();}
jsRadio2SlotView.prototype.setError=function(statusCode){var child=this.getChild(0);statusCode=statusCode?statusCode:(child.statusCode?child.statusCode:this.statusCode);if(statusCode){alert(lng(statusCode));this.showError();}}
this.inputId=null;this.inputSel=null;}
extend(jsRadio2SlotView,jsCSideView);function jsInputFieldController(value){jsInputFieldController.superclass.constructor.call(this);this.ifaceTypes.input={type:jsInputClientView};this.ifaceTypes.select={type:jsSelectClientView};if(!no(window.jsSelectExClientView)){this.ifaceTypes.selectex={type:jsSelectExClientView};}
this.ifaceTypes.radio={type:jsRadioClientView};this.ifaceTypes.radio2={type:jsRadio2ClientView};this.ifaceTypes.checkbox={type:jsCheckboxClientView};this.ifaceTypes.number={type:jsNumberClientView};this.ifaceTypes.text={type:jsStaticTextClientView};this.changeModel(new jsInputModel(value));this.modified=false;this.setModified=function(obj){this.modified=true;return true;}
this.addEventHandler("fieldchange",this.setModified);}
extend(jsInputFieldController,jsController);function jsBaseInputView(ctrl,viewInx,options){jsBaseInputView.superclass.constructor.call(this,ctrl,viewInx,options);jsBaseInputView.prototype.html=function(htmlToDraw){var options=this.options;$(options.viewBoxSel).html(htmlToDraw);this.$input=$(this.inputSel);this.updateView();for(var i in options.extrattrs){this.$input.attr(i,options.extrattrs[i]);}
if(options.title){this.$input.attr("title",lng(options.title));}
if(options.disabled)this.disable();this.$input.bind("blur",context(this).callback(this.onfieldchangejq));}
jsBaseInputView.prototype.onfieldchangejq=function(event){var value=this.val();if(this.lastValue!=value){this.ctrl.event("fieldchange",{view:this,value:value},true);event.stopPropagation();this.validate();this.lastValue=value;}
return true;}
this.val=function(value){if(!no(value)){if(this.options.summary){this.$input.html(value);}
else{this.$input.val(value);}}
if(this.options.summary){return this.$input.html();}
else{return this.$input.val();}}
jsBaseInputView.prototype.disable=function(){$(this.inputSel).attr("disabled",true);}
jsBaseInputView.prototype.enable=function(){$(this.inputSel).attr("disabled",false);}
jsBaseInputView.prototype.validate=function(){if(this.options.optional){var patt=/.*Empty$/;if(patt.test(this.statusCode))this.statusCode=null;}
this.ctrl.event("validate",this,true);return jsBaseInputView.superclass.validate.call(this);}
this.$input=null;this.lastValue=null;}
extend(jsBaseInputView,jsCSideView);function jsInputClientView(ctrl,viewInx,options){jsInputClientView.superclass.constructor.call(this,ctrl,viewInx,options);jsInputClientView.prototype.drawView=function(){jsInputClientView.superclass.drawView.call(this);var htmlToDraw="";var options=this.options;if(options.summary){this.inputSel=options.viewBoxSel;delete this.inputId;}
else{if(no(this.inputId)){this.inputId="elemId"+getUID();}
this.inputSel="#"+this.inputId;htmlToDraw="
";}
this.html(htmlToDraw);}
jsInputClientView.prototype.updateModel=function(){this.ctrl.model.value=this.val();return jsInputClientView.superclass.updateModel.call(this);}
jsInputClientView.prototype.updateView=function(){this.val(this.ctrl.model.value);jsInputClientView.superclass.updateView.call(this);}}
extend(jsInputClientView,jsBaseInputView);function jsSelectClientView(ctrl,viewInx,options){jsSelectClientView.superclass.constructor.call(this,ctrl,viewInx,options);jsSelectClientView.prototype.drawView=function(){jsSelectClientView.superclass.drawView.call(this);var htmlToDraw="";var attr;var options=this.options;var value=this.ctrl.model.value;var valset=options.valset;if(options.summary){this.inputSel=options.viewBoxSel;delete this.inputId;}
else{if(no(this.inputId)){this.inputId="elemId"+getUID();}
this.inputSel="#"+this.inputId;htmlToDraw="
";if(valset){for(var i in valset){htmlToDraw+=""+lng(i)+" ";}}
htmlToDraw+=" ";}
this.html(htmlToDraw);this.$input.unbind("blur");this.$input.bind("change",context(this).callback(this.onfieldchangejq));}
this.val=function(value){var valset=this.options.valset;if(this.options.summary){if(!no(value)){var humanValue="";for(var i in valset){if(value==valset[i]){humanValue=i;break;}}
this.$input.html(lng(humanValue));}
return valset[this.$input.html()];}
else{if(!no(value)){this.$input.val(value);}
return this.$input.val();}}
this.updateModel=function(){this.ctrl.model.value=this.val();return jsSelectClientView.superclass.updateModel.call(this);}
this.updateView=function(){this.val(this.ctrl.model.value);jsSelectClientView.superclass.updateView.call(this);}}
extend(jsSelectClientView,jsBaseInputView);function jsRadioClientView(ctrl,viewInx,options){jsRadioClientView.superclass.constructor.call(this,ctrl,viewInx,options);this.drawView=function(){jsRadioClientView.superclass.drawView.call(this);var htmlToDraw="";var attr;var value=this.ctrl.model.value;var options=this.options;var valset=options.valset;if(options.summary){this.inputSel=options.viewBoxSel;delete this.inputId;var humanValue=value;if(valset){for(var i in valset){if(value==valset[i]){humanValue=i;break;}}}
htmlToDraw+=no(humanValue)?"":lng(humanValue);}
else{if(no(this.inputId)){this.inputId="elemId"+getUID();}
this.inputSel=options.viewBoxSel+" input[name='"+this.inputId+"']";if(valset){for(var i in valset){htmlToDraw+="
"+lng(i)+"
";}}}
this.html(htmlToDraw);this.$input.unbind("blur");this.$input.bind("change",context(this).callback(this.onfieldchangejq));}
this.val=function(value){var valset=this.options.valset;if(this.options.summary){if(!no(value)){var humanValue="";for(var i in valset){if(value==valset[i]){humanValue=i;break;}}
this.$input.html(lng(humanValue));}
return valset[this.$input.html()];}
else{if(!no(value)){var j=0;for(var i in valset){if(value==valset[i]){this.$input.eq(j).attr("checked",true);}
else{this.$input.eq(j).attr("checked",false);}
j++;}}
if(this.$input.length>0&&!this.$input.filter(":checked").length){return this.$input.filter(":eq(0)").val();}
else{return this.$input.filter(":checked").val();}}}
this.updateModel=function(){this.ctrl.model.value=this.val();return jsRadioClientView.superclass.updateModel.call(this);}
this.updateView=function(){this.val(this.ctrl.model.value);jsRadioClientView.superclass.updateView.call(this);}}
extend(jsRadioClientView,jsBaseInputView);function jsRadio2ClientView(ctrl,viewInx,options){jsRadio2ClientView.superclass.constructor.call(this,ctrl,viewInx,options);this.drawView=function(){jsRadio2ClientView.superclass.drawView.call(this);var htmlToDraw="";var attr;var value=this.ctrl.model.value;var options=this.options;var valset=options.valset;var obj;var id;if(options.summary){this.inputSel=options.viewBoxSel;delete this.inputId;}
else{if(no(this.inputId)){this.inputId="elemId"+getUID();}
this.inputSel=this.myBoxSel+" input[name='"+this.inputId+"']";if(valset){htmlToDraw+="
";}}
this.html(htmlToDraw);this.$input.unbind("blur");this.$input.bind("change",context(this).callback(this.onfieldchangejq));}
this.val=function(value){var valset=this.options.valset;if(this.options.summary){if(!no(value)){this.$input.html(lng(valset[value].value));}
var humanValue=this.$input.html();for(var i in valset){if(humanValue==lng(valset[i])){return i;}}}
else{if(!no(value)){var j=0;for(var i in valset){if(value==i){this.$input.eq(j).attr("checked",true);}
else{this.$input.eq(j).attr("checked",false);}
j++;}}
if(this.$input.length>0&&!this.$input.filter(":checked").length){return this.$input.filter(":eq(0)").val();}
else{return this.$input.filter(":checked").val();}}}}
extend(jsRadio2ClientView,jsRadioClientView);function jsCheckboxClientView(ctrl,viewInx,options){jsCheckboxClientView.superclass.constructor.call(this,ctrl,viewInx,options);this.drawView=function(){jsCheckboxClientView.superclass.drawView.call(this);var htmlToDraw="";var options=this.options;if(options.summary){this.inputSel=options.viewBoxSel;delete this.inputId;}
else{if(no(this.inputId)){this.inputId="elemId"+getUID();}
this.inputSel="#"+this.inputId;htmlToDraw+="
";}
this.html(htmlToDraw);this.$input.unbind("blur");this.$input.bind("change",context(this).callback(this.onfieldchangejq));}
this.val=function(value){var options=this.options;var valset=options.valset;if(options.summary){if(!no(value)){if(value==valset.on){this.$input.html(lng("yes"));}
else{this.$input.html(lng("no"));}}
if(this.$input.html()==lng("yes")){return valset.on;}
else{return valset.off;}}
else{if(!no(value)){if(value==options.valset.on){this.$input.attr("checked",true);}
else{this.$input.attr("checked",false);}}
if(this.$input.attr("checked")){return valset.on;}
else{return valset.off;}}}
this.updateModel=function(){this.ctrl.model.value=this.val();return jsCheckboxClientView.superclass.updateModel.call(this);}
this.updateView=function(){this.val(this.ctrl.model.value);jsCheckboxClientView.superclass.updateView.call(this);}}
extend(jsCheckboxClientView,jsBaseInputView);function jsNumberClientView(ctrl,viewInx,options){jsNumberClientView.superclass.constructor.call(this,ctrl,viewInx,options);this.drawView=function(){jsNumberClientView.superclass.drawView.call(this);}
this.updateView=function(){jsNumberClientView.superclass.updateView.call(this);}
this.updateModel=function(){var res=false;if(this.validate()){res=jsNumberClientView.superclass.updateModel.call(this);var value=this.ctrl.model.value;if(value&&value!=""){this.ctrl.model.value=parseInt(this.ctrl.model.value,10);}}
return res;}
this.validate=function(){var result=true;var value;var re=new RegExp("^[0-9]+(\.?[0-9]+|[0-9]*)$");var options=this.options;value=this.val();if(value.match(/^\s*$/)){this.statusCode="numEmpty";}
else if(!re.test(value)){this.statusCode="numNaN";}
else if(!no(options.minval)&&value
options.maxval){this.statusCode="numMoreThanMax";}
else{this.statusCode=null;}
if((this.options.ishidden||this.options.disabled)&&this.statusCode){this.val(undefined);this.statusCode=null;}
return jsNumberClientView.superclass.validate.call(this);}}
extend(jsNumberClientView,jsInputClientView);function jsStaticTextClientView(ctrl,viewInx,options){jsStaticTextClientView.superclass.constructor.call(this,ctrl,viewInx,options);jsStaticTextClientView.prototype.drawView=function(){jsStaticTextClientView.superclass.drawView.call(this);var options=this.options;this.inputSel=options.viewBoxSel;delete this.inputId;this.html("");}
this.val=function(value){if(!no(value)){this.$input.html(value);}
return this.$input.html();}
jsStaticTextClientView.prototype.updateView=function(){this.val(this.ctrl.model.value);jsStaticTextClientView.superclass.updateView.call(this);}}
extend(jsStaticTextClientView,jsBaseInputView);controlTypes.input=function(obj){obj.ctrl=new jsInputController(obj.value);obj.nextIface="input";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;}
controlTypes.password=function(obj){obj.ctrl=new jsInputController(obj.value);obj.nextIface="input";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;opt.password=true;}
controlTypes.select=function(obj){obj.ctrl=new jsInputController(obj.value);obj.nextIface="select";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;opt.valset=obj.valset;}
controlTypes.radio=function(obj){obj.ctrl=new jsInputController(obj.value);obj.nextIface="radio";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;opt.valset=obj.valset;}
controlTypes.checkbox=function(obj){obj.ctrl=new jsInputController(obj.value);obj.nextIface="checkbox";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;if(obj.valset){opt.valset=obj.valset;}
else{opt.valset={on:true,off:false};}}
controlTypes.number=function(obj){obj.ctrl=new jsInputController(obj.value);obj.nextIface="number";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;opt.minval=obj.minval;opt.maxval=obj.maxval;}
controlTypes.text=function(obj){obj.ctrl=new jsInputController(obj.value);obj.nextIface="text";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;}
controlTypes.selectex=function(obj){obj.ctrl=new jsInputController(obj.value);obj.nextIface="selectex";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;opt.editable=obj.editable;opt.width=obj.width;opt.height=obj.height;}
function jsSelectExClientView(ctrl,viewInx,options){jsSelectExClientView.superclass.constructor.call(this,ctrl,viewInx,options);jsSelectExClientView.prototype.drawView=function(){var htmlToDraw="";var options=this.options;var elemID="elemID"+getUID();var childCtrls=this.ctrl.children;var childBoxSel=null;var obj;if(options.summary){this.inputSel=options.viewBoxSel+">div.selectex>div.s_ex_input";this.childBoxSel=options.viewBoxSel+">div.selectex>div.box";this.options.childBoxSel=this.childBoxSel;if(childCtrls.length>0){obj=this.getChild(0);obj.options.viewBoxSel=this.options.childBoxSel;obj.viewBoxSel=obj.options.viewBoxSel;}
htmlToDraw+="";htmlToDraw+="
";htmlToDraw+="
";htmlToDraw+="
";delete this.inputId;}
else{if(no(this.inputId)){this.inputId="elemId"+getUID();}
this.inputSel="#"+this.inputId;this.childBoxSel=options.viewBoxSel+">div.selectex>div.box";this.options.childBoxSel=this.childBoxSel;if(childCtrls.length>0){obj=this.getChild(0);obj.options.viewBoxSel=this.options.childBoxSel;obj.viewBoxSel=obj.options.viewBoxSel;}
htmlToDraw+="";htmlToDraw+="
";htmlToDraw+=" ";htmlToDraw+="
";htmlToDraw+="
";htmlToDraw+="
";htmlToDraw+="
";htmlToDraw+="
";}
this.html(htmlToDraw);jsSelectExClientView.superclass.drawView.call(this);if(!options.summary){if(options.width){$(this.childBoxSel).css('width',options.width);}
if(options.height){$(this.childBoxSel).css('height',options.height);}
if(childCtrls.length>0){$(this.childBoxSel).append("
");}
if(!options.disabled){this.$input.click(context(this).callback(this.showBox));$(options.viewBoxSel+'>div.selectex>div.s_ex_btn').click(context(this).callback(this.setDisplayBox));this.$input.keypress(context(this).callback(this.keyPress));if($.browser.msie||$.browser.webkit){this.$input.keydown(context(this).callback(this.keyDown));}
$(window).click(context(this).callback(this.onbodyclick));$(options.viewBoxSel).click(context(this).callback(this.onviewboxclick));}
else{$(options.viewBoxSel+'>div.selectex>div.s_ex_btn').addClass("disabled");}
this.getChild(0).setItemSelected(this.ctrl.model.value);}}
this.onbodyclick=function(){if(!this.infocus){this.hideBox(this.getChild(0).selectedSelectExItem.length);}
this.infocus=false;return true;}
this.onviewboxclick=function(){this.infocus=true;}
this.setDisplayBox=function(e){this.$input.focus();if($(this.childBoxSel).is(':visible')){this.hideBox(false);}else{this.showBox();}
this.onviewboxclick(e);$(window).click();return false;}
this.showBox=function(){$(this.childBoxSel).slideDown();}
this.hideBox=function(isSelected){if(!isSelected){this.updateView();}
$(this.childBoxSel).slideUp();}
this.keyDown=function(event){if(event.keyCode==9||event.keyCode==38||event.keyCode==40){this.keyPress(event);return false;}}
this.keyPress=function(event){var rootOfList=this.getChild(0);var item;var name;if(event.keyCode==13){if($(this.childBoxSel).is(':visible')){if(rootOfList.currentSelectExItem){if(rootOfList.currentSelectExItem.getName()){this.onselectitem(rootOfList.currentSelectExItem);}
var i=this.$input.val().length;this.$input.caret(i,i);}}
else if(!$(this.childBoxSel).is(':visible')){this.showBox();}}
if(!isCharCode(event.which)&&event.keyCode!=9&&event.keyCode!=38&&event.keyCode!=40){return true;}
if(!$(this.childBoxSel).is(':visible')){this.showBox();}
if(event.keyCode==38){if(rootOfList.currentSelectExItem.ctrl.thisInx>0){item=rootOfList.currentSelectExItem.getParent().getChild(rootOfList.currentSelectExItem.ctrl.thisInx-1).setItemSelected();name=item.getName();if(name){this.$input.val(lng(name));}}
return true;}
if(event.keyCode==40){if(rootOfList.currentSelectExItem.ctrl.thisInx0&&rightText==null){rootOfList.clearVisited();rightText=rootOfList.searchItem(leftText);}
if(rightText!=null){this.$input.val(rightText);this.$input.caret(caret.start+offset,rightText.length);}else{this.$input.caret(caret.start,this.$input.val().length);}
return false}
isCharCode=function(x){if(x>46&&x!=91&&x!=92||x==32){return true;}else{return false;}}
this.updateModel=function(){this.ctrl.model.value=this.val();return jsSelectExClientView.superclass.updateModel.call(this);}
this.updateView=function(){this.val(this.ctrl.model.value);jsSelectExClientView.superclass.updateView.call(this);}
this.onselectitem=function(obj){var name=lng(obj.getName());var val=obj.ctrl.model.getValue();this.tempValue=val;this.$input.val(name);obj.setItemSelected();this.hideBox(true);this.ctrl.event('fieldchange',{view:this,value:val},true);return false;}
this.val=function(value){if(!no(value)){var name=this.getChild(0).findItemName(value);if(this.options.summary){this.$input.html(lng(name));}
else{this.$input.val(lng(name));}
this.tempValue=value;}
return this.tempValue;}
this.bind("selectitem",this.onselectitem);this.tempValue=this.ctrl.model.value;this.infocus=false;}
extend(jsSelectExClientView,jsBaseInputView);function jsSelectExItemModel(itemInfo){jsSelectExItemModel.superclass.constructor.call(this);this.itemName=(itemInfo.name)?itemInfo.name:'';this.itemValue=(itemInfo.value)?itemInfo.value:null;this.getValue=function(){if(!this.ctrl.children.length){return this.ctrl.model.itemValue;}
return null;};}
extend(jsSelectExItemModel,jsModel);function jsSelectExItemController(itemInfo,options){jsSelectExItemController.superclass.constructor.call(this);if(itemInfo==undefined){itemInfo={};}
this.changeModel(new jsSelectExItemModel(itemInfo));this.ifaceTypes.tree={type:jsSelectExItemView,def:true,options:{style:null,open:false,noPath:true}};}
extend(jsSelectExItemController,jsController);function jsSelectExItemView(ctrl,viewInx,options){jsSelectExItemView.superclass.constructor.call(this,ctrl,viewInx,options);this.getName=function(){if(!this.ctrl.children.length){return this.ctrl.model.itemName;}
return null;};this.click=function(e){this.ctrl.event("selectitem",this,true);return true;}
jsSelectExItemView.prototype.drawView=function(){jsSelectExItemView.superclass.drawView.call(this);if(!this.ctrl.root){$(this.myBoxSel).html(lng(this.ctrl.model.itemName));$(this.viewBoxSel).parent().addClass('selectexItem');if(this.ctrl.children.length>0){$(this.viewBoxSel).addClass('branch_close');}else{$(this.viewBoxSel).addClass('leaf');$(this.viewBoxSel+'>a').bind('click',context(this).callback(this.click));}}}
jsSelectExItemView.prototype.onactivate=function(){jsSelectExItemView.superclass.onactivate.call(this);if(!this.ctrl.root){if(this.ctrl.children.length>0){$(this.viewBoxSel).removeClass('branch_close');$(this.viewBoxSel).addClass('branch_open');}else{$(this.viewBoxSel+'>a').css('font-weight','normal');}}
return false;}
jsSelectExItemView.prototype.ondeactivate=function(){jsSelectExItemView.superclass.ondeactivate.call(this);if(!this.ctrl.root){if(this.ctrl.children.length>0){$(this.viewBoxSel).removeClass('branch_open');$(this.viewBoxSel).addClass('branch_close');}}
return false;}
this.setItemSelected=function(value){if(no(value)||value==this.ctrl.model.itemValue){this.clearSelection();$(this.options.viewBoxSel).addClass('marked');this.ctrl.activate();this.rootOfTree.currentSelectExItem=this;this.rootOfTree.selectedSelectExItem.push(this);return this;}
else{var obj;for(var i in this.ctrl.children){obj=this.getChild(i).setItemSelected(value);if(obj){return obj;}}}
return null;}
this.clearSelection=function(){$(this.rootOfTree.options.viewBoxSel+' ul.selectexItem>li.marked').removeClass('marked');}
this.clearVisited=function(){this.rootOfTree.selectedSelectExItem=[];}
this.isNotVisited=function(){for(var i in this.rootOfTree.selectedSelectExItem){if(this.rootOfTree.selectedSelectExItem[i]==this){return false;}}
return true;}
this.searchItem=function(str){var result=null;var obj;var currName=lng(this.ctrl.model.itemName);if(this.isNotVisited()&&!no(this.ctrl.model.itemValue)&&currName.length>=str.length&&currName.substring(0,str.length).toLowerCase()==str.toLowerCase()){this.setItemSelected();return currName;}
else{for(var i in this.ctrl.children){result=this.getChild(i).searchItem(str);if(!no(result)){return result;}}}
return null;}
this.findItemName=function(value){var model=this.ctrl.model;if(model.itemValue==value){return model.itemName;}
else{var itemName;for(var i in this.ctrl.children){itemName=this.getChild(i).findItemName(value);if(!no(itemName)){return itemName;}}}
return null;}
this.selectedSelectExItem=[];this.bind("activate",this.onactivate);this.bind("deactivate",this.ondeactivate);}
extend(jsSelectExItemView,jsViewTree);function jsSubNetAddrModel(bits,addr,radix,delim,expandZero,omitFullMask){jsSubNetAddrModel.superclass.constructor.call(this);jsSubNetAddrModel.prototype.getMaskParts=function(){var i=0;var partCount=this.parts.length;var partMax=Math.pow(2,this.partBitCount)-1;var b=this.bitmask-this.partBitCount;var maskParts=new Array();while(b>=0&&i1){this.bitmask=addrArray[1];}
else{this.bitmask=this.bits}}
this.radix=no(radix)?this.radix:radix;this.delim=no(delim)?this.delim:delim;if(!addr&&this.parts instanceof Array){for(var i in this.parts){this.parts[i]=null;}}
else if(addr){if(addr instanceof Array){this.parts=addr;}
else{if(this.radix&&this.delim){var strParts=addr.split(this.delim);this.partBitCount=this.bits/strParts.length;for(var i in strParts){this.parts[i]=this.parsePart(strParts[i],this.radix);}}}}
this.partBitCount=this.bits/this.parts.length;this.digitCount=Math.ceil(Math.log(Math.pow(2,this.partBitCount))/Math.log(this.radix));}
jsSubNetAddrModel.prototype.parsePart=function(part,radix){var res=null;if(!this.checkPart(part,Math.pow(2,this.partBitCount)-1)){res=parseInt(part,radix);}
return res;}
this.checkPart=function(part,maxval,radix){var res=null;var empty=(no(part)||part.toString().match(/^\s*$/));var isString=part instanceof String||typeof(part)=="string";var radix=radix?radix:this.radix;if(empty){res="Empty";}
else{if(isString){var p=parseInt(part,radix).toString(radix);if(!part.match(/^0+$/)&&(p=="NaN"||p.length!=part.replace(/^0*/,"").length)){res="NaN";}
else{part=parseInt(part,radix);}}
if(!res){if(part<0){res="OutOfScope";}
else if(part>maxval){res="OutOfScope";}}}
return res;}
jsSubNetAddrModel.prototype.toString=function(){var parts=this.parts;var addr="";var clear=false;var part;var format="%."+this.digitCount;switch(this.radix){case 2:format+="b";break;case 8:format+="o";break;case 10:format+="d";break;case 16:format+="X";break;default:format+="d";break;}
if(parts.length){var noPart;for(var i=0;i ";}
this.html(htmlToDraw);if(!options.summary&&(model.bitmask0){var classX=parseInt(ip.substring(0,ip.indexOf('.')));if(classX>=1&&classX<=126){return'255.0.0.0';}
if(classX>=128&&classX<=191){return'255.255.0.0';}
if(classX>=192&&classX<=223){return'255.255.255.0';}
return'255.255.255.0';}
return null;}
var mask=guessMask(ip);if(mask){this.ctrl.model.setParts(mask);this.updateView();}
return true;}
this.partCount=this.ctrl.model.parts.length;this.partBitCount=this.ctrl.model.bits/this.partCount;this.bitmaskDigitCount=Math.ceil(Math.log(this.ctrl.model.bits)/Math.log(10));this.bind("fieldchange",this.onfieldchange);this.bind("guessmask",this.onguessmask);}
extend(jsSubNetAddrClientView,jsBaseInputView);controlTypes.mac=function(obj){obj.ctrl=new jsMAController(obj.value);obj.nextIface="client";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;}
function jsNetAddrController(bits,addr,radix,delim,expandZero){jsNetAddrController.superclass.constructor.call(this);this.ifaceTypes.client={type:jsSubNetAddrSlotView,options:{}};this.addChild(new jsSubNetAddrFieldController(bits,addr,radix,delim,expandZero,true),"field");this.changeModel(this.getChild("field").model);}
extend(jsNetAddrController,jsEditController);function jsMAController(addr){if(!addr)addr=[null,null,null,null,null,null];jsMAController.superclass.constructor.call(this,48,addr,16,":",true);this.ifaceTypes.client.options={delim:":",radix:16};}
extend(jsMAController,jsNetAddrController);controlTypes.ipsubnet=function(obj){obj.ctrl=new jsSubNetIPController(obj.value,obj.version);obj.nextIface="client";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;}
controlTypes.ipv4subnet=function(obj){obj.ctrl=new jsSubNetIPv4Controller(obj.value);obj.nextIface="client";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;}
controlTypes.ipv6subnet=function(obj){obj.ctrl=new jsSubNetIPv6Controller(obj.value);obj.nextIface="client";if(!obj.options)obj.options={};var opt=obj.options;opt.humanName=obj.name;}
function jsSubNetIPModel(bits,addr,radix,delim,expandZero,omitFullMask){jsSubNetIPModel.prototype.setParts=function(addr,radix,delim){if(this.bits==32){jsSubNetIPModel.superclass.setParts.call(this,addr,radix,delim);}
else{if(!addr||addr instanceof Array){jsSubNetIPModel.superclass.setParts.call(this,addr,radix,delim);}
else{this.radix=no(radix)?this.radix:radix;this.delim=no(delim)?this.delim:delim;this.partBitCount=16;var bitmask=addr.split("/")[1];if(no(bitmask)){this.bitmask=this.bits;}
else{this.bitmask=parseInt(bitmask);}
if(addr.match(/^::ffff:[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}/)){this.parts=this.parseIPv4MappedIPv6(addr);}
else if(addr.match(/::/)||addr.match(/^0+:0+/)||addr.match(/0+:0+$/)){this.parts=this.parseShortNotation(addr);}
else{jsSubNetIPModel.superclass.setParts.call(this,addr,radix,delim);}
this.partBitCount=this.bits/this.parts.length;this.digitCount=Math.ceil(Math.log(Math.pow(2,this.partBitCount))/Math.log(this.radix));}}}
this.parseShortNotation=function(addr){addr=addr.split(/\//)[0];addr=addr.replace(/^::/,"z:");addr=addr.replace(/::$/,":z");addr=addr.replace(/^0:0/,"z:");addr=addr.replace(/0:0$/,":z");addr=addr.replace(/::/,":z:");var arr=addr.split(/:/);var parts=[0,0,0,0,0,0,0,0];var j=0;for(var i in arr){if(arr[i]!="z"){parts[j++]=this.parsePart(arr[i],this.radix);}
else{break;}}
j=parts.length-1;for(var i=arr.length-1;i>=0;i--){if(arr[i]!="z"){parts[j--]=this.parsePart(arr[i],this.radix);;}
else{break;}}
return parts;}
this.parseIPv4MappedIPv6=function(addr){var parts=[0,0,0,0,0,0xffff,0,0];var ipv4=addr.match(/[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,3}/)[0];var arr=ipv4.split(".");var part7=sprintf("%.2X%.2X",parseInt(arr[0],10),parseInt(arr[1],10));parts[6]=this.parsePart(part7,this.radix);var part8=sprintf("%.2X%.2X",parseInt(arr[2],10),parseInt(arr[3],10));parts[7]=this.parsePart(part8,this.radix);return parts;}
jsSubNetIPModel.prototype.toString=function(noMappedIPv4){if(this.bits==32){return jsSubNetIPModel.superclass.toString.call(this);}
else{var addr="";var parts=this.parts;if(!noMappedIPv4&&parts[0]==0&&parts[1]==0&&parts[2]==0&&parts[3]==0&&parts[4]==0&&parts[5]==0xffff){if(!no(parts[6])&&!no(parts[7])){addr=sprintf("::ffff:%d.%d.%d.%d",(parts[6]&0xff00)>>>8,parts[6]&0x00ff,(parts[7]&0xff00)>>>8,parts[7]&0x00ff);if(this.bitmask0&&z<=i)){addr+=part.toString(this.radix);}
else{z++;}
addr+=this.delim;}
else{clear=true;break;}}
if(!no(parts[parts.length-1])&&!clear){if(parts[parts.length-1]||(z>0&&z<=i)){addr+=parts[parts.length-1].toString(this.radix);}}
else{addr="";}
addr=addr.replace(/:[0:]+/,"::");addr=addr.replace(/::[0:]+/,"::");addr=addr.replace(/:::+/,"::");if(!clear&&(this.bitmask"
+"
"
+""
if(options.label){htmlToDraw+=""
+" "+lng(options.label)
+" ";}
htmlToDraw+=""
+"
"
+""
+"
"
+" ";htmlToDraw+="