animationLock = false;
isIE = (navigator.userAgent.toLowerCase().indexOf("msie")!=-1);
stdBlockSize = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)?100:10;
gradience = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)?70:10;

k=0;

function gId(someId){return document.getElementById(someId);}

function fadeStart(targetImg,thisFadeFunction,thisEndState)
{
	if(!animationLock)
	{
		gId("arrowHome").style.visibility = "hidden";
		animationLock = true;
		targetElement = gId("myContainer1");
		backImage = new Image();
		backImage.src = targetImg;
		baseId = "element";
		endstateFunction = thisEndState;
		fadeSomeWay(thisFadeFunction);
	}
}

function outside_atrium() { setFader("bottomFader","/shared/wow-com/images/underdev/implemented/bosstiary/" + lang + "/siege.jpg",bottomToTop,atrium_outside,335,530); setFader("topFader","/shared/wow-com/images/underdev/implemented/bosstiary/" + lang + "/keepers.jpg",topToBottom,atrium_mainhall,340,5); setAntechamberBosses() }
function atrium_outside() { setFader("topFader","/shared/wow-com/images/underdev/implemented/bosstiary/" + lang + "/antechamber.jpg",topToBottom,outside_atrium,454,0); hideFader("bottomFader"); setSiegeBosses() }
function atrium_mainhall() { setFader("bottomFader","/shared/wow-com/images/underdev/implemented/bosstiary/" + lang + "/antechamber.jpg",bottomToTop,mainhall_atrium,478,555); setFader("topFader","/shared/wow-com/images/underdev/implemented/bosstiary/" + lang + "/spark.jpg",topToBottom,mainhall_spark,240,190); setFader("leftFader","/shared/wow-com/images/underdev/implemented/bosstiary/" + lang + "/descent.jpg",leftToRight,mainhall_descent,263,464); setKeepersBosses() }
function mainhall_atrium() { outside_atrium(); hideFader("leftFader") }
function mainhall_spark() { setFader("bottomFader","/shared/wow-com/images/underdev/implemented/bosstiary/" + lang + "/keepers.jpg",bottomToTop,spark_mainhall,400,520); hideFader("leftFader"); hideFader("topFader"); setSparkBosses() }
function mainhall_descent() { setFader("rightFader","/shared/wow-com/images/underdev/implemented/bosstiary/" + lang + "/keepers.jpg",rightToLeft,descent_mainhall,330,311+2); hideFader("leftFader"); hideFader("topFader"); hideFader("bottomFader"); setDescentBosses() }
function spark_mainhall() { atrium_mainhall(); }
function descent_mainhall() { atrium_mainhall(); hideFader("rightFader"); }

function setSiegeBosses() { setBoss("xt",471,81); setBoss("razor",528,163); setBoss("ignis",370,161); setBoss("flamo",477,245); }
function setAntechamberBosses() { setBoss("kologarn",359,69); setBoss("algalon",780,295); setBoss("council",140,366); }
function setKeepersBosses() { setBoss("aurayia",498,366); setBoss("hodir",656,411); setBoss("thoooor",708,310); setBoss("freya",519,140); }
function setSparkBosses() { setBoss("mimiron",422,260); }
function setDescentBosses() { setBoss("vezax",556,389); setBoss("yoggie",669,258); }

function setBoss(thisBoss,thisX,thisY)
{
	var newBossElement = document.createElement("div");
	newBossElement.className = "bossElement";
	newBossElement.style.left = (thisX>0)?thisX+"px":thisX+320+"px";
	var leftShow = (thisX+335>902)?thisX-350:thisX+60;
	newBossElement.style.top = thisY+"px";
	newBossElement.onmouseover = function(){setLolBoss(thisBoss,leftShow,thisY+10)};
	newBossElement.onmouseout = function(){hideLolBoss()};
	newBossElement.onclick = function(){hydraVision("/shared/wow-com/images/underdev/implemented/bosstiary/" + thisBoss+ ".jpg")};
	targetElement.appendChild(newBossElement);
}

function setFader(thisFader,thisImage,thisFadeFunction,thisEndState,fLeft,fTop)
{
	var targetFader = gId(thisFader);
	targetFader.style.display = "block";
	targetFader.style.left = fLeft+"px";
	targetFader.style.top = fTop+"px";
	targetFader.onclick = function(){ fadeStart(thisImage,thisFadeFunction,thisEndState) }
}

