// JavaScript Document
var scrollPos;
var mytimer=0;
var timemark=null;

function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}

function hiden(){
	clearInterval(timemark);
	var rb = $("RequestBody");
	rb.style.position = "absolute";
	rb.style.display = "none";
	$("mask").style.display= "none";
	if(textid!=undefined&&textid!=null)
	{
		textid.style.display='';
	}
	//document.location.reload(); 
}
function show(){
	var mask = $("mask");
	var textid=$("text");
	if(textid!=undefined&&textid!=null)
	{
		textid.style.display='none';
	}
	if(mask!=undefined)
	{
		
	mask.style.position = "absolute";
	mask.style.display = "";
	mask.style.width = document.body.scrollWidth+"px";
	mask.style.height = ((document.body.scrollHeight>document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight-5)+"px";
	////var gCat = $("Cat");
	//if(gCat!=undefined)
	//{
		//gCat.style.display="none";
	//	}
	//setInterval('MoveDiv()',10);
	timemark=setInterval('MoveDiv()',50);
	
	}
	else
	{
		
	}
}
function MoveDiv()
{
	var rb = $("RequestBody");
	rb.style.display = "";
	rb.style.position = "absolute";
	if (typeof window.pageYOffset != 'undefined') { 
	   scrollPos = window.pageYOffset; 
	} 
	else if (typeof document.compatMode != 'undefined' && 
		 document.compatMode != 'BackCompat') { 
	   scrollPos = document.documentElement.scrollTop; 
	} 
	else if (typeof document.body != 'undefined') { 
	   scrollPos = document.body.scrollTop; 
	} 
	rb.style.left = (document.body.clientWidth-rb.offsetWidth)/2+document.body.scrollLeft +"px";
	rb.style.top =((rb.style.top.replace("px","")-0)+(150+scrollPos-rb.style.top.replace("px",""))/2)+"px"; 
	//(rb.style.top+(150+scrollPos-rb.style.top)/6)+"px";//(document.body.clientHeight-rb.offsetHeight)/2
	
	var mask = $("mask");
	mask.style.width = document.body.scrollWidth+"px";
	mask.style.height = ((document.body.scrollHeight>document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight-5)+"px";

}
function clearform(mform)
{
	//清空数据
	mform.Title.value="";
	mform.UserName.value="";
	mform.Text.value="";
	mform.ChkNum.value="";
	$("imgChkNum").src="Manage/Inc/scode.asp";
	EditClear();//引用自Editor.js
}
function autoClose()
{
//定时器
//用于定时关闭窗口
	if(mytimer>1)
	{
		mytimer=0;
		autoClose()
		hiden();
	}
	else
	{
		mytimer++;
		setTimeout("autoClose()",1000);	
	}
}

  function showResponse(originalRequest) 
  { 
  	var rtnstr;
//显示添加数据返回信息
//
   //put returned XML in the textarea 
   // $('SRtn').innerHTML = originalRequest.responseText; 
	var results =  originalRequest.responseText;
	
	rtnstr=results.split("|")
	if (rtnstr[0]=="false")
	{
		//$("rtnInfo").innerHTML=rtnstr[1];
	}
	else
  	{
		//$("usernameid").innerHTML=rtnstr[2];
		hiden();
		//$("outid").innerHTML='<table width="180" border="0" align="center" cellpadding="0" cellspacing="0"><tr valign="bottom"><td height="28" align="center" valign="middle"><a href="ToLogins.asp?q=quit" class="grey">LOGINOUT</a></td></tr></table>';
	}
	//autoClose();	 
  }
function ChkLogin(mform)
{
	$("rtnInfo").innerHTML="Login...";
	var username,pas,url,pars;
	url="Logins.asp";
	username=mform.UserName.value;
	pas=mform.PassWord.value;
	var nowdate=new Date();
	pars="UserName="+username+"&PassWord="+pas+"&nowdate"+nowdate;
	var myAjax = new Ajax.Request( 
     url, 
     {method: 'post', parameters: pars, onComplete: showResponse} 
     ); 
	return false;
}
