	<!-- 
	//   All code, text, etc copyright 1996-2002 by Raymond Camden 
	//   Permission to use/copy/modify is not granted. Period.
	//   For those living in the shallow end of the gene pool.... 
	//   YOU MAY NOT COPY THIS. YOU MAY NOT BORROW THIS. YOU MAY NOT
	//   PUT THIS ON YOUR OWN WEB PAGE.
	// -->

if(top != self) top.location = "http://www.deathclock.com";

if(document.images) {
	obits = new Image(150,30); obits.src = "images/nav/obituaries.gif";
	obits_over = new Image(150,30); obits_over.src = "images/nav/obituaries.h.gif";
	will = new Image(150,29); will.src = "images/nav/yourwill.gif";
	will_over = new Image(150,29); will_over.src = "images/nav/yourwill.h.gif";
	mort = new Image(150,35); mort.src = "images/nav/mortuary.gif";
	mort_over = new Image(150,35); mort_over.src = "images/nav/mortuary.h.gif";
	letter = new Image(150,30); letter.src = "images/nav/deadletter.gif";
	letter_over = new Image(150,30); letter_over.src = "images/nav/deadletter.h.gif";
	testament = new Image(150,30); testament.src = "images/nav/testament.gif";
	testament_over = new Image(150,30); testament_over.src = "images/nav/testament.h.gif";
	prayer = new Image(150,25); prayer.src = "images/nav/yourprayer.gif";
	prayer_over = new Image(150,25); prayer_over.src = "images/nav/yourprayer.h.gif";
}

function over(img) {
	if(document.images) document [img].src = eval(img+"_over.src");
}

function off(img) {
	if(document.images) document [img].src = eval(img+".src");
}

var BASE = "http://www.deathclock.com/";

function windowob(name,src, width, height,options) {
	this.name = name;
	this.src = BASE + src;
	this.width = width;
	this.height = height;
	if(options) this.options = options;
}

var deathwin = new windowob('deathwin','dw.cfm',340,155,'toolbar=no,directories=no,status=no,scrollbars=no,resizable=yes,menubar=no')

function launchwindow(obj) {
var width = obj.width;
var height = obj.height;
var src = obj.src;

	if(obj.options) obj = window.open("",obj.name,"width="+width+",height="+height+","+obj.options);
	else obj = window.open("",obj.name,"toolbar=no,width="+width+",height="+height+",directories=no,status=no,scrollbars=yes,resizable=no,menubar=no");
	if(obj != null) {
		if(obj.opener == null) obj.opener = self;
		obj.location.href = src;
		if(document.images) obj.focus();
	}
}



function Valid(val,errormsg) {
       for(var y = 0; y<val.length; y++) {
               var letter = val.substring(y,y+1);
               if(letter < "0" || letter > "9") {
                       alert("Illegal character in "+errormsg+" field.\nOnly digits are allowed.");
                       return false;
               }       
       }
       return true;
}

function LeapYear(year) {
	if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) return true;
	else return false;
 }

function okForm(myday,mymonth,myyear) {
	//Check for valid numbers
	if(!Valid(myday,"Day")) {
		document.main.day.value = 1;
		return false;
	}

	if(!Valid(myyear,"Year")) {
		document.main.year.value = 1973;
		return false;
	}

	if(!myday || myday<1) {
		alert("You must specify what day you were born.");
		document.main.day.value = 1;
		return false;
	}
	if(myday > 31) {
		alert("The maximum number of days in a month is 31.\n"+myday+" is invalid.");
		document.main.day.value = 1;
		return false;
	}
	if((mymonth==3) || (mymonth==5) || (mymonth==8) || (mymonth==10)) {
		if(myday>30) {
		alert("Only 30 days in the month you have selected.");
		document.main.day.value = 30;
		return false;
		}
	}
	if((mymonth==1) && (myday > 29)) {
		alert("The maximum number of days in February is 29.\n"+myday+" is invalid.");
		document.main.day.value = 29;
		return false;
	}
	if( !LeapYear(myyear) && (mymonth == 1) && (myday > 28)) {
		alert("There are only 28 days in February "+myyear);
		document.main.day.value = 28;
		return false;
	}
	if(myyear < 1900) {
		alert("You must enter a year after 1899.");
		return false;
	}
	if(myyear > 2100) {
		alert("You must enter a year before 2100.");
		return false;
	}
	if(!myyear || myyear == 0) {
		alert("You must enter a year of birth.");
		document.main.year.value = 1973;
		return false;
	}

	return true;
}
	
function startDeath(form) {
	if(okForm(form.day.value,form.month.selectedIndex,form.year.value)) {
		trueSex = form.sex.options[form.sex.selectedIndex].text;
		trueMode = form.mode.options[form.mode.selectedIndex].text;
		deathwin.src = BASE + "dw.cfm?Day=" + form.day.value + "&Month=" + (form.month.selectedIndex+1) + "&Year=" + form.year.value + "&Sex=" + trueSex + "&Mode=" + trueMode;
		launchwindow(deathwin);
	}
	return false;
}