$Reg = {
	Email : /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,Int : /^[0-9|-][0-9]{0,}$/,Real : /^[+-]?\d+(\.\d+)?$/,IDCard15 : /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/,
	IDCard18 : /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/,IDCard17X : /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}(x|X)$/,IDCard: /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}(x|X|\d)?$/,Post : /^[0-9]\d{5}$/,
Mob : /(130|131|132|133|134|135|136|137|138|139|147|150|151|152|153|154|155|156|157|158|159|166|176|177|178|181|182|183|184|185|186|187|188|189|198|199)\d{8}$/,
Mob_New : /(13|14|15|16|17|18|19)\d{9}$/,
Date : /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/,En:  /[u00-uFF]/,Ch  : /^[u4E00-u9FA5]+$/,NormalChar:/^[\w][\w]{0,}$/,	SpecialChar:/[\\\$\*=<>\{\}\+\?\|\^]+/,URL:/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/,IP:/^(([01]?[\d]{1,2})|(2[0-4][\d])|(25[0-5]))(\.(([01]?[\d]{1,2})|(2[0-4][\d])|(25[0-5]))){0,3}$/,QQ:/^\d{5,10}$/};
String.prototype._Date= function(){return $Reg.Date.test(this);}
String.prototype._IDCard=function(){return $Reg.IDCard18.test(this)?true:$Reg.IDCard17X.test(this);}
String.prototype._En=function(){return $Reg.En.test(this);}
String.prototype._Ch=function(){return $Reg.Ch.test(this);}
String.prototype._Real=function(){return $Reg.Real.test(this);}
String.prototype._Int=function(){return $Reg.Int.test(this);}	
String.prototype._Email=function(){return $Reg.Email.test(this);}
String.prototype._Mob=function(){return $Reg.Mob.test(this);}
String.prototype._Mob_New=function(){return $Reg.Mob_New.test(this);}
String.prototype._Post=function(){return $Reg.Post.test(this);}
String.prototype._NormalChar=function(){return $Reg.NormalChar.test(this);}
String.prototype._Special=function(){return $Reg.NormalChar.test(this);}
String.prototype._SpecialChar = function(){return !$Reg.SpecialChar.test(this);}
String.prototype._URL = function(){return $Reg.URL.test(this);}
String.prototype._QQ = function(){return $Reg.QQ.test(this);}
String.prototype._delLastChar = function(){	if(this.length<=0){return "";}return this.substr(0,this.length-1);}
function mybt(o,style,size,fun){
	var color = [];
	color["area"] = "#9cc2cb";
	color["green"] = "#1b7e5a";
	color["pink"] = "#a77a94";
	color["red"] = "#d54e21";
	color["black"] = "#000000";
	color["purple"] = "#6a5a8c";
	color["gray"] = "#73716e";
	color["blue"] = "#2489c5";
	color["orange"] = "#de8650";
	color["yellow"] = "#ffcc33";
	color["no"] = "#eee";
	color["white"] = "#fff";

	o = o==null?document.body:o;
	var a = [];//normal over check normaldisabled checkdisabled
	var btstatus = [];
	var temp = "";
	var btcolor = [];
	btstatus[""] = 0;
	btstatus["normal"] = 0;
	btstatus["over"] = 1;
	btstatus["check"] = 2;
	btstatus["normaldisabled"] = 3;
	btstatus["checkdisabled"] = 4;
	
	a[0] = ["fa fa-circle-o bt_normal","fa fa-dot-circle-o","fa fa-dot-circle-o","fa fa-circle-o bt_disabled","fa fa-dot-circle-o bt_disabled"];
	a[1] = ["fa fa-square-o bt_normal","fa fa-square-o","fa fa-check-square-o","fa fa-square-o bt_disabled","fa fa-check-square bt_disabled"];
	a[2] = ["fa fa-check bt_normal","fa fa-check","fa fa-check","fa fa-check btdisabled","fa fa-check bt_disabled"];
	a[3] = ["fa fa-check bt_normal","fa fa-check","fa fa-check","fa fa-check btdisabled","fa fa-check bt_disabled"];
	a[4] = ["fa fa-close bt_normal","fa fa-close","fa fa-close","fa fa-close btdisabled","fa fa-close bt_disabled"]
	a[5] = ["fa fa-male","fa fa-male","fa fa-male","fa fa-male btdisabled","fa fa-male bt_disabled"];
	a[6] = ["fa fa-female","fa fa-female","fa fa-female","fa fa-female btdisabled","fa fa-female bt_disabled"];
	a[15] = ["numpoint_normal","numpoint_over","numpoint_select","numpoint_disabled","numpoint_disabled"];
	$(o).unbind("mouseout click mouseover");
	$(o).find("i[mybt='yes']").each(function(){
		temp = btstatus[$(this).attr("btstatus")];
		if($(this).attr("btcolor")==""){
			$(this).attr("btcolor","gray,green,green,no,no");
		}
		btcolor = $(this).attr("btcolor").split(",");
		$(this).attr("classgroup",a[$(this).attr("btstyle")].join(","));
		$(this).attr("class",a[$(this).attr("btstyle")][temp]);
		$(this).css({"color":btcolor[temp],"cursor":"pointer"});
		if((temp==4)||(temp==3)){
			$(this).css({"cursor":"no-drop"});
		}
	});
	$(o).bind("mouseover",function(e){
		var t = $(e.target);
		if(t.attr("mybt")!="yes"){
			return;	
		}
		var BTStatus = btstatus[t.attr("btstatus")];
		
		if(BTStatus<=1){
			t.attr("class",a[t.attr("btstyle")][1]);
			t.css({"color":color[  t.attr("btcolor").split(",")[1] ]});
		}
		
	});
	
	$(o).bind("mouseout",function(e){
		var t = $(e.target);
		if(t.attr("mybt")!="yes"){
			return;	
		}
		var BTStatus =btstatus[t.attr("btstatus")];

		if(BTStatus<=1){
			t.attr("class",a[t.attr("btstyle")][0]);
			t.css({"color":color[  t.attr("btcolor").split(",")[0] ]});
		}
	});
	$(o).bind("click",function(e){
		var t = $(e.target);
		if(t.attr("mybt")!="forbt"){		
			if(t.attr("mybt")!="yes"){
				return;	
			}
		}
		else{
			t = $("#"+t.attr("for"));
		}

		var BTStatus =btstatus[t.attr("btstatus")];
		var BTType = t.attr("bttype");
		var btstyle = 0;
		var btcolor = null;
		
		if(BTType=="checkbox"){
			if(BTStatus<=2){
				var oldstatus = btstatus[t.attr("btstatus")];
				btstyle = $(t).attr("btstyle");
				btcolor = $(t).attr("btcolor").split(",");
				if(oldstatus!=2){
					t.attr("btstatus","check");
					t.attr("class",a[btstyle][2]);
					t.css("color",btcolor[2]);
					var name = t.attr("name");
					var reject = t.attr("reject").split(",");
					for(var i=1;i<reject.length;i++){	
						if(reject[i]!=""){
							$(o).find("i[name='"+name+"'][value='"+reject[i]+"']").attr("btstatus","normal");
							$(o).find("i[name='"+name+"'][value='"+reject[i]+"']").attr("class",a[btstyle][0]);
							$(o).find("i[name='"+name+"'][value='"+reject[i]+"']").css("color",btcolor[0]);
						}
					}
				}
				else{
					t.attr("btstatus","normal");
					t.attr("class",a[btstyle][0]);
					t.css("color",btcolor[0]);
				}
			}
		}
		else{
			if(BTStatus<=2){
				var list = $(o).find("i[name='"+t.attr("name")+"']");
				var oldstatus = btstatus[t.attr("btstatus")];
				var currbtstyle = "";
				var currbtcolor = "";
				list.each(function(index, element) {
					
					btstyle = $(this).attr("btstyle");
					btcolor = $(this).attr("btcolor").split(",");
					if($(this).attr("id")==$(t).attr("id")){
						currbtstyle = btstyle;
						currbtcolor = btcolor;
					}
					if($(this).attr("btstatus")=="checkdisabled"){
						$(this).attr("btstatus","normaldisabled");
						$(this).attr("class",a[btstyle][3]);
						$(this).css("color",btcolor[3]);
					}
					if($(this).attr("btstatus")=="normaldisabled"){
						
					}
					else{
						$(this).attr("btstatus","normal");
						$(this).attr("class",a[btstyle][0]);
						$(this).css("color",btcolor[0]);
					}
				});
				if(oldstatus!=2){
					t.attr("btstatus","check");
					t.attr("class",a[currbtstyle][2]);
					t.css("color",currbtcolor[2]);
				}
				else{
					t.attr("btstatus","normal");
					t.attr("class",a[currbtstyle][0]);
					t.css("color",currbtcolor[0]);
				}
			}	
		}
		try{
			progress(t);
		}
		catch(e){
			//alert(e);	
		}
		if(fun!=undefined){
			fun();
		}
	});
}

