//var end = 600;		// end position from scrollTop
var speed = 6;	// speed for the bubble motion
var curmovie = "" // set variable so we can use it in the functions
//////////////////////////////////////////////////////////
// function to get the bubble movie by id
function getFlashMovie(movieName) {
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
}
////////////////////////////////////////////////////////
// video functions
////////////////////////////////////////////////////////
function changevideo(str){
	curmovie = str;
	setTimeout("openBubble()", 1000);
}
////////////////////////////////////////////////////////
// function to call the flash function to open the video
function openBubble(){
	getFlashMovie('bubble').openBubble(curmovie);
}
/////////////////////////////////////////////////////////////
// code for only playing once (set a cookie)
/////////////////////////////////////////////////////////////
function playonce(vstring){
	var thecookie = document.cookie;
	if(thecookie == "" || thecookie == undefined){
		changevideo(vstring);
		setCookie();
	}
}
function setCookie(){
	document.cookie = "play_once=1";	
}
////////////////////////////////////////////////////////
/// animation functions
////////////////////////////////////////////////////////
function moveBubble(){
	mydiv = document.getElementById('bdiv');
	var diff = (parseInt(document.body.scrollTop+end) - parseInt(mydiv.style.top));
	mydiv.style.top = parseInt(mydiv.style.top) + parseInt(diff/speed);
	var d;
	if(diff < 0){
		d = parseInt(-diff);
	}else{
		d = parseInt(diff);
	}
	if(d < 10){
		clearInterval(s);
	}
}
function init(){
	clearInterval(s);
	s = setInterval(moveBubble, 40);
}
	var s = setInterval(moveBubble, 40);
////////////////////////////////////////////////////////
window.onscroll = init;
////////////////////////////////////////////////////////