


function checkLogin()
{
try
{

//alert('Cookie:' + document.cookie);
var fname = readCookie('ClientFirstName');
//alert(fname);
var lname = readCookie('ClientLastName');
//alert(lname);
var isIn = readCookie('ProductList');
var isAdmin = readCookie('IsAdmin');
var adminString;
if(isAdmin.length>0)
{
  adminString = '|  <a href=\"admin.aspx\" class=\"loginanchor\">Admin</a>  ';
}
else
{
 adminString='';
}
if(lname.length>0&&fname.length>0 && isIn.length>0)
{
loginForm=document.getElementById('login_form');

loginForm.innerHTML='<br/><h3>Welcome ' 
                + fname 
                + " " 
                + lname 
                + "</h3><a href=\"login.aspx\" class=\"loginanchor\" >Pricing</a>  "+ adminString + "|  <a href=\"Specials.aspx\" class=\"loginanchor\" >Specials</a>  |  <a href=\"javascript:cookieDelete('KAPCookie')\" class=\"loginanchor\" >Logout</a>  </div>";

}
}
catch(err)
{
alert('Error in checkLogin(): ' + err);
} 
}

function readCookie(name)

{

  var cookieValue = '';

  var search = name + '=';

  if(document.cookie.length > 0)

  { 

    offset = document.cookie.indexOf(search);

    if (offset != -1)

    { 

      offset += search.length;

      end = document.cookie.indexOf('&', offset);

      if (end == -1) end = document.cookie.length;

      cookieValue = unescape(document.cookie.substring(offset, end))

    }

  }

  return cookieValue;
}



function cookieDelete(cookie_name) {
if (document.cookie != document.cookie) {
index = document.cookie.indexOf(cookie_name);
} else {
index = -1;
}
if (index == -1) {
document.cookie=cookie_name+"=GONEcbEndCookie; expires=Monday, 19-Aug-1996 05:00:00 GMT";
}

//to reload without queryString parameters, use the line below instead
//alert(document.location.href);
var x = document.location.href.substring(0,document.location.href.indexOf('?'));
    //alert(x);
if (x.length==0)
document.location = document.location.href;
else
document.location = document.location.href.substring(0,document.location.href.indexOf('?'));
} 