function loadcss(csslist){
	var a = csslist.split(",");
	var container = document.getElementsByTagName("head")[0];
	
	for(var i=0;i<a.length;i++){
		var addStyle = document.createElement("link");
		addStyle.rel = "stylesheet";
		addStyle.type = "text/css";
		addStyle.media = "screen";
		addStyle.href = a[i];
		container.appendChild(addStyle);
	}
 
}

var loadeditor = false;

function loadEditor(src){
	if(!loadeditor){		
		$("#loadmodal").modal('show');
		jQuery.getScript("../js/bootstrap-wysiwyg.js", function() {
			$.get("../tools/filemanage/filemanage_getfile.aspx?src="+src,function(data){
				var a = [];
				var path = $(data).find("r:first").attr("path");
				$(data).find("i").each(function(index, element) {
                    a.push('<li type="img" img="'+path+$(this).find("n:first").text()+'" data-edit="insertimage" style="width:100px;height:100px;float:left;margin:5px;border:1px solid #eee;list-style:none;cursor:pointer;background-image:url('+path+$(this).find("n:first").text()+');background-size:100%"></li>');
                });
				jQuery.getScript("../js/external/jquery.hotkeys.js", function() {
					$("#loadmodal").modal('hide');
					loadeditor = true;
					initToolbarBootstrapBindings(a); 
					$('#editor').wysiwyg({ fileUploadError: showErrorAlert} );
				});	
			},"xml");
		});	
		
	}
}



