
$(document).ready(function(){var item='<a href="#" class="wizard-add-row" onclick="wizard_add_row(this);return false">Add Row</a> | <a href="#" class="wizard-del-row" onclick="wizard_del_row(this);return false" title="Deletes bottom-most row">Delete Row</a>';$(item).insertAfter('.adddeleterow');$("#wizardimportonly").change(function(){if(this.checked){var val=1}else{var val=0}
var optsarr={"keyname":"wizard_import_only","keyvalue":val};var opts=JSON.stringify(optsarr);get_ajax_data('setusermeta',opts);});$('#sel-default-tpl').change(function(){var wizard=$('input[name="wizard"]').val();var optsarr={"keyname":"wizard_"+wizard+"_tpl_default","keyvalue":$(this).val()};var opts=JSON.stringify(optsarr);get_ajax_data('setusermeta',opts);});if($('#open-cwform').length>0){var p=$('#open-cwform').position();var left=Math.floor(p.left+16)-($('#cwform').outerWidth()/2);var top=Math.floor(p.top+26);$('#cwform').css('left',left+'px');$('#cwform').css('top',top+'px');$("#open-cwform").click(function(){var d=$("#cwform").css("display");if(d=="none"){$("#cwform").fadeIn("fast");}else{$("#cwform").fadeOut("fast");}});}
function onFocusHandler(){var $this=$(this);$this.data('original-name',$this.attr('name')||null);$this.data('original-id',$this.attr('id')||null);if($this.attr('name')){$this.attr('name','obfuscated-name-'+Math.random());}
if($this.attr('id')){$this.attr('id','obfuscated-id-'+Math.random());}
$this.on('keydown',function(e){if(e.which===13){revertToOriginal($this);}});}
function onBlurHandler(){revertToOriginal($(this));}
function revertToOriginal($element){if($element.data('original-name')){$element.attr('name',$element.data('original-name'));}else{$element.removeAttr('name');}
if($element.data('original-id')){$element.attr('id',$element.data('original-id'));}else{$element.removeAttr('id');}}
var selectors=['input[id="address"]','input[id="hostname"]','input[id="ip_address"]','input[id="domain_name"]','input[name="address"]','input[name="hostname"]','input[name="ip_address"]','input[name="domain_name"]'];$(selectors.join(',')).focus(onFocusHandler);$(selectors.join(',')).blur(onBlurHandler);$('input[type="text"], textarea').change(function(){var $this=$(this);$this.val($this.val().trim());});});function wizard_add_row(clickedelement){var table=$(clickedelement).prev()[0];var $tr=$(table).find("tbody tr:last").clone();$tr.find("input,select").attr("name",function(){var parts=this.name.match(/(\d+)/g);var newname=this.name.replace(/[\d]+/g,++parts);switch(this.type){case"text":this.value="";break;case"checkbox":this.checked=true;break;case"select-one":this.selectedIndex=0;break;}
return newname;});$(table).find("tbody tr:last").after($tr);}
function wizard_del_row(clickedelement){try{var table=$(clickedelement).prev().prev()[0];var row_count=table.rows.length;if(row_count<=2){return;}
table.deleteRow(row_count-1);}catch(e){alert(e);}}