
var browser = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	],
	
	
	isIE6: function()
	{
		if (this.browser == "Explorer" && this.version == 6)
			return true;
		
		return false;
	},
	
	isIE7: function()
	{
		if (this.browser == "Explorer" && this.version == 7)
			return true;
		
		return false;
	},
	
	isIE: function()
	{
		if (this.browser == "Explorer")
			return true;
		
		return false;
	},
	
	isFirefox: function()
	{
		if (this.browser == "Firefox")
			return true;
		return false;
	},
	
	isFirefox2: function()
	{
		if (this.browser == "Firefox" && this.version == 2)
			return true;
		return false;
	},
	
	isOpera: function()
	{
		if (this.browser == "Opera")
			return true;
		
		return false;
	},
	
	isSafari: function()
	{
		if (this.browser == "Safari")
			return true;
		
		return false;
	}

};

browser.init();

function setOpacity(object, value)
{
	if (typeof(value) != "number")
	{
		object.opacity = "";
		object.style.filter = "alpha(opacity=\"\")";
		return;
	}
	object.style.opacity = value/100;
	object.style.filter = 'alpha(opacity=' + value + ')';
}


function scrollScroll()
{
	if (scroll)
	{
		scroll.pageScroll();
	}
}

function Directories(directories)
{
	
};

Directories.prototype.getChild = function(name)
{
	for (var i=0; i<this.contents.length; i++)
	{
		if (this.contents[i].name == name)
		{
			return this.contents[i];
		}
	}
	
	return null;
};

Directories.prototype.hasChildren = function()
{
	if (this.contents.length > 0)
	{
		return true;
	}
	
	return false;
};

Directories.prototype.getLink = function()
{
	if (this.relative == false)
	{
		return this.address;
	}
	
	if (this.name.length <= 0)
	{
		return "";
	}
	
	var toReturn = "";
	if (this.parent)
	{
		toReturn += this.parent.getLink();
	}
	
	if (this.isParameter)
	{
		return toReturn + "?" + this.address;
	}
	
	return toReturn + "/" + this.address;
}

function augmentDirectories(directory)
{
	YAHOO.lang.augmentObject(directory, Directories.prototype);
	
	if (directory.contents != null)
	{
		for (var i=0; i<directory.contents.length; i++)
		{
			directory.contents[i].parent = directory;
			augmentDirectories(directory.contents[i]);
		}
	}
};

augmentDirectories(directories);


function hasChild(element, child)
{
	if (element == child)
	{
		return true;
	}
	
	var children = element.childNodes;
	
	for (var i=0; i<children.length; i++)
	{
		if (hasChild(children.item(i), child))
		{
			return true;
		}
	}
	
	return false;
}


function SubMenu(parent, directory)
{
	this.parent = parent;
	this.directory = directory;
	
	this.containerElement = document.getElementById("sub_menu_template").cloneNode(true);
	this.containerElement.style.display = "block";
	
	this.contentElement = YAHOO.util.Dom.getElementsByClassName("mini_subsection_content", null, this.containerElement)[0];
	
	
	this.items = [];
	for (var i=0; i<directory.contents.length; i++)
	{
		this.items[i] = new SubMenuItem(this, directory.contents[i]);
		this.contentElement.appendChild(this.items[i].containerElement);
	}
	
	document.body.appendChild(this.containerElement);
	
	this.next = null;
	
	YAHOO.util.Event.addListener(this.containerElement, "mouseout", this.mouseOut, this, true);

}

SubMenu.prototype.mouseOut = function(event)
{
	var relatedTarget = YAHOO.util.Event.getRelatedTarget(event);
	
	if (this.containsElement(relatedTarget))
	{
		return;
	}
	
	var next = this.next;
	
	while (next)
	{
		if (next.containsElement(relatedTarget))
		{
			return;
		}
		
		next = next.next;
	}
	
	next = this.parent;
	
	while (next)
	{
		if (next.containsElement(relatedTarget))
		{
			return;
		}
		
		if (next.parent == null)
		{
			next.scrollCase.clearSubMenu();
		}
		next = next.parent;
	}
};

SubMenu.prototype.containsElement = function(element)
{
	return hasParent(element, this.containerElement);
}

