

$(function () {
	 //添加修改密码窗口开始
	frame("updatePasswordContentWin", "movePasswordWin", "closePasswordWin");
	 //添加修改密码窗口结束
	
	if ($("#usertypeId").val() == "0" || $("#usertypeId").val() == "1" || $("#usertypeId").val() == "2" || $("#usertypeId").val() == "-1") {
		$("#menu_manager").show();
	}
});
function openUpdatePwdWin(){
	$("#updatePasswordContentWin").center();
	$("#updatePasswordContentWin").show();
	$("#updatePassBtn").removeAttr("disabled");
}
function updatePassword(){
	$("#updatePassBtn").attr("disabled", true);
	var curPwdcurPwd = $("#curPassword").val(), newPwd = $("#newPassword").val(), renewPwd = $("#renewPassword").val();
	if (curPwdcurPwd.length == 0 || newPwd.length == 0 || renewPwd.length == 0) {
		$("#updatePasswordMsg").css("color", "red");
		$("#updatePasswordMsg").text(language.mmbnwk);
		$("#updatePassBtn").removeAttr("disabled");
		return;
	}
	if (newPwd != renewPwd) {
		$("#updatePasswordMsg").css("color", "red");
		$("#updatePasswordMsg").text(language.cfmmhxmmbyz);
		$("#updatePassBtn").removeAttr("disabled");
		return;
	}
	$("#updatePasswordMsg").css("color", "rgb(153, 153, 153)");
	$("#updatePasswordMsg").text(language.zztj);
	$.ajax({type:"POST", dataType:"json", url:"json/loginAction_update.action", data:{"userPass":curPwdcurPwd, "newUserPass":newPwd, "renewUserPass":renewPwd}, success:function (json) {
		if (json.flag == true) {
			$("#closePasswordWin").click();
			$("#updatePasswordMsg").css("color", "rgb(153, 153, 153)");
			$("#updatePasswordMsg").text(language.mmbnwk);
		} else {
			$("#updatePasswordMsg").css("color", "red");
			$("#updatePasswordMsg").text(json.msg);
			$("#updatePassBtn").removeAttr("disabled");
			return;
		}
	}, error:function () {
	}});
}
function memoryStatus(flag) {
	if ($("#userId").val().length != 0) {
		var statusCookie = $.cookie("userStatus");
		var statusArr = null;
		if (statusCookie != null && statusCookie.length != 0){
			statusArr = JSON.parse(statusCookie); //字符串转化成JSON数据
		} else {
			statusArr = new Array();
		}
		var obj = null;
		for (var i = 0; i < statusArr.length; i++) {
			if (statusArr[i].id == $("#userId").val()) {
				obj = statusArr[i];
				if (flag) {
					obj.mapType = mapType;
				} else {
					obj.mapType = mapType;
				}
				if (mapType == 2) {
					if (map != undefined) {
						statusArr[i].lat = map.getCenter().lat();
						statusArr[i].lng = map.getCenter().lng();
						statusArr[i].gzoom = map.getZoom();
					}
				} else {
					if (baidMap != undefined) {
						statusArr[i].lat = baidMap.getCenter().lat;
						statusArr[i].lng = baidMap.getCenter().lng;
						statusArr[i].bzoom = baidMap.getZoom();
					}
				}
				break;
			}
		}
		if (obj == null) {
			obj = new Object();
			obj.id = $("#userId").val();
			if (flag) {
				obj.mapType = (mapType == 1) ? 2 : 1;
			} else {
				obj.mapType = mapType;
			}
			
				if (mapType == 2) {
					if (map != undefined) {
						obj.gzoom = map.getZoom();
						obj.lat = map.getCenter().lat();
						obj.lng = map.getCenter().lng();
						obj.bzoom = 6;
					}
				} else {
					if (baidMap != undefined) {
						obj.bzoom = baidMap.getZoom();
						obj.lat = baidMap.getCenter().lat;
						obj.lng = baidMap.getCenter().lng;
						obj.gzoom = 6;
					}
				}
			statusArr.push(obj);
		}
		var statusString = JSON.stringify(statusArr); //JSON 数据转化成字符串
		$.cookie("userStatus",statusString,{expires:7});
	}
}
function getUserStatus(){
	var obj = null;
	if ($("#userId").val().length != 0) {
		var statusCookie = $.cookie("userStatus");
		if (statusCookie != null && statusCookie.length != 0) {
			var statusArr = JSON.parse(statusCookie); //字符串转化成JSON数据
			for (var i = 0; i < statusArr.length; i++) {
				if (statusArr[i].id == $("#userId").val()) {
					obj = statusArr[i];
					break;
				}
			}
			return obj;
		} else {
			return null;
		}
	} else {
		return null;
	}
}
function memoryWarmVoiceStatus(status) {
	if ($("#userId").val().length != 0) {
		var statusCookie = $.cookie("warmVoiceStatus");
		var statusArr = null;
		if (statusCookie != null && statusCookie.length != 0) {
			statusArr = JSON.parse(statusCookie); //字符串转化成JSON数据
		} else {
			statusArr = new Array();
		}
		var obj = null;
		for (var i = 0; i < statusArr.length; i++) {
			if (statusArr[i].id == $("#userId").val()) {
				obj = statusArr[i];
				statusArr[i].warmstatus = status;
				break;
			}
		}
		if (obj == null) {
			obj = new Object();
			obj.id = $("#userId").val();
			obj.warmstatus = status;
			statusArr.push(obj);
		}
		var statusString = JSON.stringify(statusArr); //JSON 数据转化成字符串
		$.cookie("warmVoiceStatus", statusString, {expires:7});
	}
}
function getWarmVoiceStatus() {
	var flag = true;
	if ($("#userId").val().length != 0) {
		var statusCookie = $.cookie("warmVoiceStatus");
		if (statusCookie != null && statusCookie.length != 0) {
			var statusArr = JSON.parse(statusCookie); //字符串转化成JSON数据
			for (var i = 0; i < statusArr.length; i++) {
				if (statusArr[i].id == $("#userId").val()) {
					flag = statusArr[i].warmstatus;
					break;
				}
			}
			return flag;
		} else {
			return flag;
		}
	} else {
		return flag;
	}
}
function initTool() {
	temp = 0;
	isShowTraffic = true;
	document.getElementById("traffic-switcher").className = "maplibTcBtnOff maplibTcBtn google";
	if (mapType == 1) {
		//loadJs("http://api.map.baidu.com/api?v=1.5&amp;ak=WVbVv3GM8fFnj8nwe1xNVMOc");
		loadJs("http://api.map.baidu.com/api?v=1.5&amp;ak=YVXeNpRyEhlayK1ufa7U79vwKhAmetUo");
		loadJs("http://api.map.baidu.com/library/DistanceTool/1.2/src/DistanceTool_min.js");
	} 
	/*else if( mapType == 3 ){
		loadJs("http://webapi.amap.com/maps?v=1.3&key=311f25d6868ca0039f68575345df8e04");
	}*/
	//closeRectangShape();
	//closeDistance();
}
function loadJs(file) {
	var head = $("head").remove("script[role='reload']");
	$("<scri" + "pt>" + "</scr" + "ipt>").attr({role:"reload", src:file, type:"text/javascript"}).appendTo(head);
}


