/*
Version:	Joekoe CMS 3.0
*/

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

//浏览器类型变量
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
//论坛广告
var ads_txt_num=0;

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 form_value(strer)
{
  if (strer!="")
  {
    if (strer.indexOf(".")==-1) strer="all."+strer;
    return eval("document."+strer+".value;");
  }
}

function click_return(strvar,strt)
{
  var tmpvar='';
  switch (strt)
  {
    case 1:
      tmpvar='您确定要'+strvar+'吗？';
      break;
    case 5:
      tmpvar=strvar;
      break;
    default :
      tmpvar='您确定要'+strvar+'吗？\n\n执行该操作后将不可恢复！';
      break;
  }
  var tmptrue=window.confirm(tmpvar);
  if (tmptrue) { return true; }
  return false;
}

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

function disp(str1,str2,str3)
{
  return str1.replace(str2,str3);
}

function is_num(strer,strt,strv)
{
  var tmp_var="0123456789";
  if (strt==1) tmp_var="0123456789.";
  var tmp_value=new Array(1);
  if (strv=="" || strv==null)
  {
    tmp_value[0]=false;
    tmp_value[1]=true;
  }
  else
  {
    tmp_value[0]=0;
    tmp_value[1]=strer;
  }
  if (strer=="" || strer==null) return tmp_value[0];
  for (var i=0;i<strer.length;i++)
  {
    if (tmp_var.indexOf(strer.charAt(i))==-1) return tmp_value[0];
  }
  return tmp_value[1];
}

function rnd_num(strnum)
{
  var dd=new Date();
  var ms=dd.getMilliseconds();
  if (ms<1) ms=1;
  for(i=1;i<3;i++)
  {
    if (ms<=strnum) break;
    ms=Math.floor(ms/2);
    i-=1;
  }
  return(ms);
}

// onKeyPress="event.returnValue=on_int(0);"
function on_int(strer)
{
  var knum=event.keyCode;
  var ktrue=false;
  if (knum >= 48 && knum <= 57) { ktrue=true; }
  if (strer==1)
  {
    if (!ktrue && knum==46) { ktrue=true; }
  }
  return ktrue;
}

function insert_value(strinput,strvalue)
{
  var tmpstr="";
  strvalue=disp(strvalue,"'","\\'");
  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 frm_oncesubmit(strobj)
{
  if (strobj._sbt) strobj._sbt.disabled=true;
  if (strobj._rst) strobj._rst.disabled=true;
}

function pagecute_go(strtxt,strnum,strpage)
{
  if (strtxt=="" || strtxt==null) strtxt="page_url";
  if (strnum=="" || strnum==null) strnum="page_num";
  if (strpage=="" || strpage==null) strpage="{$page}";
  var tmpurl=form_value(strtxt);
  var tmppage=form_value(strnum);
  tmpurl=disp(tmpurl,strpage,tmppage);
  document.location.href=tmpurl;
}

function get_now_time()
{
  var d_time=new Date();
  var week_dim=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
  //var week_dim=week_dim.concat("星期三","星期四","星期五");
  var temp1="今天是：";
  temp1+=d_time.getYear()+"年";
  temp1+=(d_time.getMonth() + 1) + "月";
  temp1+=d_time.getDate() + "日&nbsp;";
  temp1+=week_dim[d_time.getDay()]
  temp1+="&nbsp;&nbsp;";
  return temp1;
}

function login_true()
{
  if (document.frm_login.username.value=="") { alert("请输入您在本站注册时的 用户名称 ！"); document.frm_login.username.focus(); return false; }
  if (document.frm_login.password.value=="") { alert("请输入您在本站注册时的 登陆密码 ！"); document.frm_login.password.focus(); return false; }
}

function ads_txt_type()
{
  if (ads_txt_num<1)
  { return("<font class=gray>[<font class=red>广告</font>]</font>&nbsp;这里是广告内容，可以在后台广告管理设置！"); }
  var na=rnd_num(ads_txt_num);
  return(ads_txt_dim[na]);
}

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];}
}