SubMenu.prototype.clear = function()
{
	if (browser.isIE())
	{
		/*
			IE doesn't like to remove element under SSL when there is a background-image set via inline styles.
			This solves that by removing the element without setting the background-image to about:blank.
		*/
		this.containerElement.outerHTML = " ";
	}
	else
	{
		document.body.removeChild(this.containerElement);
	}
	
	if (this.parent)
	{
		this.parent.cleared(this);
	}
	
	if (this.next)
	{
		this.next.clear();
	}
};

SubMenu.prototype.cleared = function(subMenu)
{
	if (this.next == subMenu)
	{
		this.next = null;
	}
};

SubMenu.prototype.setSubMenu = function(directory, position)
{
	this.clearSubMenu();
	
	this.next = new SubMenu(this, directory);
	
	var left = YAHOO.util.Dom.getXY(this.containerElement)[0] + this.containerElement.offsetWidth;
	
	this.next.setPosition(left - 16 - YAHOO.util.Dom.getDocumentScrollLeft(), position - 10 - YAHOO.util.Dom.getDocumentScrollTop());
};

SubMenu.prototype.clearSubMenu = function()
{
	if (this.next)
	{
		this.next.clear();
		this.next = null;
	}
};

SubMenu.prototype.setPosition = function(x, y)
{
	this.containerElement.style.left = x + "px";
	this.containerElement.style.top = y + "px";
};

function SubMenuItem(parent, directory)
{
	this.parent = parent;
	this.directory = directory;
	
	this.containerElement = document.createElement("a");
	YAHOO.util.Dom.addClass(this.containerElement, "sub_menu_item");
	this.containerElement.href = directory.getLink();
	
	
	this.contentElement = document.createElement("div");
	YAHOO.util.Dom.addClass(this.contentElement, "sub_menu_item_content");
	
	this.contentElement.innerHTML = directory.name;
	
	if (directory.contents.length > 0)
	{
		var arrowElement = document.createElement("img");
		YAHOO.util.Dom.addClass(arrowElement, "sub_menu_item_arrow");
		arrowElement.src = "/images/static/submenu_arrow.png";
		
		this.contentElement.appendChild(arrowElement);
	}
	
	this.containerElement.appendChild(this.contentElement);

	YAHOO.util.Event.addListener(this.containerElement, "mouseover", this.mouseOver, this, true);
	YAHOO.util.Event.addListener(this.containerElement, "mouseout", this.mouseOut, this, true);

}

SubMenuItem.prototype.mouseOver = function(event)
{
	if (!this.hoverDelay)
	{
		this.hoverDelay = YAHOO.lang.later(333, this, this.hovered);
	}
	
	if (this.parent.next && this.parent.next.directory != this.directory)
	{
		this.parent.clearSubMenu();
	}
};

SubMenuItem.prototype.mouseOut = function(event)
{
	var relatedTarget = YAHOO.util.Event.getRelatedTarget(event);
	
	if (hasChild(this.containerElement, relatedTarget))
	{
		return;
	}
	
	if (this.hoverDelay)
	{
		this.hoverDelay.cancel();
		this.hoverDelay = null;
	}
};

SubMenuItem.prototype.hovered = function()
{
	if (this.directory.contents.length <= 0)
	{
		return;
	}
	
	var position = YAHOO.util.Dom.getXY(this.containerElement);
	this.parent.setSubMenu(this.directory, position[1]);
};



function CaseButton(scrollCase, name)
{
	this.scrollCase = scrollCase;
	this.containerElement = document.getElementById(name.toLowerCase() + "_button_container");
	this.imageElement = document.getElementById(name.toLowerCase() + "_button");
	
	this.name = name;
}

CaseButton.prototype.containsElement = function(element)
{
	if ((this.containerElement == element) || (this.imageElement == element))
	{
		return true;
	}
	
	return false;
}

CaseButton.prototype.cleared = function(subMenu)
{
	if (this.scrollCase.subMenu == subMenu)
	{
		this.scrollCase.subMenu = null;
	}
}

