// 
// ===================================================
// === SuperCookieŽ ==================================
// ===================================================
// Version 1.2
// 
//      User Identification Cookie
//             (C)1999 Austin Hines/ Metapage
// 
// Web site:       http://www.geocities.com/~protozone
// MetaPage Site:  http://pages.prodigy.net/proto
// Email: proto@prodigy.net
// 
//   [:::] Information: [:::]
// 
//   This script asks the user for their name, 
//   and recognizes them the next time they 
//   enter. It also tells How many times they
//   have been there and the last time they 
//   entered. Plus it tells the user what 
//   time they entered the site and what 
//   browser they used and makes a comment 
//   based on that time. This script also 	
//   places a clock in the status bar of 
//   the browser. You may copy this script as
//   long as you leave this message in here 
//   when you copy it. This script was 
//   designed for use by AHP Online
//      (http://pages.prodigy.net/proto)
// 
// Have fun!    
//              Thanks, 
//                      -Austin Hines-
//      
//      THAT'S ALL!!!
//              Real simple eh?
//      There's just alot to copy...
// 
//  [::] Version Notices: [::]
// 
//      1.1- Added 24 hr time recognigion to Last Visit Time
//      1.2- Fixed AMpm bug in last visit time
// 
// ==================================================

// 
// ================================
//       -Begin SuperCookieŽ-
// ================================

// 
// 
// [:::::::::- WARNING! -::::::::::]
// 
//   If you don't know what you're
//   doing inside this script, and
//   you want to use it for your
//   own page, I suggust, you do 
//   not change the following 
//   code. Another tag will end 
//   this vitial script. Thanks!
// 
// [:::::- Vital Code Ahead!-::::::]
// 
// ])))))))- Vital Code Start -(((((((([



// Define day, hr, min, year
day = new Date()
hr = day.getHours()
min = day.getMinutes()
year = day.getYear()

function changeBackground(hexNumber)
{
        document.bgColor=hexNumber
}
// get cookie information
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
// Get more information
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

// Set the cookie
function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}
// Cookie expires...
function DeleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1000*(24 * 60 * 60 * 1000));  // This cookie is history
  var cval = GetCookie (name);
  SetCookie (name, cval, exp);
}
// Stores user's name
function setName (myName) {
   var expdate = new Date();
   expdate.setTime (expdate.getTime() + 365*(24 * 60 * 60 * 1000)); // 1 year from now
   myName = prompt("Who are you?");
   SetCookie ("myName", myName.value, expdate);
   location="#"
}
// Stores the time user last visited
function setLastVisitCookie () {
    var nowDate = new Date();
    var expdate = new Date();
    expdate.setTime (expdate.getTime() + 30*(24 * 60 * 60 * 1000)); // 30 days from now
    SetCookie ("lastVisit", nowDate.getTime(), expdate)
}
// Reset the cookie for Last visit
function resetReg () {
   DeleteCookie("lastVisit")
   location="#"
}
// Reset the cookie for user name
function resetName () {
   DeleteCookie("myName")
   location="#"
}
// Browser Version
var theVersion = navigator.appVersion;
var platform = "";
var nversion = "";
var i = 1;

if (theVersion.substring(0,3) == "3.0") {
        nversion="3"
}

else

if (theVersion.substring(0,3) == "2.0") {
        nversion="2"
}

else    {
        nversion="1"
}
        

// Platform Detection
while (i < theVersion.length) {
   if (theVersion.substring(i,i+1) == "(") {
      if (theVersion.substring(i+1,i+4) == "Mac") {
         platform="Mac";
      }
      else if (theVersion.substring(i+1,i+4) == "Win") {
         platform="Win";
      }
      else {
         platform = "X";
      }
      if (theVersion.substring(i+1,i+6) == "Win95") {
         platform="Win95";
      }
      break;
   }
   i = i + 1;
}



// ]))))))))- Vital Code End -((((((((([

// [::::::::- End Warning -::::::::]
// 
//   If you wish, It is now safe 
//   to modify the code below.
//   If you are new to JavaScript
//   I still suggust you leave it
//   alone.
// 
// [:::::::::::::::::::::::::::::::]



//  ================================
//           -Greet User-
//  ================================

// Hello, User!
var expdate = new Date();
expdate.setTime (expdate.getTime() + 365*(24 * 60 * 60 * 1000));
var lastTime = GetCookie("lastVisit")
// ================================
//      -Origional htmlOut-
// ================================
// DO NOT DELETE!!!!
var htmlOut = "<font face='Arial'><b>"

function writename () {
var myName = GetCookie("myName")
if (myName != null) {
        return(myName)
}
else {
if (myName == null) {
   myName = prompt("Who are you?(Type in your name or an alias)");
   SetCookie ('myName', myName, expdate);
   myName="New User"
                          }
        }
return(myName)
}


