function fun_del(strTableName,tablename,ReturlUrl,delpltable){if(!document.getElementById(tablename))return;
var ctl = document.getElementById(tablename);var checkbox = ctl.getElementsByTagName("input"); var k=0;var par1="";
for(var j=0;j<checkbox.length;j++){if(checkbox[j].type=="checkbox"){if(checkbox[j].checked==true ){k++;par1+=(checkbox[j].parentNode.title+",");}}}
if(k==0)alert("没有选中项！");
else{if(confirm("确实要删除这 "+k+" 项吗？")){
var url=location.href;url=url.substring(0,url.indexOf("?"));
if(par1.length>1){
var strUrl="do.aspx";var strPar="dotype=dels&strTableName="+strTableName+"&par1="+par1+"&ReturnUrl="+base64en(ReturlUrl);if(delpltable!=null||delpltable!=""||delpltable!="undefined")strPar+="&delpltable="+delpltable;
ajax("post",strUrl,strPar,function OnHandler(){if(xmlHttp.readyState == 4){document.write(xmlHttp.responseText);}});
}}}}

function fun_lock(strTableName,tablename,ReturlUrl,type){if(!document.getElementById(tablename))return;
var ctl = document.getElementById(tablename);var checkbox = ctl.getElementsByTagName("input"); var k=0;var par1="";
for(var j=0;j<checkbox.length;j++){if(checkbox[j].type=="checkbox"){if(checkbox[j].checked==true ){k++;par1+=(checkbox[j].parentNode.title+",");}}}
if(k==0)alert("没有选中项！");
else{if(confirm("确实要操作这 "+k+" 项吗？")){
var url=location.href;url=url.substring(0,url.indexOf("?"));
if(par1.indexOf(",")!=-1){
var strUrl="do.aspx";var strPar="dotype=locks&strTableName="+strTableName+"&par1="+par1+"&type="+type+"&ReturnUrl="+base64en(ReturlUrl);
ajax("post",strUrl,strPar,function OnHandler(){if(xmlHttp.readyState == 4){document.write(xmlHttp.responseText);}});
}}}}

function doPZ(InputText){if(!document.getElementById(InputText))return;
var sNum=document.getElementById(InputText).value;
if(sNum==""||sNum=="0"||sNum.indexOf("-")!=-1||isNaN(sNum))return;
else{
var url=location.href;if(url.indexOf("#")!=-1)url=url.substring(0,url.indexOf("#"));
if(url.indexOf("pagesize=")!=-1){
var strs = location.search.substr(1).split("&");var par1="";for(i=0;i<strs.length;i++){if([strs[i].split("=")[0]].toString()=="pagesize")par1=strs[i].split("=")[1];}
if(!isNaN(par1))window.location=url.replace("pagesize="+par1,"pagesize="+sNum);
}
else{if(url.indexOf("?")!=-1)window.location=url+"&pagesize="+sNum;else window.location=url+"?pagesize="+sNum;}
}}


if(location.href.indexOf("pagesize=")!=-1){
if(document.getElementById("PZ")){
var strs = location.search.substr(1).split("&");var par1="";for(i=0;i<strs.length;i++){if([strs[i].split("=")[0]].toString()=="pagesize"){par1=strs[i].split("=")[1];}}
document.getElementById("PZ").value=par1;
}}

function initfuntab(){
if(GetCookie("CK_list_fun_tab1")!=""&&GetCookie("CK_list_fun_tab2")!=""){if(document.getElementById(GetCookie("CK_list_fun_tab1"))&&document.getElementById(GetCookie("CK_list_fun_tab2")))movearea1(GetCookie("CK_list_fun_tab1"),GetCookie("CK_list_fun_tab2"));}
}
function movearea1(obj1,name){SetCookie("CK_list_fun_tab1",obj1,1);SetCookie("CK_list_fun_tab2",name,1);var b =document.getElementById(obj1).parentNode.getElementsByTagName("li");var v = document.getElementById(name).getElementsByTagName("blockquote");for(i=0;i<v.length;i++){if(document.getElementById(obj1)==b[i]){b[i].className = "on";SetCookie("CK_list_fun_tab1",obj1,1);SetCookie("CK_list_fun_tab2",name,1);v[i].className = "block";}else{b[i].className = "";v[i].className = "none";}}}


