var foo = null; // object
var moving = false;
var down = false;
var mouseover = false;
  
function initDown() {
	mouseover = true;
	foo = document.getElementById('livechat'); // get the "foo" object
	if(moving == false && down == false){
  foo.style.top = '-62px'; // set its initial position to 0px
  moveDown(); // start animating
  }
}

function initUp() {
	mouseover = false;
	if(moving == false && down == true){
  foo.style.top = '0px'; // set its initial position to 0px
  moveUp(); // start animating
	}
}

function moveDown() {
	if(parseInt(foo.style.top) < 0){
		moving = true;
  foo.style.top = parseInt(foo.style.top)+1+'px';
  setTimeout(moveDown,5); // call doMove in 20msec
	} else {if(mouseover == false){
		moveUp();
		} else{
		moving = false;
		down = true;
	}}
}

function moveUp() {
	if(parseInt(foo.style.top) > "-62"){
		moving = true;
  foo.style.top = parseInt(foo.style.top)-1+'px';
  setTimeout(moveUp,5); // call doMove in 20msec
	}else {if(mouseover == true){
		moveDown();
		} else{
		moving = false;
		down = false;
	}}
}
