<!-- start
// (c) 2000-2006 ricocheting.com

// format: dateFuture = new Date(year,month-1,day,hour,min,sec)
//dateFuture = new Date(2003,04,15,0,0,00)

var previewdateFuture="";

//################################
// function: generate()
// decs: creates the source depending out textboxes
function generate(){
var f=document.myForm;
string="";

var reYear = /^\d{4,4}$/
var reDay = /^\d{1,2}$/

//test year
if(!reYear.test(f.year.value)){
	alert("Please enter the four digit year");
	f.year.focus();
	f.year.select();
	return;
}else{
	string+=f.year.value+",";
}

//month
	string+=f.month.value+",";

//test day
if(!reDay.test(f.day.value) || f.day.value < 1 || f.day.value > 32){
	alert("Please enter the day of month (1-31)");
	f.day.focus();
	f.day.select();
	return;
}else{
	string+=f.day.value+",";
}

//test hour
if(!reDay.test(f.hour.value) || f.hour.value < 1 || f.hour.value > 12){
	alert("Please enter the 12-hour time to expire (1-12)");
	f.hour.focus();
	f.hour.select();
	return;
}else{
	string+=(eval(f.hour.value +"+"+ f.ampm[f.ampm.selectedIndex].value))+",";
}

//test min
if(!reDay.test(f.min.value) || f.min.value < 0 || f.min.value > 59){
	alert("Please enter the minute to expire (0-59)");
	f.min.focus();
	f.min.select();
	return;
}else{
	string+=f.min.value+",";
}

//test sec
if(!reDay.test(f.sec.value) || f.sec.value < 0 || f.sec.value > 59){
	alert("Please enter the second to expire (0-59)");
	f.sec.focus();
	f.sec.select();
	return;
}else{
	string+=f.sec.value;
}

previewdateFuture = eval("new Date("+string+")");

f.output.value='<script type="text/javascript">\n'+
'<!-- //start\n\n'+
'//######################################################################################\n'+
'// Author: ricocheting.com\n'+
'// For: public release (freeware)\n'+
'// Date: 4/24/2003 (update: 5/15/2009)\n'+
'// Description: displays the amount of time until the "dateFuture" entered below.\n\n\n'+
'// NOTE: the month entered must be one less than current month. ie; 0=January, 11=December\n'+
'// NOTE: the hour is in 24 hour format. 0=12am, 15=3pm etc\n'+
'// format: dateFuture = new Date(year,month-1,day,hour,min,sec)\n'+
'// example: dateFuture = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pm\n\n'+
'dateFuture = new Date('+string+');\n\n'+
'// TESTING: comment out the line below to print out the "dateFuture" for testing purposes\n'+
'//document.write(dateFuture +"<br />");\n\n\n'+
'//###################################\n'+
'//nothing beyond this point\n'+
'function GetCount(){\n\n'+
'	dateNow = new Date();									//grab current date\n'+
'	amount = dateFuture.getTime() - dateNow.getTime();		//calc milliseconds between dates\n'+
'	delete dateNow;\n\n'+
'	// time is already past\n'+
'	if(amount < 0){\n'+
'		document.getElementById(\'countbox\').innerHTML="Now!";\n'+
'	}\n'+
'	// date is still good\n'+
'	else{\n'+
'		days=0;hours=0;mins=0;secs=0;out="";\n\n'+
'		amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs\n\n'+
'		days=Math.floor(amount/86400);//days\n'+
'		amount=amount%86400;\n\n'+
'		hours=Math.floor(amount/3600);//hours\n'+
'		amount=amount%3600;\n\n'+
'		mins=Math.floor(amount/60);//minutes\n'+
'		amount=amount%60;\n\n'+
'		secs=Math.floor(amount);//seconds\n\n'+
'		if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}\n'+
'		if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}\n'+
'		if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}\n'+
'		out += secs +" seconds";\n'+
'		document.getElementById(\'countbox\').innerHTML=out;\n\n'+
'		setTimeout("GetCount()", 1000);\n'+
'	}\n'+
'}\n\n'+
'window.onload=GetCount;//call when everything has loaded\n\n'+
'//-->\n'+
'</'+'script>\n'+
'<div id="countbox"></div>\n';

}//end function generate()


var worker=''+location.hostname+'';
if((worker.indexOf('ri'+'coche'+'ting.c'+'om') == -1)&&(location.hostname!='')&&(location.hostname!='localhost')){
document.write('or'+'igi'+'nal jav'+'ascr'+'ipt fr'+'om <a href="ht'+'tp://w'+'ww.ri'+
'coche'+'ting.c'+'om/j'+'s/">ri'+'coche'+'ting.c'+'om</a>');}



//################################
// function: init()
// decs: sticks in default vals in form when loads
function init(){
	var f=document.myForm;
	var now = new Date();

	f.year.value = now.getFullYear()
	f.month.selectedIndex = now.getMonth();
	f.day.value = now.getDate()+1;
	f.min.value = now.getMinutes();
	f.sec.value = now.getSeconds();

	//calc for now.getHours()=24-hour, display=12-hour clock
	if(now.getHours() > 12){
		f.hour.value = now.getHours()-12;
		f.ampm.selectedIndex=1
	}else{
		f.hour.value = now.getHours();
		f.ampm.selectedIndex=0
	}

	f.year.focus();
	f.year.select();

}//init()


//################################
// function: view()
// decs: displays a preview of the script
function view() {
		generate();
		PreviewGetCount();
}//view()


//###################################
//nothing beyond this point
function PreviewGetCount(){

	dateNow = new Date();									//grab current date
	amount = previewdateFuture.getTime() - dateNow.getTime();		//calc milliseconds between dates
	delete dateNow;

	// time is already past
	if(amount < 0){
		document.getElementById('previewcountbox').innerHTML="Your countdown expires: Now!";
	}
	// date is still good
	else{
		days=0;hours=0;mins=0;secs=0;out="";

		amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs

		days=Math.floor(amount/86400);//days
		amount=amount%86400;

		hours=Math.floor(amount/3600);//hours
		amount=amount%3600;

		mins=Math.floor(amount/60);//minutes
		amount=amount%60;

		secs=Math.floor(amount);//seconds

		if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
		if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
		if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}
		out += secs +" seconds";
		document.getElementById('previewcountbox').innerHTML="Your countdown expires: "+out;

		setTimeout("PreviewGetCount()", 1000);
	}
}

// End -->