function doOrderCustom(OrderCustom){if(!document.getElementById(OrderCustom))return;
var str1=document.getElementById(OrderCustom).value;
if(str1 ==""||str1.indexOf("输入排序语句，例如：")!=-1||str1.indexOf(">")!=-1||str1.indexOf("<")!=-1||str1.indexOf("=")!=-1||str1.indexOf("<>")!=-1){return;}
var url=location.href.replace("&&","&");if(url.indexOf("#")!=-1)url=url.substring(0,url.indexOf("#"));
var strs = location.search.substr(1).split("&");var par1="";for(i=0;i<strs.length;i++){if([strs[i].split("=")[0]].toString()=="ordercustom"){par1=strs[i].split("=")[1];}}
if(url.indexOf("orderby_")!=-1)
{
var par2="";par3="";for(i=0;i<strs.length;i++){if([strs[i].split("=")[0]].toString().indexOf("orderby_")!=-1){par2=strs[i].split("=")[0];par3=strs[i].split("=")[1];}}
url=url.replace(par2+"="+par3,"");url=url.replace("?&","?");if(url.substring(url.length-1)=="?")url=url.substring(0,url.length-1);if(url.substring(url.length-1)=="&")url=url.substring(0,url.length-1);
}
if(par1!="")window.location=url.replace("ordercustom="+par1,"ordercustom="+base64en(str1));
else{if(url.indexOf("?")!=-1)window.location=url+"&ordercustom="+base64en(str1);else window.location=url+"?ordercustom="+base64en(str1);}
}


if(location.href.indexOf("ordercustom=")!=-1){
if(document.getElementById("OrderCustom")){
var strs = location.search.substr(1).split("&");var par1="";for(i=0;i<strs.length;i++){if([strs[i].split("=")[0]].toString()=="ordercustom"){par1=strs[i].split("=")[1];}}
document.getElementById("OrderCustom").value=base64de(par1);
}}


function doSqlWhere(InputText){if(!document.getElementById(InputText))return;
var str1=document.getElementById(InputText).value;if(str1 =="")str1="id>0";
if(str1.indexOf("输入条件语句，例如：")!=-1){return;}
else{
var url=location.href;if(url.indexOf("#")!=-1)url=url.substring(0,url.indexOf("#"));
if(url.indexOf("sqlwhere=")!=-1){
var strs = location.search.substr(1).split("&");var par1="";for(i=0;i<strs.length;i++){if([strs[i].split("=")[0]].toString()=="sqlwhere")par1=strs[i].split("=")[1];}
window.location=url.replace("sqlwhere="+par1,"sqlwhere="+base64en(str1));
}
else{if(url.indexOf("?")!=-1)window.location=url+"&sqlwhere="+base64en(str1);else window.location=url+"?sqlwhere="+base64en(str1);}
}}


if(document.getElementById("DropDownListWhereFields")){if(DableWhereFields!=""){strs = DableWhereFields.split(",");for(i=0;i<strs.length;i++)SetDropDownListWhereFields(strs[i].split("=")[0],strs[i].split("=")[1]);}}
function SetDropDownListWhereFields(obj1,obj2){
var selectobj=document.getElementById("DropDownListWhereFields");
for(var i=0;i<selectobj.length;i++)if(selectobj.options[i].text==obj1){
if(obj2=="null"){if (navigator.userAgent.indexOf('Firefox')!=-1)selectobj.remove(selectobj.options[i].index);else selectobj.options.remove(selectobj.options[i].index);}else {selectobj.options[selectobj.options[i].index].text=obj2;}
}
}


if(document.getElementById("DropDownListOrderbyFields")){if(DableOrderbyFields!=""){strs = DableOrderbyFields.split(",");for(i=0;i<strs.length;i++)SetDropDownListOrderbyFields(strs[i].split("=")[0],strs[i].split("=")[1]);}}
function SetDropDownListOrderbyFields(obj1,obj2){
var selectobj=document.getElementById("DropDownListOrderbyFields");
for(var i=0;i<selectobj.length;i++)if(selectobj.options[i].text==obj1){
if(obj2=="null"){if (navigator.userAgent.indexOf('Firefox')!=-1)selectobj.remove(selectobj.options[i].index);else selectobj.options.remove(selectobj.options[i].index);}else {selectobj.options[selectobj.options[i].index].text=obj2;}
}
}


