// Register the onclick event for all elements
// the given class name
window.onload = function() {
// Find all elements that use that given CSS class
// var elements = document.getElementsByClassName("orter_select");
//elements.each(function(e) {
// Assign the onclick method to the element
if($('orter_select')){
	Event.observe($('orter_select'), "change", selectNavigation);
}

if($('right_container'))
{
	Event.observe(window, "scroll", scrollrightdiv);
}

//}
//);
}

// Send the user to the URL of the selected element
function selectNavigation()
{
	location.href = this.options[this.selectedIndex].value;
}

function scrollrightdiv()
{
	maxpos = 310;
	//Element.absolutize($('right_container'));
	offset = Element.cumulativeScrollOffset($('right_container'))['top'];
	if(offset > maxpos)
	{
		margin = offset - maxpos + 10;
		console.log("Margin:" + margin);
		$($('right_container')).setStyle({
		  paddingTop: margin + 'px'
		});
		console.log("Current padding" + $('right_container').paddingTop);
	}
	
}

