function killErrors() {
return true;
}
window.onerror=killErrors;

var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

var ietype="";
if(document.getElementById)
{
ietype="Public";
}
else if(document.all)
{
ietype="IE4"
}
else if(document.layers)
{
ietype="NS4"
}

function $(obj){
switch(ietype)
{
  case "Public":
  {
   return document.getElementById(obj);
  }
   break;
  case "IE4":
  {
   return document.all[obj];
  }
   break;
  case "NS4":
  {
   return document.layers[obj];
  }
   break;
}
}

function formok(){
            if($('username').value==''){
                alert('用户名不能为空！');
                $('username').focus;
                return false;
                }
            if($('tel').value==''){
                alert('电话不能为空！');
                $('tel').focus;
                return false;
                }
            if($('content').value==''){
                alert('留言内容不能为空！');
                $('content').focus;
                return false;
                }
            msgform.submit();
            return true;
            }

function checkuser(){
	
	if($("username").value==""){
		alert("用户名不能为空");
		$("username").focus();
		return false;
		}
	else{
		var username=/^[u4e00-u9fa5]|[a-zA-Z0-9_]{4,15}$/;
		if (!username.exec($("username").value)){
			alert("用户名格式不正确");
			$("username").focus();
			return false;
			}
		}
	}

function leftlogin(){
	if($("username_l").value==""){
		alert("用户名不能为空");
		$("username_l").focus();
		return false;
		}
	else{
		var username_l=/^[u4e00-u9fa5]|[a-zA-Z0-9_]{4,15}$/;
		if (!username_l.exec($("username_l").value)){
			alert("用户名格式不正确");
			$("username_l").focus();
			return false;
			}
		}
	if($("username_l").value==""){
		alert("用户名不能为空");
		$("username_l").focus();
		return false;
		}
	}

function checkform(){
	
	if($("username").value==""){
		alert("用户名不能为空");
		$("username").focus();
		return false;
		}
	else{
		var username=/^[u4e00-u9fa5]|[a-zA-Z0-9_]{4,15}$/;
		if (!username.exec($("username").value)){
			alert("用户名格式不正确");
			$("username").focus();
			return false;
			}
		}
	if($("useremail").value==""){
		alert("Email地址不能为空");
		$("useremail").focus();
		return false;
		}
	else{
		var email=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
		if (!email.exec($("useremail").value)){
			alert("Email地址不正确");
			$("useremail").focus();
			return false;
			}
		}
		
	if($("usertel").value==""){
		alert("电话不能为空");
		$("usertel").focus();
		return false;
		}
	else{
		var tel=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
		if (!tel.exec($("usertel").value)){
			alert("电话格式不正确");
			$("usertel").focus();
			return false;
			}
		}
		
	if($("userqq").value==""){
		alert("QQ号码不能为空");
		$("userqq").focus();
		return false;
		}
	else{
		var qq=/[1-9][0-9]{4,}/;
		if (!qq.exec($("userqq").value)){
			alert("QQ号码不正确");
			$("userqq").focus();
			return false;
			}
		}
		
	if($("usermsn".value)==""){
		alert("MSN不能为空");
		$("usermsn").focus();
		return false;
		}
	else{
		var msn=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
		if (!msn.exec($("usermsn").value)){
			alert("MSN地址不正确");
			$("usermsn").focus();
			return false;
			}
		}
		

	userform.submit();
	return true;

	}



function createxmlhttp()
{
	xmlhttpobj = false;
	try{
		xmlhttpobj = new XMLHttpRequest;
	}catch(e){
		try{
			xmlhttpobj=new ActiveXObject("MSXML2.XMLHTTP");
		}catch(e2){
			try{
				xmlhttpobj=new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e3){
				xmlhttpobj = false;
			}
		}
	}
	return xmlhttpobj;
	
}

function xmlobjpost(url,act){
	var xmlobj;
	xmlobj=createxmlhttp();
	xmlobj.open("post",url,true);
	xmlobj.setRequestHeader("Content-Type","gb2312"); 
	xmlobj.onreadystatechange=function(){
		if (xmlobj.status!=404){
			act(xmlobj.status);
		}
	};
	xmlobj.send(null);
}

function xmlobjok(url,act){
	var xmlobjhdw;
	xmlobjhdw=createxmlhttp();
	xmlobjhdw.open("post",url,true);
	xmlobjhdw.setRequestHeader("Content-Type","gb2312"); 
	xmlobjhdw.onreadystatechange=function(){
			if (xmlobjhdw.readyState==4){
				if (xmlobjhdw.status==200){
					act(xmlobjhdw.responseText);
				}
			}
	};
	xmlobjhdw.send(null);
}

function loginjs1(){
		$('username_l').style.backgroundPosition='-50px bottom';
	}
function loginjs2(){
	if($('username_l').value!=''){
		$('username_l').style.backgroundPosition='-50px bottom';
		}
	else{
		$('username_l').style.backgroundPosition='left bottom';
	}
	}
function loginjs3(){
		$('password_l').style.backgroundPosition='-50px top';
	}
function loginjs4(){
	if($('password_l').value!=''){
		$('password_l').style.backgroundPosition='-50px top';
		}
	else{
		$('password_l').style.backgroundPosition='left top';
	}
	}