var SqlWhereItem=0;
if(location.href.indexOf("sqlwhere=")!=-1){
if(document.getElementById("SqlWhere")&&document.getElementById("sqlwherearea1")&&document.getElementById("sqlwherearea2")){
var strs = location.search.substr(1).split("&");var par1="";for(i=0;i<strs.length;i++){if([strs[i].split("=")[0]].toString()=="sqlwhere"){par1=strs[i].split("=")[1];}}
if(base64de(par1)!="id>0"){document.getElementById("SqlWhere").value=base64de(par1);document.getElementById('sqlwherearea1').style.display='none';document.getElementById('sqlwherearea2').style.display='';initsqlwhere(base64de(par1));}
}}
function initsqlwhere(str1){var j=0;
for(var i=0;i<10;i++){
var a=GetCookie("CK_SqlWhereItem"+i+"a");var b=GetCookie("CK_SqlWhereItem"+i+"b");var c=GetCookie("CK_SqlWhereItem"+i+"c");var d=GetCookie("CK_SqlWhereItem"+i+"d");
if(a!=null&&a!=""&&a!="null"){j++;ShowWhereItem(b);
if(document.getElementById("whereitem"+i.toString()+"a"))document.getElementById("whereitem"+i.toString()+"a").selectedIndex=a;
if(document.getElementById("whereitem"+i.toString()+"c"))document.getElementById("whereitem"+i.toString()+"c").selectedIndex=c;
if(document.getElementById("whereitem"+i.toString()+"d")){if(d==null){d="";}document.getElementById("whereitem"+i.toString()+"d").value=d;document.getElementById("whereitem"+i.toString()+"d").setAttribute("value",d);}
}}
if(j>0)document.getElementById("sqlwherearea1").style.display="";
}




function ShowWhereItem(obj1){if(SqlWhereItem>9){alert("最多只能添加10个条件！");return;}
document.getElementById("sqlwherearea3").style.display="";document.getElementById('sqlwherearea2').style.display='';
var strtemp1="";var selectobj=document.getElementById("DropDownListWhereFields");for(var i=0;i<selectobj.length;i++){if(i>0){if(obj1==selectobj.options[i].value) strtemp1+="<option value=\""+selectobj.options[i].value+"\" selected>"+selectobj.options[i].text+"</option>"; else strtemp1+="<option value=\""+selectobj.options[i].value+"\">"+selectobj.options[i].text+"</option>";}}
var str1="<div style=\"padding-top:5px\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><select onChange=\"KeyupWhereItem(\'"+SqlWhereItem+"\')\" class=\"s12\" style=\"width:80px\" name=\"whereitem"+SqlWhereItem+"a\" id=\"whereitem"+SqlWhereItem+"a\"><option value=\"AND\">AND</option><option value=\"OR\">OR</option></select></td><td><select onChange=\"KeyupWhereItem(\'"+SqlWhereItem+"\')\" class=\"s12\" style=\"width:200px\" name=\"whereitem"+SqlWhereItem+"b\" id=\"whereitem"+SqlWhereItem+"b\">"+strtemp1+"</select></td><td><select onChange=\"KeyupWhereItem(\'"+SqlWhereItem+"\')\" class=\"s12\" style=\"width:80px\" name=\"whereitem"+SqlWhereItem+"c\" id=\"whereitem"+SqlWhereItem+"c\"><option value=\"=\">=</option><option value=\">\">&gt;</option><option value=\">=\">&gt;=</option><option value=\"<\">&lt;</option><option value=\"<=\">&lt;=</option><option value=\"<>\">&lt;&gt;</option><option value=\"like\" selected>like</option><option value=\"not like\">not like</option><option value=\"in\">in</option><option value=\"not in\">not in</option><option value=\"is null\">is null</option><option value=\"is not null\">is not null</option></select></td><td><input name=\"whereitem"+SqlWhereItem+"d\" type=\"text\" id=\"whereitem"+SqlWhereItem+"d\" class=\"inp1\" style=\"width:340px\" maxlength=\"100\" onfocus=\"KeyTurn=0\" onblur=\"KeyTurn=1;KeyupWhereItem(\'"+SqlWhereItem+"\')\" onkeyup=\"this.setAttribute(\'value\',this.value);KeyupWhereItem(\'"+SqlWhereItem+"\')\" /></td><td style=\"padding-left:3px\"><input name=\"\" type=\"button\" value=\"删除\" class=\"but1\" onclick=\"DelWhereItem(\'"+SqlWhereItem+"\');this.style.display=\'none\';KeyupWhereItem(\'"+SqlWhereItem+"\')\"></td></tr></table></div>";
SqlWhereItem++;
document.getElementById("sqlwherearea3").innerHTML+=str1;
document.getElementById("DropDownListWhereFields").selectedIndex=0;
}
function KeyupWhereItem(theID){
for(var i=0;i<10;i++){DelCookie("CK_SqlWhereItem"+i+"a");DelCookie("CK_SqlWhereItem"+i+"b");DelCookie("CK_SqlWhereItem"+i+"c");DelCookie("CK_SqlWhereItem"+i+"d");}
var str1="";
for(var i=0;i<SqlWhereItem;i++){
var obja=document.getElementById("whereitem"+i+"a").value;var objb=document.getElementById("whereitem"+i+"b").value;var objb_text=document.getElementById("whereitem"+i+"b").options[document.getElementById("whereitem"+i+"b").selectedIndex].text;var objc=document.getElementById("whereitem"+i+"c").value;var objd=document.getElementById("whereitem"+i+"d").value;
if(obja!=""){
var type=objb_text.substring(objb_text.length-2);
var s1L="'";var s1R="'";var DataType_DateTime_SQL_Symbols="#";if(GetCookie("DataType_DateTime_SQL_Symbols")=="1")DataType_DateTime_SQL_Symbols="'";
if(type=="_N"){s1L="";s1R="";}if(type=="_B"){s1L="";s1R="";if(objd.toLowerCase()=="false")objd="0";if(objd!="1"&&objd!="0")objd="1";}if(type=="_D"){s1L=DataType_DateTime_SQL_Symbols;s1R=DataType_DateTime_SQL_Symbols;}  //三种数据类型  _N（数值或ID）  _B（布尔）  _D（日期）
var s2L="";var s2R="";
if(objc=="like"||objc=="not like"){s1L="'";s1R="'";s2L="%"; s2R="%";}
if(objc=="in"||objc=="not in"){s1L="("+s1L;s1R=s1R+")";}
if(objc=="is null"||objc=="is not null"){s1L="";s1R="";objd="";}
str1+=obja+" "+objb+" "+objc+" "+s1L+s2L+""+objd+""+s2R+s1R+" ";
SetCookie("CK_SqlWhereItem"+i+"a",document.getElementById("whereitem"+i+"a").selectedIndex,1);SetCookie("CK_SqlWhereItem"+i+"b",objb,1);SetCookie("CK_SqlWhereItem"+i+"c",document.getElementById("whereitem"+i+"c").selectedIndex,1);SetCookie("CK_SqlWhereItem"+i+"d",objd,1);
}
}
if(str1.substring(0,4).toLowerCase()=="and ")str1=str1.substring(4);if(str1.substring(0,3).toLowerCase()=="or ")str1=str1.substring(3);
document.getElementById("SqlWhere").value=str1;
}
function DelWhereItem(theID){
var obj1=document.getElementById("whereitem"+theID+"a");
if(obj1.options.length==2)obj1.options[obj1.options.length++] = new Option('已排除','');
obj1.selectedIndex=2;
}


