
// Inserts Event ID
 function createEventID(){
 	var Create = new Date();
 	var dYear = Create.getYear();
 	var dMonth = Create.getMonth();
	var dDay = Create.getDay();
	var dMinutes = Create.getMinutes();
	var dSeconds = Create.getSeconds();
	dMonth++; // Add one to month

	if (dMonth <=9){dMonth="0" + dMonth;}
	if(dDay <=9){dDay="0" + dDay;}
	if(dMinutes <=9){dMinutes="0" + dMinutes;}
	if(dSeconds <=9){dSeconds="0" + dSeconds;}
 	window.document.frmInsertTime.txtEventID.value=dYear+ "" + dMonth + "" + dDay + "" + dMinutes + "" + dSeconds;// + ":" + dDay + ":" + dMinutes; // Display fields
 }

   // Puts manually inputted Start field into Hidden Start field
 function fillText(strText,objFormField){
 	objFormField.value="";
 	objFormField.value+=strText;
 }
// Formats date and time to work with calender scipt 
function Date_Format(){
var d = new Date();
var day = d.getDay();
var month = (d.getMonth() + 1);
var date_day = d.getDate();
var year = d.getFullYear();
// Get days of the week
if (day==0) {day = "Sun";}
else if (day==1) {day = "Mon";}
else if (day==2) {day = "Tues";}
else if (day==3) {day = "Wed";}
else if (day==4) {day = "Thurs";}
else if (day==5) {day = "Fri";}
else if (day==6) {day = "Sun";}
// Get months of the year
if (month==01) {month = "Jan";}
else if (month==02) {month = "Feb";}
else if (month==03) {month = "Mar";}
else if (month==04) {month = "Apr";}
else if (month==05) {month = "May";}
else if (month==06) {month = "Jun";}
else if (month==07) {month = "Jul";}
else if (month==08) {month = "Aug";}
else if (month==09) {month = "Sep";}
else if (month==10) {month = "Nov";}
else if (month==11) {month = "Dec";}

var hours = (d.getHours() < 10 ? '0' : '') + d.getHours();
var minutes = (d.getMinutes() < 10 ? '0' : '') + (d.getMinutes());
var seconds = (d.getSeconds() < 10 ? '0' : '') + (d.getSeconds());
	return ( day + ' ' + month + " " + date_day + " " + year + " " + hours + ":" + minutes + ":" + seconds );
} 
    // Adds the current date to Start Time Fields (3) 
 function fillStartTime(){
	if (window.document.frmInsertTime.targetStartTime.value == "") //
	{ 
 	window.document.frmInsertTime.targetStartTime.value=Date_Format(); // Display fields
 	window.document.frmInsertTime.targethdnStartTime.value=Date_Format();
 	window.document.frmInsertTime.targethdnUndoStartTime.value=Date_Format();
	}
	else
	{
	window.document.frmInsertTime.targetStartTime.value=""; // Empty Start field 1
 	window.document.frmInsertTime.targethdnStartTime.value=""; // Empty Start field 2
	}
 }
 
    // Undo the Start Button Toggle Delete feature
 function fillUndoStartTime(){
	if (window.document.frmInsertTime.targetStartTime.value != "") //
	{ 
	window.document.frmInsertTime.targetStartTime.value=""; // Empty Start fields
	}
	else
	{
	window.document.frmInsertTime.targetStartTime.value+=window.document.frmInsertTime.targethdnUndoStartTime.value; // Empty Start fields
 	window.document.frmInsertTime.targethdnStartTime.value+=window.document.frmInsertTime.targethdnUndoStartTime.value;
	}
 }
    // Adds the current date to Stop Time Fields (3) 
 function fillStopTime(){
	if (window.document.frmInsertTime.targetStopTime.value == "") //
	{ 
 	window.document.frmInsertTime.targetStopTime.value=Date_Format(); // Display fields
 	window.document.frmInsertTime.targethdnStopTime.value=Date_Format();
 	window.document.frmInsertTime.targethdnUndoStopTime.value=Date_Format();
	}
	else
	{
	window.document.frmInsertTime.targetStopTime.value=""; // Empty Stop field 1
 	window.document.frmInsertTime.targethdnStopTime.value=""; // Empty Stop field 2
	}
 }
 
    // Undo the Stop Button Toggle Delete feature
 function fillUndoStopTime(){
 	var d = new Date();
	if (window.document.frmInsertTime.targetStopTime.value != "") //
	{ 
	window.document.frmInsertTime.targetStopTime.value=""; // Empty Stop fields
	}
	else
	{
	window.document.frmInsertTime.targetStopTime.value+=window.document.frmInsertTime.targethdnUndoStopTime.value; // Empty Stop fields
 	window.document.frmInsertTime.targethdnStopTime.value+=window.document.frmInsertTime.targethdnUndoStopTime.value;
	}
 }
 
   //     // Undo the Stop Button Toggle Delete feature
 function fillUndoStopTime(){
 	var d = new Date();
	if (window.document.frmInsertTime.targetStopTime.value != "") //
	{ 
	window.document.frmInsertTime.targetStopTime.value=""; // 
	}
	else
	{
	window.document.frmInsertTime.targetStopTime.value+=window.document.frmInsertTime.targethdnUndoStopTime.value; // 
 	window.document.frmInsertTime.targethdnStopTime.value+=window.document.frmInsertTime.targethdnUndoStopTime.value;
	}
 }
 
    // Calculate Hours
 function fillCalculateTime(){
	var startString=window.document.frmInsertTime.targetStartTime.value;
	var endString=window.document.frmInsertTime.targetStopTime.value;
	
	var start = new Date(startString);
	var end = new Date(endString);
	
	var time_dif = (end.getTime()-start.getTime());
	var seconds_dif = (time_dif/1000);
	if (seconds_dif < 1 ){seconds_dif = 0;}

	var minutes_dif = (seconds_dif/60);
	if (minutes_dif < 1 ){minutes_format = 0;}

	var hours_dif = (minutes_dif/60);
	if (hours_dif < 1 ){hours_format = 0;}

	var dours = (hours_dif*100000)/100000; // Converts to decimal hours

//  The following breaks down hours, minutes and seconds
	hours = parseInt(hours_dif);
	hours_dif -= parseInt(hours_dif); hours_dif *= 60;
	minutes = parseInt(hours_dif);
	hours_dif -= parseInt(hours_dif); hours_dif *= 60;
	seconds = parseInt(hours_dif);

	window.document.frmInsertTime.targetCalculateTime.value=dours; // Writes decimal hours
	window.document.frmInsertTime.targetUserCalculateTime.value="";
	window.document.frmInsertTime.targetUserCalculateTime.value=hours + " hrs " + minutes + " min " + seconds + " sec";
	}

