function $(id){
	try{
		return document.getElementById(id);
	}catch(e){
		return null;
	}
}

function copyToClipBoard(){ 
   	var clipBoardContent=""; 
    clipBoardContent+=document.title; 
   	clipBoardContent+="\n"; 
    clipBoardContent+=this.location.href; 
   	window.clipboardData.setData("Text",clipBoardContent); 
   	alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友"); 
}

var xhr;

function createXHR(){
	if(window.ActiveXObject){
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}
	return xhr;
}

function login(){
	createXHR();

	var username=$("username").value;
	var password=$("password").value;
	if(username == ''){
		alert('请输入您的用户名');
		return false;
	}
	
	if(password == ''){
		alert('请输入您的密码');
		return false;
	}
			
	var args="username="+username+"&password="+password;
	if(!args) return false;
	var url = "function/ajaxLogin.php";
	xhr.onreadystatechange =  function(){
		if(xhr.readyState == 4){
			if(xhr.status == 200){//alert(xhr.responseText);
				if(xhr.responseText == 'LOGIN_FAIL'){
					$("password").value = ''
					alert('登录失败，请检查您的用户名或密码是否输入有误');
				}else{
					$('loginDIV').innerHTML = xhr.responseText;
				}
			}
		}
	}
	xhr.open("POST", url, true);
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
	xhr.send(args);
}