<head>
<title>NameCookie2010</title>
</head>
<body>
<script language="JavaScript">
<!--
//This script was made by Giedrius gietam@eunet.lt

cookie_name = "NameCookie2010";
var GuestName;
var FirstTime

function putCookie()
{
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
FirstTime = "n"
}

else

{
FirstTime = "y"
index = -1;

}

if (index == -1)
{
GuestName=window.prompt("Hello! What's your name?","Nobody");
if (GuestName==null) GuestName="Nobody";
document.cookie=cookie_name+"="+GuestName+"; expires=Tuesday, 05-Apr-2010 05:00:00 GMT";
}
else
{
namestart = (document.cookie.indexOf("=", index) + 1);
nameend = document.cookie.indexOf(";", index);
if (nameend == -1) { nameend = document.cookie.length;}
GuestName = document.cookie.substring(namestart, nameend);
if (GuestName=="Nobody")
{
GuestName=window.prompt("Hello again!!!"+"\n"+"Last time you didn't tell me your name. Maybe you want to do it now?","Nobody");
if ((GuestName!="Nobody")&&(GuestName!=null))
{document.cookie=cookie_name+"="+GuestName+"; expires=Tuesday, 05-Apr-2010 05:00:00 GMT";}
if (GuestName==null) GuestName="Nobody";
}
}
}

function getName()
{
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index != -1)
{
namestart = (document.cookie.indexOf("=", index) + 1);
nameend = document.cookie.indexOf(";", index);
if (nameend == -1) {nameend = document.cookie.length;}
GuestName = document.cookie.substring(namestart, nameend);
return GuestName;
}
}
}

putCookie();
GuestName=getName();

//-->
</script>
<P>
<script language="javascript">

if (FirstTime == "y")
{document.write("Hello, "+GuestName+", nice to meet you!!!");}
else
{document.write("Hello, "+GuestName+", welcome back!!!");}
</script>