function input_onkeydown(e){
  var keycode=isIE?e.keyCode:e.which;
  var SendStr=false;
  if(TheKey==1 && keycode==13){
    SendStr=true;
  }else if(TheKey==2 && window.event.ctrlKey && keycode==13){
    SendStr=true;
  }
  if(SendStr){
    isIE ? e.returnValue=false : e.preventDefault();
    Send();
  }
}
function SendKey(id){
  if(id=='1'){
    $('#HotKey').html('回车键发送消息');
  }else{
    $('#HotKey').html('Ctrl+回车键发送消息');
  }
  TheKey=id;
  setcookie('sendkey',id);
}
SendKey(TheKey=='2'?'2':'1');

function PrintChat(str,cname,newid){
  var o=$('<div />').html(str);
  if(cname!='')o.addClass(cname);
  if(newid!='')o.attr('id',newid)
  o.appendTo($('#showbox'));
  ScrollControl();
}
function ScrollControl(){
  $('#showbox').scrollTop($('#showbox')[0].scrollHeight);
}
function Now(){
	date = new Date();
	H_=date.getHours().toString();
	i_=date.getMinutes().toString();
	s_=date.getSeconds().toString();
	if(i_.length==1)i_="0"+i_;
	if(s_.length==1)s_="0"+s_;
	return H_+":"+i_+":"+s_;
}
function Day(){
	var date = new Date();
	Y_=date.getYear().toString();
	m_=(date.getMonth()+1).toString();
	d_=(date.getDate()).toString();
	if(m_.length==1)m_="0"+m_;
	if(d_.length==1)d_="0"+d_;
	return Y_+"-"+m_+"-"+d_;
}
var ImgCount=0;
function ubbtohtml(fdata){
  fdata=fdata.replace(new RegExp('\\[:([^_]+)_([0-9]{1,3})\\]','g'),'<img src="images/smiley/$1/$2.gif">');
  fdata=fdata.replace(new RegExp('\\[url\\](www.|http:\/\/){1}([^\[\"\']+?)\\[\/url\\]','gi'),'<a href="$1$2" target="_blank">$1$2</a>');
  fdata=fdata.replace(new RegExp('\\[url=(www.|http:\/\/){1}([^\[\"\']+?)\\](.+?)\\[\/url\\]','gi'),'<a href="$1$2" target="_blank">$3</a>');
  fdata=fdata.replace(new RegExp('\\[P\\/([^\\/]+)\\/([^\\]]+)\\]','g'),'<img src="'+homepage+'/down.php?P/$1/$2" onload="resetImg(this)">');
  fdata=fdata.replace(new RegExp('\\[F\\/([^\\/]+)\\/([^\\]]+)\\]','g'),'<div class="im_file"><a href="'+homepage+'/down.php?F/$1/$2" target="_blank">$1</a></div>');
  fdata=fdata.replace(new RegExp('\\[img\\]([^\[\"\']+?)\.(gif|jpg|bmp|png){1}\\[\/img\\]','gi'),'<img src="$1.$2" onload="resetImg(this)" />');
  return fdata;
}
function resetImg(obj,icount){
  try{
    if(obj.width>300){
      obj.width=300;
    }
    ScrollControl();
  }catch(e){}
}
var curUsr='';
function Toolbar(args){
  try{eval(args)}catch(e){}
}
function Upload(args){
  var t=args.split('\t');
  if(t[0]=='-1'){
    alert('上传文件太大');
  }else if(t[0]=='1'){
    var str='['+(t[2]=='pic' ? 'P' : 'F')+'/'+t[1]+'/'+t[3]+']';
    $('#inputbox').val($('#inputbox').val()+str);
  }
}

function CloseAllDiv(){
  $('.opendiv,.autoclose').hide();
}