// ==================== rotation script ====================
// using a cookie, loop through a different image with each visit to the home page


function rotateBanner(MAX_PHOTOS) {
	var names = new Array('firemen', 'chopper', 'emts');
	if (isNaN(num = getCookie('banner')) || num > MAX_PHOTOS) num = 0;
	++num;
	setCookie('banner', (num % MAX_PHOTOS));
	return names[--num];
}



function setCookie(name, value) {
	var date = new Date();
	var exp = date.getTime() + (90 * 60 * 60 * 1000);	// expires in 90 days
	date.setTime(exp);
	
	document.cookie = name + "=" + value + "; expires=" + date.toGMTString();
}


function getCookie(name) {
	name = name + '=';			// MacIE includes the equals sign
	var nameLen = name.length;
	var cookie = document.cookie;
	var cookieLen = cookie.length;
	
	var end;
	var start;
	var i = 0;
	while (i < cookieLen) {
		start = i + nameLen;
		if (cookie.substring(i, start) == name) {
			end = cookie.indexOf(";", start);
			if (end == -1) {
				end = cookie.length;
			}
			return unescape(cookie.substring(start, end));
		}
		i = cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return ""	// cookie not found
}
