if (typeof Prototype != "undefined") {
	document.observe("dom:loaded", function() {
		if ($("protofade")) {
			if ($$("#protofade > li").length >= 2) {
				new Protofade('protofade', {
					randomize: true,
					delay: 8
				});
			}
		}
		
		
		$$(".box1.recent_jobs ol").each(function(list) {
		try {
			// Mark this list as scripted
			list.addClassName("scripted");
			
			list.items = list.select("li");
			
			if (list.items.length > 0) {
				list.currentItem = list.items[0];
				list.fadeInDuration = 0.5;
				list.fadeOutDuration = list.fadeInDuration;
				list.hovered = false;
				list.idleDuration = 6;
				list.intervalHandle = false;
				list.state = 0;
				list.states = [];
				
				list.observe("mouseover", function() {
					list.hovered = true;
				});
				
				list.observe("mouseout", function() {
					list.hovered = false;
				});
				
				list.moveNext = function() {
					//list.state++;
					list.state = (list.state + 1) % list.states.length;
					
					list.stateTime = (new Date()).getTime() / 1000;
				};
				
				list.halt = function() {
					if (list.intervalHandle) {
						clearInterval(list.intervalHandle);
						list.intervalHandle = false;
					}
				};
				
				// Reset the item prior to fade-in
				list.states.push(function() {
					list.currentItem.setOpacity(0);
					list.currentItem.style.display = "block";
					
					list.moveNext();
				});
				
				// Fade in
				list.states.push(function() {
					var progress = ((new Date()).getTime() / 1000 - list.stateTime) / list.fadeInDuration;
					
					if (progress >= 1) {
						progress = 1;
					}
					
					if (list.hovered) {
						progress = 1;
					}
					
					// Set opacity
					list.currentItem.setOpacity(progress);
						
					if (progress >= 1) {
						list.moveNext();
					}
				});
				
				// Sit idle
				list.states.push(function() {
					var progress = ((new Date()).getTime() / 1000 - list.stateTime) / list.idleDuration;
					
					if (!list.hovered && progress >= 1) {
						list.moveNext();
					}
				});
				
				// Fade out
				list.states.push(function() {
					if (list.hovered) {
						list.state = 1;
					} else {
						var progress = ((new Date()).getTime() / 1000 - list.stateTime) / list.fadeInDuration;
						
						if (progress >= 1) {
							progress = 1;
						}
						
						// Set opacity
						list.currentItem.setOpacity(1 - progress);
							
						if (progress >= 1) {
							list.moveNext();
						}
					}
				});
				
				// Clean up before looping
				list.states.push(function() {
					// Hide the current item
					list.currentItem.setOpacity(0);
					list.currentItem.style.display = "none";
					
					var nextItem;
					
					// Look for an immediate "next"
					nextItem = list.currentItem.next("li")
					if (!nextItem) {
						// Okay, so, look for one at the beginning
						nextItem = list.down("li");
						if (!nextItem) {
							// Well fine then, the list is now strangely empty, halt
							list.halt();
						}
					}
					
					if (nextItem) {
						list.currentItem = nextItem;
						
						list.moveNext();
					}
				});
				
				// Start
				if (list.states.length > 0) {
					list.intervalHandle = setInterval(function() {
						list.states[list.state]();
					}, 50);
				}
			}
		} catch (e) {
			alert("Unhandled Exception: " + e.getMessage());
		}
		});
	});
}

