window.onload = checkCookie;

function checkCookie() {
	var outMsg = "";
    var found = 0;

	if (document.cookie == "") {
		outMsg = "Log In";
	   }

	else {
		var allCookies = document.cookie.split("; ");
		for (var i=0; i<allCookies.length; i++) {
            this_cookie = allCookies[i].split("=")[0]
            full_cookie_data = allCookies[i].split("=")[1]
            if ( this_cookie == "gmlogin" ) {
                  found = 1;
		    	  outMsg += "<A HREF=\"javascript:logout()\";><FONT color=white>Log Out</A>";
		          }
	       }
       }

if ( found == 0 ) {
		outMsg = "<A HREF=\"/members/\"><FONT color=white>Log In</FONT><\/A>";
}
 document.getElementById("login_logout").innerHTML = outMsg;

}

function logout() {
        var found = 0;
		var allCookies = document.cookie.split("; ");
		for (var i=0; i<allCookies.length; i++) {
            this_cookie = allCookies[i].split("=")[0]
            full_cookie_data = allCookies[i].split("=")[1]
            if ( this_cookie == "gmlogin" ) {
                  found = 1;
                  var expireDate = new Date();
		          expireDate.setDate(expireDate.getDate()-1);
                  document.cookie = "gmlogin=; expires=Fri, 3 Jun 2010 12:00:00 UTC; path=/";
//		          outMsg = "<A HREF=\"/members/\"><FONT COLOR=white>Log In</FONT><\/A>";
//                document.getElementById("login_logout").innerHTML = outMsg;
		          window.location = "/";
//                  checkCookie()
		         }
	       }

if ( found == 0 ) {
		window.location = "/members/";
      }

}

//#############