//function onKeyPress () {
//var keycode;
//if (window.event) keycode = window.event.keyCode;
//else if (e) keycode = e.which;
//else return true;
//if (keycode == 13) {
//alert("Please Click on the Submit button to send this");
//return false
//}
//return true 
//}
//document.onkeypress = onKeyPress;


// Start Tab within Textarea
function setSelectionRange(input, selectionStart, selectionEnd) {
  if (input.setSelectionRange) {
    input.focus();
    input.setSelectionRange(selectionStart, selectionEnd);
  }
  else if (input.createTextRange) {
    var range = input.createTextRange();
    range.collapse(true);
    range.moveEnd('character', selectionEnd);
    range.moveStart('character', selectionStart);
    range.select();
  }
}

function replaceSelection (input, replaceString) {
	if (input.setSelectionRange) {
		var selectionStart = input.selectionStart;
		var selectionEnd = input.selectionEnd;
		input.value = input.value.substring(0, selectionStart)+ replaceString + input.value.substring(selectionEnd);
    
		if (selectionStart != selectionEnd){ 
			setSelectionRange(input, selectionStart, selectionStart + 	replaceString.length);
		}else{
			setSelectionRange(input, selectionStart + replaceString.length, selectionStart + replaceString.length);
		}

	}else if (document.selection) {
		var range = document.selection.createRange();

		if (range.parentElement() == input) {
			var isCollapsed = range.text == '';
			range.text = replaceString;

			 if (!isCollapsed)  {
				range.moveStart('character', -replaceString.length);
				range.select();
			}
		}
	}
}