function hideFader(thisFader) { gId(thisFader).style.display = "none"; }

function newSegment(thisWidth,thisHeight,bgLeft,bgTop,offsetTop,offsetLeft,thisID)
{
	var newElement = document.createElement("div");
	newElement.style.backgroundImage = "url("+backImage.src+")";
	newElement.style.backgroundPosition = bgLeft+"px "+bgTop+"px";
	newElement.style.height = thisHeight+"px";
	newElement.style.width = thisWidth+"px";
	newElement.style.opacity = "0";
	newElement.style.filter = "alpha(opacity=0)"
	newElement.className = "0";
	newElement.style.position = "absolute";
	newElement.style.top = offsetTop+"px";
	newElement.style.left = offsetLeft+"px";
	newElement.id = baseId+thisID;
	return newElement;
}

//thisWidth,thisHeight,bgLeft,bgTop,offsetTop,offsetLeft,thisID

function leftToRight(i) {targetElement.appendChild(newSegment(stdBlockSize,backImage.height,(-i*stdBlockSize),0,0,(i*stdBlockSize),i));}
function rightToLeft(i) {targetElement.appendChild(newSegment(stdBlockSize,backImage.height,(-backImage.width+i*stdBlockSize+stdBlockSize),0,0,(backImage.width-i*stdBlockSize-stdBlockSize),i));}
function topToBottom(i) {targetElement.appendChild(newSegment(backImage.width,stdBlockSize,0,(-i*stdBlockSize),(i*stdBlockSize),0,i));}
function bottomToTop(i) {targetElement.appendChild(newSegment(backImage.width,stdBlockSize,0,(-backImage.height+i*stdBlockSize+stdBlockSize),(backImage.height-i*stdBlockSize-stdBlockSize),0,i));}

function fadeSomeWay(someDirection)
{
	if(backImage.complete)
	{
		numSegments = Math.ceil(backImage.width/stdBlockSize);
		for(i=0;i<numSegments;i++)
		{
			someDirection(i);
		}
		faderArray = new Array();
		faderCounter = 0;
		for(j=0;j<numSegments;j++)
		{
			window.setTimeout("launchFade("+j+")",j*gradience);
		}
	}
	else window.setTimeout("fadeSomeWay("+someDirection+")",50);
}

function launchFade(thisElement)
{
	faderArray[faderCounter++] = window.setInterval("fadeSegment("+thisElement+")",10);
}

fadeSegment = (!isIE)?function(thisElement)
{
	var currentSegment = gId(baseId+thisElement);
	if(currentSegment.style.opacity >= 1)
	{
		window.clearInterval(faderArray[thisElement]);
		if(thisElement==numSegments-1)
		{
			targetElement.style.backgroundImage = "url("+backImage.src+")";
			targetElement.innerHTML = "";
			endstateFunction();
			gId("arrowHome").style.visibility = "visible";
			animationLock = false;
		}
	}
	else
	{
		currentSegment.style.opacity = eval(currentSegment.style.opacity)+0.04;
	}
}:
function(thisElement)
{
	var currentSegment = gId(baseId+thisElement);
	var ieOpacityCrutch = currentSegment.className;
	if(ieOpacityCrutch == "100")
	{
		window.clearInterval(faderArray[thisElement]);
		if(thisElement==numSegments-1)
		{
			targetElement.style.backgroundImage = "url("+backImage.src+")";
			targetElement.innerHTML = "";
			endstateFunction();
			gId("arrowHome").style.visibility = "visible";
			animationLock = false;
		}
	}
	else
	{
		currentSegment.className = 10+parseInt(currentSegment.className);
		currentSegment.style.filter = "alpha(opacity="+currentSegment.className+")";
	}
}

function setLolBoss(thisBoss,thisLeft,thisTop)
{
	gId("loreBox").innerHTML = "<div class='lolthumb'><div><img src='/shared/wow-com/images/underdev/implemented/bosstiary/"+thisBoss+"-thumb.jpg'/></div></div>"+bossLol[thisBoss];
	gId("lolBoss").style.top = (thisTop+gId("lolBoss").offsetHeight<640)?thisTop+"px":640-gId("lolBoss").offsetHeight+"px";
	gId("lolBoss").style.left = thisLeft+"px";
	gId("lolBoss").style.visibility = "visible";
}

function hideLolBoss() { gId("lolBoss").style.visibility = "hidden"; }

//localization
