
function admin_resize(tnum,tname)
{
  var obj=document.getElementById(tname);
  if (parseInt(obj.rows)+tnum>=3) { obj.rows = parseInt(obj.rows) + tnum; }
  if (tnum>0) { obj.width="90%"; }
}

function find_copy(n, d)
{
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[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers.document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function YSvoid_copy(ob,nb)
{
  var obj=find_copy(ob);
  if (obj)
  {
    obj.select();
    js=obj.createTextRange();
    if (nb==1) js.execCommand("Copy");
  }
}
window.onerror=function(a,b,c){return true;}

function runscript(n){
	txtRun=n;
	open_win("../Editor/Skin_Html_Edit.asp?style=htmledit","html_edit",580,380,"no");
}

function doChange(objText, objDrop){
	if (!objDrop) return;
	var str = objText.value;
	var arr = str.split("|");
	var d = objDrop.length;
	var j = arr.length;
	j-=1;
	objDrop.options[d] = new Option(arr[j], arr[j]);
}

function PostUrl(strfrm,objname,objname2)
{
	var tmpobj=eval("document."+strfrm+"."+objname);
	var tmpobj2=eval("document."+strfrm+"."+objname2);
  for(var i=0;i<tmpobj.length;i++)
  {
    if (tmpobj2.value=='') 
    {
      tmpobj2.value=tmpobj.options[i].value;
    }
    else 
    {	
      tmpobj2.value+='@@@'+tmpobj.options[i].value;
    }
  }
}

function AddUrl(cname,objname){
  var obj=document.getElementById(objname);
  var thisurl=cname+(obj.length+1)+'|http://'; 
  var url=prompt('请输入'+cname+'和链接，中间用“|”隔开：',thisurl);
  if(url!=null&&url!=''){obj.options[obj.length]=new Option(url,url);}
}

function ModifyUrl(cname,objname){
  var obj=document.getElementById(objname);
  if(obj.length==0) return false;
  var thisurl=obj.value; 
  if (thisurl=='') {alert('请先选择一个'+cname+'，再点修改按钮！');return false;}
  var url=prompt('请输入'+cname+'和链接，中间用“|”隔开：',thisurl);
  if(url!=thisurl&&url!=null&&url!=''){obj.options[obj.selectedIndex]=new Option(url,url);}
}

function DelUrl(cname,objname){
  var obj=document.getElementById(objname);
  if(obj.length==0) return false;
  var thisurl=obj.value; 
  if (thisurl=='') {alert('请先选择一个'+cname+'，再点删除按钮！');return false;}
  if(obj.selectedIndex==0){alert('不能删除第一个'+cname+'！');return false;}
  obj.options[obj.selectedIndex]=null;
}

function UpUrl(cname,objname) {
	var obj=document.getElementById(objname);
	var nIndex = obj.selectedIndex;
	var nLen = obj.length;
	if ((nLen<1)||(nIndex==0)) return;
	if (nIndex<0) {
		alert("请选择一个要移动的"+cname+"！");
		return;
	}
	var sValue=obj.options[nIndex].value;
	var sValue2=obj.options[nIndex-1].value;
	//var sHTML=obj.options[nIndex].innerHTML;
	obj.options[nIndex]=new Option(sValue2,sValue2);
	obj.options[nIndex-1]=new Option(sValue,sValue);
	obj.selectedIndex=nIndex-1;
}

function DownUrl(cname,objname) {
	var obj=document.getElementById(objname);
	var nIndex = obj.selectedIndex;
	var nLen = obj.length;
	if ((nLen<1)||(nIndex==nLen-1)) return;
	if (nIndex<0) {
		alert("请选择一个要移动的"+cname+"！");
		return;
	}
	var sValue=obj.options[nIndex].value;
	var sValue2=obj.options[nIndex+1].value;
	obj.options[nIndex]=new Option(sValue2,sValue2);
	obj.options[nIndex+1]=new Option(sValue,sValue);
	obj.selectedIndex=nIndex+1;
}

function SelectFiles(sChannelID,type,objname,objname2)
{
  var arr=window.showModalDialog('Admins_UploadFiles.asp?FileType=select', '', 'dialogWidth:750px;dialogHeight:450px;help:no;scroll:yes;status:no;directories:yes;scrollbars:no;Resizable=no;');
	if(arr!=null)
	{
		var obj = document.getElementById(objname);
		var strT=arr.split('|');
		if (type=='1'){
			var url='下载地址'+(obj.length+1)+'|'+strT[0];
			obj.options[obj.length]=new Option(url,url);
		}
		else if (type=='2'){
			var url='图片名称'+(obj.length+1)+'|'+strT[0];
			obj.options[obj.length]=new Option(url,url);
		}
		else {
			obj.value=strT[0];
		}
		if (objname2!='') {document.getElementById(objname2).value=strT[1];}
	}
}

function SelectColor(tcstr)
{
  var c=window.showModalDialog("../Editor/Dialog/selcolor.htm","s","dialogWidth=300px;dialogHeight=270px;status=0");
  var d=c;
  if (c && c!="")
  {
    if (d.length==7) { d=d.substr(1,d.length); }
    eval("window.document.all."+tcstr+".value=d;window.document.all."+tcstr+".style.backgroundColor=c;");
  }
}
function ClearColor(tcstr)
{
  eval("window.document.all."+tcstr+".value='';window.document.all."+tcstr+".style.backgroundColor='';");
}

function slect_color(tcstr)
{
  var c=window.showModalDialog("/htmledit/Dialog/selcolor.htm","s","dialogWidth=300px;dialogHeight=270px;status=0");
  var d=c;
  if (c && c!="")
  {
    if (d.length==7) { d=d.substr(1,d.length); }
    eval("window.document.all."+tcstr+".value=d;");
  }
}

//<input type=test name=tim value='2003-5-19' size=12 maxlength=10 readonly>
//<input type=button name=st_btn value="选择" onclick="javascript:select_time(tim);return false;">

function select_time(st_obj)
{
  var showx=event.screenX-event.offsetX-14;
  var showy=event.screenY-event.offsetY-168;
  var retval=window.showModalDialog("../Admin/Include/Admin_Select_Data.asp?"+st_obj.value,"","dialogWidth:197px; dialogHeight:210px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no;");
  if( retval!=null ) { st_obj.value=retval; }
  //else { }
}

function sel_type(trsurl,turl)
{
	var sn,i,wdim,temp1,nurl;
	wdim=turl.split("|");
	sn=wdim.length;
	for (i=0;i<sn;i++)
	{
	nurl=wdim[i];
		temp1="<OPTION value='"+nurl+"'";
		if (trsurl==nurl) { temp1+=" selected"; }
		temp1+=">"+nurl+"</option>";
	document.write(temp1);
	}
}

function re_load() { location.reload(); }

function click_return(cvar,ct)
{
  var nvar='';
  switch (ct)
  {
    case 1:
      nvar='提示信息！';
    default :
      nvar='您确定要'+cvar+'吗？\n\n执行该操作后将不可恢复！';
  }
  var cf=window.confirm(nvar);
  if (cf) { return true; }
  return false;
}

function open_win(url,name,width,height,scroll)
{
  var Left_size = (screen.width) ? (screen.width-width)/2 : 0;
  var Top_size = (screen.height) ? (screen.height-height)/2 : 0;
  var open_win=window.open(url,name,'width=' + width + ',height=' + height + ',left=' + Left_size + ',top=' + Top_size + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scroll + ',resizable=no' );
}

function YSvoid_int(itp)
{
  var knum=event.keyCode;
  var ktrue=false;
  if (knum >= 48 && knum <= 57) { ktrue=true; }
  if (itp==1)
  {
    if (!ktrue && knum==46) { ktrue=true; }
  }
  return ktrue;
}

function frm_submitonce(theform)
{
  if (document.all||document.getElementById)
  {
    for (var i=0;i<theform.length;i++)
    {
      var tempobj=theform.elements[i]
      if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") { tempobj.disabled=true; }
    }
  }
}

function frm_quicksubmit(eventobject) { if (event.keyCode==13 && event.ctrlKey) write_frm.submit(); }

//*****************选择框 开始******************
function select_all(frm)
{
  var slength=0;
  if (frm.sel_id==null) { return false; }
  var sall=frm.sel_all.checked;
  if (frm.sel_id.length)
  {
    slength=frm.sel_id.length;
    for (var i=0;i<slength;i++) { frm.sel_id[i].checked=sall; }
  }
  else { frm.sel_id.checked=sall; }
}

function sel_click(frm)
{
  var slength=0;
  var issel=false;
  if (frm.sel_id!=null)
  {
    if (frm.sel_id.length)
    {
      slength=frm.sel_id.length;
      for (var i=0;i<slength;i++) { if (frm.sel_id[i].checked==true) { issel=true; break; } }
    }
    else { if (frm.sel_id.checked==true) { issel=true; } }
  }
  if (issel==true)
  {
    if (confirm("执行此操作后可能无法恢复！你确定吗？")) { return true; }
    else { return false; }
  }
  else { alert("没有选择任何记录！"); return false; }
}
//*****************选择框 结束******************

//window.onerror=function(a,b,c){return true;}

//浏览器类型变量
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

var client_browse="";
if (document.getElementById)	// IE5+,NN6+	document.getElementById("id");
{ client_browse="ie5"; }
else if (document.all)		// IE4		document.all("id");
{ client_browse="ie4"; }
else if (document.layers)	// NN4		document.layers["id"];
{ client_browse="ns4"; }

function get_id(strname)
{
  switch (client_browse)
  {
    case "ie5":
      return document.getElementById(strname);
      break;
    case "ns4":
      return document.layers[strname];
      break;
    default :	//"ie4"
      return document.all(strname);
      break;
  }
}

function insert_value(strinput,strvalue)
{
  var tmpstr="";
  switch (client_browse)
  {
    case "ie5":
      tmpstr="document.all."+strinput+".value='"+strvalue+"';";
      break;
    case "ns4":
      tmpstr="document.layers.[\""+strinput+"\"].value='"+strvalue+"';";
      break;
    default :	//"ie4"
      tmpstr="document.all."+strinput+".value='"+strvalue+"';";
      break;
  }
  if (tmpstr!="") eval(tmpstr);
}

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_findObj(n, d) { //v3.0
  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); return x;
}

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];}
}
//提示框
//***********默认设置定义.*********************
var tPopWait=300;    //停留tWait豪秒后显示提示。
var tPopShow=10000;    //显示tShow豪秒后关闭提示
var showPopStep=20;
var popOpacity=95;
var tfontcolor="#000000";
var tbgcolor="#ffffff";
var tbordercolor="#808080";

