function Lvl_FluidBrowser(winW,winH,endW,endH,wMod,hMod,fullscreen){ //ver1.0

 	if (fullscreen){
		endW = screen.availWidth;
		endH = screen.availHeight;
 }
	if (winW < endW) winW += wMod;
	if (winH < endH) winH += hMod;
	if (winW > endW) winW -= wMod;
	if (winH > endH) winH -= hMod;
	wLeft = (screen.availWidth / 2) - (winW / 2);
	wTop  = (screen.availHeight / 2) - (winH / 2);
	ns4   = (document.layers);
	ie5   = (document.all && document.getElementById);
	ns6   = (!document.all && document.getElementById);
	br    = "";
	 if (ns4)br = "NS";
	 if (ie5 || ns6)br = "MS";
	 if (br == "NS") {
     window.resizeTo(winW-10,winH-30);}
	 if (br == "MS") {
	 window.resizeTo(winW,winH);}
	 window.moveTo(wLeft,wTop);
	 if (winW != endW || winH != endH)
		    setTimeout('Lvl_FluidBrowser('+ winW + ', ' + winH + ', ' + endW + ', ' + endH + ', ' + wMod + ', ' + hMod + ', ' + fullscreen + ');',2);
}



function openCentered(URL,winName,features,center){
	if(center!="values"){
	a=new Array();
	a=center.split('|');
	t=((screen.height)-a[0])/2;
	l=((screen.width)-a[1])/2;
	features=features+",top="+t+",left="+l;
	}
	window.open(URL,winName,features);
}


// STEP 6

function Is() {
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ns2 = (this.ns && (this.major == 3));
	this.ns3 = (this.ns && (this.major == 3));
	this.ns4 = (this.ns && (this.major >= 4));
	this.ie   = (agent.indexOf("msie") != -1);
	this.ie3  = (this.ie && (this.major == 2));
	this.ie4  = (this.ie && (this.major >= 4));
	this.op3 = (agent.indexOf("opera") != -1);
}

var is = new Is()

if(is.ns4) {
	doc = "document";
	sty = "";
	htm = ".document"
} else if(is.ie4) {
	doc = "document.all";
	sty = ".style";
	htm = ""
}

// STEP 7

var count = 0;

function preLoad() {
	off = new Image();
	off.onload = loadCheck;
	off.src = "images/off.gif";

	on = new Image();
	on.onload = loadCheck;
	on.src = "images/on.gif";

	blank = new Image();
	blank.onload = loadCheck;
	blank.src = "images/blank.gif";

	magic = new Image();
	magic.onload = loadCheck;
	magic.src = "images/magic.gif";
}

function loadCheck() {
	count++;
	if(count == 4) {
		layerSetup();
	}
}

// STEP 8

function layerSetup() {
	offLyr = eval(doc + '["offLayer"]' + sty);
	offLyr.left = available_width-280;
	offLyr.top = 240;

	onLyr = eval(doc + '["onLayer"]' + sty);
	onLyr.left = available_width-280;
	onLyr.top = 240;

	mapLyr = eval(doc + '["mapLayer"]' + sty);
	mapLyr.left = available_width-280;
	mapLyr.top = 240;

	magicLyr = eval(doc + '["magicLayer"]' + sty);
	magicLyr.left = (available_width-353)/4;
	magicLyr.top = 380;

	visibilitySetup();
}

// STEP 9

function visibilitySetup() {
	offLyr.visibility = "visible";
	onLyr.visibility = "visible";
	mapLyr.visibility = "visible";
	magicLyr.visibility = "visible";

	arraySetup();
}

// STEP 10

function arrayValues(top,right,bottom,left) {
	this.top = top;
	this.right = right;
	this.bottom = bottom;
	this.left = left;
}

function arraySetup() {
	clippingBox = new Array()
	clippingBox[0] = new arrayValues(0,0,0,0);
	clippingBox[1] = new arrayValues(21,60,74,0);
	clippingBox[2] = new arrayValues(0,124,47,71);
	clippingBox[3] = new arrayValues(11,191,54,142);
	clippingBox[4] = new arrayValues(47,234,88,189);
	clippingBox[5] = new arrayValues(91,241,131,197);
	clippingBox[6] = new arrayValues(133,220,171,180);
	clippingBox[7] = new arrayValues(160,169,194,133);

	clipMenu(0);
}

