//ShieldZone Alternating Content (MSN rip-off, hehe) javascript

var rotationBox, rotationContent, focus, superfocus, rotationNavi, contentLinks, rotationBegin, currentDisplay;
currentDisplay = 0;
focus = 0;
superfocus = 0;

function startRotation(){
	rotationBegin = setInterval("rotation()","7500");
}

function rotationSetup() {
	rotationBox = document.getElementById("rotation");
	rotationContent = rotationBox.getElementsByTagName("div");
	rotationNavi = document.getElementById("rotationnavi");
	for (i=0; i<rotationContent.length; i++){
		var contentTitle = rotationContent[i].getAttribute("title");
		//var theOrder = rotationContent[i].getAttribute("order");
		var newLink = document.createElement("li");
		var stupidMozillaWontShowThePointer = document.createElement("a");
		stupidMozillaWontShowThePointer.href = "";
		stupidMozillaWontShowThePointer.innerHTML = contentTitle;
		stupidMozillaWontShowThePointer.onclick = pausePlayback;
		newLink.appendChild(stupidMozillaWontShowThePointer);
		newLink.setAttribute("order",i);
		newLink.className = "off";
		newLink.id = "navilink" + i;
		newLink.onmouseover = function(){focus = 1;};
		newLink.onmouseout = function(){focus = 0;};
		newLink.onclick = function(){superfocus = 0;};
		rotationNavi.appendChild(newLink);
	}
	contentLinks = rotationNavi.getElementsByTagName("li");
	contentLinks[0].className = "on";
	rotationBox.onmouseover = function(){focus = 1;};
	rotationBox.onmouseout = function(){focus = 0;};
	startRotation();
}

function rotation(){
	if ((focus == 0)&&(superfocus == 0)){
		if (currentDisplay > 3){
			currentDisplay = 0;
		}
		rotationContent[currentDisplay].className = "nowyoudont";
		contentLinks[currentDisplay].className = "off";
		currentDisplay++;
		if (currentDisplay > 3){
			currentDisplay = 0;
		}
		rotationContent[currentDisplay].className = "nowyouseeit";
		contentLinks[currentDisplay].className = "on";
	}
}

function pausePlayback(){
	focus = 1;
	clearInterval(rotationBegin);
	for (i=0; i<contentLinks.length; i++){
		contentLinks[i].className = "off";
	}
	this.parentNode.className = "on";
	rotationContent[currentDisplay].className = "nowyoudont";
	currentDisplay = this.parentNode.getAttribute("order");
	rotationContent[currentDisplay].className = "nowyouseeit";
	rotationBegin = setInterval("rotation()","5000");
	return false;
}

function init(){
		rotationSetup();
		preloadImages("/images/rotationNavi_01.jpg");
		preloadImages("/images/rotationNavi_02.jpg");
		preloadImages("/images/rotationNavi_03.jpg");
		preloadImages("/images/rotationNavi_04.jpg");
		preloadImages("/images/blank_rotation.jpg");
		preloadImages("/images/rockstic3rd.jpg");
		preloadImages("/images/MacBook-air-WEB-OT.jpg");
		preloadImages("/images/blank.gif");
	}
	
	var oldonload = window.onload;
	var initalize = function(){
	   init();
		};
	window.onload = function() {
	   initalize();
		if (oldonload) {
			oldonload();
	   }
	}