CaseButton.prototype.setNormal = function()
{
	if (!browser.isIE())
	{
		var bgpos = YAHOO.util.Dom.getStyle(this.imageElement, "background-position");
		bgpos = bgpos.split(" ", 1);
		if (bgpos[0].length <= 0)
		{
			bgpos[0] = "0";
		}
		this.imageElement.style.backgroundPosition = bgpos[0] + " 0px";
	}
	else
	{
		this.imageElement.style.backgroundPositionY = "0px";
	}
}

CaseButton.prototype.setHover = function()
{
	if (!browser.isIE())
	{
		var bgpos = YAHOO.util.Dom.getStyle(this.imageElement, "background-position");
		bgpos = bgpos.split(" ", 1);
		if (bgpos[0].length <= 0)
		{
			bgpos[0] = "0";
		}
		this.imageElement.style.backgroundPosition = bgpos[0] + " -17px";
	}
	else
	{
		this.imageElement.style.backgroundPositionY = "-17px";
	}
}

CaseButton.prototype.setPressed = function()
{
	if (!browser.isIE())
	{
		var bgpos = YAHOO.util.Dom.getStyle(this.imageElement, "background-position");
		bgpos = bgpos.split(" ", 1);
		if (bgpos[0].length <= 0)
		{
			bgpos[0] = "0";
		}
		this.imageElement.style.backgroundPosition = bgpos[0] + " -34px";
	}
	else
	{
		this.imageElement.style.backgroundPositionY = "-34px";
	}
}

function ScrollCase()
{
	this.menuImageCache = [];
	this.menuImageCache[0] = new Image();
	this.menuImageCache.src = "/images/subsection/corners_dark.png";
	this.menuImageCache[1] = new Image();
	this.menuImageCache.src = "/images/subsection/vertical_dark.png";
	this.menuImageCache[2] = new Image();
	this.menuImageCache.src = "/images/subsection/horizontal_dark.png";
	
	this.PAGE_STATIC = 0;
	this.CASE_STATIC = 1;
	this.PANORAMA_STATIC = 2;

	this.mode = this.PAGE_STATIC;
	this.state = this.PAGE_STATIC;
	
	
	this.extraCaseHeight = 279;
	this.extraPanoramaHeight = 484;
	
	if (browser.isIE7())
	{
		this.extraCaseHeight -= 5;
		this.extraPanoramaHeight -= 5;
	}
	
	this.directories = directories;
	
	this.subMenu = null;
	
	this.switchContainer = document.getElementById("case_switch_container");
	this.switchButton = document.getElementById("case_switch");
	
	
	this.caseButtons = [];
	this.caseButtons[this.caseButtons.length] = new CaseButton(this, "Menu");
	this.caseButtons[this.caseButtons.length] = new CaseButton(this, "Game");
	this.caseButtons[this.caseButtons.length] = new CaseButton(this, "Media");
	this.caseButtons[this.caseButtons.length] = new CaseButton(this, "Support");
	
	this.panorama = document.getElementById("panorama");
	this.scrollCase = document.getElementById("scroll");
	this.frame = document.getElementById("scroll_frame");
	this.shadow = document.getElementById("scroll_shadow");
	this.pageBottom = document.getElementById("body_bottom");
	
	this.leftPosition = 0;
	
	this.lastScrollPosition = 0;
	
	YAHOO.util.Event.onAvailable("scroll_handle", this.windowResize, this, true);
	YAHOO.util.Event.addListener(window, "resize", this.windowResize, this, true);
	
	YAHOO.util.Event.addListener(this.switchContainer, "click", this.changeMode, this, true);
	
	for (var i=0; i<this.caseButtons.length; i++)
	{
		YAHOO.util.Event.addListener(this.caseButtons[i].containerElement, "mouseover", this.mouseOverButton, this, true);
		YAHOO.util.Event.addListener(this.caseButtons[i].containerElement, "mouseout", this.mouseOutButton, this, true);
		YAHOO.util.Event.addListener(this.caseButtons[i].containerElement, "mousedown", this.mouseDownButton, this, true);
		YAHOO.util.Event.addListener(this.caseButtons[i].containerElement, "mouseup", this.mouseUpButton, this, true);
	}
	
	var newMode = YAHOO.util.Cookie.get("Case Mode");
	
	if (!newMode)
	{
		newMode = this.CASE_STATIC;
	}
	
	this.setMode(parseInt(newMode, 10));
	
	this.windowResize();
};

