(function(factory) {
		 onloads(); 
		 var formid = $("input[name='FORMID']").val();
			var subFormid = $("input[name='SUB_FORMID']").val();
		    $(".action-buttons").attr("style","display:none");
			$(".action-buttons").parent().css("min-width","20px");
			$(".action-buttons").css("min-width","20px");
			$(".radio ").css("padding-top","5px");
		    var len = $(".subtable").find("tr").length - 2;//去除动态表格的拷贝行
			if("hidden" != $("input[name='"+subFormid+"_BUILDING_FLOOR_0']").attr('type')){
				for (var i = 0; i < len; i++) {
		    		var APPARATUS_TYPE=document.getElementsByName(subFormid+"_APPARATUS_TYPE_"+i);
	                APPARATUS_TYPE[0].parentNode.setAttribute("class","hidden");
	                APPARATUS_TYPE[0].parentNode.parentNode.innerHTML+="<span class='form-control'>"+APPARATUS_TYPE[0].getAttribute('default-value')+"</span>"
	               
	                var BUSINESS_TYPE=document.getElementsByName(subFormid+"_BUSINESS_TYPE_"+i);
	                BUSINESS_TYPE[0].parentNode.setAttribute("class","hidden");
	                BUSINESS_TYPE[0].parentNode.parentNode.innerHTML+="<span class='form-control'>"+BUSINESS_TYPE[0].getAttribute('default-value')+"</span>"

					var BUILDING_NUMBER=document.getElementsByName(subFormid+"_BUILDING_NUMBER_"+i);
	                BUILDING_NUMBER[0].parentNode.setAttribute("class","hidden");
	                BUILDING_NUMBER[0].parentNode.parentNode.innerHTML+="<span class='form-control'>"+BUILDING_NUMBER[0].getAttribute('default-value')+"</span>"
					wbkzd(subFormid+"_BUILDING_FLOOR_"+i);
					wbkzd(subFormid+"_ROOM_NUMBER_"+i);
					wbkzd(subFormid+"_OPENING_TIME_"+i);
					wbkzd(subFormid+"_CLOSE_TIME_"+i);
	                wbkzd(subFormid+"_USER_ID_"+i);
					wbkzd(subFormid+"_REMARK_"+i);
					dxkzd(subFormid+"_TEMPORARY_STATUE_"+i);
					dxkzd(subFormid+"_INSTALL_STATUE_"+i);
					var cldtype=document.getElementsByName(formid+"_CHULD_OPINION");
					var cldstatus=document.getElementsByName(formid+"_CLD_STATUS");
 					if(cldtype[0].getAttribute('type') =="hidden"){
						dxkzd(subFormid+"_SH_STATUE_"+i);
					}
					if("Node3"!=document.getElementsByName("nodeId")[0].value){
						dxkzd(subFormid+"_PHONE_NUMBER_"+i);
					}else{
						if("否"==$("input[name='"+subFormid+"_SH_STATUE_"+i+"']:checked").val()){
							dxkzd(subFormid+"_PHONE_NUMBER_"+i);
						}
					}	 
		    	}  
            }
}(function($) {
	
}));


