// JavaScript Document
window.step = 50;
window.container = 'scrollContainer';
window.contentDiv = 'scrollContent';
function scrollDown(){
	var containerHeight = document.getElementById(window.container).offsetHeight;
	var content = document.getElementById(window.contentDiv);
	var currentTop = content.style.top;
	if(currentTop == '')
		currentTop = 0;
	else 
		currentTop = parseInt(currentTop.replace('px',''));
	if(content.offsetHeight + currentTop > containerHeight){
		var newTop = currentTop-step;
		if((newTop * -1)>content.offsetHeight-containerHeight)
			newTop = -1*(content.offsetHeight-containerHeight);
		content.style.top = (newTop) + "px";
	}
}

function scrollUp(){
	var content = document.getElementById(window.contentDiv);
	var currentTop = content.style.top;
	if(currentTop == '')
		currentTop = 0;
	else 
		currentTop = parseInt(currentTop.replace('px',''));
	if(currentTop<0){
		var newTop = currentTop + step;
		if(newTop > 0)
			newTop = 0;
		content.style.top = (newTop)+"px";
	}
}

function scrollOptions(scrollContainer,scrollContent,arrows){
	var contentHeight = document.getElementById(scrollContent).offsetHeight;
	var containerHeight = document.getElementById(scrollContainer).offsetHeight;
	if(contentHeight > containerHeight)
		document.getElementById(arrows).style.display = 'inline';
	else
		document.getElementById(arrows).style.display = 'none';
}

function continuousScrollDown(){
	endContinuousScrollUp();
	endContinuousScrollDown();
	scrollDown();
	scrollDown_timeout = setInterval("scrollDown()",100);
}

function endContinuousScrollDown(){
	if (typeof(scrollDown_timeout) != "undefined") clearTimeout(scrollDown_timeout);
}

function continuousScrollUp(){
	endContinuousScrollUp();
	endContinuousScrollDown();
	scrollUp();
	scrollUp_timeout = setInterval("scrollUp()",100);
}

function endContinuousScrollUp(){
	if (typeof(scrollUp_timeout) != "undefined") clearTimeout(scrollUp_timeout);
}

function loadInspireContent(content,cost,time,menu){
	document.getElementById('price').style.display = 'inline';
	document.getElementById('scrollContent').style.display = 'inline';
	document.getElementById(window.contentDiv).style.top = '0px';
	document.getElementById(window.contentDiv).innerHTML = content.replace(/\\/g,"");
	document.getElementById('cost').innerHTML = cost.replace(/\\/g,"");
	document.getElementById('time').innerHTML = time.replace(/\\/g,"");
	scrollOptions('scrollContainer','scrollContent','arrows');
	var menuItems = document.getElementById('menuItems');
	for(var i=0;i<menuItems.childNodes.length;i++){
		menuItems.childNodes.item(i).className = 'option';
	}
	document.getElementById(menu).className = 'selected';
}

