var winId	= $.getUrlParam("winId");
var record = top.$("#"+winId).panel("options").data;
var jobid = record.jobid;
var type = record.type;
var jobStatus = record.jobStatus;
var flag = true;
var flagLog = true;
var flagPic= true;
var flagVideo = true;
var flagRecord = true;
var faultdeviceid	= $.getUrlParam("faultdeviceid");
var channelnum	= $.getUrlParam("channelnum");
var faultdevicename	= $.getUrlParam("faultdevicename");
var faultdevicetype	= $.getUrlParam("faultdevicetype");
$(function() {
	initDetailTab();
	initOrder();
});
function initOrder(){
	$.ajax({
		url : "ywrepairjobinfoAction!get_Ywrepairjobinfo.do",
		type : "POST",
		dataType : "JSON",
		async:false,
		data : {jobid:jobid},
		success : function(res){
			if(res){
				faultdevicetypename=res.faultdevicetypename;
				if(faultdevicetypename=='服务器'){
					console.log($("#detailtab .tabs li:eq(1)"))
					$("#detailtab .tabs li:eq(1)").hide();
					$("#detailtab .tabs li:eq(2)").hide();
					$("#detailtab .tabs li:eq(3)").hide();
				}
			}
			else{
				$.showMsg("未关联到工单！")
			}
		},
		error : function(res){ }
	});
}
//
function unloadWindow(){
	var winVideo		=	$("#repairVideo")[0].contentWindow;
	var winRecord		=	$("#repairRecord")[0].contentWindow;
	winVideo&&winVideo.unloadWindow&&winVideo.unloadWindow();
	winRecord&&winRecord.unloadWindow&&winRecord.unloadWindow();
}
function initDetailTab(){
	detailtab = $("#detailtab").tabs({
		onSelect:function(title,index){
			var winVideo		=	$("#repairVideo")[0].contentWindow;
			var winRecord		=	$("#repairRecord")[0].contentWindow;
			winVideo&&winVideo.unloadWindow&&winVideo.unloadWindow();
			winRecord&&winRecord.unloadWindow&&winRecord.unloadWindow();
			if(index==2){
				if(!flagVideo){
					$("#repairRecord").prop("src",'');
					$("#repairVideo").prop("src",'../ywrepairjobVideo/ywrepairjobVideo.jsp?jobid='+jobid+"&videonum="+faultdeviceid+"&channelnum="+channelnum+"&channelname="+encodeURI(faultdevicename));
				}
			}else if(index==3){
				if(!flagRecord){
					$("#repairVideo").prop("src",'');
					$("#repairRecord").prop("src",'../ywrepairjobRecord/ywrepairjobRecord.jsp?jobid='+jobid+"&videonum="+faultdeviceid+"&channelnum="+channelnum+"&channelname="+encodeURI(faultdevicename));
				}
			}else {
			}
			loadUserChannel(index);
		}
	});
}
//
function loadUserChannel(index){
	if(flag){
		if(index == 0 ){
			flag = false;
			$("#repairOrder").prop("src",'../ywworkorder/ywacceptworkorder.jsp?type='+type+'&jobid='+jobid+"&winId="+winId);
			return;
		}	
	}
	if(flagPic){
		if(index == 1){
			flagPic = false;
			$("#repairPic").prop("src",'../ywrepairjobPic/ywrepairjobPic.jsp?jobid='+jobid+'&jobStatus='+encodeURI(jobStatus));
			return;
		}
	}
	if(flagVideo){
		if(index == 2){
			flagVideo = false;
			$("#repairVideo").prop("src","../ywrepairjobVideo/ywrepairjobVideo.jsp?jobid="+jobid+"&videonum="+faultdeviceid+"&channelnum="+channelnum+"&channelname="+encodeURI(faultdevicename));
			return;
		}
	}
	if(flagRecord){
		if(index == 3){
			flagRecord = false;
			$("#repairRecord").prop("src","../ywrepairjobRecord/ywrepairjobRecord.jsp?jobid="+jobid+"&videonum="+faultdeviceid+"&channelnum="+channelnum+"&channelname="+encodeURI(faultdevicename));
			return;
		}
	}
	if(flagLog){
		if(index == 4){
			flagLog = false;
			$("#opreateLog").prop("src",'../ywrepairjoboplog/ywrepairjoboplog.jsp?jobid='+jobid);
			return;
		}
	}
}