var setSystemObject={
	init : function (){
		    //添加设置系统参数窗口开始
			frame("setSystemContentWin", "moveSetSystemWin", "closeSetSystemWin");
			//添加设置系统参数窗口结束
			setSystemObject.addListener();
			
			initMapWinParmsShowSelect();
			
			initOverTimeVehicleSetBtn();
			
			initShowClientGroupBtn();
			
	},
	openWin : function(type){
		$("#mean2").hide();
		if($("#usertypeId").val()==0){
			if(type==0){
				sysSetTab_(2);
				$("#syssetting_span_id").html("系统参数设置");
			}else{
				sysSetTab_(1);
				$("#syssetting_span_id").html("气泡框参数设置");
			}
			initSysSetting();
		}else{
			
			hideSysSetting();
			if(isEmbeddedPage){
				sysSetTab_(3);
				getCLientIdPrefix_Set();
			}else{
				if(type==0){
					sysSetTab_(2);
					$("#syssetting_span_id").html("系统参数设置");
				}else{
					sysSetTab_(1);
					$("#syssetting_span_id").html("气泡框参数设置");
				}
			}
		}
		
		initRefreshTime();

		$("#setSystemContentWin").show();
		$("#setSystemContentWin").center();
	},
	closeWin : function(){
		
		        			$("#systemParm_homeLoadLngLat").attr("checked",false); 
		        			$("#systemParm_update").attr("checked",false); 		        		
		        			$("#systemParm_userExperience").attr("checked",false); 
		        			$("#systemParm_useroverduetime").attr("checked",true); 
		        			$("#systemParm_vehicleoverduetime").attr("checked",true); 
		        			$("#baiduMapKey").val(""); 
		        			$("#baiduMapKey").attr("disabled","disabled");
		        			
		        			$("#setSystemMsg").css("color","rgb(153, 153, 153)");
		        		    $("#setSystemMsg").html("&nbsp;");
		        		    
		        		    $("#baiduMapKeySaveBtn").hide();
							$("#baiduMapKeyEditBtn").show();
		        			
	},
	submitParm : function(key,value){
		$.ajax({
		        type: "POST",
		        dataType: "json",
		        async : false,
		        url: "json/systAction_setup.action",
		        data:key+"="+value,
		        success: function(json) {
		        	
		        },
		        error: function() {
		           $("#setSystemMsg").css("color","red");
		           $("#setSystemMsg").text(json.msg);
		        }
		   });
	},
	addListener : function (){

		$("a[name='systemPermissionParm_1']").each(function(){
		    var obj=$(this);
			obj.click(function(){
				if(obj.attr("flag")=="true"){
					obj.find("img").attr("src","gpsonline/image/monitor/tool/no.gif");
					obj.attr("flag","false");
					setSystemObject.submitParm(obj.attr("id").split("_")[1],obj.attr("flag"));
					
				}else{
					obj.find("img").attr("src","gpsonline/image/monitor/tool/yes.gif");
					obj.attr("flag","true");
					setSystemObject.submitParm(obj.attr("id").split("_")[1],obj.attr("flag"));					
				}							
			});
		});
		
		$("a[name='systemPermissionParm_2']").each(function(){
		    var obj=$(this);
			obj.click(function(){
				if(obj.attr("flag")=="false"){
					obj.find("img").attr("src","gpsonline/image/monitor/tool/no.gif");
					obj.attr("flag","true");
					setSystemObject.submitParm(obj.attr("id").split("_")[1],obj.attr("flag"));
					
				}else{
					obj.find("img").attr("src","gpsonline/image/monitor/tool/yes.gif");
					obj.attr("flag","false");
					setSystemObject.submitParm(obj.attr("id").split("_")[1],obj.attr("flag"));					
				}							
			});
		});
		
		$("a[name='overTimeVehicleRemind']").each(function(){
		    var obj=$(this);
			obj.click(function(){
				if(obj.attr("flag")=="false"){
					obj.find("img").attr("src","gpsonline/image/monitor/tool/no.gif");
					obj.attr("flag","true");
					//关闭登录后提示过期设备
					setOverTimeVehicleWinSetStatusCookie($("#userId").val(),1);
					
				}else{
					obj.find("img").attr("src","gpsonline/image/monitor/tool/yes.gif");
					obj.attr("flag","false");
					//打开登录后提示过期设备
					setOverTimeVehicleWinSetStatusCookie($("#userId").val(),0);			
				}							
			});
		});
		
		$("a[name='showClientGroup']").each(function(){
		    var obj=$(this);
			obj.click(function(){
				if(obj.attr("flag")=="false"){
					obj.find("img").attr("src","gpsonline/image/monitor/tool/no.gif");
					obj.attr("flag","true");
					//关闭登录后提示过期设备
					
					setbsCookie("showClientGroup_" + $("#userId").val(), 0);
				}else{
					obj.find("img").attr("src","gpsonline/image/monitor/tool/yes.gif");
					obj.attr("flag","false");
					//打开登录后提示过期设备
					setbsCookie("showClientGroup_" + $("#userId").val(), 1);	
				}
				
				 if (confirm("设置成功! 刷新页面后生效,是否立即刷新?")) {
			            location.reload();
			      }
											
			});
		});
		
		$("#baiduMapKeyEditBtn").click(function(){
		
			$("#baiduMapKeySaveBtn").show();
			$("#baiduMapKeyEditBtn").hide();
			
			$("#baiduMapKey").attr("disabled","");
			
			
			
		});
		
		$("#baiduMapKeySaveBtn").click(function(){
		
			var value = $("#baiduMapKey").val();
			
			if(value.length != 0){
				$("#baiduMapKeySaveBtn").hide();
				$("#baiduMapKeyEditBtn").show();
				
				$("#baiduMapKey").attr("disabled","disabled");
				setSystemObject.submitParm("map_baidu_key",value);
			}else{
				alert("百度地图key值不能为空!");
			}
			
		});
		
		$("#refreshTimeEditBtn").click(function(){
		
			$("#refreshTimeSaveBtn").show();
			$("#refreshTimeEditBtn").hide();
			
			$("#refreshTime").attr("disabled","");
	
		});
		
		$("#refreshTimeSaveBtn").click(function(){
			
			var refreshTime = $("#refreshTime").val();
			
			if(refreshTime.length == 0 || parseInt(refreshTime) < 5 ){
				$("#refreshTime").val("");
				return;
			}
			
			saveRefreshTime(refreshTime);
			
			closeRefreshTimeEdit();
			
			
		});
		
	}
	
}

