var popUpWin=0;
//不可选窗口名称
function popUpWindow(URLStr, left, top, width, height)
{
var left_s=100;
var top_s=100;
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left_s+', top='+top_s+',screenX='+left_s+',screenY='+top_s+'');
}
//可选窗口名称
function popUpWindow2(URLStr, left, top, width, height,windowname)
{
var left_s=30;
var top_s=30;
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  //Edit@040906 By Linh，去掉了滚动条。
  popUpWin = open(URLStr, windowname, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left_s+', top='+top_s+',screenX='+left_s+',screenY='+top_s+'');
}
//可选窗口名称,大小,滚动条
function popUpWindow3(URLStr, left, top, width, height,windowname)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, windowname, 'toolbar=no,location=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  //popUpWin = window.showModalDialog(URLStr, windowname, "dialogWidth:"+width+"px,dialogHeight:"+height+"px,dialogLeft:"+left+"px, dialogTop:"+top+"px, status:no; directories:no; help:no; scroll:yes;screenX:"+left+",screenY:"+top);
}
//用于调试
function popUpWindow5(URLStr, left, top, width, height,windowname)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, windowname, '');
  //popUpWin = window.showModalDialog(URLStr, windowname, "dialogWidth:"+width+"px,dialogHeight:"+height+"px,dialogLeft:"+left+"px, dialogTop:"+top+"px, status:no; directories:no; help:no; scroll:yes;screenX:"+left+",screenY:"+top);
}
//与popUpWindow3功能类似,但添加了工具栏
function popUpWindow4(URLStr, left, top, width, height,windowname)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, windowname, 'toolbar=yes,location=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
//不关闭其他弹出窗口
function popUpWindow6(URLStr, left, top, width, height,windowname)
{

  window.open(URLStr, windowname, 'toolbar=no,location=no,directories=no,scrollbars=yes,status=no,menubar=no,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
  //popUpWin = window.showModalDialog(URLStr, windowname, "dialogWidth:"+width+"px,dialogHeight:"+height+"px,dialogLeft:"+left+"px, dialogTop:"+top+"px, status:no; directories:no; help:no; scroll:yes;screenX:"+left+",screenY:"+top);
}
function popUpWindow7(URLStr, left, top, width, height,windowname)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.reload();
  }
}
//顶部菜单背景变换
function chgbg(num){
    var i=0;
    var id='menu1';
    var menuitems=new Array;

    for(i=0; document.getElementById(id)!=null; i++){
        var j=i+1;
        id='menu'+j;
        if(document.getElementById(id)!=null){
            menuitems[i]=id;
        }
    }

    for(i=0; i<menuitems.length; i++){
        if (menuitems[i]==num)
            document.getElementById(menuitems[i]).style.backgroundImage='url(/images/second_in2_06.gif)';
        else
            document.getElementById(menuitems[i]).style.backgroundImage= '';
    }
}

//用于变换多个区域内容的显示
//用于一个按钮控制显示/隐藏
function ClickchangeTab(it1)
{
   var type;
   var obj=document.getElementById(it1);
   type=obj.style.display;
   if (type=='block')
       {document.getElementById(it1).style.display = "none";}
   else
       {document.getElementById(it1).style.display = "block";}
}
//用于一个Select(it1)的值控制it2的显示隐藏
function changeTab(it1,it2)
{
   var type;
   var obj=document.getElementById(it1);
   type=obj.value;
   if (type=='Y')
       {document.getElementById(it2).style.display = "block";}
   else
       {document.getElementById(it2).style.display = "none";}
}
//用于一个Select(it1)的值控制it2的显示隐藏,show用于控制"Y"时显示还是"N"时显示
function changeTab2(it1,it2,show)
{
   var type;
   var type2;
   var obj=document.getElementById(it1);
   type=obj.value;
   var shower=show;

   if (shower=='Y'){
   type2=type;
   if(type=='Y'){type2='N';}
   else if(type=='N'){type2='Y';}
   type=type2;
   }

   if (type=='Y')
       {document.getElementById(it2).style.display = "block";}
   else if(type=='N')
       {document.getElementById(it2).style.display = "none";}
   else
       {document.getElementById(it2).style.display = "none";}

}
//传入select对象和要交替显示的区域共有的ID的前缀.例如:changTab3(this,'ch_')
function changeTab3(sel,tabs)
{
    var obj=sel;
    var showerid=obj.value;
    var pref=tabs;
    var changtabs=new Array;
    if(pref==''||pref==null){
        pref='tabch_';
    }
    var all_ele=new Array;
    all_ele=document.all;
    for(i=0;i<all_ele.length;i++){
        var ele_name=all_ele[i].id;
        if(ele_name!='' && ele_name!=null && ele_name !='undefined' && ele_name.indexOf(pref)>=0){
            if(ele_name==pref+showerid){
                all_ele[i].style.display='block';
            }
            else{
                all_ele[i].style.display='none';
            }
        }
    }
}