ScrollCase.prototype.clearSubMenu = function()
{
	if (this.subMenu)
	{
		this.subMenu.clear();
		this.subMenu = null;
	}
}

ScrollCase.prototype.mouseOverButton = function(event)
{
	var target = YAHOO.util.Event.getTarget(event);
	var relatedTarget = YAHOO.util.Event.getRelatedTarget(event);
		
	var button = null;
	for (var i=0; i<this.caseButtons.length; i++)
	{
		if (this.caseButtons[i].containsElement(target))
		{
			button = this.caseButtons[i];
			break;
		}
	}
	
	if (button == null)
	{
		return;
	}
	
	button.setHover();
	
	if (this.subMenu != null)
	{
		if (this.subMenu.directory == this.directories.getChild(button.name))
		{
			return;
		}
	
		this.subMenu.clear();
	}
	
	if (this.directories.getChild(button.name).contents.length > 0)
	{
		this.subMenu = new SubMenu(button, this.directories.getChild(button.name));
		
		var position = YAHOO.util.Dom.getXY(button.imageElement);
		
		this.subMenu.setPosition(position[0] - 20 - YAHOO.util.Dom.getDocumentScrollLeft(), position[1] + 18 - YAHOO.util.Dom.getDocumentScrollTop());
	}
}

ScrollCase.prototype.mouseOutButton = function(event)
{
	var target = YAHOO.util.Event.getTarget(event);
	var relatedTarget = YAHOO.util.Event.getRelatedTarget(event);
	
	var button = null;
	for (var i=0; i<this.caseButtons.length; i++)
	{
		if (this.caseButtons[i].containsElement(target))
		{
			button = this.caseButtons[i];
			break;
		}
	}
	
	if (button == null)
	{
		return;
	}
	
	if ((relatedTarget == button.containerElement) || (relatedTarget == button.imageElement))
	{
		return;
	}
	
	button.setNormal();
	
	if (this.subMenu && this.subMenu.directory.name == button.name && !this.subMenu.containsElement(relatedTarget))
	{	
		this.clearSubMenu();
	}
	
}

ScrollCase.prototype.mouseDownButton = function(event)
{
	var target = YAHOO.util.Event.getTarget(event);
	var relatedTarget = YAHOO.util.Event.getRelatedTarget(event);
	
	var button = null;
	for (var i=0; i<this.caseButtons.length; i++)
	{
		if (this.caseButtons[i].containsElement(target))
		{
			button = this.caseButtons[i];
			break;
		}
	}
	
	if (button == null)
	{
		return;
	}
	
	button.setPressed();
	
}

ScrollCase.prototype.mouseUpButton = function(event)
{
	var target = YAHOO.util.Event.getTarget(event);
	var relatedTarget = YAHOO.util.Event.getRelatedTarget(event);
	
	var button = null;
	for (var i=0; i<this.caseButtons.length; i++)
	{
		if (this.caseButtons[i].containsElement(target))
		{
			button = this.caseButtons[i];
			break;
		}
	}
	
	if (button == null)
	{
		return;
	}
	
	button.setHover();
	
}


ScrollCase.prototype.changeMode = function()
{
	var newMode = this.mode - 1;
	if (newMode < this.PAGE_STATIC)
	{
		newMode = this.PANORAMA_STATIC;
	}
	
	this.setMode(newMode);
}

ScrollCase.prototype.modePage = function()
{
	this.setMode(this.PAGE_STATIC, getScrollX());
};
ScrollCase.prototype.modeCase = function()
{
	this.setMode(this.CASE_STATIC, getScrollX());
};
ScrollCase.prototype.modePanorama = function()
{
	this.setMode(this.PANORAMA_STATIC, getScrollX());
};

