
function checkSize() {

	var windowheight = getHeight(); 
	var flashheight = getDivHeight();

	if (windowheight > flashheight) {
		//alert("checkSize: " + windowheight + ", " + flashheight);
		resizeDiv(windowheight);
	}
}

function resizeDiv(nHeight) {

	//alert("resizeDiv: " + nHeight);
	var windowheight = getHeight(); 
	var minheight = windowheight + 4;
	if (nHeight < minheight) {
		nHeight = minheight;
	}
	//alert("resizeDiv to: " + nHeight + ", " + windowheight);

	setDivHeight(nHeight);
	
	pageScroll();
	
	// start animation
	//animateHeight(nHeight);
}

function getDivHeight() {
	return document.getElementById("flashcontent").offsetHeight;
}

function setDivHeight(h) {
	// assign the new height
	document.getElementById("flashcontent").style.height = h + "px";
}

function animateHeight(targetheight) {

	// just in case there are overlapping animations
	//if (heightdelay) clearTimeout(heightdelay);
//alert('hello');
	
	// get closer to target
	var divheight = getDivHeight(); 
	var newheight = divheight + ((targetheight - divheight) * 0.6);
	
	// if close enough, go all the way 
	if (newheight > targetheight - 1 && newheight < targetheight + 1) {
		newheight = targetheight;
	}
	
	setDivHeight(newheight);

	// either keep animating or start the page scroll
	if (newheight != targetheight) {
//alert("adjustHeight: " + newheight + ", " + targetheight + ", " + divheight);
		heightdelay = setTimeout('animateHeight(' + targetheight + ')', 33);
	} else {
		pageScroll();
	}
}

function getHeight() {
	var y = 0;
	if (self.innerHeight) {
		y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		y = document.documentElement.clientHeight;
	} else if (document.body) {
		y = document.body.clientHeight;
	}
	return y;
}

function pageScroll() {

//alert('pageScroll');
	// just in case there are overlapping animations
	//if (scrolldelay) clearTimeout(scrolldelay);
	
	var y = (document.all) ? document.body.scrollTop : window.pageYOffset; 
	window.scroll(0, y * .6);

	if (y > 1) {
		scrolldelay = setTimeout('pageScroll()', 33);

	} else {
		window.scroll(0, 0);
	}
}