// JavaScript Document
<!--
//Time Functions
var xtime = ''
var xtime1 = ''
var xmin = 0
var xhr = 0
var xtimes = ''
var xhrs = ''
var xmins = ''
var xmin1 = 0
var xhr1 = 0
var xtimes1 = ''
var xhrs1 = ''
var xmins1 = ''
var xarray 
var xarray1
var okay = 0
function check_date(field){
	var checkstr = "0123456789";
	var DateField = field;
	var Datevalue = "";
	var DateTemp = "";
//	var seperator = ".";
	var seperator = "/";
	var day;
	var month;
	var year;
	var xyear;
	var leap = 0;
	var err = 0;
	var i;
	   err = 0;
	   DateValue = DateField.value;
	   /* Delete all chars except 0..9 */
	   for (i = 0; i < DateValue.length; i++) {
		  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
		     DateTemp = DateTemp + DateValue.substr(i,1);
		  }
	   }
	   DateValue = DateTemp;
	   /* Always change date to 8 digits - string*/
	   /* if year is entered as 2-digit / always assume 20xx */
	   if (DateValue.length == 6) {
	      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
//	   if (DateValue.length == 8) {
//	      DateValue = DateValue.substr(0,4) + DateValue.substr(6,2); }
	   if (DateValue.length != 8) {
//	   if (DateValue.length != 6) {
	      err = 19;}
	   /* year is wrong if year = 0000 */
	   year = DateValue.substr(4,4);
	   xyear = DateValue.substr(6,2);
//	   year = DateValue.substr(4,2);
	   if (year == 0) {
	      err = 20;
	   }
	   /* Validation of month*/
	   month = DateValue.substr(2,2);
	   if ((month < 1) || (month > 12)) {
	      err = 21;
	   }
	   /* Validation of day*/
	   day = DateValue.substr(0,2);
	   if (day < 1) {
	     err = 22;
	   }
	   /* Validation leap-year / february / day */
	   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
	      leap = 1;
	   }
	   if ((month == 2) && (leap == 1) && (day > 29)) {
	      err = 23;
	   }
	   if ((month == 2) && (leap != 1) && (day > 28)) {
	      err = 24;
	   }
	   /* Validation of other months */
	   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
	      err = 25;
	   }
	   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
	      err = 26;
	   }
	   /* if 00 ist entered, no error, deleting the entry */
	   if ((day == 0) && (month == 0) && (year == 00)) {
	      err = 0; day = ""; month = ""; year = ""; seperator = "";
	   }
	   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
	   if (err == 0) {
//	      DateField.value = day + seperator + month + seperator + year;
	      DateField.value = day + seperator + month + seperator + xyear;
	   }
	   /* Error-message if err != 0 */
	   else {
	      alert("Date is incorrect!");
	      DateField.select();
		  DateField.focus();
	   }
}
function IsValidTime(timeStr) {
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
alert("You must specify AM or PM.");
return false;
   }
}
if  (hour > 12 && ampm != null) {
alert("You can't specify AM or PM for military time.");
return false;
}
if (minute<0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
return false;
}
function xtimecheck(field){
	if (field.value == ''){return}
//		if (field.value == xtime){return}}
	rext = /\b.\b/
	if (field.value.indexOf('.') > 0){
		field.value = field.value.replace(rext,':')}
	if (field.value.indexOf(':') == -1){
		okay = 1
		alert ('Invalid Time')
		return okay}
	xarray = field.value.split(':')
	xhr = xarray[0]
	xmin = xarray[1]
	if (xhr <0){xhr = 0}
	if (xmin <0){xmin = 0}
	if (xhr > 24){
		okay = 1
		alert ('Incorrect Hours')
		return okay}
	if (xmin > 59){
		okay = 1
		alert ('Incorrect Minutes')
		return okay}
	xhrs = xhr.toString()
	xmins = xmin.toString()
	re = /[/D]/
	if (re.test(xmins)){xmins='00'}
	if (xmins==''){xmins='00'}
	if(xhrs.length ==1){xhrs='0'+xhrs}
	if(xmins.length ==0){xmins='0'+xmins}
	if(xmins.length ==1){xmins='0'+xmins}
	return okay
}
function xtimeadd1(){
	++xhr
	xhrs1 = xhr.toString()
	xmins1 = xmin.toString()
	if (re.test(xmins1)){xmins1='00'}
	if (xmins1==''){xmins1='00'}
	if(xhrs1.length ==1){xhrs1='0'+xhrs1}
	if(xmins1.length ==0){xmins1='0'+xmins1}
	if(xmins1.length ==1){xmins1='0'+xmins1}
}
function xtimeqty(){
	xarray = xtime.split(':')
	xhr = xarray[0]
	xmin = xarray[1]
	xarray1 = xtime1.split(':')
	xhr1 = xarray1[0]
	xmin1 = xarray1[1]
// not sure how, but it works without this!
//	if (xmin > xmin1){
//		--xhr1
//		xmin1 = xmin1 + 60}
//		xmin1 + 60}
	okay = 0
	if (xhr > xhr1){
		okay = 1
		alert ('End Time before Start Time')
		return okay}
	xqty = (xhr1 - xhr) + ((xmin1 - xmin) / 60)
	return xqty
}
//Cookie Functions
function WriteCookie(name, value, days){
    if(days){
        (time = new Date()).setTime(new Date().getTime()+days*24*60*60*1000);
        var exp = '; expires='+time.toGMTString();
    }else{
        var exp='';
    }
    document.cookie=name+"="+value+exp+"; path=/";
}

function ReadCookie(name){
	    var cookies = document.cookie.split(';');
	    for(var i=0; i<cookies.length; i++){
	        var cookie=cookies[i].replace(/^\s+/, '');
	        if (cookie.indexOf(name+'=')==0) return cookie.substring(name.length+1);
		}
		return ''
}

function EraseCookie(name){
    WriteCookie(name, "", -1)
}

//Utility Functions
//Trim a field
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}
//Uppercase a field
function upp(field){
	field.value = field.value.toUpperCase()
}
//get rid of $ sign when doing calculations
function nodollar(field){
	field = field.substr (field.indexOf('$') + 1,7)
}

var imgs = new Array(); var imgcnt = 0; var thisimg = 0;
imgs[imgcnt++] = "images/photos/D01.jpg";
imgs[imgcnt++] = "images/photos/D02.jpg";

//function rotate() {
//if (document.images) {
//thisimg++;
//if (thisimg >= imgcnt) thisimg = 0;
//document.rollimg.src = imgs[thisimg];
//setTimeout("rotate();",5000);
//}
//}
//setTimeout("rotate();",10000); 

-->