function hideSysSetting(){
	$("tr[name='systemSetting']").each(function(){ $(this).hide();}); 
}

function initSysSetting(){

	$.ajax({
		        type: "POST",
		        dataType: "json",
		        async : false,
		        url: "json/systAction_findsetup.action",
		        success: function(json){
				//console.info(JSON.stringify(json));
		        	if(json.flag == true){
		        		if(json.homeLoadLngLat){
		        			$("#systemParm_homeLoadLngLat").attr("flag","true");
		        			$("#systemParm_homeLoadLngLat").find("img").attr("src","gpsonline/image/monitor/tool/yes.gif"); 
		        		}
		        		if(json.update){
		        			$("#systemParm_update").attr("flag","true");
		        			$("#systemParm_update").find("img").attr("src","gpsonline/image/monitor/tool/yes.gif");
		        		}
		        		
		        		if(json.userExperience){
		        			
		        			$("#systemParm_userExperience").attr("flag","true");
		        			$("#systemParm_userExperience").find("img").attr("src","gpsonline/image/monitor/tool/yes.gif");
		        		}
						
						
		        		if(json.persionCmdPermitFlag){
		        			
		        			$("#systemParm_persionCmdPermitFlag").attr("flag","true");
		        			$("#systemParm_persionCmdPermitFlag").find("img").attr("src","gpsonline/image/monitor/tool/yes.gif");
		        		}
		        		
		        		if(!json.useroverduetime){
		        			
		        			$("#systemParm_useroverduetime").attr("flag","false");
		        			$("#systemParm_useroverduetime").find("img").attr("src","gpsonline/image/monitor/tool/yes.gif");
		        		}
		        		if(!json.vehicleoverduetime){
		        			
		        			$("#systemParm_vehicleoverduetime").attr("flag","false");
		        			$("#systemParm_vehicleoverduetime").find("img").attr("src","gpsonline/image/monitor/tool/yes.gif");
		        		}
		        		
		        		if(json.map_baidu_key){
		        			$("#baiduMapKey").val(json.map_baidu_key); 
		        		}
		        	}else{
		        		$("#setSystemMsg").css("color","red");
		        		$("#setSystemMsg").text(json.msg);
		        	}
		         	
		        },
		        error: function() {
		           
		        }
		   });
}
	
 var sysSetCount_ =3;
 
 function sysSetTab_(id){
    for(i=1;i<=sysSetCount_;i++){
		 if(id-i==0){
			  $("#sysSet_span_"+i).show();
			  $("#sysSetT_"+i).attr("class","tanchu_qh_select");
		 }else{
			  $("#sysSet_span_"+i).hide();
			  $("#sysSetT_"+i).attr("class","");
		 }
    }
    
    if(id == 3){
    		$("#clientId_prefix_msg_sys").html("&nbsp;");
			$("#clientId_prefix_msg_sys").css("color","#CCC");
		 	$("#clientId_id_submit_sys").removeAttr("disabled");		
			$("#clientId_id_submit_sys").val("提交");
    }
    
    if(id != 2){
    
    }
 }
 
 function initMapWinParmsShowSelect(){
	 
	 
 		
 		$("#sysSet_span_1 input[type='checkbox']").click(function(){//点击设备弹出框显示项立即保存
 		
 			saveWinShowParmsType();
 			
 		});
 		getCurWinShowParms();
 		
 		if(!curUserPopuWinItems || !curUserPopuWinItems.data || !curUserPopuWinItems.data.items){
 		
 			$("#sysSet_span_1 input[type='checkbox']").each(function(){
 			    
 			    if($(this).attr("id") != "systemParm_map_win_p11" && $(this).attr("id") != "systemParm_map_win_p13" && $(this).attr("id") != "systemParm_map_win_p14"){
	 				$(this).attr("checked","checked");
	 			}
	 			
	 		});
	 		
 		}else{
 		
 			var items = curUserPopuWinItems.data.items.split(",");
 			
 			for(var i=0;i<items.length;i++){
 			
 				$("#systemParm_map_win_p"+items[i]).attr("checked","checked");
 				
 			}
	  }
	  
	  //alert(getCurUserWinShowParms());
 }
 