function initToolbarBootstrapBindings(imglist) {
      var fonts = ['Serif', 'Sans', 'Arial', 'Arial Black', 'Courier', 
            'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande', 'Lucida Sans', 'Tahoma', 'Times',
            'Times New Roman', 'Verdana'],
            fontTarget = $('[title=字体]').siblings('.dropdown-menu');
      $.each(fonts, function (idx, fontName) {
          fontTarget.append($('<li><a data-edit="fontName ' + fontName +'" style="font-family:\''+ fontName +'\'">'+fontName + '</a></li>'));
      });
      $('a[title]').tooltip({container:'body'});
    	$('.dropdown-menu input').click(function() {return false;})
		    .change(function () {$(this).parent('.dropdown-menu').siblings('.dropdown-toggle').dropdown('toggle');})
        .keydown('esc', function () {this.value='';$(this).change();});
 
      $('[data-role=magic-overlay]').each(function () { 
        var overlay = $(this), target = $(overlay.data('target')); 
        overlay.css('opacity', 0).css('position', 'absolute').offset(target.offset()).width(target.outerWidth()).height(target.outerHeight());
      });
      if ("onwebkitspeechchange"  in document.createElement("input")) {
        var editorOffset = $('#editor').offset();
        $('#voiceBtn').css('position','absolute').offset({top: editorOffset.top, left: editorOffset.left+$('#editor').innerWidth()-35});
      } else {
        $('#voiceBtn').hide();
      }
	  $("#webeditor_imglist").html(imglist);
	};
	function showErrorAlert (reason, detail) {
		var msg='';
		if (reason==='unsupported-file-type') { msg = "Unsupported format " +detail; }
		else {
			console.log("error uploading file", reason, detail);
		}
		$('<div class="alert"> <button type="button" class="close" data-dismiss="alert">&times;</button>'+ 
		 '<strong>File upload error</strong> '+msg+' </div>').prependTo('#alerts');
	};


