// ##### start display date functionality #####

function displayDate() {
	var months = new Array(12);
	months[0]  = "Jan"; //"January";
	months[1]  = "Feb"; //"February";
	months[2]  = "Mar"; //"March";
	months[3]  = "Apr"; //"April";
	months[4]  = "May";
	months[5]  = "Jun"; //"June";
	months[6]  = "Jul"; //"July";
	months[7]  = "Aug"; //"August";
	months[8]  = "Sep"; //"September";
	months[9]  = "Oct"; //"October";
	months[10] = "Nov"; //"November";
	months[11] = "Dec"; //"December";
	var today = new Date();
	var lmonth = months[today.getMonth()];
	var date = today.getDate();
	var year = today.getYear();
	if (year < 2000 && year > 99) year = year + 1900;
	// should be taken out because of display problems on mac, aol 4
	document.write(lmonth + "&#160;" + date + ",&#160;" + year);
}

// ##### end display date functionality #####



// ##### start display year functionality #####

function displayYear() {
	var today = new Date();
	var year = today.getYear();
	if (year < 2000 && year > 99) year = year + 1900;
	// should be taken out because of display problems on mac, aol 4
	document.write(year);
}

// ##### end display year functionality #####



// ##### start fractal functionality #####

function enterFractal () {
	fractalWindow = window.open ('fractalShockwave.htm','fractalWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=250,height=289');
	fractalWindow.focus();
}

// ##### end fractal functionality #####



// ##### start floating window functionality #####

var newWindow;

function floatWindow(fileNm, wTitle, wWidth, wHeight) {
	//close existing window to prevent confusion from looking at an old page 
	//while new page is loading.
	if (newWindow) newWindow.close();
	//remember that spaces in feature list cause error in netscape!
	newWindow = window.open(fileNm, wTitle, 'screenX=10,screenY=10,top=10,left=10,toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+wWidth+',height='+wHeight);
	newWindow.focus();
	if (!newWindow.opener) newWindow.opener = self;
}

// ##### start popup functionality #####


// ##### start cookie functionality #####

	// Boolean variable specified if alert should be displayed if cookie exceeds 4KB
	var caution = false;

	// name - name of the cookie
	// value - value of the cookie
	// [expires] - expiration date of the cookie (if null: end of current session)
	// [path] - path for which the cookie is valid (if null: path of calling document)
	// [domain] - domain for which the cookie is valid (if null: domain of calling document)
	// [secure] - boolean value for secure transmission
	function setCookie(name, value, expires, path, domain, secure) {
		var newCookie = name + "=" + 
			escape(value) + 
			((expires) ? "; expires=" + expires.toGMTString() : "") + 
			((path) ? "; path=" + path : "") + 
			((domain) ? "; domain=" + domain : "") + 
			((secure) ? "; secure" : "");
		if (caution && (name + "=" + escape(value)).length >= 4000) {
			if (confirm("Cookie exceeds 4KB and will be cut!")) {
				document.cookie = newCookie;
			}
		} else {
			document.cookie = newCookie;
		}
	}

	// name - name of the desired cookie
	// * return string containing value of specified cookie or null if cookie does not exist
	function getCookie(name) {
		var cookieName = name + "=";
		var cookieNameSPos = document.cookie.indexOf(cookieName);
		if (cookieNameSPos == -1) {
			return null;
		} else {
			var cookieValueSPos = cookieNameSPos + cookieName.length
			var cookieValueEPos = document.cookie.indexOf(";", cookieValueSPos);
			if (cookieValueEPos == -1) {
				cookieValueEPos = document.cookie.length;
			}
			return unescape(document.cookie.substring(cookieValueSPos, cookieValueEPos));
		}
	}

	// name - name of the cookie
	// [path] - path of the cookie (must be same as path used to create cookie)
	// [domain] - domain of the cookie (must be same as domain used to create cookie)
	// * path and domain default if assigned null or omitted if no explicit argument proceeds
	function deleteCookie(name, path, domain) {
		if (getCookie(name)) {
			document.cookie = name + "=" + 
				((path) ? "; path=" + path : "") +
				((domain) ? "; domain=" + domain : "") +
				"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	}


// ##### end cookie functionality #####



// ##### start form functionality #####

function checkQuantity(f) {
	if(inputChecker(f.elements[0].value)) {
		return true;
	} else {
		alert("Please insert a positive number.");
		return false;
	}       
}

function inputChecker(s){
	if(s.length == 0 || s == "0") { 
		return false;
	} else {
		var pattern = /\D+/;
		var result = s.match(pattern);
		if(result) {
			return false;
		} else {
			return true;
		}
	}
}

function revert(f) {
	//alert("reseting form "+f);
	eval('document.forms["' + f + '"].reset()');
}

// ##### end form functionality #####




function doNothing() {
	return false;
}


