/*

function emailCheck (emailStr)
	checks whether email addres 'emailStr' is in a correct format
		returns true or false

function constrMl(str1,str2,linkaddress,txt)
	creates (document.write) email address or link (if linkaddress == link)
	(constrMl('x','ln.x','link',constrMl('x','ln.x','link','')) shows a link with the address visible)
		returns the email address

function IsNumeric(strText)
	determine wether string is completely numeric
		returns true or false;

function alternate(id)
	creates alternating row colors in table
		returns nothing

*/

//--- emailCheck --------------------------------

/* emailCheck V1.1.4: Sandeep V. Tamhankar (stamhankar@hotmail.com)

Changes:
1.1.4: Fixed a bug where upper ASCII characters (i.e. accented letters international characters) were allowed.

1.1.3: Added the restriction to only accept addresses ending in two letters (interpreted to be a country code) or one of the known TLDs (com, net, org, edu, int, mil, gov, arpa), including the new ones (biz, aero, name, coop, info, pro, museum).  One can easily update the list (if ICANN adds even more TLDs in the future) by updating the knownDomsPat variable near the top of the function.  Also, I added a variable at the top of the function that determines whether or not TLDs should be checked at all.  This is good if you are using this function internally (i.e. intranet site) where hostnames don't have to conform to W3C standards and thus internal organization e-mail addresses don't have to either.
Changed some of the logic so that the function will work properly with Netscape 6.

1.1.2: Fixed a bug where trailing . in e-mail address was passing (the bug is actually in the weak regexp engine of the browser; I simplified the regexps to make it work).

1.1.1: Removed restriction that countries must be preceded by a domain, so abc@host.uk is now legal.  However, there's still the restriction that an address must end in a two or three letter word.

1.1: Rewrote most of the function to conform more closely to RFC 822.

1.0: Original  */
// -->

<!-- Begin
function emailCheck (emailStr) {

var showAlert = 0; //should alerts from within this function be shown?

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address.
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

if (showAlert) {
	alert("Email address seems incorrect (check @ and .'s)");
}
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
	if (showAlert) {
		alert("This username contains invalid characters.");
	}
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
	if (showAlert) {
		alert("Ths domain name contains invalid characters.");
	}
return false;
   }
}

// See if "user" is valid