function onloads(){
	var fromids = document.getElementsByName("FORMID");
	var fromid=fromids[0].value;
	var synchrotype=document.getElementsByName(fromid+"_SYNCHRO_TXL");
	//var hzdstatus=document.getElementsByName(fromid+"_HZD_STATUS");
	var synchro= document.getElementById("synchro");
	if(synchrotype[0].getAttribute('type') =="hidden"){
	  synchro.style.display="none";
	  var s = synchrotype[0].parentNode.children;
	  if(s.length>1){
	     synchro.removeAttribute("style");
	   }
	}
	var cldtype=document.getElementsByName(fromid+"_CHULD_OPINION");
	var cldstatus=document.getElementsByName(fromid+"_CLD_STATUS");
	var cldoption= document.getElementById("cldoption");
	if(cldtype[0].getAttribute('type') =="hidden"){
	  cldoption.style.display="none";
	  var cld = cldtype[0].parentNode.children;
	  if(cld.length>1 && ""!=cldstatus[1].value){
	      cldoption.removeAttribute("style");
	   }
	}else{
	 cldoption.removeAttribute("style");
	}
	var jldtype=document.getElementsByName(fromid+"_JULD_OPINION");
	var jldstatus=document.getElementsByName(fromid+"_JLD_STATUE");
	var jldoption= document.getElementById("jldoption");
	if(jldtype[0].getAttribute('type') =="hidden"){
	  jldoption.style.display="none";
	  var jld = jldtype[0].parentNode.children;
	  if(jld.length>1 && ""!=jldstatus[1].value){
	      jldoption.removeAttribute("style");
	   }
	}else{
	 jldoption.removeAttribute("style");
	}
	var fzghctype=document.getElementsByName(fromid+"_FZGHC_OPINION");
	var fzghcstatus=document.getElementsByName(fromid+"_FZGHC_STATUS");
	var fzghcoption= document.getElementById("fzghcoption");
	if(fzghctype[0].getAttribute('type') =="hidden"){
	  fzghcoption.style.display="none";
	  var fzghc = fzghctype[0].parentNode.children;
	  if(fzghc.length>1 && ""!=fzghcstatus[1].value){
	      fzghcoption.removeAttribute("style");
	   }
	}else if(fzghcstatus[0].getAttribute('disabled')){
		if( "同意"==fzghcstatus[1].value || "不同意"==fzghcstatus[1].value){
			fzghcoption.removeAttribute("style");
		}
	}else{
	 fzghcoption.removeAttribute("style");
	}
	var hzdstatue=document.getElementsByName(fromid+"_HZD_STATUS");
	var hzd= document.getElementById("hzd");
	//var hzd1= document.getElementById("hzd1");
	var hzd2= document.getElementById("hzd2");
	if(hzdstatue.length>1){
		if("是"==hzdstatue[1].value || "否"==hzdstatue[1].value){
			hzd.removeAttribute("style");
			//hzd1.removeAttribute("style");
			hzd2.removeAttribute("style");
			synchro.removeAttribute("style");
		}else{
			hzd.style.display="none";
			//hzd1.style.display="none";
			hzd2.style.display="none";
		}
	}
	
	var jctype=document.getElementsByName(fromid+"_URGENT_STATUE");
	var jc= document.getElementById("jc");
	if(jctype[0].getAttribute('type') =="hidden"){
	  jc.style.display="none";
	  var jccld = jctype[0].parentNode.children;
	  if(jccld.length>1){
	     jc.removeAttribute("style");
	   }
	}else{
	 jc.removeAttribute("style");
	}
	}
function ldsp(value,status,users){
	var phoneStatue=status;
	var phoneStatusNo="号码申请失败,"+users+"驳回";
	if("同意"==value){
		phoneStatue="1";
		phoneStatusNo="号码申请成功";
	}
	var formid = $("input[name='FORMID']").val();
    var subFormid = $("input[name='SUB_FORMID']").val();
    var len = $(".subtable").find("tr").length - 2;//去除动态表格的拷贝行
	for (var i = 0; i < len; i++) {
		  $("input[name='"+subFormid+"_PHONE_STATUE_"+i+"']").val(phoneStatue);
		  $("input[name='"+subFormid+"_PHONE_STATUENO_"+i+"']").val(phoneStatusNo);
	}
}
function getphone(phone,name){
	var i = name.substring(name.length-1,name.length);
	var subFormid = $("input[name='SUB_FORMID']").val();
	var formid = $("input[name='FORMID']").val();
	 if( phone.length==8){
	    if(!isNaN(phone)){
	    $.ajax({
		url: horizon.paths.apppath+'/app/jw/getJwInfodate.wf?phone='+phone,
		cache: false,
		dataType:'json',
		error: function(){
		horizon.notice.error(horizon.lang.message['operateError']);
		},
		success: function(viewData) {
			console.log(viewData);
			if(viewData != null){
				tsalerts('该号码('+phone+')已存在');
			     $("input[name='"+subFormid+"_PHONE_NUMBER_"+i+"']").val("");
			
			}
			}
		});
	    }else{
            tsalerts("请输入8位数字");
	     $("input[name='"+subFormid+"_PHONE_NUMBER_"+i+"']").val("");
	}
	  }else{
		  tsalerts("请输入8位数字");
	     $("input[name='"+subFormid+"_PHONE_NUMBER_"+i+"']").val("");
	}

	}
