function enter(roomid){
	roomtype=roomid.substring(0,1)
	roomtype=roomtype.toLowerCase()
  	if(roomtype=="t"){
  		document.form1.action="http://talk3.silversand.net/loginroom.php"
  	}else{
  		document.form1.action="http://talk3.silversand.net/loginchat.php"
  	}
  	if(validname(document.form1.USER)){ 	
		document.form1.roomid.value=roomid
		document.form1.submit()
var bg = document.getElementById("bgs");
      bg.setAttribute("src", "./images/sound/global.wav");
  	}
}
function b1(pport)
{
 	
  	if(validname(document.form1.elements[0])){
		document['form1'].action='http://chat.yeliao.cn:'+pport+'/';
	  	//launchchat();
	  	document['form1'].method='post';
  		document.form1.submit();
var bg = document.getElementById("bgs");
      bg.setAttribute("src", "./images/sound/global.wav");
  	}  	 
}

var wwwhost=window.location.hostname
function b(pport)
{
 	
  	if(validname(document.form1.elements[0])){
	  	document['form1'].action='http://chat.liao-tian.com:'+pport+'/';
	  	document['form1'].method='post';
  		document.form1.submit();
var bg = document.getElementById("bgs");
      bg.setAttribute("src", "./images/sound/global.wav");
  	}
  	
  	 
}
function validname(str1)
{
	var s,i,j;
	if (str1.value.length <1) {
		alert("请输入您的大名，名字不能为空！");
		str1.focus();
      		return false;
   	}
	s="'#&*\"";
	str=str1.value.toString();
	for (i=0; i<str.length; i++) {
	   for(j=0;j<s.length;j++){
		if (str.charAt(i) == s.charAt(j))
        	{
			alert("名字中不能包含特殊字符: # & * .");
 			str1.focus();
      			return false;
   		}
	  }
	}
   	return true;
}
var focusok=false;
if (navigator.appName == "Netscape") {
	focusok=true;
}
vers = navigator.appVersion;
if (navigator.appName == "Microsoft Internet Explorer") {
 pos = vers.lastIndexOf('.'); 
 vers = vers.substring(pos-1,vers.length); 
}
proper_version = parseFloat(vers); 

if(proper_version>=5){
	focusok=true;
}



function ke() {
if(event.keyCode==13)
document.getElementById("login").click()

}
function login() {
if(document.getElementById("choosecrtype").value=="bliao")
{
enter(document.getElementById("bl").value)
}
if(document.getElementById("choosecrtype").value=="yliao")
{
b1(document.getElementById("yl").value)
}
if(document.getElementById("choosecrtype").value=="xliao")
{
b(document.getElementById("xl").value)
}
}



function chcrtype() {

if(document.getElementById("choosecrtype").value=="bliao")
{
document.getElementById("bl").style.display="block";
document.getElementById("yl").style.display="none";
document.getElementById("xl").style.display="none";
}
if(document.getElementById("choosecrtype").value=="yliao")
{
document.getElementById("yl").style.display="block";document.getElementById("bl").style.display="none";
document.getElementById("xl").style.display="none";
}
if(document.getElementById("choosecrtype").value=="xliao")
{
document.getElementById("xl").style.display="block";
document.getElementById("bl").style.display="none";
document.getElementById("yl").style.display="none";
}
}

function addsetting() {
document.getElementById("addsetting").style.display="block";
document.getElementById("cname").focus();
document.getElementById("set").style.display="none";}



function setting() {

document.getElementById("set").style.display="block";
document.getElementById("usernameset").focus();
}



function delsetting() {
document.getElementById("choosecrtype").focus();
document.getElementById("login").style.display="none";
document.getElementById("login").disabled="true";
document.getElementById("del").style.display="block";
document.getElementById("set").style.display="none";
}


function showmodify() {
document.getElementById("showmod").style.display="block";
document.getElementById("choosecrtype").focus();
document.getElementById("login").style.display="none";
document.getElementById("login").disabled="true";
document.getElementById("set").style.display="none";
}


function showbl() {
document.getElementById("chname").value =document.getElementById("bl").options[bl.selectedIndex].innerText;
document.getElementById("chhm").value=document.getElementById("bl").value;
document.getElementById("hichname").value=document.getElementById("bl").options[bl.selectedIndex].innerText;
}


function showyl() {
document.getElementById("chname").value=document.getElementById("yl").options[yl.selectedIndex].innerText;
document.getElementById("chhm").value=document.getElementById("yl").value;
document.getElementById("hichname").value=document.getElementById("yl").options[yl.selectedIndex].innerText;
}
function showxl() {
document.getElementById("chname").value=document.getElementById("xl").options[xl.selectedIndex].innerText;
document.getElementById("chhm").value=document.getElementById("xl").value;
document.getElementById("hichname").value=document.getElementById("xl").options[xl.selectedIndex].innerText;
}


function nick() {
document.getElementById("User").value=document.getElementById("userpw").options[userpw.selectedIndex].innerText;
document.getElementById("Pass").value=document.getElementById("userpw").value;
}


function showchatset() {
document.getElementById("chatset").style.display="block";
document.getElementById("add").focus();
}


function showuserset() {
document.getElementById("userset").style.display="block";
document.getElementById("showadd").focus();
}


function showadd() {
document.getElementById("User").focus();
document.getElementById("adduser").style.display="block";
}


function showdel() {
document.getElementById("userpw").focus();
document.getElementById("de").style.display="block";
}
