var v;
var t;

function saveCookie(name,value,days) {
     if (days) {
          var date = new Date();
          date.setTime(date.getTime()+(days*24*60*60*1000))
          var expires = "; expires="+date.toGMTString()
     }
     else expires = ""
     document.cookie = name+"="+escape(value)+expires+"; path=/"
}
function readCookie(name) {
     var nameEQ = name + "="
     var ca = document.cookie.split(';')
     for(var i=0;i<ca.length;i++) {
          var c = ca[i];
          while (c.charAt(0)==' ') c = c.substring(1,c.length)
          if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
     }
     return null
}

//判断ie版本号
var winhandle,winname;
winhandle=null;
winname="whaty_chat";



function versionNumber() {
 
var browser = navigator.appName;
var tversion=navigator.appVersion;
if (browser == "Microsoft Internet Explorer") 
{
tversion=tversion.substr(tversion.indexOf("MSIE")+5,6);
}
 
return parseFloat(tversion);
 
}

//判断窗口拦截
var canOpenWin=true;
function setTrue()
{
canOpenWin=true;
}
 
function checkopenwin() 
{ 

OpenWindow=window.open("", "newwin", "height=100, width=100,left=5000,right=5000,toolbar=no,scrollbars=no,menubar=no");
//写成一行 
if (OpenWindow)
{
OpenWindow.document.write("<HTML>");
OpenWindow.document.write("<head>");
OpenWindow.document.write("<TITLE>检测</TITLE>");
OpenWindow.document.write("<script>");
OpenWindow.document.write("opener.setTrue();");
OpenWindow.document.write("</script>"); 
OpenWindow.document.write("</head>");
OpenWindow.document.write("<BODY BGCOLOR=#ffffff>");
OpenWindow.document.write("Check the system's openwin function!"); 
OpenWindow.document.write("</BODY></HTML>");
OpenWindow.document.close();
OpenWindow.close();

}
else canOpenWin=false;
return  canOpenWin;
} 



function CheckNum(num)
{
    if(num.replace(/^([0-9])+$/,"")!="")
      return false;
    return true;  	 
}
function CheckUser(user)
{
    //if(user.indexOf(/<>/!="")
    //  return false
    //return true;
}
function selectroom(index)
{
try{

//document.login_left.roomid.value=index; 
document.left.login_left.roomid.value=index; 
}
catch(e)
{
	alert(e);}
}
function openrecord(roomid)
{

	window.open("pubrecord.asp?roomid="+roomid,"","height=300,width=600,left=0,top=0,status=yes,scrollbars=yes,resizable=yes,fullscreen=no");
}


function logi(thisform)
{

obj=eval("document."+thisform);

room_id=obj.roomid.value;
obj.user.value=trim(obj.user.value);
if(obj.user.value==""){alert("用户名不能为空!");return false;}
if(obj.user.value.length>20){alert("用户名或昵称超过长度");return false;};
//if(!CheckUser(login.user.value)){alert("用户名不合法");return false;};
//if(login.pass.value==""){alert("密码不能为空!");return false;}
if(!canOpenWin)
{
   alert("弹出窗口功能被关闭，可能造成本站无法正常使用，请关闭google或 3721等对本站的拦截功能"); 
}

room_id=room_id.replace(/\s/g,"");

if(room_id=="")
{
   alert("必须输入房间ID");	
   return false;
}
if(!CheckNum(room_id))
{
   alert("房间ID必须输入数字");	
   return false;
}
if(canOpenWin){

//name="win"+Math.round(Math.random()*100);


for (var i = 0; i < obj.roomid.length; i++) {
if (obj.roomid[i].checked)
{
name="win"+obj.roomid[i].value+obj.user.value;
}

}
winhandle=window.open("",winname,"height="+screen.availHeight+",width="+screen.availWidth+",left=0,top=0;status=no,scrollbars=yes,resizable=yes,fullscreen=no");


if((winhandle&&!winhandle.closed)&&winhandle.location.href.indexOf("about:blank")==-1)
{
alert("你有一个窗口正在登录中，请退出再登录");
return false;	
}

obj.target=winname;

}
else{obj.target="_top"}

//if(versionNumber()<5.5&&obj.newwindow.checked)
 //   alert("本站点要求ie5以上浏览器，ie5用户最好不要开新窗进入，否则可能会导致ie死，同时建议卸载3721,否则不能正常使用所有功能。");

}
var icosel=1;
function selectico()
{if(icosel==1){
kj.style.visibility="visible";
icosel=0;
}
else{
kj.style.visibility="hidden";
icosel=1;
}}
function manlog()
{window.open("manlog.asp","manlog","height=410,width=700,left=50,top=60,resizable=no,scrollbars=auto,status=no,toolbar=no,menubar=no,location=no")}
function chatbest(){
window.open("chatbest.asp?del=yes","newwindow3","height=370,width=460,left=150,top=60,resizable=no,scrollbars=auto,status=no,toolbar=no,menubar=no,location=no");
}
function sitelog(lock)
{
	var rightedge=document.body.clientWidth-event.clientX
	var bottomedge=document.body.clientHeight-event.clientY
	if (rightedge<logbox.offsetWidth) {logbox.style.left=document.body.scrollLeft+event.clientX-logbox.offsetWidth}
	else {logbox.style.left=document.body.scrollLeft+event.clientX+50}
	if (bottomedge<logbox.offsetHeight) {logbox.style.top=document.body.scrollTop+event.clientY-logbox.offsetHeight}
	else {logbox.style.top=document.body.scrollTop+event.clientY}
	logbox.style.visibility="visible";
	
	if(lock)
	   rp.innerHTML="房间密码：<input type=\"password\" name=\"roompass\" size=\"12\" style=\"width: 90; height: 20; border-style: inset; border-width: 1\">";
	else
	   rp.innerHTML="";

	return false;
	
}
function fastlogi()
{
logintop.user.value=trim(logintop.user.value);
if(logintop.user.value==""){alert("用户名不能为空!");return false;}
//if(logintop.pass.value==""){alert("密码不能为空!");return false;}
if(logintop.roomid.value==""){alert("请填写房间ID号码");return false;}
name="win"+logintop.roomid.value+logintop.user.value;
window.open("","n"+name,"height=600,width=600,left=0,top=0;status=no,scrollbars=yes,resizable=yes,fullscreen=no");
logintop.target="n"+name;

}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function


