﻿window.onload = initAll;

function initAll() {
	document.getElementById("wylink").onclick = function() {return getCookie()};
	
	if(getCookieValue("SITEINFO") != null) {
/*		var aImg = document.createElement("img");
		aImg.setAttribute("src","images/wyimg.gif");
		aImg.setAttribute("alt","Login");
	
		var testDiv = document.getElementById("wylink");
		var oldImg = document.getElementById("oldLink");
	
		testDiv.removeChild(oldImg);
		testDiv.appendChild(aImg);
		*/
	}
};

function getCookie() {
	if(getCookieValue("SITEINFO") != null){	
		var aLink = document.getElementById("wylink");		
		aLink.setAttribute("href","/list.aspx?id=482007251600");
//		window.location.href = "/list.aspx?id=482007251600";
	}
	else {
		alert("会员请先登陆");
	}
}


/*────────────────────────────────────────
	Cookie相关操作
────────────────────────────────────────*/
// Get Cookie
function getCookieValue(sKeyName){
	var sRE = "(?:; )?" + sKeyName + "=([^;]*);?";
	var oRE = new RegExp(sRE);
	if(oRE.test(document.cookie)) return decodeURIComponent(RegExp["$1"]);
	else return null;
}
// Set Cookie
function setCookie(sKeyName,sValue,oExpires,sDomain){
	var sCookie = sKeyName + "=" + encodeURIComponent(sValue);
	if(oExpires){sCookie += "; expires=" +oExpires.toGMTString();	}
	if(sDomain){sCookie += "; domain=" + sDomain;	}
	document.cookie = sCookie;
}
// Delete Cookie
function delCookie(sKeyName){setCookie(sKeyName,"",new Date(0));}

function LoginOut() {
		delCookie("SITEINFO");
		location.replace("/");
}