//***************内部变量定义*****************
var sPop=null,curShow=null,tFadeOut=null,tFadeIn=null,tFadeWaiting=null;

document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText {  background-color: " + tbgcolor + ";color:" + tfontcolor + "; border: 1px " + tbordercolor + " solid;font-color: font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}");
document.write("</style>");
document.write("<div id='dypopLayer' style='position:absolute;z-index:1000;' class='cPopText'></div>");

function showPopupText()
{
  var o=event.srcElement;
  MouseX=event.x;
  MouseY=event.y;
  if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
  if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
  if(o.dypop!=sPop)
  {
    sPop=o.dypop;
    clearTimeout(curShow);
    clearTimeout(tFadeOut);
    clearTimeout(tFadeIn);
    clearTimeout(tFadeWaiting);  
    if(sPop==null || sPop=="")
    {
      dypopLayer.innerHTML="";
      dypopLayer.style.filter="Alpha()";
      dypopLayer.filters.Alpha.opacity=0;  
    }
    else
    {
      if(o.dyclass!=null) popStyle=o.dyclass 
      else popStyle="cPopText";
      curShow=setTimeout("showIt()",tPopWait);
    }
  }
}

function showIt()
{
  dypopLayer.className=popStyle;
  dypopLayer.innerHTML=sPop;
  popWidth=dypopLayer.clientWidth;
  popHeight=dypopLayer.clientHeight;
  if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
    else popLeftAdjust=0;
  if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
    else popTopAdjust=0;
  dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
  dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
  dypopLayer.style.filter="Alpha(Opacity=0)";
  fadeOut();
}

function fadeOut(){
  if(dypopLayer.filters.Alpha.opacity<popOpacity)
  {
    dypopLayer.filters.Alpha.opacity+=showPopStep;
    tFadeOut=setTimeout("fadeOut()",1);
  }
  else
  {
    dypopLayer.filters.Alpha.opacity=popOpacity;
    tFadeWaiting=setTimeout("fadeIn()",tPopShow);
  }
}

function fadeIn()
{
  if(dypopLayer.filters.Alpha.opacity>0)
  {
    dypopLayer.filters.Alpha.opacity-=1;
    tFadeIn=setTimeout("fadeIn()",1);
  }
}

document.onmouseover=showPopupText;