function closeBack(){
	/*
$(window).bind("beforeunload",function(){
		history.go(0);
		return;
	});
*/
		var counter = 0;
		if (window.history && window.history.pushState) {
			$(window).on('popstate', function () {
				window.history.pushState('forward', null, '#');
				window.history.forward(1);
			});
		}
		try{
		window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
		window.history.forward(1);
		}
		catch(e){
			
		}
}

function pointItem(pointitemlist,fun){
	for(var j=0;j<pointitemlist.length;j++){
		var name = $(pointitemlist[j]).attr("id");
		$(pointitemlist[j]).bind("mouseover",function(e){
			var t = e.target;
			if($(t).attr("bttype")!="point"){
				return;	
			}
			
			var list = $(t).parent(this).find("[bttype='point']");
			var sn = parseInt($(t).attr("sn"));		
			list.css("color","#eee");
			for(var i=0;i<=sn;i++){
				$(list[i]).css({"color":"#fc0"});
			}
		});
		
		$(pointitemlist[j]).bind("mouseout",function(e){
			var t = e.target;
			if($(t).attr("bttype")!="point"){
				return;	
			}
			var list = $(t).parent(this).find("[bttype='point']")
			list.css("color","#eee");
			var curr = $(t).parent(this).find("[bttype='point'][btstatus='check']").first().attr("sn");

			if(curr==undefined){
				return;	
			}
			for(var i=0;i<=parseInt(curr);i++){
				$(list[i]).css("color","#fc0");
			}
		});
		
		$(pointitemlist[j]).bind("click",function(e){
			var t = e.target;
			if($(t).attr("bttype")!="point"){
				return;	
			}
			$(t).parent(this).find("[bttype='point']").attr("btstatus","normal");
			$(t).attr("btstatus","check");
			progress($(t));
			if(fun!=undefined){
				fun();	
			}
		});
	}
}





function getOverObj(a,mX,mY){
	for(var i=0;i<a.length;i++){
		if(statOverObj(a[i],mX,mY)){
			return [a[i][0],1];	
		}
	}
	if(( mX>=a[0][1])&&(mX<=a[0][3])){
		return [null,1];	
	}
	else{
		return [null,0];		
	}
}
function statOverObj(objposi,mX,mY){
	if(( mX>=objposi[1])&&(mX<=objposi[3])){
		if(( mY>=objposi[2])&&(mY<=objposi[6])){
			return true;
		}
	}
	return false;
}

function getOverObjList(nl,scrollH){
	var a = [];
	var temp;
	for(var i=0;i<nl.length;i++){
		temp = $(nl[i]).offset();
		a.push([nl[i],temp.left,temp.top+scrollH,temp.left+nl[i].offsetWidth,temp.top+scrollH,temp.left+nl[i].offsetWidth,temp.top+nl[i].offsetHeight+scrollH,temp.left,temp.top+nl[i].offsetHeight+scrollH,nl[i].id]);
	}
	return a;
}



