var scrolling={
	
	init:function(){
		if($('leftmov') && $('rightmov')){
			
			/*if ($('input_element').value == 0) {
				$('input_element').value = 1;
			}*/
			var akt = $('input_element').value.toInt();
			var max = $('input_max').value.toInt();
		
			//$('leftmov').href = "javascript:;"; 
			//$('rightmov').href = max > 1 ? "javascript:scrolling.go(1);" : "";

			scrolling.goInit(akt);
		}
	},
	
	goInit:function(to){

		from = $('input_element').value.toInt();
		max = $('input_max').value.toInt();
		
		var scroll = new Fx.Scroll('sliderContent', {
			wait: false,
			duration: 500,
			offset: {'x': 0, 'y': 0},
			transition: Fx.Transitions.Sine.easeIn
			});
		
		//var fx = new Fx.Style($('knob'), 'left', {duration: 300, wait: false});
		var mySlide = new Slider($('area'), $('knob'), {
			steps: max,
			onChange: function(step){
				scrolling.go(step);
			}
			/*onTick: function(pos){
				fx.start(pos);
			}*/
		}).set(to);

		if ($('s'+to)) {
			scroll.toElement('s'+to);
			var mySlide2 = new Slider($('area'), $('knob'), {
					steps: max
				}).set(to);
			
			$('input_element').value = to;
		}

		if (from == 0){
			// zurück deaktivieren
			$('leftmov').href = "javascript:;";
			$('input_element').value = 1;
		}
		else {
			newTo = to - 1;
			newTo = newTo >= 0 ? newTo : 0;
			$('leftmov').href = "javascript:scrolling.go("+newTo+");"; 		
		}
		if(to == max){
			// vor deaktivieren
			$('rightmov').href = "javascript:;";
			$('input_element').value = max;
		}
		else {
			newTo = to + 1;
			newTo = newTo <= max ? newTo : max; 
			$('rightmov').href = "javascript:scrolling.go("+newTo+");";
		}
	},

	go:function(to){
		//event = new Event(event).stop();
		from = $('input_element').value.toInt();
		max = $('input_max').value.toInt();
		
		$('leftmov').blur();
		$('rightmov').blur();
		
		var scroll = new Fx.Scroll('sliderContent', {
			wait: false,
			duration: 500,
			offset: {'x': 0, 'y': 0},
			transition: Fx.Transitions.Sine.easeIn
			});
		
		//if (from != 0 && to != max + 1 ){
			if ($('s'+to)) {
				scroll.toElement('s'+to);
				//var fx2 = new Fx.Style($('knob'), 'left', {duration: 300, wait: false});
				var mySlide2 = new Slider($('area'), $('knob'), {
						steps: max /*,
						onTick: function(pos){
							fx2.start(pos);
						}*/
					}).set(to);
				
				$('input_element').value = to;
			}
		//}
		if (from == 0){
			// zurück deaktivieren
			$('leftmov').href = "javascript:;";
			$('input_element').value = 1;
		}
		else {
			newTo = to - 1;
			newTo = newTo >= 0 ? newTo : 0;
			$('leftmov').href = "javascript:scrolling.go("+newTo+");"; 		
		}
		if(to == max){
			// vor deaktivieren
			$('rightmov').href = "javascript:;";
			$('input_element').value = max;
		}
		else {
			newTo = to + 1;
			newTo = newTo <= max ? newTo : max; 
			$('rightmov').href = "javascript:scrolling.go("+newTo+");";
		}
	}
}

