function getCookie(username,password)
	{
	var shuzu=new Array();
	var quanxian="";
	var yonghu_id="";
	//alert("进入到getCookie");
	var resultusername = null;
	var resultpassword = null;
	var myCookie = document.cookie + ";";
	//alert(myCookie);
	var searchuserName = username + "=";
	var searchpassWord = password + "=";
	var startOfusernameCookie = myCookie.indexOf(searchuserName);
	var startOfpasswordCookie = myCookie.indexOf(searchpassWord);
	var endOfusernameCookie;
	var endOfpasswordCookie;
	if (startOfusernameCookie != -1  && startOfpasswordCookie  !=-1)
	{
		startOfusernameCookie += searchuserName.length;
		startOfpasswordCookie += searchpassWord.length;
		endOfusernameCookie = myCookie.indexOf(";",startOfusernameCookie);
		endOfpasswordCookie = myCookie.indexOf(";",startOfpasswordCookie);
		resultusername = unescape(myCookie.substring(startOfusernameCookie, endOfusernameCookie));
		resultpassword = unescape(myCookie.substring(startOfpasswordCookie, endOfpasswordCookie));
	    if(resultusername!=null  &&  resultpassword!=null){
	    	DWREngine.setAsync(false);
	        dwrwritesession.writeSerssion(resultusername,resultpassword,function sessioncollback(yonghuquanxian){
	        	if(yonghuquanxian=="error"){
	        	    alert("对不起，该用户已被删除！");
	        	    window.location.reload();
	        	}else{
		        	shuzu=yonghuquanxian.split(":");
		        	quanxian=shuzu[0];
		        	yonghu_id=shuzu[1];
	        	}
	        });
	        DWREngine.setAsync(true);
	        var dengluhou=document.getElementById("dengluhou");
			document.all.topnrdengluzhihou.style.display='';//显示登陆后的层
			document.all.topnrdenglu.style.display='none';//隐藏登陆层
			dengluhou.innerHTML="<span style='margin-top:3px'>&nbsp;&nbsp;会员：" +
					"<font color='red'>"+resultusername+"</font>您好，欢迎您登陆！&nbsp;&nbsp;" +
					"进入<a href='http://www.jianyouwang.com/userLogin_userLogin.action'><strong>" +
					"<font color='red'>用户中心</font></strong></a>&nbsp;&nbsp;" +
					"<a href='http://www.jianyouwang.com/userSaveExit_deleteCookies.action' onclick='return exit()'>" +
					"<strong><font color='red'>安全退出</font></strong></a></span>&nbsp&nbsp&nbsp&nbsp&nbsp<span id='renren'></span>";
	        DWREngine.setAsync(false);
	        dwrwritesession.checkRenRen(function(collback){
	        	document.getElementById("renren").innerHTML=collback;
	        })
	        DWREngine.setAsync(true);
	        return true;
	    }
	    else
	    {
			document.all.topnrdengluzhihou.style.display='none';//隐藏登陆后的层
			document.all.topnrdenglu.style.display='';//显示登陆层
	        return false;
	    }
	}
	else{
		return false;
	}
}
function exit()
{
	if(confirm('确定退出？')){
		delCookie('username');
		delCookie('password');
		return true;
	}else{
		return false;
	}	
}
function getCookiex(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}

function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookiex(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
function yonghuexist(username, password) {
	// alert("进入到getCookie");
	var resultusername = null;
	var resultpassword = null;
	var myCookie = document.cookie + ";";
	// alert(myCookie);
	var searchuserName = username + "=";
	var searchpassWord = password + "=";
	var startOfusernameCookie = myCookie.indexOf(searchuserName);
	var startOfpasswordCookie = myCookie.indexOf(searchpassWord);
	var endOfusernameCookie;
	var endOfpasswordCookie;
	if (startOfusernameCookie != -1 && startOfpasswordCookie != -1) {
		startOfusernameCookie += searchuserName.length;
		startOfpasswordCookie += searchpassWord.length;
		endOfusernameCookie = myCookie.indexOf(";", startOfusernameCookie);
		endOfpasswordCookie = myCookie.indexOf(";", startOfpasswordCookie);
		resultusername = unescape(myCookie.substring(startOfusernameCookie,
				endOfusernameCookie));
		resultpassword = unescape(myCookie.substring(startOfpasswordCookie,
				endOfpasswordCookie));
		if (resultusername != null && resultpassword != null) {
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}