function initShowClientGroupBtn(){
	
	var switchBtn = $("a[name='showClientGroup']"),
		status = findbsCookie("showClientGroup_" + $("#userId").val() );
		
	if(status != null && status == 1){
		switchBtn.find("img").attr("src","gpsonline/image/monitor/tool/yes.gif");
		switchBtn.attr("flag","false");
	}else{
		switchBtn.find("img").attr("src","gpsonline/image/monitor/tool/no.gif");
		switchBtn.attr("flag","true");
	}
	
}
 
function saveWinShowParmsType(){

	var statusArr = getValueByTargetId("sysSet_span_1");
	
	var result = [];
	
	var i = 1;
	
	for(key in statusArr){
		
		if(statusArr[key]){
		 
			result.push( i );
		
		}
		
		i++;
	}
 			
	
	$.ajax({
		        type: "POST",
		        dataType: "json",
		        async : false,
		        url: "json/userStyleAction_settingUserMapPopuWinItem.action",
		        data: {"userStyle.userId" :$("#userId").val(),"userStyle.items":result.join(",")},
		        success: function(json) {

		        		curUserPopuWinItems = json;
		        		setContentString();

		        }
   });
   
  // alert(getCurUserWinShowParms());

}
 
 var curUserPopuWinItems = null;
  
 function getCurWinShowParms(){
 		
		$.ajax({
		        type: "POST",
		        dataType: "json",
		        async : false,
		        url: "json/userStyleAction_getUserMapPopuWinItem.action",
		        success: function(json) {
		        
		        	curUserPopuWinItems = json;
		        	
		        }
		   });
 	
 }
 
  function getCurUserWinShowParms(){

 		
 		if(!curUserPopuWinItems || !curUserPopuWinItems.data || !curUserPopuWinItems.data.items){
 		
 			return "1,2,3,4,5,6,7,8,9,10,12".split(",");
 			
 		}else{
 		
 			return curUserPopuWinItems.data.items.split(",");
 			
 		}
 	
 }

 