if (user.match(userPat)==null) {

// user is not valid

if (showAlert) {
	alert("The username doesn't seem to be valid.");
}
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
	if (showAlert) {
		alert("Destination IP address is invalid!");
	}
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
	if (showAlert) {
		alert("The domain name does not seem to be valid.");
	}
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) {
	if (showAlert) {
		alert("The address must end in a well-known domain or two letter " + "country.");
	}
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
	if (showAlert) {
		alert("This address is missing a hostname!");
	}
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

//--- constrMl ----------------------------------

function constrMl(str1,str2,linkaddress,txt) {
//constrMl('x','ln.x','link',constrMl('x','ln.x','link','')) shows a link with the address visible

	revAddress = str2 + String.fromCharCode(67-3) + str1; //reverse address

	var address = "";
	for (i=revAddress.length-1; i>=0; i--) {
		address += revAddress.charAt(i);
	}

	if (linkaddress == 'link') {                   //show as link
		strText = "<a href='mailto:" + address + "'>" + txt + "</a>";
	} else {
		strText = address;
	}
	document.write(strText);                       //show result
	return (address);
}

//--- isNumeric ---------------------------------

function IsNumeric(strText) {                    //determine wether string is completely numeric
	var ValidChars = "0123456789";
	var flagIsNumber = true;
	var Char;
	for (i = 0; i < strText.length && flagIsNumber == true; i++) {
     Char = strText.charAt(i);
     if (ValidChars.indexOf(Char) == -1) {
        flagIsNumber = false;
		}
	}
	return flagIsNumber;
}

//--- alternate --------------------------------- //alternate table rows

function alternate(id){
	method = "doAlternate";
	if(document.getElementById) {                  //if capable browser
		var table = document.getElementById(id);     //get target table
		var rows = table.getElementsByTagName("tr"); //get table rows
		var j = 0;
		for (i=0; i<rows.length; i++) {
			if ((rows[i].className != "header") && (rows[i].className != "subheader")) {
				j++;
				if(j % 2 == 0){
					rows[i].className = "light";
				}else{
					rows[i].className = "dark";
				}
			}
		}
	}
}

//-----------------------------------------------


















//-----------------------------------------------------------------------------
//--- SNOWING -----------------------------------------------------------------
//-----------------------------------------------------------------------------

// CREDITS:
// Snowmaker Copyright (c) 2003 Peter Gehrig. All rights reserved.
// Distributed by http://www.hypergurl.com
// Permission given to use the script on webpages provided that this notice remains as is.
var snowmax = 35;                                //nr of snowflakes (more than 30 - 40 not recommended)
var snowcolor = new Array("#aaaacc","#ddddFF","#ccccDD"); //Snow colors. Add as you like
var snowtype = new Array("Arial Black","Arial Narrow","Times","Comic Sans MS"); //Fonts that create snowflakes. Add as many as you like
var snowletter = "*";                            //Letter that creates snowflake (recommended:*)
var sinkspeed = 0.6;                             //Speed of sinking (recommended: 0.3 to 2)
var snowmaxsize = 22;                            //Maximal-size of snowflakes
var snowminsize = 8;                             //Minimal-size of snowflakes
var snowingzone = 1;                             //Snowing-zone (1=all-over, 2=left, 3=center, 4=right)

/////////////////////////////////////////////////
// END CONFIGURATION ////////////////////////////

var snow = new Array();
var marginbottom;
var marginright;
var timer;
var i_snow = 0;
var x_mv = new Array();
var crds = new Array();
var lftrght = new Array();
var browserinfos = navigator.userAgent;
var ie5 = document.all && document.getElementById && !browserinfos.match(/Opera/);
var ns6 = document.getElementById && !document.all;
var opera = browserinfos.match(/Opera/);
var browserok = ie5 || ns6 || opera;

function randommaker(range) {
	rand = Math.floor(range*Math.random());
	return rand
}
function initsnow() {
	if (ie5 || opera) {
		marginbottom = document.body.clientHeight;
		marginright = document.body.clientWidth;
	} else if (ns6) {
		marginbottom = window.innerHeight;
		marginright = window.innerWidth;
	}
	var snowsizerange = snowmaxsize - snowminsize;
	for (i=0; i<=snowmax; i++) {
		crds[i] = 0;
		lftrght[i] = Math.random()*15;
		x_mv[i] = 0.03 + Math.random()/10;
		snow[i] = document.getElementById("s"+i);
		snow[i].style.fontFamily = snowtype[randommaker(snowtype.length)];
		snow[i].size = randommaker(snowsizerange) + snowminsize;
		snow[i].style.fontSize = snow[i].size;
		snow[i].style.color = snowcolor[randommaker(snowcolor.length)];
		snow[i].sink = sinkspeed * snow[i].size / 5;
		if (snowingzone == 1) {
			snow[i].posx = randommaker(marginright-snow[i].size);
		}
		if (snowingzone == 2) {
			snow[i].posx = randommaker(marginright/2-snow[i].size);
		}
		if (snowingzone == 3) {
			snow[i].posx = randommaker(marginright/2-snow[i].size) + marginright/4;
		}
		if (snowingzone == 4) {
			snow[i].posx = randommaker(marginright/2-snow[i].size) + marginright/2;
		}
		snow[i].posy = randommaker(2*marginbottom-marginbottom-2*snow[i].size);
		snow[i].style.left = snow[i].posx;
		snow[i].style.top = snow[i].posy;
	}
	movesnow()
}
function movesnow() {
	for (i=0; i<=snowmax; i++) {
		crds[i] += x_mv[i];
		snow[i].posy += snow[i].sink;
		snow[i].style.left = snow[i].posx + lftrght[i]*Math.sin(crds[i]);
		snow[i].style.top = snow[i].posy;
		if (snow[i].posy >= marginbottom-2*snow[i].size || parseInt(snow[i].style.left) > (marginright-3*lftrght[i])) {
			if (snowingzone == 1) {
				snow[i].posx = randommaker(marginright-snow[i].size);
			}
			if (snowingzone == 2) {
				snow[i].posx = randommaker(marginright/2-snow[i].size);
			}
			if (snowingzone == 3) {
				snow[i].posx = randommaker(marginright/2-snow[i].size) + marginright/4;
			}
			if (snowingzone == 4) {
				snow[i].posx = randommaker(marginright/2-snow[i].size) + marginright/2;
			}
			snow[i].posy = 0;
		}
	}
	var timer = setTimeout("movesnow()",50);
}
/*
for (i=0;i<=snowmax;i++) {
	document.write("<span id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</span>");
}
if (browserok) {
	window.onload = initsnow;
}
*/
//-----------------------------------------------
