I am trying to come up with a kind of IF statement for reading cookies however it's not working for me. Heres what I got so far:



<script language="JavaScript" type="text/javascript">
<!--

function createLuckyCookie() {
when= new Date()
when.setHours(when.getHours()+1)
expires=when.toGMTString()
document.cookie = "luckycookie=lucky;expires="+expires+";path=/"
}

function getCookie(luckycookie) {
var prefix = luckycookie + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function checkLuckyCookie() {
if (document.cookie.= "") {
alert(error);
luckyimage.src='images/box_time.gif';
return false;
}

else {
createLuckyCookie();
showImages();
return false;
}
}

//-->
</script>


<a href="#" onclick="checkLuckyCookie();return false">
<IMG SRC="00.gif" NAME="luckyimage" ID="g0" ALT="" BORDER="0"></A>


I am trying to get this script so basicaly say: "If cookie, do this. If no cookie, do this." It's so simple yet it's killing me I can't do it. Any comments/suggestions would greatly be apreciated. Thanks.

~Isaac Lloyd~