
function open_sub(in_el){
	if(!$(in_el).hasClass('opening') && !$(in_el).hasClass('open')){
		$(in_el).addClass('opening');
		new Fx.Tween($(in_el), {onComplete: function(){ $(in_el).removeClass('opening'); $(in_el).addClass('open'); }}).start('height', $(in_el).getStyle('height').toInt(), $(in_el).getScrollSize().y); 
	}
}

function close_sub(in_el){
	if($(in_el).hasClass('open')){
		$(in_el).removeClass('open');
		$(in_el).addClass('closing');
		new Fx.Tween($(in_el), {onComplete: function(){ $(in_el).removeClass('closing'); }}).start('height', $(in_el).getStyle('height').toInt(), 0);
	}
	 
}

function close_all_subs(in_el){
	$$('.hassubmenu').each(function(el, i){
		if($defined($('sub_'+el.id)) && in_el != el.id){
			close_sub('sub_'+el.id);
		}	
	});
}

//
//	INIT
//

function pngfix(){
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if ((version >= 5.5 && version < 7) && (document.body.filters)){
		var png_images = $$('.pngfix');	
		png_images.each(function(element) {
			var img = $(element);
			if(!img.hasClass('pngfixed')){
				img.addClass('pngfixed');
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText 
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				img.outerHTML = strNewHTML	
			}
		});
	}
}

var scroller;
var current_position = 0;
var scroll_height = 0;
var scroll_status = 0;
var scroll_speed = 10;

function scrollUp(){
	if(scroll_status >= 0){
		scroll_status = 1;
		current_position = Math.min(scroll_height, Math.max(0, current_position - scroll_speed));
		scroller.set(0, current_position);
		setTimeout("scrollUp()", 20);	
	} else {
		scroll_status = 0;
	}
}

function scrollDown(){
	if(scroll_status >= 0){
		scroll_status = 1;
		current_position = Math.min(scroll_height, Math.max(0, current_position + scroll_speed));
		scroller.set(0, current_position);
		setTimeout("scrollDown()", 20);	
	} else {
		scroll_status = 0;
	}
}

function scrollStop(){
	scroll_status = -1;
}

function make_scrollarea(content, scrollbar, handle){
	var steps = (content.getScrollSize().y - content.getSize().y);
	if(steps > 0){
		var slider = new Slider(scrollbar, handle, {	
			steps: steps,
			mode: 'vertical',
			onChange: function(step){
				content.scrollTo(0, step);
			}
		}).set(0);
		$$(content, scrollbar).removeEvents('mousewheel');
		$$(content, scrollbar).addEvent('mousewheel', function(e){	
			e = new Event(e).stop();
			var step = slider.step - e.wheel * 30;	
			slider.set(step);					
		});
		$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
	} else {
		scrollbar.setStyle('display', 'none');
		handle.setStyle('display', 'none');
	}
}