ScrollCase.prototype.setMode = function(mode)
{
	switch (mode)
	{
	case this.PAGE_STATIC:
		this.mode = mode;
		this.setScrollState(mode, getScrollX());
		this.setExtraPageHeight();
		break;
	case this.CASE_STATIC:
		this.mode = mode;
		if (this.lastScrollPosition < 205)
		{
			this.setScrollState(this.PAGE_STATIC, getScrollX());
		}
		else
		{
			this.setScrollState(mode, getScrollX());
		}
		this.setExtraPageHeight();
		break;
	case this.PANORAMA_STATIC:
		this.mode = mode;
		this.setScrollState(mode, getScrollX());
		this.setExtraPageHeight();
		break;
	default:
		return;
	}
	
	
	this.switchButton.style.backgroundPosition = -(this.mode * 27) + "px 0px";
	
	YAHOO.util.Cookie.set("Case Mode", this.mode, {domain: "legacyofwarriors.com", path: "/", expires: new Date(new Date().getTime() + 1000*60*60*24*30)});
	
};

ScrollCase.prototype.setScrollState = function(state, scrollX)
{
	if (this.state == state)
	{
		return;
	}
	
	switch (state)
	{
	case this.PAGE_STATIC:
		this.scrollState = 0;
	
		this.panorama.style.position = "";
		this.panorama.style.left = "";
		
		this.scrollCase.style.left = "";
		this.scrollCase.style.position = "";
		this.scrollCase.style.top = "";
		
		this.shadow.style.position = "";
		this.shadow.style.top = "";
		this.shadow.style.left = "";
		this.shadow.style.marginLeft = "";
		
		this.frame.style.left = "";
		this.frame.style.position = "";
		this.frame.style.top = "";
		
		break;
	case this.CASE_STATIC:
		this.panorama.style.position = "";
		this.panorama.style.left = "";
		
		this.scrollCase.style.position = "fixed";
		this.scrollCase.style.top = "-12px";
		this.scrollCase.style.left = this.leftPosition - scrollX + "px";
		
		this.shadow.style.position = "fixed";
		this.shadow.style.top = "65px";
		this.shadow.style.left = "0px";
		this.shadow.style.marginLeft = this.leftPosition - scrollX + "px";
		
		this.frame.style.position = "fixed";
		this.frame.style.top = "-35px";
		this.frame.style.left = this.leftPosition - scrollX + "px";
		
		break;
	case this.PANORAMA_STATIC:
		this.panorama.style.position = "fixed";
		this.panorama.style.left = 460 + this.leftPosition - scrollX + "px";
		
		this.scrollCase.style.position = "fixed";
		this.scrollCase.style.top = "193px";
		this.scrollCase.style.left = this.leftPosition - scrollX + "px";
		
		this.shadow.style.position = "fixed";
		this.shadow.style.top = "270px";
		this.shadow.style.left = "0px";
		this.shadow.style.marginLeft = this.leftPosition - scrollX + "px";
		
		this.frame.style.position = "fixed";
		this.frame.style.top = "170px";
		this.frame.style.left = this.leftPosition - scrollX + "px";
		
		break;
	default:
		return;
	}
	
	this.state = state;
};

ScrollCase.prototype.pageScroll = function()
{
	if (browser.isIE6())
	{
		return;
	}
	
	var scrollY = getScrollY();
	
	if (this.mode == this.CASE_STATIC)
	{
		if (scrollY < 205)
		{
			if (this.lastScrollPosition >= 200)
			{
				this.setScrollState(this.PAGE_STATIC);
			}
		}
		else
		{
			if (this.lastScrollPosition <210)
			{
				this.setScrollState(this.CASE_STATIC, getScrollX());
			}
		}
	}
	
	if (this.state == this.CASE_STATIC || this.state == this.PANORAMA_STATIC)
	{
		scrollX = getScrollX();
		this.panorama.style.left = 460 + this.leftPosition - scrollX + "px";
		this.scrollCase.style.left = this.leftPosition - scrollX + "px";
		this.frame.style.left = this.leftPosition - scrollX + "px";
		
		this.shadow.style.marginLeft = this.leftPosition - scrollX + "px";
	}
	
	this.lastScrollPosition = scrollY;
}

ScrollCase.prototype.windowResize = function()
{
	if (browser.isIE6())
	{
		if (document.documentElement.clientWidth > 920)
		{
			document.body.style.width = "100%";
		}
		else
		{
			document.body.style.width = "920px";
		}

		return;
	}
	
	this.leftPosition = parseInt((document.body.clientWidth - 920) / 2, 10);
	
	this.setExtraPageHeight();
	
	this.pageScroll();
}