var neverhere = "false"
// User has not been here in 30 days! Bummer.
if (lastTime == null) {
   htmlOut += "Welcome to CyberCalc 3.0</font></b><br><font face='arial' size='-1'>"
   neverhere = "true"
}

//  ================================
//        -End Greating User-
//  ================================


//  ================================
//        -Browser Detector-
//  ================================

// Bdetect (Browser Detection Program)
var bdetect = " "
browser = navigator.appName;
version = parseInt(navigator.appVersion); 
if (navigator.appName == "Microsoft Internet Explorer")
	{mie = 1}
	else
	{mie = 0}
if (mie == 1 && version == 4){
	bdetect += "Microsoft Internet Explorer 4. "
	}
if (mie == 1 && version < 4){
	bdetect += "A rEaLLy oLd mIcRoSoFT Internet Explorer. Upgrade! "
	}
else if (browser == "Netscape" && version < 4){
	bdetect += "A rEaLLy oLd NeTsCaPE! AAAACCCCCKKKKKK!!!! please please, Upgrade! "
	}
else if (browser == "Netscape" && version == 4.5){
	bdetect += "Netscape 4.5 . "
	}
else if (browser == "Netscape" && version == 4){
	bdetect += "Netscape 4. "
	}
if (navigator.appVersion.indexOf("Mac") != -1) {
	bdetect += "A MAC!?! "
	}

//   ================================
//        -End browser detector-
//   ================================


//  ================================
//         -Last visit Time-
//  ================================

else {
   if (platform == "Mac") {
      lastTime = lastTime - (24 * 60 * 60 * 1000)
      // This is a workaround for a bug in getTime() on the Mac
   }
   else { lastTime = 1 * lastTime }
   var amPm = "AM";
   var lastVisit = new Date(lastTime);
   lastVisit = "" + lastVisit;
   var visitString = lastVisit.substring(0,3) + " " + lastVisit.substring(4,11) + ", "
   var lastTime = lastVisit.substring(11,19);
   var lastHour = lastTime.substring(0,2);
   lastHour = 1 * lastHour;
   var lastYear = lastVisit.substring(42,47);
   if (lastHour > 11) { amPm = "PM" }
   if (lastHour == 0) { lastHour = 12 }
   if (lastHour > 12) { lastHour -= 12 }
   
}

//  ================================
//       -End last visit time-
//  ================================


//  ================================
//        -Current enter time-
//  ================================

// What time you entered:
var amPm2 = "AM";
if (hr > 11) { amPm2 = "PM" }
   if (hr == 0) { hr = 12 }
   if (hr > 12) { hr -= 12 }
htmlOut += "You launched CyberCalc at <b>";
htmlOut += hr + ":"

if (min>9)
        htmlOut += min + " " + amPm2 + ". ";
if (min < 9)
        htmlOut += "0"+min + " " + amPm2 + ". ";
htmlOut += "<br>";
// Comments based on that time:

if (hr ==1 && amPm2 == "AM")
        htmlOut +="<B>It's getting late... </B>";
if (hr ==2 && amPm2 == "AM")
htmlOut +="<B>Hey, it is after 2am. Tired? Waaannnttt Mmmooorrree Cafffiiinnneeee? </B>";
if (hr ==3 && amPm2 == "AM")
htmlOut +="<B>Hey, it is after 3 am. </B>";
if (hr ==4 && amPm2 == "AM")
htmlOut +="<B>Hey, it is after 4 AM. Let's just hope you don't have hourly Fees. </B>";
if (hr ==5 && amPm2 == "AM")
htmlOut +="<B>Hey, it is after 5 am. GO TO BED!!</B>";
if (hr ==6 && amPm2 == "AM")
htmlOut +="<B>Hey, it is too early to be using your computer! </B>";
if ((hr ==7 && amPm2 == "AM") || (hr ==8 && amPm == "AM") || (hr ==10 && amPm == "AM"))
htmlOut +="<B>Good Morning! </B>";
if (hr ==9 && amPm2 == "AM")
htmlOut +="<B>Good Morning, I hope you will enjoy your day. </B>";
if (hr ==11 && amPm2 == "AM")
htmlOut +="<B>It's soon time for Lunch! </B>";
if (hr ==12 && amPm2 == "PM")
htmlOut +="<B>It's time for some Lunch! Mo Food... </B>";
if ((hr==1 && amPm2 == "PM")|| (hr ==2 && amPm2 == "PM"))
htmlOut +="<B>Good afternoon. Did you enjoy your lunch? </B>";
if ((hr==3 && amPm2 == "PM") || (hr==4 && amPm2 == "PM"))
htmlOut +="<B>Good afternoon. </B>";
if ((hr==5 && amPm2 == "PM") || (hr==6 && amPm2 == "PM") || (hr==7 && amPm2 == "PM") || (hr==8 && amPm2 == "PM") || (hr==9 && amPm2 == "PM") || (hr==10 && amPm2 == "PM"))
htmlOut +="<B><B>Good evening. </B></B>";
if (hr==11 && amPm2 == "PM")
htmlOut +="<B>It is nearly midnight. </B>";
if (hr==12 && amPm2 == "AM")
htmlOut +="<B>Midnight and all is well. </B>";
htmlOut += "</font>";