// STEP 11

function clipMenu(box) {
	var cTop = clippingBox[box].top;
	var cRight = clippingBox[box].right;
	var cBottom = clippingBox[box].bottom;
	var cLeft = clippingBox[box].left;

	if(is.ns4) {
		onLyr.clip.top = cTop;
		onLyr.clip.right = cRight;
		onLyr.clip.bottom = cBottom;
		onLyr.clip.left =  cLeft;
	} else {
		onLyr.clip = 'rect(' + cTop + ' ' + cRight + ' ' + cBottom + ' ' + cLeft + ')';
	}
}


function Sizer(){
		 UserWidth = window.screen.width
		 UserHeight = window.screen.height
		 UserAvailableWidth = window.screen.availWidth
		 UserAvailableHeight = window.screen.availHeight
		 ClientWidth = document.body.clientWidth
		 ClientHeight = (document.body.clientHeight)

		 DivTop = ((((ClientHeight/100)*95)-520)/2)+240
		 DivLeft = ((ClientWidth-800)/2)+325

		 UserWidth = "Screen Width = " + UserWidth + "\n"
		 UserHeight = " Screen Height = " + UserHeight + "\n"
		 AvailableWidth = " Screen Width = " +  UserAvailableWidth + "\n"
		 AvailableHeight = " Screen Height = " +  UserAvailableHeight + "\n"
		 ClientWidth = " Client Width = " +  ClientWidth + "\n"
		 ClientHeight = " Client Height = " +  ClientHeight + "\n"
		 DivTop = " Div Top  = " +  DivTop + "\n"
		 DivLeft = " Div Left  = " +  DivLeft + "\n"
		 alert(UserWidth + UserHeight + AvailableWidth + AvailableHeight + ClientWidth + ClientHeight + DivTop + DivLeft );
}



function rollin(Area)
      {
	  if(navigator.appName == "Netscape")
	        {
			document.all[Area].style.top=DivTop;
			document.all[Area].style.left=DivLeft;
			document.layers[Area].visibility = "show";
			}
			else
			{
			document.all(Area).style.top=DivTop;
			document.all(Area).style.left=DivLeft;
			document.all(Area).style.visibility='visible';
			}
      }

function rollout(Area)
      {
	  if(navigator.appName == "Netscape")
	        {
			document.layers[Area].visibility = "hide";
			}
			else
			{
			document.all(Area).style.visibility='hidden';
			}
      }

function Resize()
      {
      ClientWidth = document.body.clientWidth
      ClientHeight = document.body.clientHeight
      DivLeft = ((ClientWidth-800)/2)+255
      DivTop = ((((ClientHeight/100)*95)-520)/2)+173

      if(DivTop < 150)
	        {
			DivTop=150;
			}
			else
			{
			//do nothing;
			}

      if(DivLeft < 260)
	        {
			DivLeft=260;
			}
			else
			{
			//do nothing;
			}
      }

function changeOpacity(J)
    {
    horizon.filters.alpha.opacity = J;
    if (J < 100) setTimeout("changeOpacity(" + (J + 1) + ")", 15);
    }

function fadeIn2(i,j,fadeObject)
    {
	document.getElementById(fadeObject).filters.alpha.opacity=i;
    i++;
	if (i<j) setTimeout("fadeIn("+i+","+j+",'"+fadeObject+"')",0);
    }
	
function fadeIn(i,j,x,fadeObject)
    // i = Starting Opacity, j = Final Opacity,  x = Opacity Increment, fadeObject = Image id
    {
	document.getElementById(fadeObject).filters.alpha.opacity=i;
    if (i<j) setTimeout("fadeIn("+(i+x)+","+j+","+x+",'"+fadeObject+"')",0);
    }

function fadeOut(i,j,x,fadeObject)
    // i = Starting Opacity, j = Final Opacity,  x = Opacity Increment, fadeObject = Image id
    {
	document.getElementById(fadeObject).filters.alpha.opacity=i;
    if (i>j) setTimeout("fadeOut("+(i-x)+","+j+","+x+",'"+fadeObject+"')",0);
    }
