


var baseURL = (document.getElementsByTagName ('BASE')[0] && document.getElementsByTagName('BASE')[0].href) || location.href



function openSelectURL(selectId) {
	var URL = $(selectId).options[$(selectId).selectedIndex].value;
	if(URL != '') {
		document.location.href = baseURL + URL;
	}
}

function clearField(feld) {	if (feld.defaultValue==feld.value)	feld.value = ""} 


function setRating(score) {
	lastScore = 0;
	if(score != lastScore) {
		var filePath = 'fileadmin/thegap/i/';
		var scoreMessages = new Array("poor", "nothing special", "worth reading", "pretty cool", "very good", "excellent");
		var htmlout="";	
		for (i=1; i<=10; i++) {
			if(i <= score) {
				htmlout += '<a href="javascript:enableRating(); return false;" onmouseover="setRating(' + i + ');"><img src="'+ baseURL + filePath +'ico_star.gif" alt="*" /></a>';
			} else {
				htmlout += '<a href="javascript:"enableRating(); return false;" onmouseover="setRating(' + i + ');"><img src="'+ baseURL + filePath +'ico_star_lo.gif" alt="*" /></a>';
			}
		}
		$('ratingscore').setHTML();
		$('ratingscore').setHTML(htmlout);
		$('scoredata').value = score;
		$('scoremessage').setHTML(scoreMessages[score-1]);
		lastScore = score;
	}
}		
function enableRating() {
	$('ratingsubmit').style.display = "inline";	
}


function tgSlide(id) {
	var s = $(id);	s.fx = new Fx.Slide(s, {duration:200});	s.fx.toggle();
}


function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
	var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
	var slider = new Slider(scrollbar, handle, {	
		steps: steps,
		mode: (horizontal?'horizontal':'vertical'),
		onChange: function(step){
			// Scrolls the content element in x or y direction.
			var x = (horizontal?step:0);
			var y = (horizontal?0:step);
			content.scrollTo(x,y);
		}
	}).set(0);
	if( !(ignoreMouse) ){
		// Scroll the content element when the mousewheel is used within the 
		// content or the scrollbar element.
		$$(content, scrollbar).addEvent('mousewheel', function(e){	
			e = new Event(e).stop();
			var step = slider.step - e.wheel * 30;	
			slider.set(step);					
		});
	}
	// Stops the handle dragging process when the mouse leaves the document body.
	$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
}