var flashOffsetLeft = 0;
var sailingObjContainer;
var objTopMargin = 0;
var startTop = 0;
var posTo;

var headHeight = 100;
var underMenuBlock = 'bl_2';
var botBlock = 'bl_3';
var botLimit = 0;


function closeMovie() {
	document.getElementById('sailingContainer').style.display='none';
	document.getElementById('sailingContainer').style.visibility='hidden';
}

function initMovie() {  
    init();	

	document.getElementById('sailingContainer').style.left = flashOffsetLeft;
	document.getElementById('sailingContainer').style.display='block';
	document.getElementById('sailingContainer').style.visibility='visible';
	
	//objTopMargin = document.getElementById('bl_1').offsetHeight;

}


function init() {
	headHeight += document.getElementById('bl_1').offsetHeight;
	botLimit = document.getElementById(botBlock).offsetHeight;
	//alert(botLimit);
	sailingObjContainer = document.getElementById('sailingContainer');
	setInterval("moveSailingBlock()", 100);
}

function moveSailingBlock() {		
	menuHeight = document.getElementById('gPageMenu1').offsetHeight + document.getElementById(underMenuBlock).offsetHeight;
	menuWidth = document.getElementById('gPageMenu1').offsetWidth;
	
	if(document.getElementById('sailingBlockContainer').offsetHeight < menuHeight + botLimit)
		return;

	documentObjTop = window.document.body.scrollTop;
	/*if(documentObjTop < headHeight)
		documentObjTop = headHeight;		
	else
		documentObjTop = 0;
		*/
	
	documentObjTop = (documentObjTop < headHeight) ?  0 : window.document.body.scrollTop - headHeight;			
	posTo = documentObjTop + objTopMargin;
	
	
	//alert(botLimit);
	//alert(menuHeight);
	if(posTo > document.getElementById('sailingBlockContainer').offsetHeight /*- botLimit*/ - menuHeight)
		posTo = document.getElementById('sailingBlockContainer').offsetHeight /*- botLimit*/ - menuHeight;
		//alert(posTo);
	
		
		ydiff = startTop - posTo;
	
		if (ydiff != 0) {
			movey=Math.floor(ydiff/3);
			startTop -= movey;
		}
	
	sailingObjContainer.style.top = startTop;
}

var isOpera = self.opera
var isIE = document.all && !isOpera;

if(isIE || isOpera) {	
	window.attachEvent("onload", initMovie);
} else {	
	window.addEventListener("load", initMovie, true);
}