/* height fixing due to css bug */
function init_page(noreset) {
	var height, docHeight, offset;
	offset = 367;
	if(window.opera || navigator.userAgent.indexOf('Firefox') != -1) offset = 371;
	if(!noreset) document.getElementById('page').style.height = '';
	if (self.innerHeight) height = self.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight) height = document.documentElement.clientHeight;
	else if (document.body) height = document.body.clientHeight;
	if (document.body.scrollHeight > document.body.offsetHeight) docHeight = document.body.scrollHeight;
	else docHeight = document.body.offsetHeight;
	if(docHeight <= height) document.getElementById('page').style.height = (height - offset) + 'px';
}
function init_rels() {
	var links = document.getElementsByTagName('a');
	if(links) {
		for(var i = 0; i < links.length; i++) {
			if(links[i].getAttribute('href') && links[i].getAttribute('rel') == 'blank') {
				links[i].target = '_blank';
			}
		}
	}
}
var scroll_step = 497;
var scroll_busy = false;
function scroller_next() {
	if(!scroll_busy) {
		var scroller = document.getElementById('scroller');
		var x = Number(scroller.style.left.replace('px', ''));
		var w = Number(scroller.style.width.replace('px', ''));
		if(x > -(w - scroll_step)) {
			scroll_busy = true;
			new Effect.Move(scroller, {y:0, x:-497, duration: 0.6, afterFinish: function() { scroll_busy = false; }});
		}
	}
	return false;
}
function scroller_prev() {
	if(!scroll_busy) {
		var scroller = document.getElementById('scroller');
		var x = Number(scroller.style.left.replace('px', ''));
		if(x < 0) {
			scroll_busy = true;
			new Effect.Move(scroller, {y:0, x:497, duration: 0.6, afterFinish: function() { scroll_busy = false; }});
		}
	}
	return false;
}

window.onresize = init_page;
window.onload = init_page;
Event.observe(window, 'load', init_rels, false);