//  ================================
//      -End Current Enter Time-
//  ================================



//  ================================
//         -Visits Counter-  
//  ================================

function countVisits () {
expireDate = new Date
            expireDate.setMonth(expireDate.getMonth()+6)
                count = eval(cookieVal("pageHit"))
                count++
                document.cookie = "pageHit="+count+";expires=" + expireDate.toGMTString()
                
                function cookieVal(cookieName) {
                        thisCookie = document.cookie.split("; ")
                    for (i=0; i<thisCookie.length; i++) {
                        if (cookieName == thisCookie[i].split("=")[0]) {
                                return thisCookie[i].split("=")[1]
                        }
                    }
                        return 0
                }

               return(count);
}


//  ================================
//        -End Visits Counter-
//  ================================



//  ================================
//         -Status Bar Clock-
//  ================================

var timerID = null;
var timerRunning = false;
function stopclock () {
        if(timerRunning)
                clearTimeout(timerID);
        timerRunning = false;
}

function startclock () {
        // Make sure the clock is stopped
        stopclock();
        showtime();
}

function showtime () {
        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var seconds = now.getSeconds()
        var timeValue = "" + ((hours >23) ? hours -23 :hours)
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        timeValue += ((seconds < 10) ? ":0" : ":") + seconds
        window.status = timeValue;
        // you could replace the above with this
        // and have a clock on the status bar:
        // window.status = timeValue;
        timerID = setTimeout("showtime()",1000);
        timerRunning = true;
}
// Start Timer
htmlOut += "<BODY  =# onLoad=startclock()>"
htmlOut += "</body>"
htmlOut += "<BR>"

//  ================================
//      -End Status Bar Clock-
//  ================================

//  ================================
//        -Write Today's Date-
//  ================================

function writedate () {
        var month_names = new
        Array("January","February","March","April","May","June","July","August","September","October","November","December");
        var day_names   = new
        Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
        var now        = new Date();
        var prnt_stuff_date;
        var cen_str
        
        var stuff	  = new Array();
        stuff[1]		  = "1<SUP>st</SUP>";
        stuff[2]		  = "2<SUP>nd</SUP>";
        stuff[3]		  = "3<SUP>rd</SUP>";
        stuff[21]	  = "21<SUP>st</SUP>";
        stuff[22]	  = "22<SUP>nd</SUP>";
        stuff[23]	  = "23<SUP>rd</SUP>";
        stuff[31]	  = "31<SUP>st</SUP>";
        
        if ((now.getDate()==1) || (now.getDate()==2) || (now.getDate()==3) ||
        (now.getDate()==21) || (now.getDate()==22) || (now.getDate()==23) ||
        (now.getDate()==31)) {
  	        prnt_stuff_date = stuff[now.getDate()]; }
        else {
  	        prnt_stuff_date = now.getDate()+"<SUP>th</SUP>"; }
      
        var thisYear = now.getYear();
        if ((thisYear < 1900)) {
                thisYear = thisYear + 1900
                }
      
        print_str =  day_names[now.getDay()]+", "+month_names[now.getMonth()]+" "+prnt_stuff_date+", "+ thisYear;
        return (print_str);
      }

//  ================================
//      -End Write Today's Date-
//  ================================

// 
//  ================================
//  IMPORNTANT!: The next few lines
//  write to the docoument all the 
//  things that were called from
//  the tons of script above! 
//  DON'T DELETE THEM!!!!!!!
//  ================================

// Write Todays Date.
date =  writedate();
htmlOut += "<font face='Arial, Helvitica, Vernanda' size='-1'>";
htmlOut += "</b>Today's date is <b>" + date + "</b>. ";

// Write Number of times user has visited the document.
htmlOut += "You have been to this site" + countVisits() + "times.";

// Write the time the user last visited to the document
if ((mie == 0) && (count > 0) && (count < 2)) {
		htmlOut += "</font>"
} else { if (mie == 0) {
		htmlOut += "You last launched CyberCalc on <b> " + visitString + lastYear + " at "
		htmlOut += " " + lastHour + lastTime.substring(2,8) + " " + amPm + ". </b></font></center>";
}
}

function suprcookie (){
	setLastVisitCookie();
}

// 
//  ================================
//   -End SuperCookieŽ JavaScript-
//  ================================

// Coming out of warp...