function getValueByTargetId(targetId){

	var result = {};

	
	var form = $("#"+targetId);
	
	if(!form)return result;

	
	form.find("input[type='checkbox']").each(function(){
		
		eval("result.p"+$(this).attr("id").split("_")[3]+"="+$(this).is(':checked'));
	
	});

	return result;
		
}


function getCLientIdPrefix_Set(){

	$.ajax({
	        type: "POST",
	        dataType: "json",
	        async:true,
	        url: "json/markerAction_getClientPrefix.action",
	        success: function(json) {
	        		         
		         if (json.flag==true) {
		         
	         		 $("#clientId_prefix_sys").val(json.data.prefixionStr);
	         		 $("#clientId_id_sys").val(json.data.id);
	         		 		        	 					           				
                 }else{
                 
                 	alert(json.msg);
                 	
                 }
	        },
	        error: function() {}
	      });
	   
}

function updateCLientIdPrefix(){
	
	$("#clientId_id_submit_sys").attr("disabled","disabled");
	
	$("#clientId_id_submit_sys").val("正在提交...");
	
	var prefix = $("#clientId_prefix_sys").val();	
	var id = $("#clientId_id_sys").val();
	
	
	/*if(prefix.length==0){
		
		$("#clientId_prefix_msg_sys").text("*不能为空");
	
		$("#clientId_prefix_msg_sys").css("color","red");
		
		$("#clientId_id_submit_sys").removeAttr("disabled");
		
		$("#clientId_id_submit_sys").val("提交");
		
		return false;
			
	}else{
		
		$("#clientId_prefix_msg_sys").css("color","#CCC");
		
	}*/
	
	if(id=="-1"){
		id = 0;
	}
	
	$.ajax({
	        type: "POST",
	        dataType: "json",
	        async:false,
	        url: "json/markerAction_saveOrUpdateClientPrefix.action",
	        data:{"form.id":id,"form.prefixionStr":prefix},
	        success: function(json) {
	        		         
		         if (json.flag) {      					
					 
					 $("#clientId_prefix_msg_sys").html("&nbsp;已保存");
	         		 $("#clientId_prefix").val(prefix);
	         		 		        	 					           				
                 }else{
  
					 $("#clientId_prefix_msg_sys").text(json.msg);
					 
					 $("#clientId_prefix_msg_sys").css("color","red");
                 	
                 }
	        },
	        error: function() {
	        		
	        		$("#clientId_prefix_msg_sys").text("*提交异常");
					 
					$("#clientId_prefix_msg_sys").css("color","red");
					
	        }
	 });
	 
	  $("#clientId_id_submit_sys").removeAttr("disabled");
			
	  $("#clientId_id_submit_sys").val("提交");

}

