var currentpos,timer; 
function initialize(){timer=setInterval("scrollwindow()",16);} 
function sc(){clearInterval(timer);} 
function scrollwindow()
{ 
	currentpos=document.body.scrollTop; 
	window.scroll(0,++currentpos); 
	if (currentpos != document.body.scrollTop) 
	sc(); 
} 
document.onmousedown=sc 
document.ondblclick=initialize

function runCode()

{
  var code=event.srcElement.parentElement.children[0].value;
  var newwin=window.open('','','');
  newwin.opener = null;
  newwin.document.write(code);
  newwin.document.close();

}

function doComment(){
	var o=document.getElementById('PostComment');
	if(o.style.display=='none'){
		o.style.display='block';
		o.author.focus();
	}else
		o.style.display='none';
}
function fitSize(o){
	if(o.width>screen.width-333) {
		o.width=screen.width-333;
		//by janlay
		o.outerHTML="<a href="+o.src+" target=_blank><img src="+o.src+" width="+(screen.width-333)+" alt=单击查看完整图像 border=0></a>"
	}
}


function getCookie(Name) {
   var search = Name + "=";
   if(document.cookie.length > 0) {
      offset = document.cookie.indexOf(search);
      if(offset != -1) {
         offset += search.length;
         end = document.cookie.indexOf(";", offset);
         if(end == -1) end = document.cookie.length;
         return unescape(document.cookie.substring(offset, end));
      }
      else return('');
   }
   else return('');
}

function setCookie(name,value) {
   var today = new Date();
   var expires = new Date();
   expires.setTime(today.getTime() + 1000*60*60*24*365);
   document.cookie = name + "=" + escape(value) + ";path=/"+"; expires=" + expires.toGMTString();
}

function formatTime(time,format){
	var dt = new Date(time.toString());
	var arr=time.split(" ");
	var arrdate=arr[0].split("-");
	var arrtime=arr[1].split(":");

	var year=arrdate[0];
	var month=arrdate[1];
	var day=arrdate[2];
	var hour=arrtime[0];
	var minute=arrtime[1];
	var second=arrtime[2];

	var s=format.replace(/yyyy/i,year);
	s=s.replace(/yy/i,year.substr(2,2));
	s=s.replace(/mm/i,month<10?("0"+month):month);
	s=s.replace(/m/i,month);
	s=s.replace(/dd/i,day<10?("0"+day):day);
	s=s.replace(/d/i,day);
	s=s.replace(/hh/i,hour);
	s=s.replace(/nn/i,minute);
	//s=s.replace(/

	return s;
}

String.prototype.len=function()
{
var str=this;
return str.replace(/[^\x00-\xff]/g, "**").length
}

String.prototype.limit=function(n){
	var oText=this;
	var len=oText.length+oText.len;
	if(len>n){
		while(len>n){
			oText=oText.substring(0,oText.length-1);
			len=oText.length+oText.len;
		}
		oText+="...";
	}
	return oText;
}

function CheckOthers(form){
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if(e.type=='checkbox'){
			if (e.checked==false) e.checked = true;
			else e.checked = false;
		}
	}
}

function CheckAll(form){
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if(e.type=='checkbox') e.checked = true;
	}
}


//add
function doOption(o){
	if(o.autologin.checked){
		o.antiTimeout.checked=true;
		o.antiTimeout.disabled=true;
		document.all.antiTimeoutText.disabled=true;
	} else {
		o.antiTimeout.disabled=false;
		document.all.antiTimeoutText.disabled=false;
	}
}

function checkform(o){
	if(o.username.value.length<3 || o.password.value.length<3)
		{alert("请输入用户名和密码");return false;}
	o.Submit.disabled=true;
	o.Reg.disabled=true;
	return true;
}
function lostPw(o){
	o.Submit.disabled=true;
	o.Reg.disabled=true;
	o.Reg.disabled=true;
	o.Lost.disabled=true;
	if(o.username.value.length>3)
		top.location.href="/service/resetpassword.asp?action=step2&u="+o.username.value;
	else
		top.location.href="/service/resetpassword.asp";
}