//检测页面是否在相应的框架内,如果不是,则在框架中载入该页面
function isInframe(pageobj,frame){

    //Edit@040906 By Linh，增加了弹出窗口判断
    //Edit@040908 By Linh，修正
    if(pageobj.location.href.indexOf('index.jsp')>=0 && pageobj.opener!=null){
        pageobj.opener.location=pageobj.location;
        pageobj.window.close();
        pageobj=pageobj.opener;
        }

    if(typeof(frame)=="string"){
        if(pageobj.name!=frame){
            for(obj=parent;obj.name==frame;){
            if(obj.name==frame){
                obj.location=pageobj.location;
                break;
                }
            if(obj=top) break;
            }
        }
        }
    else if(typeof(frame)=="object"){
        if(pageobj.location!=frame.location)
            frame.location=pageobj.location;
        }
}

//add by zy. if sel.value = value, the style of item :display:none
function changeTab4(sel, value, item)
{
    if (sel.value==value)
    {
        document.getElementById(item).style.display='none';
    }
    else
    {
        document.getElementById(item).style.display='block';
    }
}
// add by zy. it disabled=true
function changeTab5(it,confirmFlag,ajstate)
{
    if(confirmFlag != '3' || ajstate >= '02')
    {
   		document.getElementById(it).disabled = true;
   		var arrobj = document.all.item(it);
   		for (var i=0;i<arrobj.length;i++)
       		arrobj[i].disabled = true;
    }
}
//it1=R,it2 display=block
function changeTab6(it1,it2)
{
   if (it1=='R')
       {document.getElementById(it2).style.display = "block";}
   else
       {document.getElementById(it2).style.display = "none";}
}
//ctrlobj=0、1、2；if 0 ,display none
function changeTab7(ctrlobj,showobj0,showobj1,showobj2)
{

    if(ctrlobj.value==0){
    document.getElementById(showobj0).style.display = "none";
    document.getElementById(showobj1).style.display = "none";
    document.getElementById(showobj2).style.display = "none";
    }
    else if(ctrlobj.value==1){
    document.getElementById(showobj0).style.display = "block";
    document.getElementById(showobj1).style.display = "block";
    document.getElementById(showobj2).style.display = "none";
    }
    else if(ctrlobj.value==2){
    document.getElementById(showobj0).style.display = "block";
    document.getElementById(showobj1).style.display = "none";
    document.getElementById(showobj2).style.display = "block";
    }
}