ScrollCase.prototype.setExtraPageHeight = function()
{
	var windowHeight = 0;
	
	if (document.documentElement.clientHeight)
	{
		windowHeight = document.documentElement.clientHeight;
	}
	else if (window.innerHeight)
	{
		windowHeight = window.innerHeight;
	}
	
	var newHeight;
	switch (this.mode)
	{
	case this.PAGE_STATIC:
		newHeight = 0;
		break;
	case this.CASE_STATIC:
		newHeight = (windowHeight - this.extraCaseHeight);
		break;
	case this.PANORAMA_STATIC:
		newHeight = (windowHeight - this.extraPanoramaHeight);
		break;
	default:
		break;
	}
	
	if (newHeight < 0)
	{
		newHeight = 0;
	}
	this.pageBottom.style.height = newHeight + "px";
}



function scrollPage(to, dur, ease) {   
    var setAttr = function(a, v, u) {   
        window.scrollTo(0, v);   
    };   
  
    var anim = new YAHOO.util.Anim(null,   
        { 'scroll' : {   
            from : YAHOO.util.Dom.getDocumentScrollTop(),   
            to : to }   
        },   
        dur, ease   
    );   
    anim.setAttribute = setAttr;   
    anim.animate();   
}

function openScroll()
{
	if (this.mode == this.CASE_STATIC)
	{
		scrollPage(200, 0.5, YAHOO.util.Easing.easeOut);
	}
	else if (this.mode == this.PANORAMA_STATIC)
	{
		scrollPage(0, 0.5, YAHOO.util.Easing.easeOut);
	}
	
};

function closeScroll()
{
	var position = getPageSize().height - getWindowSize().height;
	scrollPage(position, 0.5, YAHOO.util.Easing.easeOut);
};



function hasParent(element, parent)
{
	while (element)
	{
		if (element == parent)
		{
			return true;
		}
		try
		{
			element = element.parentNode;
		}
		catch (e)
		{
			return false;
		}
	}
	
	return false;
}

function getWindowSize()
{
	var windowSize = {};
	windowSize.width = 0;
	windowSize.height = 0;
	
	if (typeof(window.innerWidth) == 'number')
	{
		windowSize.width = window.innerWidth;
		windowSize.height = window.innerHeight;
	}
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{
		windowSize.width = document.documentElement.clientWidth;
		windowSize.height = document.documentElement.clientHeight;
	}
	else if (document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		windowSize.width = document.body.clientWidth;
		windowSize.height = document.body.clientHeight;
	}
	
	return windowSize;
}

function getPageSize()
{
	var pageSize = {};
	pageSize.width = 0;
	pageSize.height = 0;
	
	if (window.innerHeight && window.scrollMaxY)
	{
		pageSize.width = window.innerWidth + window.scrollMaxX;
		pageSize.height = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{
		pageSize.width = document.body.scrollWidth;
		pageSize.height = document.body.scrollHeight;
	}
	else
	{ 
		pageSize.width = document.body.offsetWidth;
		pageSize.height = document.body.offsetHeight;
	}
	
	return pageSize;
}

function getScrollY()
{
	var scrollY = 0;
	if (typeof(window.pageYOffset) == 'number')
	{
		//Netscape compliant
		scrollY = window.pageYOffset;
	}
	else if (document.body && document.body.scrollTop)
	{
		//DOM compliant
		scrollY = document.body.scrollTop;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		//IE6 standards compliant mode
		scrollY = document.documentElement.scrollTop;
	}

	return scrollY;
}

function getScrollX()
{
	var scrollX = 0;
	if (typeof(window.pageXOffset) == 'number')
	{
		//Netscape compliant
		scrollX = window.pageXOffset;
	}
	else if (document.body && document.body.scrollLeft)
	{
		//DOM compliant
		scrollX = document.body.scrollTop;
	}
	else if (document.documentElement && document.documentElement.scrollLeft)
	{
		//IE6 standards compliant mode
		scrollX = document.documentElement.scrollLeft;
	}
	
	if (browser.isFirefox())
	{
		scrollX = scrollX - 1;
	}

	return scrollX;
}


function initialize()
{
	scroll = new ScrollCase();

};

var scroll = null;
window.onscroll = scrollScroll;
YAHOO.util.Event.onDOMReady(initialize);


