var QOM = 'rockkefu_',device='',admintoken='',CFROM='',nwjsgui=false,ISDEMO=false,HOST='',NOWURL='',ismobile=0;
function initbody(){}
function bodyunload(){}
$(document).ready(function(){
	if(typeof(nw)=='object')nwjsgui = nw;
	HOST  = js.gethost();
	js.getsplit();
	device= js.cookie(''+QOM+'deviceid');
	if(device=='')device=js.now('time');
	js.savecookie(''+QOM+'deviceid', device, 365);
	admintoken = js.getoption('admintoken');
	if(HOST=='127.0.0.1' || HOST=='localhost')window.addEventListener('error',function(e){
		var msg = '文件：'+e.filename+'<br>行：'+e.lineno+'<br>错误：<font color=red>'+e.message+'</font>';
		js.alert(msg);
	});
	$('body').click(function(e){
		js.downbody(this, e);
	});
	$(window).unload(function(){
		js.onunload();
		bodyunload();
	});
	initbody();
});
var js={path:'index',openarr:{}};
var isIE=true;
if(!document.all)isIE=false;
var get=function(id){return document.getElementById(id)};
var isempt=function(an){var ob	= false;if(an==''||an==null||typeof(an)=='undefined'){ob=true;}if(typeof(an)=='number'){ob=false;}return ob;}
var strreplace=function(str){if(isempt(str))return '';return str.replace(/[ ]/gi,'').replace(/\s/gi,'')}
var strhtml=function(str){if(isempt(str))return '';return str.replace(/\</gi,'&lt;').replace(/\>/gi,'&gt;')}
var form=function(an,fna){if(!fna)fna='myform';return document[fna][an]}
var xy10=function(s){var s1=''+s+'';if(s1.length<2)s1='0'+s+'';return s1;};
js.getarr=function(caa,bo){
	var s='';
	for(var a in caa)s+=' @@ '+a+'=>'+caa[a]+'';
	if(!bo)alert(s);
	return s;
}
function winHb(){
	var winH=(!isIE)?window.innerHeight:document.documentElement.offsetHeight;
	return winH;
}
function winWb(){
	var winH=(!isIE)?window.innerWidth:document.documentElement.offsetWidth;
	return winH;
}
js.onunload=function(){}
js.scrolla	= function(){
	var top	= $(document).scrollTop();
	js.scroll(top);
}
js.request=function(name,dev,url){
	this.requestarr = {};
	if(!dev)dev='';
	if(!name)return dev;
	if(!url)url=location.href;
	if(url.indexOf('\?')<0)return dev;
	if(url.indexOf('#')>0)url = url.split('#')[0];
	var neurl=url.split('\?')[1];
	neurl=neurl.split('&');
	var value=dev,i,val;
	for(i=0;i<neurl.length;i++){
		val=neurl[i].split('=');
		this.requestarr[val[0]] = val[1];
		if(val[0].toLowerCase()==name.toLowerCase()){
			value=val[1];
			break;
		}
	}
	if(!value)value='';
	return value;
}
js.now=function(type,sj){
	if(!type)type='Y-m-d';
	if(type=='now')type='Y-m-d H:i:s';
	var dt,ymd,his,weekArr,Y,m,d,w,H=0,i=0,s=0,W;
	if(typeof(sj)=='string')sj=sj.replace(/\//gi,'-');
	if(/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}/.test(sj)){
		sj=sj.split(' ');
		ymd=sj[0];
		his=sj[1];if(!his)his='00:00:00';
		ymd=ymd.split('-');
		his=his.split(':');
		H = his[0];if(his.length>1)i = his[1];if(his.length>2)s = his[2];
		dt=new Date(ymd[0],ymd[1]-1,ymd[2],H,i,s);
	}else{
		dt=(typeof(sj)=='number')?new Date(sj):new Date();
	}
	weekArr=new Array('日','一','二','三','四','五','六');
	Y=dt.getFullYear();
	m=xy10(dt.getMonth()+1);
	d=xy10(dt.getDate());
	w=dt.getDay();
	H=xy10(dt.getHours());
	i=xy10(dt.getMinutes());
	s=xy10(dt.getSeconds());
	W=weekArr[w];
	if(type=='time'){
		return dt.getTime();
	}else{
		return type.replace('Y',Y).replace('m',m).replace('d',d).replace('H',H).replace('i',i).replace('s',s).replace('w',w).replace('W',W);
	}
}
js.gethost=function(){
	var url = location.href,sau='';
	try{sau = url.split('//')[1].split('/')[0];}catch(e){}
	if(sau.indexOf('kefu.rockoa.com')>=0)ISDEMO=true;
	var lse = url.lastIndexOf('/');NOWURL = url.substr(0, lse+1);
	return sau;
}
js.apiurl = function(m,a,cans){
	var url='api.php?m='+m+'&a='+a+'';
	url+='&cfrom='+CFROM+'';
	if(!cans)cans={};
	for(var i in cans)url+='&'+i+'='+cans[i]+'';
	return url;
}
js.float=function(num,w){
	if(isNaN(num)||num==''||!num||num==null)num='0';
	num=parseFloat(num);
	if(!w&&w!=0)w=2;
	var m=num.toFixed(w);
	return m;	
}
js.decode=function(str){
	var arr	= {length:-1};
	try{
		arr	= new Function('return '+str+'')();
	}catch(e){}
	return arr;
}
js.reload=function(){
	location.reload();
}
js.loading=function(txt){
	js.msg('wait',txt);
}
js.msgerror=function(txt){
	js.msg('msg',txt);
}
js.getchecked=function(na,bh){
	var s = '';
	var o1;
	if(bh){
		o1=$("input[name^='"+na+"']");
	}else{
		o1=$("input[name='"+na+"']");
	}
	for(var i=0;i<o1.length;i++){
		if(o1[i].checked && !o1[i].disabled)s+=','+o1[i].value+'';
	}
	if(s!='')s=s.substr(1);
	return s;
}
js.getformdata=function(nas){
	var da	={},ona='',o,type,val,na,i,obj;
	if(!nas)nas='myform';
	obj	= document[nas];
	for(i=0;i<obj.length;i++){
		o 	 = obj[i];type = o.type,val = o.value,na = o.name;
		if(!na)continue;
		if(type=='checkbox'){
			val	= '0';
			if(o.checked)val='1';
			da[na]	= val;
		}else if(type=='radio'){
			if(o.checked)da[na]	= val;					
		}else{
			da[na] = val;
		}
		if(na.indexOf('[]')>-1){
			if(ona.indexOf(na)<0)ona+=','+na+'';
		}
	}
	if(ona != ''){
		var onas = ona.split(',');
		for(i=1; i<onas.length; i++){
			da[onas[i].replace('[]','')] = js.getchecked(onas[i]);
		}
	}
	return da;
}
js.setmsg=function(txt,col,ids){
	if(!ids)ids='msgview';
	$('#'+ids+'').html(js.getmsg(txt,col));
}
js.getmsg  = function(txt,col){
	if(!col)col='red';
	var s	= '';
	if(!txt)txt='';
	if(txt.indexOf('...')>0){
		s='<img src="images/loading.gif" height="16" width="16" align="absmiddle"> ';
		col = '#ff6600';
	}	
	s+='<span style="color:'+col+'">'+txt+'</span>';
	if(!txt)s='';
	return s;
}
js.setoption=function(k,v,qzb){
	if(!qzb)k=QOM+k;
	try{
		if(isempt(v)){
			localStorage.removeItem(k);
		}else{
			localStorage.setItem(k, escape(v));
		}
	}catch(e){
		js.savecookie(k,escape(v));
	}
	return true;
}
js.getoption=function(k,dev, qzb){
	var s = '';
	if(!qzb)k=QOM+k;
	try{s = localStorage.getItem(k);}catch(e){s=js.cookie(k);}
	if(s)s=unescape(s);
	if(isempt(dev))dev='';
	if(isempt(s))s=dev;
	return s;
}
js.location = function(url){
	location.href = url;
}
js.msg = function(lx, txt,sj){
	clearTimeout(this.msgshowtime);
	if(typeof(sj)=='undefined')sj=5;
	$('#msgshowdivla').remove();
	if(lx == 'none' || !lx){
		return;
	}
	if(lx == 'wait'){
		txt	= '<img src="images/loadings.gif" height="14" width="15" align="absmiddle"> '+txt;
		sj	= 60;
	}
	if(lx=='msg')txt='<font color=red>'+txt+'</font>';var t=10;
	if(get('header_title'))t+=50;
	var s = '<div onclick="$(this).remove()" id="msgshowdivla" style="position:fixed;top:'+t+'px;z-index:200;" align="center"><div style="padding:8px 20px;background:rgba(0,0,0,0.7);color:white;font-size:16px;border-radius:5px">'+txt+'</div></div>';
	$('body').append(s);
	var w=$('#msgshowdivla').width(),l=(winWb()-w)*0.5;
	$('#msgshowdivla').css('left',''+l+'px');
	if(sj>0)this.msgshowtime= setTimeout("$('#msgshowdivla').remove()",sj*1000);	
}
js.splittime=0;
js.getsplit=function(){
	if(!js.servernow)return false;
	var dt=js.now('Y-m-d H:i:s');
	var d1=js.now('time',dt);	
	var d2=js.now('time',js.servernow);
	js.splittime=d1-d2;
}
js.serverdt=function(atype){
	if(!atype)atype='Y-m-d H:i:s';
	var d1=js.now('time')-js.splittime;
	var dt=js.now(atype,d1);
	return dt;
}
js.open=function(url,w,h,wina,can,wjcan){
	if(wina){try{var owina	= this.openarr[wina];owina.document.body;owina.focus();return owina;}catch(e){}}
	if(!w)w=600;if(!h)h=500;
	var l=(screen.width-w)*0.5,t=(screen.height-h)*0.5-50,rnd = parseInt(Math.random()*50);
	if(rnd%2==0){l=l+rnd;t=t-rnd;}else{l=l-rnd;t=t+rnd;}
	if(!can)can={};
	var s='resizable=yes,scrollbars=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no';
	var a1={'left':''+l+'px','top':''+t+'px','width':''+w+'px','height':''+h+'px'};
	a1 = js.apply(a1,can);
	for(var o1 in a1)s+=','+o1+'='+a1[o1]+'';
	var ja=(url.indexOf('?')>=0)?'&':'?';
	if(wina)url+=''+ja+'winobj='+wina+'';
	if(typeof(nw)=='undefined'){
		var opar=window.open(url,'',s);
	}else{
		var ocsn=js.apply({'frame':true,width:w,height:h,x:l,y:t,icon:'images/logo.png'},wjcan);
		if(url.substr(0,4)!='http')url=NOWURL+url;
		var opar=nw.Window.open(url, ocsn);
	}
	if(wina)this.openarr[wina]=opar;
	return false;
}
js.ajax	= function(cans){
	if(!cans)cans={};
	var ajaxcan = {
		type:'get',
		success:function(){},
		error:function(e){
			js.msg('msg','处理出错:'+e.responseText+'');
		}
	};
	for(var i in cans)ajaxcan[i]=cans[i];
	$.ajax(ajaxcan);
}
js.getrand=function(){
	var r;
	r = ''+new Date().getTime()+'';
	r+='_'+parseInt(Math.random()*9999)+'';
	return r;
}
js.applyIf=function(a,b){
	if(!a)a={};
	if(!b)b={};
	for(var c in b)if(typeof(a[c])=='undefined')a[c]=b[c];
	return a;
}
js.apply=function(a,b){
	if(!a)a={};
	if(!b)b={};
	for(var c in b)a[c]=b[c];
	return a;
}
js.back=function(){
	history.back();
}
js.focusval	= '0';
js.number=function(obj){
	val=strreplace(obj.value);
	if(!val){
		obj.value=js.focusval;
		return false;
	}
	if(isNaN(val)){
		js.msg('msg','输入的不是数字');
		obj.value=js.focusval;
		obj.focus();
	}else{
		obj.value=val;
	}
}
js.cookie=function(name){
	var str=document.cookie,cda,val='',arr,i;
	if(str.length<=0)return '';
	arr=str.split('; ');
	for(i=0;i<arr.length;i++){
		cda=arr[i].split('=');
		if(name.toLowerCase()==cda[0].toLowerCase()){
			val=cda[1];
			break;
		}
	}
	if(!val)val='';
	return val;
}
js.savecookie=function(name,value,d){
	var expires = new Date();
	if(!d)d=365;
	if(!value)d=-10;
	expires.setTime(expires.getTime()+d*24*60*60*1000);
	var str=''+name+'='+value+';expires='+expires.toGMTString()+';path=/;SameSite=Strict';
	document.cookie = str;
}
js.initbtn = function(obj){
	var o = $("[click]"),i,o1,cl;
	for(i=0; i<o.length; i++){
		o1	= $(o[i]);
		cl	= o1.attr('clickadd');
		if(cl!='true'){
			o1.click(function(eo){
				var cls = $(this).attr('click');
				if(typeof(cls)=='string'){
					cls=cls.split(',');
					obj[cls[0]](this, cls[1], cls[2], eo);
				}
				return false;
			});
		}
	}
	o.attr('clickadd','true');
}
js.tanbody=function(act,title,w,h,can1){
	var H	= (document.body.scrollHeight<winHb())?winHb()-5:document.body.scrollHeight;
	var W	= document.documentElement.scrollWidth+document.body.scrollLeft;
	if(!this.tanbodyindex)this.tanbodyindex=80;
	this.tanbodyindex++;
	var l=(winWb()-w)*0.5,t=(winHb()-h-20)*0.5;
	var s = '',mid	= ''+act+'_main',i,d;
	var can	= js.applyIf(can1,{html:'',btn:[]});
	if(w>winWb())w=winWb()-50;
	var s = '<div id="'+mid+'" style="position:fixed;background-color:#ffffff;left:'+l+'px;width:'+w+'px;top:'+t+'px;box-shadow:0px 0px 10px rgba(0,0,0,0.3);border-radius:5px">';
	s+='	<div style="-moz-user-select:none;-webkit-user-select:none;user-select:none;border-bottom:1px #eeeeee solid">';
	s+='		<table border="0" width="100%" cellspacing="0" cellpadding="0"><tr>';
	s+='			<td height="50" style="font-size:16px; font-weight:bold;color:#000000; padding-left:10px" width="100%" onmousedown="js.move(\''+mid+'\')" id="'+act+'_title">'+title+'</td>';
	s+='			<td><div  id="'+act+'_spancancel1" style="padding:0px 8px;height:50px;line-height:45px;overflow:hidden;cursor:pointer;color:gray;" onclick="js.tanclose(\''+act+'\')">✖</div></td>';
	s+='		</tr></table>';
	s+='	</div>';
	s+='	<div id="'+act+'_content" style="height">'+can.html+'</div>';
	s+='	<div style="height:60px;overflow:hidden;line-height:60px;padding:0px 10px;background:#f1f1f1;border-radius:0px 0px 5px 5px" align="right"><span id="msgview_'+act+'"></span>';
	for(i=0; i<can.btn.length; i++){
		d = can.btn[i];
		if(!d.bgcolor)d.bgcolor='';
		s+='<button type="button" oi="'+i+'" style="border-radius:5px;padding:8px 15px;margin-left:10px;background:'+d.bgcolor+'" id="'+act+'_btn'+i+'" class="webbtn">'+d.text+'</button>';
	}
	s+='		<button type="button" id="'+act+'_spancancel" onclick="js.tanclose(\''+act+'\')" style="border-radius:5px;padding:8px 15px;background:gray;margin-left:10px" class="webbtn">取消</button>';
	s+='		';
	s+='	</div>';
	s+='</div>';
	var str = '<div id="amain_'+act+'" oncontextmenu="return false" style="position:absolute;height:'+H+'px;width:'+W+'px;background:rgba(0,0,0,0.3);z-index:'+this.tanbodyindex+';left:0px;top:0px">'+s+'</div>';
	$('body').append(str);
	if(can.closed=='none'){
		$('#'+act+'_spancancel').remove();
		$('#'+act+'_spancancel1').remove();
	}
	this.resizetan(act);
}
js.alert=function(msg,fun,tit,slx){
	if(!tit)tit='系统提示';
	var btn=[{text:'确定'}],act = 'alert';
	if(get(''+act+'_main'))act=''+act+''+this.getrand()+'';
	if(slx)btn.push({text:'取消',bgcolor:'gray'});
	this.tanbody(act,tit,400,300,{closed:'none',html:'<div style="padding:20px">'+msg+'</div>',btn:btn});
	$('#'+act+'_btn0').click(function(){
		var val = $('#rockpromptinput').val(),fbo=true;
		if(fun)fbo=fun('yes', val, act);
		if(fbo!==false)js.tanclose(act);
	});
	$('#'+act+'_btn1').click(function(){
		var val = $('#rockpromptinput').val();
		js.tanclose(act);
		if(fun)fun('no', val, act);
	});
	$('#'+act+'_spancancel1').remove();
}
js.alertclose=function(){
	this.tanclose('alert');
}
js.confirm=function(msg,fun,tit){
	js.alert(msg,fun,tit,1);
}
js.prompt=function(msg,fun,tit,txt){
	if(!txt)txt='';
	var msg1 = '<div>'+msg+'</div><div style="margin-top:5px"><input id="rockpromptinput" class="input" style="width:95%;border-radius:5px" value="'+txt+'" type="input"></div>';
	js.alert(msg1,fun,tit,2);
	setTimeout("get('rockpromptinput').focus()",100);
}
js.resizetan=function(act){
	var mid	= ''+act+'_main';
	var o1  = $('#'+mid+'');
	var h1 = o1.height();
	var w1 = o1.width();	
	var l=(winWb()-w1)*0.5,t=(winHb()-h1-50)*0.5;
	o1.css({'left':''+l+'px','top':''+t+'px'});
}
js.tanclose=function(act){
	$('#amain_'+act+'').remove();
}
js.move=function(id,rl){
	var _left=0,_top=0,_x=0,_right=0,_y=0;
	var obj	= id;if(!rl)rl='left';
	if(typeof(id)=='string')obj=get(id);
	var _Down=function(e){
		try{
			var s='<div id="divmovetemp" style="filter:Alpha(Opacity=0);opacity:0;z-index:99999;width:100%;height:100%;position:absolute;background-color:#000000;left:0px;top:0px;cursor:move"></div>';
			$('body').prepend(s);
			_x = e.clientX;_y = e.clientY;_left=parseInt(obj.style.left);_top=parseInt(obj.style.top);_right=parseInt(obj.style.right);
			document.onselectstart=function(){return false}
		}catch(e1){}		
	}
	var _Move=function(e){
		try{
			var c=get('divmovetemp').innerHTML;
			var x = e.clientX-_x,y = e.clientY-_y;
			if(rl=='left')obj.style.left=_left+x+'px';
			if(rl=='right')obj.style.right=_right-x+'px';
			obj.style.top=_top+y+'px';
		}catch(e1){_Down(e)}
	}
	var _Up=function(){
		document.onmousemove='';
		document.onselectstart='';
		$('#divmovetemp').remove();	
	}
	document.onmousemove=_Move;
	document.onmouseup=_Up;
}
js._bodyclick = {};
js.downbody=function(o1, e){
	this.allparent = '';
	this.getparenta($(e.target),0);
	var a,s = this.allparent,a1;
	for(a in js._bodyclick){
		a1 = js._bodyclick[a];
		if(s.indexOf(a)<0){
			if(a1.type=='hide'){
				$('#'+a1.objid+'').hide();
			}else{
				$('#'+a1.objid+'').remove();
			}
		}
	}
	return true;
}
js.addbody = function(num, type,objid){
	js._bodyclick[num] = {type:type,objid:objid};
}
js.getparenta=function(o, oi){
	try{
	if(o[0].nodeName.toUpperCase()=='BODY')return;}catch(e){return;}
	var id = o.attr('id');
	if(!isempt(id)){
		this.allparent+=','+id;
	}
	this.getparenta(o.parent(), oi+1);
}
js.formatsize=function(size){
	var arr = new Array('Byte', 'KB', 'MB', 'GB', 'TB', 'PB');
	var e	= Math.floor(Math.log(size)/Math.log(1024));
	var fs	= size/Math.pow(1024,Math.floor(e));
	return js.float(fs)+' '+arr[e];
}
js.isimg = function(lx){
	var ftype 	= '|png|jpg|bmp|gif|jpeg|';
	var bo		= false;
	if(ftype.indexOf('|'+lx+'|')>-1)bo=true;
	return bo;
}
js.fileall=',aac,ace,ai,ain,amr,app,arj,asf,asp,aspx,av,avi,bin,bmp,cab,cad,cat,cdr,chm,com,css,cur,dat,db,dll,dmv,doc,docx,dot,dps,dpt,dwg,dxf,emf,eps,et,ett,exe,fla,ftp,gif,hlp,htm,html,icl,ico,img,inf,ini,iso,jpeg,jpg,js,m3u,max,mdb,mde,mht,mid,midi,mov,mp3,mp4,mpeg,mpg,msi,nrg,ocx,ogg,ogm,pdf,php,png,pot,ppt,pptx,psd,pub,qt,ra,ram,rar,rm,rmvb,rtf,swf,tar,tif,tiff,txt,url,vbs,vsd,vss,vst,wav,wave,wm,wma,wmd,wmf,wmv,wps,wpt,wz,xls,xlsx,xlt,xml,zip,';
js.filelxext = function(lx){
	if(js.fileall.indexOf(','+lx+',')<0)lx='wz';
	return lx;
}
js.fileopt=function(fid,lx,slx){
	this.loading();
	var da  = {fileid:fid,lx:lx}
	if(slx==1)da.token = admintoken;
	if(slx==0){da.key = agentkey;da.device = device;}
	var url = this.apiurl('upload','fileinfo',da);
	this.ajax({
		url:url,dataType:'json',
		success:function(ret){
			js.unloading();
			if(!ret.success){
				js.msgerror(ret.msg);
			}else{
				var da=ret.data;
				if(!da.url)return;
				if(da.lx==0){
					if(ismobile==1){
						js.location(da.url);
					}else{
						js.open(da.url,screen.width-200,screen.height-150);
					}
				}else if(da.lx==1){
					js.location(da.url);
				}
			}
		}
	});
}

js.ontabsclicks=function(){};
js.inittabs=function(){
	$('.r-tabs div').click(function(){
		js.tabsclicks(this);
	});
}
js.tabsclicks=function(o1){
	var o = $(o1);
	var tid= o.parent().attr('tabid');
	$('.r-tabs[tabid="'+tid+'"] div').removeClass('active');
	$('[tabitem][tabid="'+tid+'"]').hide();
	var ind = o.attr('index');
	o.addClass('active');
	var ho = $('[tabitem='+ind+'][tabid="'+tid+'"]');
	ho.show();
	this.ontabsclicks(ind, tid, o, ho);
}
js.selall = function(o,na,bh){
	var i,oi1;
	if(bh){
		o1=$("input[name^='"+na+"']");
	}else{
		o1=$("input[name='"+na+"']");
	}
	for(i=0;i<o1.length;i++){
		if(!o1[i].disabled)o1[i].checked = o.checked;
	}
}