// The script which is used to validate the name entry form on FirstPage.html and calls cookie creation routine from cookiecode.js

function validate()
{
var name = document.getElementById('submitname').value;
    if (!name)
    {
        window.alert("Please enter your name before submitting this form");
        document.entername.focus();
        return false;
    }
    
    else if (name.length < 3 || name.length > 25)
    {
       window.alert("You Must be having a laugh, get a new name");
       document.getElementById('submitname').focus();
       return false;
    }
    
    else
    {       
        window.alert("Thanks");
	SetCookie("enteredname", name);
        return true;
    }
}


// Function to display name along with a short message at he top of each page.

function showMessage() {
	var username = GetCookie("enteredname");
 	document.write("<p>Congratulations I hope you, " + username + " enjoy your visit to my website.</p>");
}







//Script for the e-mail validation and submission of an e-mail utilising form data. Users e-mail address is used and subject line and content are set by form fields.

var good;
function checkEmailAddress(field) {
//A very simple e-mail validation
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail) {
good = true;
}
else {
alert('Please enter a valid e-mail address.');
field.focus();
field.select();
good = false;
   }
}

m = "I thought this might interest you...";

function mailThisUrl() {
u = document.getElementById('comments').value;
good = false
checkEmailAddress(document.getElementById('address'));
if (good) {
alert('Like I actually care what you think!!');
// the following expression must be all on one line...
window.location = "mailto:"+document.getElementById('address').value+"?subject="+m+"&body="+u;
   }
}


//Script for displaying time and date in the status bar, very neat, unobtrusive and smart
//Modified from a collaboration of script sourced on codeproject.com and scriptsearch.com
varia_stat()
tim_int=window.setInterval("varia_stat()",1000)

function varia_stat()
{
date_=new Date()
date1_=date_.getDate()
month_=date_.getMonth()
year_=date_.getYear()
hour_=date_.getHours()
min_=date_.getMinutes()
sec_=date_.getSeconds()
tim_=hour_+":"+min_+":"+sec_+"  Todays date is "+date1_+"/"+month_+"/"+year_
window.status=(tim_)
}


//Here begins the code to utilise the cookie in a matrix style way.
//I just need to get the link(s) parsed into the text. This code has been modified from the original source.
<!-- Original:  Matt Lewis (matt999_999@yahoo.com) -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin-->


var name = GetCookie("enteredname");

var matrix_window;
function MatrixWrite(string, bold, italic, speed) {
var height = window.screen.height;
var width = window.screen.width;
var win_dimensions = "height = " + eval(height + 10) + ", width = " + eval(width + 30);
matrix_window = window.open("blank.htm", "matrix_window", win_dimensions);
matrix_window.document.open("text/html", "replace");
var i;
var timer = 0;
if(matrix_window.moveTo)
matrix_window.moveTo(-10, -30);
if(matrix_window.resizeBy)
matrix_window.resizeBy(0, 50);
matrix_window.document.write("<body bgcolor=000000 text=00ff00 onBlur='self.focus()'>");
matrix_window.document.write("<font face=system>");
if(bold == true) matrix_window.document.write("<b>");
if(italic == true) matrix_window.document.write("<i>");
for(i = 0; i <= string.length; i++) {
timer += (Math.random() * speed);
setTimeout("matrix_window.document.write('" + string.charAt(i) + "');", timer);
}
timer += 2000;
setTimeout("matrix_window.close()", timer);
}
var messages = new Array("The Matrix has you "+name+"...", "Follow the white rabbit "+name, "Wake up,"+name, "Knock, knock, "+name);
function GetRndIndex() {
return (parseInt(Math.random() * messages.length));
}
function WriteRndMsg(bold, italic, speed) {
MatrixWrite(messages[GetRndIndex()], bold, italic, speed);
}