function closeRefreshTimeEdit(){

		$("#refreshTimeEditBtn").show();
		$("#refreshTimeSaveBtn").hide();
		
		$("#refreshTime").attr("disabled","disabled");
}

function initRefreshTime()
{
	$("#refreshTime").val(getRefreshTime());
	getRefreshTime();
	closeRefreshTimeEdit();
}

function saveRefreshTime(refreshTime)
{	
	
	saveRefreshTimeCookie($("#refreshTime").val());
	
	setCount();
	
}

function saveRefreshTimeCookie(content){
	var refreshTimeCookie = getmyCookie("refreshTimeCookie");
	var userId = $("#userId").val();
	
	if(!refreshTimeCookie){
		refreshTimeCookie = userId + "_" + content;
	}else{
		if(refreshTimeCookie.indexOf(userId) < 0 ){
			refreshTimeCookie += (refreshTimeCookie + "," + userId + "_" + content);
		}else{
		
			var refreshTimeCookieArr = refreshTimeCookie.split(",");
		
			for(var i = 0; i < refreshTimeCookieArr.length; i++)
			{
				if(refreshTimeCookieArr[i].split("_")[0] == userId)
				{
					refreshTimeCookieArr[i] = userId + "_" + content;
					break;
				}
			}
			
			refreshTimeCookie = refreshTimeCookieArr.join(",");
			
		}
		
	}
	
	setmyCookie("refreshTimeCookie",refreshTimeCookie,365);
}

