addOnLoad(initLink);

function addOnLoad(newFunction) {
	var oldOnload = window.onload;
	
	if (typeof oldOnload == 'function') {
		window.onload = function() {
			if (oldOnload) { 
				oldOnload();
			}
			newFunction();
		}
	} else {
		window.onload = newFunction;
	}
}

var demoText = new Array(
	"LZPix: a picture browser that runs in both DHTML and Flash",
	"Calendar: a demo showing 4.0 functionality in DHTML and Flash",
	"YouTube: streaming video in Flash",
	"Weather: rendering XML data, DHTML or Flash",
	"Amazon Store: an RIA interpretation of a music store",
	"World Clock -- show the time in different locations"
);


var demoURL = new Array(
	"/node/409#LZPIX",
	"/node/409#Calendar",
	"/node/409#YouTube",
	"/node/409#Weather",
	"/node/409#AmazonStore",
	"/node/409#World Clock"
);

var thisDemo = 0;

function rotateDemo() {
	thisDemo++;
	
	if (thisDemo == demoText.length) {
		thisDemo = 0;
	}
	
	document.getElementById("demoTxt").innerHTML = demoText[thisDemo];

	setTimeout("rotateDemo()", 3 * 1000);
}


function newWindow() {
	var newWindow = window.open(demoURL[thisDemo])
	return false;
}


function initLink() {
	if (document.getElementById("demoTxt").parentNode.tagName == "A") {
		document.getElementById("demoTxt").parentNode.onclick = newWindow;
	}
	
	rotateDemo();
}
