﻿/*
*Just Often Using JS Function
*Powered By Edison TSai
*Create:2006-09-14@9:32:06
*Modify:2006-11-04@9:07:33
*/
var sPop = null;
/*Select Object of the Select Menu*/
function SelectMe(names,objSelect){
  var lenme; lenme = document.getElementById(names).length;
  for(i=0;i<lenme;i++){
    if(document.getElementById(names).options[i].value == objSelect){

	       document.getElementById(names).options[i].selected = true;
		   break;
	}
  }
}
//Check All Object of the CheckBox Menu
function CheckAll(form) 
  { 
  for (var i=0;i<form.elements.length;i++) 
    { 
    var e = form.elements[i]; 
    if (e.name != 'CheckAllBox') 
       e.checked = form.CheckAllBox.checked; 
    } 
  } 

//check all table or uncheck talbe first cloumn's checkbox
function CheckAll(obj,tablename){    
    var o=$(tablename);
    if(o){
      for(var i=1;i<o.rows.length;i++){
         o.rows[i].cells[0].firstChild.checked= obj.checked;                            
       }
    }
}

function IsCheck(tablename){
    var o=$(tablename);
    if(o){
     for(var i=1;i<o.rows.length;i++){
       if(o.rows[i].cells[0].firstChild.checked){
            return true;
       }
     }
    }
    return false;
}

function Delete(tablename){
 var msg;
 var ret=false;
 if(IsCheck(tablename)){
  msg ='确定要删除所选的数据记录?数据删除后不可恢复。';                        
  ret = confirm(msg);
  if(ret){
    DNSingProcesser('0','60','40','0','0','0','0');
  }
 }
 else{
    msg ='请选择所要操作的数据记录。您未选任何数据,暂停当前操作!';
    TipBox(msg,5);
    ret=false; 
 }
 return ret;
}

function Stop(tablename){
 var msg;
 var ret=false;
 if(IsCheck(tablename)){
  msg ='确定要停用当前所选的帐号。';                        
  ret = confirm(msg);
  if(ret){
   DNSingProcesser('正在停用帐号，请稍后...','60','40','0','0','0','0');
  }
 }
 else{
    msg ='请选择所要操作的数据记录。您未选任何数据,暂停当前操作!';
    TipBox(msg,5);
    ret=false; 
 }
 return ret;
}

function AddMoney(tablename){
 var msg;
 var ret=false;
 if(IsCheck(tablename)){
  msg ='确定要为当前所选的帐号冲值?冲值后不更';                        
  ret = confirm(msg);
  if(ret){
   DNSingProcesser('正在帐号冲值，请稍后...','60','40','0','0','0','0');
  }
 }
 else{
    msg ='请选择所要操作的数据记录。您未选任何数据,暂停当前操作!';
    TipBox(msg,5);
    ret=false; 
 }
 return ret;
}
/*
*Show Tips Function
*/