function unselect(v){
	if(v==0){
		$(document.body).attr("onselectstart","return false;");	
		$(document.body).css("-moz-user-select","none");
		$(document).css("-webkit-user-select","none");
	}
	else{
		$(document.body).attr("onselectstart","return true;");	
		$(document.body).css("-moz-user-select","");
		$(document).css("-webkit-user-select","");
	}
}

function msgbox(msg,status,posi){
	var MBox = $("<div id='MBox' style='width:100%; text-align:center'><span class='label label-danger'></span></div>").appendTo("body");
	MBox.find("span").first().attr("class","label label-"+status)
	MBox.find("span").first().html(msg);
	var top =$(document).scrollTop()+300;
	var left = $(document).width()/2-80;
	left = 0;
	if(posi!=undefined){
		if(typeof(posi)=="String"){
			top = $("#"+posi).position().top;
			left = $("#"+posi).position().left;			
		}
		else{
			top = posi[0];	
			left = posi[1];	
		}
	}
	MBox.css({"position":"absolute","z-Index":"99999999","top":top,"left":left,"font-size":"24px"});
	MBox.animate({
		top:($(document).scrollTop()+100)+"px",
		opacity:'0'

	},3000);
	setTimeout(function(){MBox.remove()},3000);
}

String.prototype.colorHex = function(){
	var that = this;
	var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
	if(/^(rgb|RGB)/.test(that)){
		var aColor = that.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(",");
		var strHex = "#";
		for(var i=0; i<aColor.length; i++){
			var hex = Number(aColor[i]).toString(16);
			if(hex === "0"){
				hex += hex;	
			}
			strHex += hex;
		}
		if(strHex.length !== 7){
			strHex = that;	
		}
		return strHex;
	}else if(reg.test(that)){
		var aNum = that.replace(/#/,"").split("");
		if(aNum.length === 6){
			return that;	
		}else if(aNum.length === 3){
			var numHex = "#";
			for(var i=0; i<aNum.length; i+=1){
				numHex += (aNum[i]+aNum[i]);
			}
			return numHex;
		}
	}else{
		return that;	
	}
};

//-------------------------------------------------

String.prototype.colorRgb = function(){
	var sColor = this.toLowerCase();
	var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
	if(sColor && reg.test(sColor)){
		if(sColor.length === 4){
			var sColorNew = "#";
			for(var i=1; i<4; i+=1){
				sColorNew += sColor.slice(i,i+1).concat(sColor.slice(i,i+1));	
			}
			sColor = sColorNew;
		}
		var sColorChange = [];
		for(var i=1; i<7; i+=2){
			sColorChange.push(parseInt("0x"+sColor.slice(i,i+2)));	
		}
		return "RGB(" + sColorChange.join(",") + ")";
	}else{
		return sColor;	
	}
};

function escapehtml(s){
	try{
		s = s.replace(/&/g,"&amp;");
		s = s.replace(/</g,"&lt;");
		s = s.replace(/>/g,"&gt;");
		s = s.replace(/"/g,"&quot;");
		s = s.replace(/'/g,"&apos;");
		//s = s.replace(/ /g,"&amp;nbsp;");
		s = s.replace(/ /g,"");
	}
	catch(e){
	//alert(e+"-escapehtmlErr:"+s	)
	}
	return s;
}
function unescapehtml(s){
	try{
		//s = s.replace(/&amp;nbsp;/g," ");
		s = s.replace(/&lt;/g,"<");
		s = s.replace(/&gt;/g,">");
		s = s.replace(/&quot;/g,"\"");
		s = s.replace(/&apos;/g,"'");
		s = s.replace(/&amp;/g,"&");
	}
	catch(e){
	//alert(e+"-escapehtmlErr:"+s	)
	}
	return s;
}



function getCheckBoxValue(name){ //jquery获取复选框值
	var v =[];
	$('input[name="'+name+'"]:checked').each(function(){
		v.push($(this).val());
	});
	return v;
} 

function fillCheckBox(name,v){
	var a = v.toString().split(",");
	$('input[name='+name+']').removeAttr("checked");
	for(var i=0;i<a.length;i++){
		$('input[name='+name+'][value='+a[i]+']').get(0).checked = true;
	}
}



function setmenu(win,init){
	if(init){
		var s = '<i class="togglewin fa fa-angle-double-right" bttype="setmenu" title="最大化" id="togglewin"></i>';
		$('body').append(s);
		$("#togglewin").css({"left":($(window).width()-30)});
		$("#togglewin").bind("click",function(e){
			if(!window.parent.isMax){
				$("#togglewin").attr("class","togglewin fa fa-angle-double-left");
				$("#togglewin").css({"left":($(window).width()+30)});
				window.parent.$("#mainmenu").css("display","none");	
				window.parent.$("#body").css("width","100%");
				window.parent.$("#win").css("width","100%");
				window.parent.isMax  = true;
			}
			else{
				$("#togglewin").attr("class","togglewin fa fa-angle-double-right");
				$("#togglewin").css({"left":($(window).width()-30-60)});
				window.parent.$("#mainmenu").css({"display":"block","width":"60px"});	
				window.parent.$("#body").css("width",($(window).width()-60)+"px");
				window.parent.$("#win").css("width",($(window).width()));
				window.parent.isMax = false;
			}
		});
		return;	
	}
	
}

function getieversion(){
	var v = "";
	if(navigator.userAgent.indexOf("MSIE")>0){   
		  if(navigator.userAgent.indexOf("MSIE 6.0")>0){   
			v = ("ie6");    
		  } 
		  if(navigator.userAgent.indexOf("MSIE 7.0")>0){  
			v= ("ie7");   
		  }   
		  if(navigator.userAgent.indexOf("MSIE 8.0")>0 && !window.innerWidth){//这里是重点，你懂的
			v =("ie8");  
		  }   
		  if(navigator.userAgent.indexOf("MSIE 9.0")>0){  
			v = ("ie9");  
		  } 
		  if(navigator.userAgent.indexOf("MSIE 10.0")>0){  
			v = ("ie10");  
		  } 
    } 
	return v;
}

function autobg(o,imgaddr){
	function setbg(w,h){
		var boxw = $(o).width();
		var boxh = $(o).height();
		var wp = "100%";
		var hp = "100%";
		if(w>h){
			wp = "100%";
			hp = "auto";

		}
		else{
			hp = "100%";
			wp = "auto";
		}
		$(o).css({"background-size":(w>h?"100%":"auto")+" "+(h>=w?"100%":"auto"),"background-image":"url("+imgaddr+")"});	
	}
	var img = new Image();
	img.src = imgaddr;
	 if(img.complete){
		setbg(img.width,img.height);
	 }
	 else{
		img.onload = function(){
			setbg(img.width,img.height);
		}
	 }
}

function browserRedirect() {
            var sUserAgent = navigator.userAgent.toLowerCase();
            var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
            var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
            var bIsMidp = sUserAgent.match(/midp/i) == "midp";
            var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
            var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
            var bIsAndroid = sUserAgent.match(/android/i) == "android";
            var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
            var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
            //document.writeln("您的浏览设备为：");
            if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
                return ("phone");
            } else {
                return ("pc");
            }
}


function goodcardbt(id){
	 $("#"+id).bind("click",{a:"aaa"},function(e){
		var t = e.target;
		if($(t).attr("iscardbt")!="1"){
			return;	
		}
		if($(t).attr("class")=="cardbt cardbtcurr"){
			return;	
		}
		setBt(t);
	});
	this.setBt = function(t) {
		$("#"+id).find("div[iscardbt='1']").attr("class","cardbt cardbtnormal");
		$("#"+id).find("div[istab='1']").css("display","none");
		$(t).attr("class","cardbt cardbtcurr");
		 $("#"+$(t).attr("targettab")).fadeIn();
	}
	setBt($("#"+id).find("div[iscardbt='1']:first"));
}

function openEditor(e){
	var ie = getieversion();
	if( (ie=="ie8")||(ie=="ie7")||(ie=="ie6")){
		alert("此功能暂不支持ie8及以下版本浏览器");
		return;
	}
	var t = e.target;
	loadEditor("editsurvey");
	var target = $("#"+$(t).attr("edittarget"));
	$("#EditorBoxModal").modal("show");
	$("#editor").html($(target).html());
	$("#editortargetid").val($(t).attr("edittarget"));
}

function convertCDATA(s){
	if(s!=""){
		s = s.substr( s.indexOf("<![CDATA[")+ "<![CDATA[".length);
		s = s.substr(0,s.lastIndexOf("]]>"));
	}
	return s;
}



function createpage(loadListFn, param) {	

	var pagebox = null;
	if(typeof(param.pagebox)=="string"){
		pagebox = $("#"+param.pagebox);	
	}
	else{
		pagebox = param.pagebox;
	}
	var bigpage = param.bigpage;
	var pagenum = param.pagenum;

	var currpage = parseInt(param.currpage);
	var beginpage = parseInt(currpage/bigpage)*bigpage;
	if(beginpage==0){
		beginpage = 1;	
	}
	var endpage = parseInt(currpage/bigpage)*bigpage+bigpage;
	endpage = endpage>pagenum?pagenum:endpage;

	console.log(param)	

	$(pagebox).attr("aria-label","Page navigation");
	if($(pagebox).attr("init")!="yes"){
		$(pagebox).attr("init","yes");
		$(pagebox).bind("click",function(e){
			var t =$(e.target).parent("li");			
			if($(t).attr("bttype")=="pagebt"){
				 var v = $(t).attr("v")	;
				 param.currpage = v;
				 loadListFn(param);
				 return;
			}
		});
	}
	else{
		
	}

	
	
	var a = [];
	a.push("<ul class='pagination' >");
	a.push("<li v='"+(1)+"' bttype='pagebt' class='normalpage'><a href='#' bttype='pagebt' class='glyphicon glyphicon-step-backward' title='第一页'> </a></li>");			
	if(currpage>1){
		a.push("<li v='"+(currpage-1)+"' bttype='pagebt' class='normalpage'><a  href='javascript:void(0)'  bttype='pagebt' title='上一页' class='glyphicon glyphicon-chevron-left'> </a></li>");		
	}
for (var i = beginpage; i <= endpage; i++) {

		a.push("<li v='"+i+"' bttype='pagebt'><a href='javascript:void(0)' v='"+i+"'  bttype='pagebt' class='glyphicon'   "+(i==parseInt(currpage)?"style='color:#f60'":"normalpage")+">"+i+"</a></li>");	
	}
	if(currpage<pagenum){
		a.push("<li v='"+(currpage+1)+"' bttype='pagebt' class='normalpage'><a  href='javascript:void(0)' bttype='pagebt' class='glyphicon glyphicon-chevron-right' title='下一页'> </a></li>");		
	}
a.push("<li v='" + (param.pagenum) + "' bttype='pagebt' class='normalpage'><a  href='javascript:void(0)' bttype='pagebt' class='glyphicon glyphicon-step-forward' title='最末页'> </a></li>");		
	if(param.showStat){
	    a.push("<li class='normalpage '><a class='glyphicon'>" + currpage + "/" + param.pagenum + "页[" + param.recordnum + "]</a></li>");
	}
	a.push("</ul>");

	pagebox.html(a.join(""));

}


function createMask(maskid,showmask){
	if($("#"+maskid).length==0){	
		$("body").append('<div data-keyboard="false" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" id="'+maskid+'" data-backdrop="false"><div class="modal-dialog modal-sm" role="document"><div class="modal-content" style="height:100px; text-align:center;"><div class="fa fa-spin  fa-spinner" style="margin-top:4rem;color:#f60"></div><br />请等待...</div></div></div>');
	}
	if(showmask!=undefined){
		$("#"+maskid).modal(showmask);	
	}
}



 



    function fillList() {
        var a = [];
        a.push(["朝阳门兆泰国际社区", "https://img.krspace.cn/community_public_upload/201807/F/200721556_921.jpg", "500起/工位", "北京市朝阳区兆泰国际中心C座3-4层"]);
        a.push(["国贸大都会社区", "https://img.krspace.cn/community_public_upload/201807/O/200720100_70.jpg", "500起/工位", "北京市朝阳区东三环中路甲10号"]);

        a.push(["国贸海航实业大厦社区", "https://img.krspace.cn/community_public_upload/201804/X/191727890_677.jpg", "700元/工位/月", "北京市朝阳区建国路108号海航实业大厦8、9层"]);

        a.push(["创业大街社区", "https://img.krspace.cn/community_public_upload/201808/U/153918826_867.jpg?x-oss-process=image/resize,m_fill,w_278,h_215,color_eeeeee,quality,q_90", "600元/工位/月"]);

        var b = [];
        for (var i = 0; i < a.length; i++) {
            b.push("<div class='col-lg-3 col-md-12 itembox'><img src='" + a[i][1] + "' class='itemimg' /><div class='iteminfo'>");
            b.push("<p>" + a[i][0] + "</p>");
            b.push("<p>价格：" + a[i][2] + "</p>");
            b.push("<p>位置：" + a[i][3] + "</p>");
            b.push("</div></div>");
        }

        $("#officelist").html(b.join(""));
    }


    //fillList();

function getCheckBoxValue(o,name){
	var a = [];
	$(o).find("input[name='"+name+"']").each(function(index, element) {
		if($(this).get(0).checked){
			a.push($(this).get(0).value);	
		}
	});
	return a.join(",");
}

function fillCheckBox(o,name,v){
	$(o).find("input[name='"+name+"']").each(function(index, element) {
		$(this).get(0).checked = (","+v+",").indexOf(","+$(this).get(0).value+",")>=0;
	});
}


function toTop(e) {
  return e.preventDefault(), $("html, body").animate({
    scrollTop: 0
  }, 300), !1
}

$(window).scroll(function(){
        var winHeight = $(window).scrollTop();
        if(winHeight>100){

			$("#toupbt").fadeIn();
		    $("#toupbt").fadeIn(3000);
        }else{

			$("#toupbt").fadeOut();
		    $("#toupbt").fadeOut(3000);
        }
    })

function getClient(){	
	var browser = {
		versions: function () {
			var u = navigator.userAgent, app = navigator.appVersion;
			return {         //移动终端浏览器版本信息
				trident: u.indexOf('Trident') > -1, //IE内核
				presto: u.indexOf('Presto') > -1, //opera内核
				webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
				gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
				mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
				ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
				android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
				iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
				iPad: u.indexOf('iPad') > -1, //是否iPad
				webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部
			};
		}(),
		language: (navigator.browserLanguage || navigator.language).toLowerCase()
	}
	var result = "";
	if (browser.versions.mobile) {//判断是否是移动设备打开。browser代码在下面
        var ua = navigator.userAgent.toLowerCase();//获取判断用的对象
        if (ua.match(/MicroMessenger/i) == "micromessenger") {
			result = "wx";
        }
        if (ua.match(/WeiBo/i) == "weibo") {
			result = "wb";
        }
        if (ua.match(/QQ/i) == "qq") {
			result = "qq";
        }
        if (browser.versions.ios) {
			result = "ios";
        } 
        if(browser.versions.android){
			result = "android";
        }
	} else {
		result = "pc";
	}
	return result;
}


if (getClient() == "pc") {
    $("#bottom").css("display","block");
}

