
// window.onload

(function() {

	var DEFAULT_TIMEOUT = 10000;

	$(function() {
		$("p > a").filter(
			function() {
				return this.hostname && this.hostname !== location.hostname;
			}
		).addClass("external");
	});


	function getTimeoutValue(currElement, nextElement, opts, isForward) {

	//	alert("timeout");

	//	var debug = document.getElementById("cycle-debug");

		var marker = "duration-";

		if (nextElement && nextElement.className) {

			var i = nextElement.className.indexOf(marker) + marker.length;
			var j = nextElement.className.indexOf(" ", i);

			var duration = nextElement.className.substring(i,j);

			var duration = nextElement.className.match(/duration\-(\d+|auto)/)[1];

			var timeout = (duration.replace("auto", "0") * 1000) || DEFAULT_TIMEOUT;

		//	$("#cycle-debug").html("timeout: " + timeout + " for " + nextElement.id);

			return timeout;

		} else {
			return DEFAULT_TIMEOUT;
		}
	}


	$(function() {
		$("#headline").cycle({
			pause: true,
			speed: 500,
			timeout: DEFAULT_TIMEOUT,
			timeoutFn: getTimeoutValue,
			fx: "cover"
		});
	});

})();