function goToURL() { //v3.0
  var i, args=goToURL.arguments; document.returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

//首页图片预载
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//图片轮换
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//查找对象
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//选中所有checkbox,sellall和chkboxname分别为控制用的checkbox和被控制的checkbox的"name"值字符串,
function selectall(selall,chkboxname)
{
    var ctrlchk="chkall";
    var listchk="chk";
    if(selall!=null & selall!=""){ctrlchk=selall;}
    if(chkboxname!=null & chkboxname!=""){listchk=chkboxname;}
    var i;
    var sels=document.getElementsByTagName('INPUT');
    var chkv;
    chkv=document.all[ctrlchk].checked;
//    for(i=0;i<sels.length;i++){
//        if(sels[i].name==ctrlchk) chkv=sels[i].checked;
//        break;
//        }
    for (i=0;i<sels.length;i++)
    {
        if(sels[i].name==listchk){
        	if((chkv==true || chkv=="checked") && sels[i].disabled==false){
                	sels[i].checked=true;
        	}
        	else{
                	sels[i].checked=false;
        	}
        }
    }
}
function openwin(server, filepath, ggly){
    var serverfilepath=server+filepath;
//    serverfilepath=StringUtils.replace(serverfilepath,"\\","/");//格式化路径
//    if (ggly!="1")
//        serverfilepath = filepath;

    var location= serverfilepath;
    if(location==""){
       alert("数据库中没有该广告的广告素材！");}
       else{
    var dot=/\./g;
    var dotlocation = location.match(dot).lastIndex;
    var type=location.substring(dotlocation,location.length);
    type=type.toLowerCase();
    if (type=="jpg"|type=="gif"||type=="bmp"||type=="htm"||type=="html")
    popUpWindow3("/mtfk/pictureview.jsp?path="+location,'20','20','500','500','广告素材');
    else{
         if(type=="swf")
         popUpWindow3(location,'20','20','500','500','广告素材');
         else
         popUpWindow2(location,'20','20','440','410','广告素材');
        }
       }
}

function analyseview(server, filepath)
{
    var path=filepath;
    var filepath=server+filepath;
    if(path==""||path=="null"){
       alert("数据库中没有该广告素材的分析结果！");
    }
    else{
         var dot=/\./g;
         if(filepath.match(dot)!=null)
         {
          var dotlocation = filepath.match(dot).lastIndex;
          var directory=filepath.substring(0,dotlocation-1);
          popUpWindow4(directory,'20','20','500','500','分析结果');
         }
         else
         {
          alert("未知的文件类型,无法查看分析结果!");
          return;
         }
    }
}

//控制页面的只读属性，zlm add
function disableInput(){
    array = document.getElementsByTagName('INPUT');
    for (i=0;i<array.length;i++){
        if(array[i].type == "text"){//将所有的input框设置为disabled
            array[i].readOnly = true;
        }
    }
}

function disableButtonAj(){
    array = document.getElementsByTagName('INPUT');
    for (i=0;i<array.length;i++){//将所有submit按钮以及“确认”“批准”按钮隐藏
    if(array[i].type == "submit" || (array[i].type == "button" && (array[i].value != "关闭" || array[i].value != "打印"))){
            array[i].style.display = "none";
        }
    }
}

function disableButtonGg(){
    array = document.getElementsByTagName('INPUT');
    for (i=0;i<array.length;i++){//将所有submit按钮以及“确认”“批准”按钮隐藏
    if(array[i].type == "submit"){
            array[i].style.display = "none";
        }
    }
}

function disableSelect(){
    array = document.getElementsByTagName('SELECT');//将所有的select设置为disabled
    for (i=0;i<array.length;i++){
        	array[i].disabled = true;
    }
}

function disableTextarea(){
    array = document.getElementsByTagName('TEXTAREA');//将所有的textarea框设置为disabled
    for (i=0;i<array.length;i++){
        	array[i].readOnly = true;
    }
}

function disablepage(){//使页面为只读,案件部分使用
    disableInput();
    disableButtonAj();
    disableSelect();
    disableTextarea();
}

function disablepageGg(){//使页面为只读，查看广告详细信息
    disableInput();
    disableSelect();
    disableTextarea();
    disableButtonGg();
}
//控制页面的只读属性___end，zlm add

//为select添加option，写在onload()或onclick()之类的触发函数中。参数：显示的文本、值、select框的名字
function addOptions(text,value,select_obj,isselected){
  if(!document.all[select_obj]){
      return;
  }
  var the_option= new Option(text,value);
  document.all[select_obj].add(the_option);
  //alert(document.all[select_obj].length);
  if(isselected=="selected"){
  	document.all[select_obj].selectedIndex=document.all[select_obj].length-1;
  }
}

function addOptionForId(selobjid,text,value,selected){
    var selobj=document.getElementById(selobjid);
  if(!selobj){
      return;
  }
  var the_option= new Option(text,value);
  try{selobj.add(the_option,null);}catch(exception){selobj.add(the_option);}//IE\FF兼容
  //alert(document.all[select_obj].length);
  if(selected=="selected"){
  	selobj.selectedIndex=selobj.length-1;
  }
}
/**
* sortSelect:对SELECT框进行中文拼音排序，可选升/降序（sortorder）、
* 默认值（defaultvalue）、对value排列还是对text排列（sorttype），需要同时引入GB2312的文件
* 参数依次为：
* 目标select对象，升/降序(asc/desc)，上一级的值(前缀)，默认项的匹配字符串，默认匹配字符值类型(code/text)，默认值匹配方式(end/full)，末尾项的匹配字符串，末尾匹配字符值类型(code/text)，末尾值匹配方式(end/full)，排序方式(code/text)
* sortSelect(document.getElementById('tssplb_2'),'asc',this.value,'00','code','end','99','code','end','text');//完全匹配的默认值full，以默认值结束end
* doLoad('BM_TSSPLB','3',null,'tssplb_3','tssplb_4','tssplb_2','4');//级联菜单中需要对目标select重新执行doLoad方法，以同步下一级select
* @param s1 oSel Object 目标select对象
* @param sortorder String 升/降序(asc/desc)
* @param parentValue String 上一级的值(前缀)，可以为空
* @param defaultvalue String 默认项的匹配字符串，留空表示不用设置默认项
* @param defaultvaluetype String 默认匹配字符值类型(code/text)，按照select的文本或value值取默认项
* @param matchtype String 默认值匹配方式(end/full)，end表示选中以defaultvalue结尾的项，full表示选中完全匹配defaultvalue的项
* @param lastvalue String 末尾项的匹配字符串，留空表示不用设置末尾项
* @param lastvaluetype String 末尾匹配字符值类型(code/text)，按照select的文本或value值取末尾项
* @param lastmatchtype String 末尾值匹配方式(end/full)，end表示选中以defaultvalue结尾的项，full表示选中完全匹配defaultvalue的项
* @param sorttype String 排序方式(code/text)：根据select的value值或文本值排序
* @return
* @author Linh
* */
function sortSelect(oSel,sortorder,parentValue,defaultvalue,defaultvaluetype,matchtype,lastvalue,lastvaluetype,lastmatchtype,sorttype){
    var ln = oSel.options.length;//select框的选项数
    defaultvalue=parentValue.toString()+defaultvalue.toString();//组合的默认值
    lastvalue=parentValue.toString()+lastvalue.toString();//组合的最后值
    var arr = new Array(); //保存排序的值，如value
    var arrV = new Array(); //保存不排序的值，与arr对应，如text
    var arrS = new Array(); //保存arr排序后的数组
    var arrVS = new Array(); //保存arrV排序后的数组
    var arrT = new Array(); //临时数组
    var defaultV="";//默认值
    var defaultT="";//默认文本
    var lastV="";//最后值
    var lastT="";//最后的文本

    // 将select中的所有option的sorttype值将保存在Array中，非sorttype值将保存在arrV中
    var isDefaultValue=false;
    var defaultValueGetted=false;
    var isLastValue=false;
    var lastValueGetted=false;
    for (var i = 0,j=0; i < ln; i++){
        isDefaultValue=false;
        isLastValue=false;

        //文本排序
        if(sorttype=="text"){
            //检测是否为默认值
            if(!defaultValueGetted && defaultvalue!=""){
                if(defaultvaluetype=="code"){//根据value取默认值
                    if(matchtype=="end"){//包含在末尾
                        if(oSel.options[i].value.indexOf(defaultvalue)==(oSel.options[i].value.length-defaultvalue.length)){
                            isDefaultValue=true;
                            defaultValueGetted=true;
                        }
                    }else{//完全匹配
                        if(oSel.options[i].value==defaultvalue){
                            isDefaultValue=true;
                            defaultValueGetted=true;
                        }
                    }
                }else{//根据文本取默认值
                    if(matchtype=="end"){//包含
                        if(oSel.options[i].text.indexOf(defaultvalue)==(oSel.options[i].value.length-defaultvalue.length)){
                            isDefaultValue=true;
                            defaultValueGetted=true;
                        }
                    }else{//完全匹配
                        if(oSel.options[i].text==defaultvalue){
                            isDefaultValue=true;
                            defaultValueGetted=true;
                        }
                    }
                }
            }

            //检测是否为最后
            if(!lastValueGetted && lastvalue!=""){
                if(lastvaluetype=="code"){//根据value取默认值
                    if(lastmatchtype=="end"){//包含
                        if(oSel.options[i].value.indexOf(lastvalue)==(oSel.options[i].value.length-lastvalue.length)){
                            isLastValue=true;
                            lastValueGetted=true;
                        }
                    }else{//完全匹配
                        if(oSel.options[i].value==lastvalue){
                            isLastValue=true;
                            lastValueGetted=true;
                        }
                    }
                }else{//根据文本取默认值
                    if(lastmatchtype=="end"){//包含
                        if(oSel.options[i].text.indexOf(lastvalue)==(oSel.options[i].value.length-lastvalue.length)){
                            isLastValue=true;
                            lastValueGetted=true;
                        }
                    }else{//完全匹配
                        if(oSel.options[i].text==lastvalue){
                            isLastValue=true;
                            lastValueGetted=true;
                        }
                    }
                }
            }

            if(!isDefaultValue && !isLastValue){//将select内容存入数组
                arr[j] = oSel.options[i].text;
                arrT[j] = oSel.options[i].text;
                arrV[j] = oSel.options[i].value;
                j++;
            }else if(isDefaultValue){//将第一个找到的default值单独存储
                defaultV=oSel.options[i].value;
                defaultT=oSel.options[i].text;
            }else{//将第一个找到的last值单独存储
                lastV=oSel.options[i].value;
                lastT=oSel.options[i].text;
            }
        }else{//值排序
            //检测是否为默认值
            if(!defaultValueGetted && defaultvalue!=""){
                if(defaultvaluetype=="text"){//根据文本取默认值
                    if(matchtype=="end"){//包含
                        if(oSel.options[i].text.indexOf(defaultvalue)==(oSel.options[i].value.length-defaultvalue.length)){
                            isDefaultValue=true;
                            defaultValueGetted=true;
                        }
                    }else{//完全匹配
                        if(oSel.options[i].text==defaultvalue){
                            isDefaultValue=true;
                            defaultValueGetted=true;
                        }
                    }
                }else{//根据value取默认值
                    if(matchtype=="end"){//包含
                        if(oSel.options[i].value.indexOf(defaultvalue)==(oSel.options[i].value.length-defaultvalue.length)){
                            isDefaultValue=true;
                            defaultValueGetted=true;
                        }
                    }else{//完全匹配
                        if(oSel.options[i].value==defaultvalue){
                            isDefaultValue=true;
                            defaultValueGetted=true;
                        }
                    }
                }
            }

            //检测是否为最后
            if(!lastValueGetted && lastvalue!=""){
                if(lastvaluetype=="text"){//根据text取默认值
                    if(lastmatchtype=="end"){//包含
                        if(oSel.options[i].text.indexOf(lastvalue)==(oSel.options[i].value.length-lastvalue.length)){
                            isLastValue=true;
                            lastValueGetted=true;
                        }
                    }else{//完全匹配
                        if(oSel.options[i].text==lastvalue){
                            isLastValue=true;
                            lastValueGetted=true;
                        }
                    }
                }else{//根据文本取默认值
                    if(lastmatchtype=="end"){//包含
                        if(oSel.options[i].value.indexOf(lastvalue)==(oSel.options[i].value.length-lastvalue.length)){
                            isLastValue=true;
                            lastValueGetted=true;
                        }
                    }else{//完全匹配
                        if(oSel.options[i].value==lastvalue){
                            isLastValue=true;
                            lastValueGetted=true;
                        }
                    }
                }
            }

            if(!isDefaultValue && !isLastValue){//将select内容存入数组
                arr[j] = oSel.options[i].value;
                arrT[j] = oSel.options[i].value;
                arrV[j] = oSel.options[i].text;
                j++;
            }else if(isDefaultValue){//将第一个找到的default值单独存储
                defaultV=oSel.options[i].value;
                defaultT=oSel.options[i].text;
            }else{//将第一个找到的default值单独存储
                lastV=oSel.options[i].value;
                lastT=oSel.options[i].text;
            }
        }
    }
//    arrT=arr;

    //排序
    if(sortorder=="desc"){
    	arrS=arrT.sort(spellSortDesc); }
    else{
    	arrS=arrT.sort(spellSort); }
//    alert(arrS);
//    alert(arr);
    for (i = 0; i < arrS.length; i++){
        for (k = 0; k < arr.length; k++){
            if(arr[k]==arrS[i]){
                arrVS[i]=arrV[k];
            }
        }
    }

    // 清空Select中全部Option
    while (ln--){
        oSel.options[ln] = null;
    }
    // 将排序后的数组重新添加到Select中
    if(defaultValueGetted){
        oSel.add (new Option(defaultT, defaultV));
//        if(sorttype=="text"){
//        }else{
//            oSel.add (new Option(defaultV, defaultvalue));
//        }
    }
    for (i = 0; i < arrS.length; i++){
        if(sorttype=="text"){
            if(arrS[i]!="" && arrS[i]!=null)
            oSel.add (new Option(arrS[i], arrVS[i]));
        }else{
            if(arrS[i]!="" && arrS[i]!=null)
            oSel.add (new Option(arrVS[i], arrS[i]));
        }
    }
    if(lastValueGetted){
        oSel.add (new Option(lastT, lastV));
    }
}
//displaytag翻页页码记录处理
function chkDspTblIndex(flag,url){
    if(flag=="true"){
        window.location=url;
    }
}
function gotoDspPage(pageParam,pageNum,url){
    if(isNaN(pageNum)){
        alert("请输入数字！");
        return;
    }
    if(url.indexOf("?")>0){
        window.location=url+"&"+pageParam+"="+pageNum;
    }else{
        window.location=url+"?"+pageParam+"="+pageNum;
    }
}
function setDspPageSizeAndPageNum(pageParam,pageNum,url,pageSize){
    if(isNaN(pageNum)||isNaN(pageSize)){
        alert("请输入数字！");
        return;
    }
    url=replaceURLParamValue(url,"pageSize",pageSize);
    url=replaceURLParamValue(url,pageParam,pageNum);
    window.location=url;
}
function setDspPageSize(url,pageSize){
    if(isNaN(pageSize)){
        alert("请输入数字！");
        return;
    }
    window.location=replaceURLParamValue(url,"pageSize",pageSize);
}
//替换url中已有的参数的值；匹配所找到的第一个参数，如果没有，则附加
function replaceURLParamValue(url,pageParam,newValue){
    var newURL;
    if(url.indexOf("?")>0){
        if(url.indexOf(pageParam+"=")>url.indexOf("?")){
            var urlPart1=url.substring(0,url.indexOf(pageParam+"="));
            var urlPart2=url.substring(url.indexOf(pageParam+"="));
            urlPart2=urlPart2.substring(urlPart2.indexOf("&"));
            newURL=urlPart1+pageParam+"="+newValue+urlPart2;
        }else{
            newURL=url+"&"+pageParam+"="+newValue;
        }
    }else{
        newURL=url+"?"+pageParam+"="+newValue;
    }
    return newURL;
}
//从select生成多选框、单选框列表
function buildChkBoxesFromSelect(htmlarea,obj,name,exAtt,defaultValue){
	var opts=obj.options;
	var chkHtml="";
	for(i=0;i<opts.length;i++){
        chkHtml+="<input type=checkbox name="+name+" id=" +name+" value="+opts[i].value+" ";
        if(opts[i].selected==true || defaultValue.indexOf(opts[i].value)>=0){
            chkHtml+=" checked=true ";
        }
		chkHtml+=exAtt+"/>"+opts[i].text;
	}
	htmlarea.innerHTML=chkHtml;
}
function buildRadiosFromSelect(htmlarea,obj,name,exAtt,defaultValue){
	var opts=obj.options;
	var chkHtml="";
	for(i=0;i<opts.length;i++){
		chkHtml+="<input type=radio name="+name+" id=" +name+" value="+opts[i].value+" ";
        if(opts[i].selected==true || defaultValue.indexOf(opts[i].value)>=0){
            chkHtml+=" checked=true ";
        }
		chkHtml+=exAtt+"/>"+opts[i].text;
	}
	htmlarea.innerHTML=chkHtml;
}
