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 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)';
            document.getElementById(menuitems[i]).className='td_on';
        else
//            document.getElementById(menuitems[i]).style.backgroundImage= '';
document.getElementById(menuitems[i]).className='td_out';
    }
}

//用于变换多个区域内容的显示
//用于一个按钮控制显示/隐藏
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';
    }
}
function changeTab7(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) {
   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";}
}

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==listchk){
        	if(chkv==true || chkv=="checked"){
                	sels[i].checked=true;
        	}
        	else{
                	sels[i].checked=false;
        	}
        }
    }
}

//控制页面的只读属性，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;
        }else if(array[i].type == "radio"){
            array[i].disabled = true;
        }else if(array[i].type == "checkbox"){
            array[i].disabled = 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;
  }
}
