﻿function loginStaus()
{

var cookies = document.cookie; 
var start = cookies.indexOf("BaoCms="); 
if(start != -1){ 
    start = cookies.indexOf("=", start) + 1; 
    var end = cookies.indexOf(";", start); 
    if(end == -1){ 
        end = cookies.length; 
     } 
     var value = unescape(cookies.substring(start, end)); 

     if(value != null){ 
	var myDate = new Date();
        var outTime = value.split('&')[1].split('=')[1];
	outTime = outTime.replace("-","/").replace("-","/");
	var beginDate = new Date(myDate);
	var endDate = new Date(outTime);
	var minute = (myDate  - endDate) ; 
	if(minute <= 0){
		document.getElementById("spanLoginStatus").innerHTML="<a href=\"http://shop.bao99.com/member/index.html\">我的包包网</a> | <a href=\"http://shop.bao99.com/logout.html\" onclick=\"delCookie('BaoCms')\">退出</a>";
	}else{
		document.getElementById("spanLoginStatus").innerHTML="<a href=\"http://shop.bao99.com/register.html\">注册</a> | <a href=\"http://shop.bao99.com/login.html\">登录</a>";
	}
     }
}else{
	document.getElementById("spanLoginStatus").innerHTML="<a href=\"http://shop.bao99.com/register.html\">注册</a> | <a href=\"http://shop.bao99.com/login.html\">登录</a>";
}
}

function delCookie(name)//删除cookie
{
    var exp = new Date();
	alert(document.cookie);
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);alert(cval);
    if(cval!=null){ 
        document.cookie= name + "=" + cval + "; expires=" + exp.toGMTString();
	alert(name+"="+cval);
    }
}

function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^|utmcct=\/; )"+name+"=([^;]*)(;|$)"));
    if(arr != null){ 
	return arr[2]; 
    }else{
    	arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null){
   	    return arr[2]; 
	}else{
		return null;	
	}
    }
}