function getRefreshTime()
{
	var refreshTimeCookie = getmyCookie("refreshTimeCookie");
	var userId = $("#userId").val();
	
	if(!refreshTimeCookie){
		return 10;
	}else{
		if(refreshTimeCookie.indexOf(userId) < 0 ){
			return 10;
		}else{
		
			var refreshTimeCookieArr = refreshTimeCookie.split(",");
		
			for(var i = 0; i < refreshTimeCookieArr.length; i++)
			{
				if(refreshTimeCookieArr[i].split("_")[0] == userId)
				{
					return refreshTimeCookieArr[i].split("_")[1];
				}
			}	
		}
		
	}
}

//登录后台管理

var managerDictionary=null;

var isloginManager=false;
var modelJson=null;
var managermodelcount=0;

function loginManager(){
	  
	
	  if(isloginManager || managermodelcount>=3){
	  	return;
	  }
	  doRequest("manager/loginAction_loginLimit.action","",function (json){
	  		if(json.flag==true){
	          	modelJson =json.ml;
	          	isloginManager=true;
	        }else{
	          	managermodelcount++;
	          	loginManager();
	          	isloginManager=false;
	          	return; 
	          }
	  
	  });
}
	

function openPopuWin(html_src_){
	var popuWin = $("#popuWin");
	$.ajax({type:"GET",
		 dataType:"html",
		 async:false,
		 url:html_src_, 
	     success:function (html){
	     	popuWin.html(html);
	     	frame("popuWin","movePopuWin","closePopuWin");
	    	popuWin.show();
	    	popuWin.center();
	    	
    	 },error:function(e){
    	 }
	 });
	
}

/**********************
 * 功能权限
 **********************/
 var funAut = null;

 //装载功能权限
 function loadFunAut(busFun){
 	doRequest("manager/loginAction_funAut.action", null, function(result){
 		funAut = (result.data != null) ? result.data : [];
 	});
 }
 
 //是否有功能权限 
 //AutCode权限码
 function isHasAut(AutCode){
 
 	var flag = false;
 	
 	if(flag != null){
 	
	 	for(var i = 0; i < funAut.length; i++){
	 		if(funAut[i] == AutCode){
	 			flag = true;
	 			break;
	 		}
	 	}
 	
 	}
 	
 	return flag;
 }
 
 //是否有轨迹回放权限
 var isHasPBackAut = function(){
 
 	if(funAut == null){
 		loadFunAut();
 	}

 	return isHasAut(801010) || usertype == "-100" || usertype == "-1000" || usertype == "0";
 }
 

//*********************
//bscookie管理
//*********************
function setbsCookie(key, value){
	var cookie = getSysCookie() || {};
	cookie[key] = value;
	setSysCookie(cookie);
}

function findbsCookie(key){
	var cookie = getSysCookie();
	return (cookie && cookie[key]) ? cookie[key] : null;
}

function getSysCookie(){
	var bscookie = getmyCookie("bs");
	
	if(bscookie){
		bscookie = JSON.parse(bscookie);
		return bscookie;
	}
	
	return null;
}

function setSysCookie(value){
	setmyCookie("bs",JSON.stringify(value),365);
}


function getmyCookie(name){
	return $.cookie(name);
}

function setmyCookie(name,content,days){
	$.cookie(name, content, {expires:days,path: '/'});
}

