


/* Need to keep the everything inside the DIV */
/* Check the cookie for user state */
function get_cookie ( cookie_name){
	var results = document.cookie.match ( cookie_name+ '=(.*?)(;|$)' );
	//alert('results'+results);
	if ( results )
		return ( unescape ( results[1] ) );
	else
		return null;
}

var sign_in = "../source/SubscriberSign-in.asp";
var site = "NY";
var site_limited = "NY:LIMITED";
var subscribe_page = "http://www.law.com/jsp/nylj/subscribe.jsp";
var site_name = site.toLowerCase();
var useremail = get_cookie ("useremail");
var products = get_cookie ("prodlist");
var hasAccess=new Boolean()
var hasLimitedAccess=new Boolean()
var isLoggedIn=new Boolean()

if ((useremail=="") || (useremail==null)){
	isLoggedIn=false
} else {
	isLoggedIn=true
}
if ((products == "") || (products == null)){
	hasAccess=false
} else {
	var product_array=products.split(";");
	var product=0;
	while (product < product_array.length){
		if(product_array[product] == site){
			hasAccess=true
		}
		if(product_array[product] == site_limited){
			hasLimitedAccess=true
		}

	product+=1;
	}
}
var userAccount = get_cookie ("userAccount");
var userAccess = get_cookie ("userAccess");
if ((userAccess==null) && (userAccount!=null)){
	thisUrl=location.href;
	thisUrl=escape(thisUrl.substring(7));
	silentlogin="http://store.law.com/signin/sign-in.asp?mode=silent&source="+thisUrl;
	window.location=silentlogin;
} 

//alert("Beerendra Singh");
/* Write the login state and links */
//document.write("<div id='loginbar'>")
if ((hasAccess == true) && (isLoggedIn == true))  {
	document.write("<a href='javascript:signOut()'>Sign Out</a>")

} else if ((hasLimitedAccess == true) && (isLoggedIn == true))  {
	document.write("<a href='https://store.law.com/registration/register.asp?subscribeTo="+site_name+"&w="+site_name+"&mode=&returnurl=http://www.law.com/jsp/"+site_name+"/index.jsp'>Upgrade</a> | <a href='javascript:signOut()'>Sign Out</a><br>")

} else if ((hasAccess == false) && (isLoggedIn == true))  {
	document.write("<a href="+subscribe_page+">Subscribe</a> | <a href='javascript:signOut()'>Sign Out</a><br>")


} else {
	document.write("<a href='"+sign_in+"'>Sign In</a>")


}
//document.write("</div>"); // End loginbar div

/* Need to keep the everything inside the DIV */