/* VARIABLES */
var fighting_style = navigator.userAgent.toLowerCase();
var is_snake = fighting_style.indexOf("msie") != -1;	// IE (evil, slippery serpent)
var is_monkey = fighting_style.indexOf("opera") != -1;	// Opera (still a bit goofy)
var is_mantis = ((!is_snake) && (!is_monkey));			// Safari, Camino, Firefox (quick, agile)


/* FUNCTIONS */
// Resize Flash object within HTML
function resizeFlashHeight(newH) {
	if (document.getElementById) {
		// DOM objects
		var container = document.getElementById("container");
		var flash = document.getElementById("bestAndWorst");
	
		// IE Versions
		if (is_snake) {
			// IE 7
			if (typeof document.body.style.maxHeight != "undefined") {
				container.style.minHeight = newH + "px";
				container.style.height = "100%";
				flash.style.height = "100%";
			} 
			// IE5 and 6
			else {
				container.style.setExpression("height", "document.body.clientHeight < "+ (newH+10) +" ? \""+ newH +"px\": \"100%\"");
			}
		}
		
		// Opera
		if (is_monkey) {
			container.style.minHeight = newH + "px";
			container.style.height = "100%";
			if (newH > document.body.clientHeight) {
				flash.style.height = newH + "px";
			} else {
				flash.style.height = "100%";
			}
		}
		
		// Safari, Camino, Firefox
		if (is_mantis) {
			container.style.minHeight = newH + "px";
			flash.style.minHeight = newH + "px";
			flash.style.height = "100%";
		}
	}
}

// Get available height in browser
function getBrowserHeight() {
	if(typeof(window.innerWidth) == 'number') {
		//Non-IE
		return window.innerHeight;
	} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		return document.body.clientHeight;
	}
}

// Get Vertical Scrolling Position
function getVeritcalScrollPosition() {
	if(typeof(window.pageYOffset) == 'number') {
		//Netscape compliant
		return window.pageYOffset;
	} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		//DOM compliant
		return document.body.scrollTop;
	} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		//IE6 standards compliant mode
		return document.documentElement.scrollTop;
	}
}

// Gets position in Flash to place Zoom Display
function getZoomPosition($h) {
	var browserh = getBrowserHeight();
	var scrollpos = getVeritcalScrollPosition();
	return Math.round( ((browserh - $h) / 2) + scrollpos );
}
