﻿var isAdmin=false;
var mbopen =false;

function adminck(){
var sendatas;
sendatas ="cmd=adminck&sn="+Math.random();
$.ajax({ type: "POST", url: "/contrl/App.aspx",data:sendatas,dataType:"json",success: function(callback){adminCkBack(callback);},error:function(){return false;}});
}

function adminCkBack(json){
if(json.Admin =='true'){
isAdmin=true;
initFunToMg();
}
}

function initFunToMg(){
//初始化管理程序
var mgbox='';
$(".newsbox .content").each(function(){
this.oncontextmenu = function(){ return false; };
});

$(".newsbox .content li a").mousedown(function(e){

$(".mgbox").hide();
if(this.style.color !='' && !Posting && (3==e.which)){ //start 
var pms = this.className.split('-');
mgbox='<div class="mgbox" style="border:1px solid #666;background-color:#eee;padding:2px;" >';

var stl= this.innerHTML;
if(stl.indexOf('<IMG') != -1){ 
var txtck =/<img[^#]+txt=([^&]+)[^>]+>/i
stl = URLdecode(stl.replace(txtck,"$1"));
}

if(this.title.indexOf('[') !=-1){
stl=this.title.substring(0,this.title.indexOf(']')+1)+stl;
}

mgbox+='<input id="stl" type="text" style="width:200px;" value="'+stl+'" /><br/>';
mgbox+='<input id="cblue" type="checkbox" ';

if(this.style.color == "#0000ff")
mgbox+='checked="checked" ';

mgbox+='/>加蓝 置项 <input id="dlev" type="text" maxlength="2" style="width:16px;" value="'+pms[2]+'" /> 级<input id="cindex" type="checkbox" checked="checked"  />生成 <input type="button" value="提交" style="padding-top:2px;" onclick="submitC('+pms[1]+','+pms[0]+')" /></div>';
$(this).after(mgbox);
} //end

});
}

var Posting =false;

function submitC(cdid,ccid){
var sendatas;
sendatas ="cmd=dotl&sn="+Math.random();
var stl =$("div.mgbox input#stl").val();
var cblue = $("div.mgbox input#cblue")[0].checked;
var clev = $("div.mgbox input#dlev").val();
var cindex = $("div.mgbox input#cindex")[0].checked;
//--------------
//stl = URLencode(stl);
sendatas += "&cblue="+cblue+"&clev="+clev+"&cindex="+cindex+"&cdid="+cdid+"&ccid="+ccid+"&stl="+stl;
//alert(sendatas);
Posting=true;
$.ajax({ type: "POST", url: "/contrl/App.aspx",data:sendatas,dataType:"json",success: function(callback){dotlBack(callback);},error:function(){return false;}});
}

function dotlBack(json){
if(json.err == "0"){
//alert("更新成功");
Posting =false;
location.reload();
}
}