document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText { font-family: Tahoma, Verdana; background-color: #FFFFCC; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; line-height: 18px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=80)}");


document.write("</style>");
document.write("<div id='popLayer' style='position:absolute;z-index:1000' class='cPopText'></div>");

function showPopupText(event) {
	if(event.srcElement) o = event.srcElement; else o = event.target;
	MouseX=event.clientX;
	MouseY=event.clientY;
	if(o.alt!=null && o.alt!="") { o.pop=o.alt;o.alt="" }
	if(o.title!=null && o.title!=""){ o.pop=o.title;o.title="" }
	if(o.pop!=sPop) {
		sPop=o.pop;
		if(sPop==null || sPop=="") {
			document.getElementById("popLayer").style.visibility="hidden";        
		} else {
			if(o.dyclass!=null) popStyle=o.dyclass; else popStyle="cPopText";
			document.getElementById("popLayer").style.visibility="visible";
			showIt();
		}
	}
}

function showIt() {
	document.getElementById("popLayer").className=popStyle;
	document.getElementById("popLayer").innerHTML=sPop.replace(/<(.*)>/g,"&lt;$1&gt;").replace(/\n/g,"<br>");;
	popWidth=document.getElementById("popLayer").clientWidth;
	popHeight=document.getElementById("popLayer").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;
	document.getElementById("popLayer").style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
	document.getElementById("popLayer").style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
}

function TipBox(msg,times) {
	  //need id or name : TipBoxer
	  //times:< 1 Forever Time,> 1 Just 1
	  //Wrote at 06-09-14 11:00:58
	  //Work at XHTML
	   var msg;
	   var times;
	   var myTips;
	   myTips = document.getElementById("TipBoxer");
	   myTips.style.display = '';
	   myTips.style.visibility = '';
	   //myTips.innerHTML = '<div id=\"TipBox\" style=\"padding:3px;background-color:#ffffe7;border:1px solid #999;text-align:left;color:#666;\"><span style=\"display:inline;width:88%;\">'+msg+'</span><span style=\"display:inline;width:10%;cursor:pointer;vertical-align:top;text-align:right;\"><img src=\"../images/imgClose.gif\" alt=\"关闭\" title=\"关闭\" onclick=\"HideTipBox()\" /></span></div>';
      // myTips.innerHTML = '<div id=\"TipBox\" ><span class=\"msg\">'+msg+'</span><span class=\"cls\"><img src=\"../images/imgClose.gif\" alt=\"关闭\" title=\"关闭\" onclick=\"HideTipBox()\" /></span></div>';
       myTips.innerHTML='<div id=\"TipBox\"><div class=\"msg\">'+msg+'</div><div class=\"cls\"><a onclick=\"javascript:HideTipBox();\" alt=\"关闭\" title="\关闭\" style=\"cursor:hand\"></a></div></div>';
    
	   times < '1' ? '' :window.setTimeout(HideTipBox,times*1000);

	  }
	  function HideTipBox() {
	  document.getElementById("TipBoxer").style.display = 'none';
	  document.getElementById("TipBoxer").style.visibility = 'hidden';
	  }
//Find Ojbect
function findObj(objname) 
{ 
  var obj = null; 
  if (document.getElementById) 
      obj = document.getElementById(objname); 
  else if (document.all) 
      obj = document.all[objname]; 
  return(obj); 
} 
//Catch All CheckBox
function CatchBox(d){
 var ids="";
 var d = document.all[d];
 var dlength = d.length;
  
  if(!dlength) {
  ids = d.value;
 } else {
  for(i=0;i<dlength;i++)
 {
	if(d[i].checked==true) ids=ids+d[i].value+",";
 }

 }

 return ids;
 }
function RefreshWin(itime){
 //itime 刷新的时间,必须是整型阿拉伯数
 var itime = itime+'000';

 window.setInterval('window.location.reload()',itime);
 window.clearInterval();
}
//Post Processer
function DNSingProcesser(msg,settop,setleft,setwidths,setheights,setload,isClose)
{

	/*
	*DNSing Processer v 1.5
	*Powered By Edison TSai in DNSing Network at 2006-11-01@10:26:25
	*msg     = 显示的内容,为0就默认显示
	*settop  = 设置与浏览器的顶部的间距,为0时就自动分配
	*setleft = 设置与浏览器左侧的间距,为0时就自动分配
	*setwidth= 设置DIV的宽度,为0时就自动分配
	*setheight = 设置DIV的高度,为0时就自动分配
	*setload = 设置为1时显示Processing图标
	*isClose = 设置为1时显示关闭按钮，否则无显示
	*/
        document.body.style.cursor='wait';
        
	if(document.getElementById("bgdiv")){
	   document.body.removeChild(document.getElementById("bgdiv"));
	}
		var bgdiv = document.createElement("div");
        var msg,settop,setleft,setload,isClose;
        msg = msg == '0' ? '<span class=\"loading\"></span>正在提交数据，请稍候...' : msg;
		setload = setload == '1' ? "<img src=\"../images/progress.gif\" />" : '';
		isClose = isClose == '1' ? "<p align=\"right\"><img src=\"../images/dClose.gif\" border=\"0\" alt=\"点击这里关闭本窗口！\" onclick=\"window.location.reload()\" onmouseover=\"this.style.cursor='hand'\" /></p>" : '<br />';
		bgdiv.innerHTML = isClose+"<font color=\"#003399\">"+msg+"</font>&nbsp;"+setload;
		bgdiv.style.cursor = "default";
		bgdiv.style.background = "#EDF0F5";
		bgdiv.style.filter = "alpha(Opacity=100)";
		bgdiv.style.width = setwidths != '0' ? setwidths : 250;
		bgdiv.style.height = setheights != '0' ? setheights : 100;
		bgdiv.style.border = "2px solid #99cc00";
		bgdiv.align = "center";
		bgdiv.setAttribute('name','bgdiv');
		bgdiv.id = "bgdiv";
		bgdiv.style.lineHeight = "30px";
		bgdiv.style.position = "absolute";
		bgdiv.style.top = settop != '0' ? settop : document.body.clientHeight/2-30;
		bgdiv.style.left = setleft != '0' ? setleft : document.body.clientWidth/2-100;
		bgdiv.style.zIndex = 101;
		bgdiv.style.overflow = "hidden";
		document.body.appendChild(bgdiv);


	if(document.getElementById("vdiv")){
	document.body.removeChild(document.getElementById("vdiv"));
	}
		var vdiv = document.createElement("div");
		var w, h;
		with(document.body){
			if (scrollWidth<clientWidth){
				w = clientWidth;
				
			}else{
				w = scrollWidth; 
				
			}
			if (scrollHeight<clientHeight){
				h = clientHeight;
			}else{
				h = scrollHeight;
			}
		}
		
		vdiv.style.background = "black";
		vdiv.style.filter = "alpha(Opacity=35)";
		vdiv.style.position = "absolute";
		vdiv.style.top = "0";
		vdiv.style.left = "0";
		vdiv.setAttribute('name','vdiv');
		vdiv.id   = "vdiv";
		vdiv.style.width = w+20;        //修改
		vdiv.style.height = h+20;
		vdiv.style.zIndex = 100;
		document.body.appendChild(vdiv);
		
		vdiv.focus();

		var sels = document.getElementsByTagName("SELECT");
		for(var i=0; i<sels.length; i++){
			sels[i].style.visibility = "hidden";
		}


}
 function showa(n){
	 var n = n;
	 if (n !='')
	 {
		 findObj(n).style.display = '';
		 findObj(n).style.visibility = '';
	 } else {
	 alert('名称不能为空!');
		 }
 
 }
 function showwin(url,setT,setL,setW,setH){
var url = url;
var setT = isNaN(setT) ? '1' : setT;
var setL = isNaN(setL) ? '50' : setL;
var setH = isNaN(setH) ? '600' : setH;
var setW = isNaN(setW) ? '780' : setW; 
window.open(url,'Dwin','height='+setH+',width='+setW+',top='+setT+',left='+setL+',toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no');
}
if(!document.onmouseover) {
	document.onmouseover = function(e) {
		if (!e) showPopupText(window.event); else showPopupText(e);
	};
}


window.onerror = function(){
//alert('抱歉！系统发生了一些异常，暂时不能执行您所请求的事件！\n\n\r请刷新一下本页！\n\n\r原因：可能您的浏览器版本较低或者禁止了执行脚本程序！\n\n\r请把情况告诉管理员，谢谢您的合作！');
return true;
}

//----END Show Tips Function



function err_msg(msg){
	return "&nbsp;<img src='images/note_error.gif' border='0'/> <span class='redfont'>"+msg+"</span>";
}
//成功提示信息
function suc_msg(msg){	
	return "&nbsp;<img src='images/note_ok.gif' border='0'/> <span class='bluefont'>"+msg+"</span>";
}