var teaser={
	start:function(){
		if($('catTeaserOff')){
			$('catTeaserInner').setStyle('display','none');
			teaser.appearText();
		}
	},
	
	appearText:function(){
		var timer=0;
		var sideblocks=$$('#catTeaserInner .content_box_top');
		var sideblocks2=$$('#catTeaserInner .content_box_bottom');
		var slidefxs=[];
		var colorfxs=[];
		sideblocks.each(function(el,i){
			el.setStyle('margin-top','-150px');
			timer+=150;slidefxs[i]=new Fx.Style(el,'margin-top',{
				duration:800,
				transition:Fx.Transitions.backOut,
				wait:false,
				onComplete:teaser.createOver.pass([el,i])
			});
			$('catTeaserInner').setStyle('display','block');
			slidefxs[i].start.delay(timer,slidefxs[i],10);
		},this);
		
		sideblocks2.each(function(el,i){
			el.setStyle('margin-top','150px');
			timer+=150;slidefxs[i]=new Fx.Style(el,'margin-top',{
				duration:800,
				transition:Fx.Transitions.backOut,
				wait:false,
				onComplete:teaser.createOver2.pass([el,i])
			});
			$('catTeaserInner').setStyle('display','block');
			slidefxs[i].start.delay(timer,slidefxs[i],10);
		},this);
	
	/*sideblocksImg.each(function(el,i){
		el.setStyle('opacity',.5);
		var myEffects=el.effects({
			duration:250,
			transition:Fx.Transitions.Sine.easeInOut
		});
	el.mouseouted=true;
	el.addEvent('mouseenter',function(e){
		myEffects.start({
			'opacity':1.0
		});
	});
	el.addEvent('mouseleave',function(e){
		myEffects.start({
			'opacity':.5
		});
	});
	},this);*/
	
	theTips = new TipsX3 ($$('.tipper'), {showDelay: 0});
	
	//$('page').style.verticalAlign="middle";
},

createOver:function(el,i){
	var first=el;
	var overfxs=new Fx.Styles(first,{
		'duration':200,
		'wait':false,
		transition:Fx.Transitions.Sine.easeOut
	});
	var tocolor='AA0000';
	var fromcolor='1C1C1C';
	el.mouseouted=true;
	el.addEvent('mouseenter',function(e){
		overfxs.start({
			'color':tocolor,
			'margin-top':2
		});
	});
	el.addEvent('mouseleave',function(e){
		overfxs.start({
			'color':fromcolor,
			'margin-top':10
		});
	});
	},
	
createOver2:function(el,i){
	var first=el;
	var overfxs=new Fx.Styles(first,{
		'duration':200,
		'wait':false,
		transition:Fx.Transitions.Sine.easeOut
	});
	var tocolor='AA0000';
	var fromcolor='1C1C1C';
	el.mouseouted=true;
	el.addEvent('mouseenter',function(e){
		overfxs.start({
			'color':tocolor,
			'margin-top':18
		});
	});
	el.addEvent('mouseleave',function(e){
		overfxs.start({
			'color':fromcolor,
			'margin-top':10
		});
	});
	}
};

var admin={
	start:function(){
		if($('box_admin')){
			admin.appearText();
		}
	},
	
	appearText:function(){	
		el = $('box_admin');
			
		el.setStyle('opacity',.5);
		var myEffects=el.effects({
			duration:250,
			transition:Fx.Transitions.Sine.easeInOut
		});
		
		el.mouseouted=true;
		el.addEvent('mouseenter',function(e){
			myEffects.start({
				'opacity':1.0
			});
		});
		el.addEvent('mouseleave',function(e){
			myEffects.start({
				'opacity':.5
			});
		});
		
	}
};

var tooltips ={
	start:function(){
		if($('leftmov') && $('rightmov')){
			tooltips.appearText();
		}
	},
	
	appearText:function(){
		
		var Tips2 = new Tips($$('.sliderTdContainer'), {
			initialize:function(){
				this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
			},
			onShow: function(toolTip) {
				this.fx.start(1);
			},
			onHide: function(toolTip) {
				this.fx.start(0);
			}
		});
		
		
		/*var as = [];
		var sideblocksImg=$$('.sliderTdContainer a img');
	
		//$S('a').each(function(a){
		sideblocksImg.each(function(el,i){
			if (el.getAttribute('title')) as.push(el);
		});
		
		new Tips(as, {maxOpacity: 0.9, maxTitleChars: 25});*/
	}
};

//window.addEvent('load',gal.start);
window.addEvent('load',admin.start);
window.addEvent('load',teaser.start);
window.addEvent('domready',scrolling.init);
//window.addEvent('load',tooltips.start);
/* Tips 2 */

/*
var message="Function Disabled!";

function clickIE4(){
	if (event.button==2){
		alert(message);
		return false;
	}
}

function clickNS4(e){
	if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
			alert(message);
			return false;
		}
	}
}

if (document.layers){
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
	document.onmousedown=clickIE4;
}

document.oncontextmenu = new Function("return false");*/