function selectphonne(name){
	document.getElementById("iframe1").src=document.getElementById("iframe2").value;
	document.getElementById("iframe1").src=document.getElementById("iframe1").src+"?inputName="+name+"&math="+Math.random();
	setTimeout(function(){
		document.getElementById("div_1").style.display="block";
	},200);
}
function returnPhone(value,inputName,type,index){
	var len = $(".subtable").find("tr").length - 2;//去除动态表格的拷贝行
	var subFormid = $("input[name='SUB_FORMID']").val();
	if(type=='single'){
		$("input[name='"+inputName+"']").val(value);
		document.getElementById("div_1").style.display="none";
	}else if(type=='doubles'){
		
			
		var phone_number=value.split(",");
		
		var j = 0;
		for (var i = 0; i < len; i++) {
			$("input[name='"+subFormid+"_PHONE_NUMBER_"+i+"']").val("");
			if($("input[name='"+subFormid+"_PHONE_NUMBER_"+i+"']").length>0){
				var is_fp_value=$("input[name='"+subFormid+"_SH_STATUE_"+i+"']:checked").val();
				if( is_fp_value=='是'){
					if(j < phone_number.length){
						$("input[name='"+subFormid+"_PHONE_NUMBER_"+i+"']").val(phone_number[j]);
						j++;
					}
				}
			}
			
			
		}
		
		document.getElementById("div_1").style.display="none";
	}
}
function returnPhone11(value,inputName,type,index){
	var len = $(".subtable").find("tr").length - 2;//去除动态表格的拷贝行
	var subFormid = $("input[name='SUB_FORMID']").val();
	if(type=='single'){
		$("input[name='"+inputName+"']").val(value);
		document.getElementById("div_1").style.display="none";
	}else if(type=='doubles'){
		if($("input[name='"+subFormid+"_PHONE_NUMBER_"+index+"']").length>0){
		  var is_fp_value=$("input[name='"+subFormid+"_SH_STATUE_"+index+"']:checked").val();
		  if( is_fp_value=='是'){
			$("input[name='"+subFormid+"_PHONE_NUMBER_"+index+"']").val(value);
				document.getElementById("div_1").style.display="none";
		  }
		}
	}
	/**for (var i = 0; i < len; i++) {
		  var input_value=$("input[name='"+subFormid+"_PHONE_NUMBER_"+i+"']").val();
		  var is_fp_value=$("input[name='"+subFormid+"_SH_STATUE_"+i+"']:checked").val();
		  if(input_value=='' && is_fp_value=='是'){
			$("input[name='"+subFormid+"_PHONE_NUMBER_"+i+"']").val(value);
				document.getElementById("div_1").style.display="none";
				return false;
		  }
		}*/
}
function returnPhoneOld(value,inputName){
	var len = $(".subtable").find("tr").length - 2;//去除动态表格的拷贝行
	var subFormid = $("input[name='SUB_FORMID']").val();
	if(inputName!=''){
		$("input[name='"+inputName+"']").val(value);
		document.getElementById("div_1").style.display="none";
	}else{
		for (var i = 0; i < len; i++) {
		  var input_value=$("input[name='"+subFormid+"_PHONE_NUMBER_"+i+"']").val();
		  var is_fp_value=$("input[name='"+subFormid+"_SH_STATUE_"+i+"']:checked").val();
		  if(input_value=='' && is_fp_value=='是'){
			$("input[name='"+subFormid+"_PHONE_NUMBER_"+i+"']").val(value);
				document.getElementById("div_1").style.display="none";
				return false;
		  }
		}
	}
	
	document.getElementById("iframe1").src=document.getElementById("iframe2").value;
	//document.getElementById("div_1").style.display="none";
}
function closeDiv(){
	document.getElementById("div_1").style.display="none";
	document.getElementById("iframe1").src=document.getElementById("iframe2").value;
	return false;
	//document.getElementById("iframe1").src=document.getElementById("iframe2").value;
}

function tsalerts(titles){
	var $dialogMessage = $('<div id="deleteRowConfirm"></div>');
    $dialogMessage.removeClass('hide').dialog({
        title: '提示',
        closeText: '关闭',
        dialogText: titles,
        dialogTextType: 'alert-danger',
        
    });
}
function dxkzd(id){
	$("input[name='"+id+"']").attr('onClick',"javascript:return false");
	$("input[name='"+id+"']").attr('readonly','true');
	$("input[name='"+id+"']").removeAttr("placeholder");
}
function wbkzd(id){
	$("input[name='"+id+"']").attr('readonly','true');
	$("input[name='"+id+"']").removeAttr("placeholder");
	$("input[name='"+id+"']").next().addClass('hidden');
}