function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}

function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_doc, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_doc && (!n_result || (n_result > n_doc)))
		n_result = n_doc;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}


// DETECTS BROWSER RESIZE EVENTS
// CALLED EVERY 100ms
function isResized() {
	var currentSize = getViewportSize();	
	if (currentSize[0] != lastSize[0] || currentSize[1] != lastSize[1]) {
		// alert(currentSize[0]+"\n"+lastSize[0]);
		// alert(currentSize[1]+"\n"+lastSize[1]);
		lastSize = currentSize;
		get_browserSize(currentSize);
		// doResize(currentSize);
	}
}

// WIDTH & HEIGHT OF BROWSER
function getViewportSize() {
	var size = [0, 0];	
	size = [ f_clientWidth(), f_clientHeight() ];
	return size;
}

// INIT BROWSER RESIZE VAR
window.onload = function() {
	init();
}

function init() {
	window.lastSize = getViewportSize();
	//setInterval(isResized, 100);
}


// EXTERNAL INTERFACE
// passes js browser width and height to flash onload
function init_browserSize(){		
	var currentSize = getViewportSize();
	get_browserSize(currentSize);
}

// SEND TO FLASH
// passes js browser width and height to flash onresize
function get_browserSize(currentSize){		
	if (document.getElementById) {
		flashMovie = document.getElementById("LeilaSutton");
	} else if (document.all) {
		flashMovie = document.all("LeilaSutton");
	}
	flashMovie.js_id(currentSize[0], currentSize[1]);
}

// CALLED FROM FLASH
// sets flash object width & height
function set_FlashSize(newFlashW, newFlashH) {	
	flashMovie.style.width = newFlashW;
	flashMovie.style.height = newFlashH;
}