function singlewhere(str1){for(var i=0;i<10;i++){DelCookie("CK_SqlWhereItem"+i+"a");DelCookie("CK_SqlWhereItem"+i+"b");DelCookie("CK_SqlWhereItem"+i+"c");DelCookie("CK_SqlWhereItem"+i+"d");}
var url=location.href;if(url.indexOf("#")!=-1)url=url.substring(0,url.indexOf("#"));
if(url.indexOf("sqlwhere=")!=-1){
var strs = location.search.substr(1).split("&");var par1="";for(i=0;i<strs.length;i++){if([strs[i].split("=")[0]].toString()=="sqlwhere")par1=strs[i].split("=")[1];}
window.location=url.replace("sqlwhere="+par1,"sqlwhere="+base64en(str1));
}
else{if(url.indexOf("?")!=-1)window.location=url+"&sqlwhere="+base64en(str1);else window.location=url+"?sqlwhere="+base64en(str1);}
}

function singlewhereblur(str1){
str1=str1.replace(/\"/g,'').replace(/\'/g,'').replace(/\//g,'').replace(/\\/g,'').replace(/\[/g,'').replace(/\]/g,'').replace(/,/g,'').replace(/\./g,'').replace(/\(/g,'').replace(/\)/g,'').replace(/\{/g,'').replace(/\}/g,'');
return str1;
}

function FormatBH(BH){
BH=BH.replace(/ /g,"").replace(/　/g,"");
if(isNaN(BH)){
BH=BH.substring(2);BH=BH.substring(0,BH.length-6);if(isNaN(BH))return "0"; else return BH;
}else return BH;
}