// We are going to catch the TAB key so that we can use it, Hooray! Does not woprk in IE
function addListener(){document.getElementById('txtareaEventNotes').addEventListener('keypress', InsertTab, true);}
function InsertTab(e){
if (e.keyCode==9){
e.preventDefault()
sText=new String(document.getElementById('txtareaEventNotes').value+'\t')
document.getElementById('txtareaEventNotes').value=sText
e.stopPropagation();
}
}
// End Tab with Textarea
//-->

<!-- COLOPHON -->
<!--  -->
<!-- TITLE -->
<!-- TempersFewGit v 2.1 (ISO 8601 Time/Date script)  -->
<!--  -->
<!-- OBJECTIVE -->
<!-- Javascript script to detect the time zone where a browser -->
<!-- is and display the date and time in accordance with the  -->
<!-- ISO 8601 standard. -->
<!--  -->
<!-- AUTHOR -->
<!-- John Walker  -->
<!-- http://321WebLiftOff.net -->
<!-- jfwalker@ureach.com -->
<!--  -->
<!-- ENCOMIUM -->
<!-- Thanks to Stephen Pugh for his help. -->
<!--  -->
<!-- CREATED -->
<!-- 2000-09-15T09:42:53+01:00  -->
<!--  -->
<!-- REFERENCES -->
<!-- For more about ISO 8601 see: -->
<!-- http://www.w3.org/TR/NOTE-datetime -->
<!-- http://www.cl.cam.ac.uk/~mgk25/iso-time.html -->
<!--  -->
<!-- COPYRIGHT -->
<!-- This script is Copyright  2000 JF Walker All Rights  -->
<!-- Reserved but may be freely used provided this colophon is  -->
<!-- included in full. -->
<!--  -->
<!-- ENDS -->


<!-- Begin
function isodatetime() {
var today = new Date();
var year  = today.getYear();
if (year < 2000)    // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
var month = today.getMonth() + 1;
var day  = today.getDate();
var hour = today.getHours();
var hourUTC = today.getUTCHours();
var diff = hour - hourUTC;
var hourdifference = Math.abs(diff);
var minute = today.getMinutes();
var minuteUTC = today.getUTCMinutes();
var minutedifference;
var second = today.getSeconds();
var timezone;
if (minute != minuteUTC && minuteUTC < 30 && diff < 0) { hourdifference--; }
if (minute != minuteUTC && minuteUTC > 30 && diff > 0) { hourdifference--; }
if (minute != minuteUTC) {
minutedifference = ":30";
}
else {
minutedifference = ":00";
}
if (hourdifference < 10) { 
timezone = "0" + hourdifference + minutedifference;
}
else {
timezone = "" + hourdifference + minutedifference;
}
if (diff < 0) {
timezone = "-" + timezone;
}
else {
timezone = "+" + timezone;
}
if (month <= 9) month = "0" + month;
if (day <= 9) day = "0" + day;
if (hour <= 9) hour = "0" + hour;
if (minute <= 9) minute = "0" + minute;
if (second <= 9) second = "0" + second;
time = "ISO 8601 D " + year + "-" + month + "-" + day + " T " + hour + ":" + minute + ":" + second + timezone;
document.isoclock.display.value = time;
window.setTimeout("isodatetime();", 500);
}
//  End -->
<!-- Start
//Select the text in form elements text boxes
//  End -->
