// constants
var imgHeight = 430;
var slideStep = 10;
var slideoutTimeout = 1000;
var scrollOutDelay = 10;
var scrollInDelay = 10;
var scrolledOut = false;
var MAX_OUT = -1 * (imgHeight - 100);
var MAX_IN = 0;
var hasFlash = false;


// variables
var insofar = 0;		// how far the image has been scrolled in
var iiid;				//interval identifier
var oiid;				//interval identifier
var tid;				//timeout identifier

var scrollingIn = false;
var scrollingOut = false;


function setHasFlash() {
	hasFlash = true;
	var o = getObj("flashcontent");
	o.style.top = MAX_OUT + "px";
}

function getObj(name) {

	
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
	this._height = document.getElementById(name).clientHeight;
  }
  else if (document.all) {
	this.obj = document.all[name];
	this.style = document.all[name].style;
	//this._height = document.all[name].clientHeight
  }
  else if (document.layers) {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
	//this._height = document.layers[name].offsetHeight
  }
  return this.obj;
}


function scrollin() {
	var o = getObj("flashcontent");
	if (o) {
		o.style.zIndex = 1000;
		if (insofar <= MAX_IN) {
			insofar = Math.min(imgHeight, insofar+slideStep);
			insofar = Math.min(imgHeight, (insofar / 1.8));
			o.style.top = insofar + "px";
		} else {
			// auto-scroll out: 
			//tid = setTimeout("startScrollOut()", slideoutTimeout);
			//alert ("clearing iid: " + iid)
			o.style.top = MAX_IN + "px";
			scrollingIn = false;
			clearInterval(oiid);
			clearInterval(iiid);
		}
	}
}

function scrollout() {
	var o = getObj("flashcontent");
	if (o) {
		if (insofar >= MAX_OUT) {
			insofar = Math.min(imgHeight, (-1 * Math.abs(insofar * 1.8)));
			insofar = Math.min(imgHeight, insofar - 20);
			o.style.top = insofar + "px";
		} else {
			//alert ("clearing iid: " + iid)
			//scrolledOut = false;
			o.style.top = MAX_OUT + "px";
			scrollingOut = false;
			clearInterval(oiid);
			clearInterval(iiid);
		}
	}
}



function startScrollIn() {
	if (!scrollingOut && hasFlash) {
		var o = getObj("flashcontent");
		scrollingIn = true;
		scrollingOut = false;
		clearInterval(oiid);
		clearInterval(iiid);
		iiid = setInterval("scrollin()", scrollInDelay);
	}
}

function startScrollOut() {
	if (!scrollingIn && hasFlash) {
		scrollingIn = false;
		scrollingOut = true;
		clearInterval(oiid);
		clearInterval(iiid);
		oiid = setInterval("scrollout()", scrollOutDelay);
	}
}
