function scrollinaccordion(scrollElement){
var scrollElements = $$(scrollElement);
scrollElements.each(function(el, i){
		var first = el.getFirst();	
		if (!el || el.getTag() != 'span') return;
		/*
		if (!el.hasClass('activenav')){
			var effect = el.effect('background-position', {duration: 500, wait: false, transition: Fx.Transitions.circOut, fps: 50}).set(0);
			el.addEvent('mouseenter', effect.start.pass(187, effect)).addEvent('mouseleave', effect.start.pass(0, effect));
		}
		*/
		var effect = el.effect('background-position', {wait: false, transition: Fx.Transitions.Elastic.easeOut}).set(0);
		el.addEvent('mouseenter', function(){
					effect.options.duration = 1000;
					effect.start(187);
				});		
		el.addEvent('mouseleave', function(){
					effect.options.duration = 2000;
					effect.start(0);
				});			
});
}

function fadeinlang(langElement){
var langElements = $$(langElement);
langElements.each(function(el, i){
		var first = el.getFirst();	
		var fxlang = new Fx.Styles(el, {'wait': false});
		if (!el.hasClass('active')){
			fxlang.set({'opacity': 0.6});
			el.addEvent('mouseenter', function(){
						fxlang.start({
							'opacity': 1
						});
					});
			el.addEvent('mouseleave', function(){
						fxlang.start({
							'opacity': 0.6
						});
					});			
		}
		else{
			fxlang.set({'opacity': 1});
		}
});
}

function fadeinit(fadeElement, opacityValue){
var fadeElements = $$(fadeElement);
fadeElements.each(function(el, i){
	var overfxs = new Fx.Styles(el, {'opacity': 1, 'wait': false});
	el.addEvent('mouseenter', function(){
				overfxs.start({
					'opacity': opacityValue
				});
			});
	el.addEvent('mouseleave', function(){
				overfxs.start({
					'opacity': 1
				});
			});			
});
}

function subnavinit(){
var list = $$('a.subnav');
list.each(function(element) {
 
	//var fx = new Fx.Styles(element, {'duration':200, 'wait':false});
	var fx = new Fx.Styles(element, {'wait':false});
	//var fx2 = new Fx.Styles(element, {'duration':600, 'wait':false});
 
	if (!element.hasClass('active')){
		element.addEvent('mouseenter', function(){
			fx.options.duration = 200;
			fx.start({
				'background-color': '#CC0033',
				'color': '#FFFFCC'
			});
		});
	 
		element.addEvent('mouseleave', function(){
			fx.options.duration = 600;
			fx.start({
				'background-color': '#feebcf',
				'color': '#CC0033'
			});
		});
	}
 
});	
}

function techDataTableSelect(tableCellElement, cellDelimiter) {
	var tableElements = $$(tableCellElement);
	tableElements.each(function(el){
		var a = el.id.split(cellDelimiter);
		var typ = $(a[0] + cellDelimiter + '0');
		var description = $('0' + cellDelimiter + a[1]);
		var unitDescr = $('1' + cellDelimiter + a[1]);
		
		var fx = new Fx.Styles(el, {'wait':false});
		/*
		var fxTyp = new Fx.Styles(typ, {'wait':false, 'duration':500});
		var fxDescription = new Fx.Styles(description, {'wait':false, 'duration':500});
		var fxUnitDescr = new Fx.Styles(unitDescr, {'wait':false, 'duration':500});
		*/
		el.addEvent('mouseenter', function(){
			if(el.className != 'cords'){
				typ.className = 'cordsHighlight';
				description.className = 'cordsHighlight';
				unitDescr.className = 'cordsHighlight';
				el.className = 'target';
				
				fx.options.duration = 200;
				fx.start({'background-color': '#CC0033', 'color': '#F7FFBB'});
				/*
				fxTyp.start({'background-color': '#CC0033', 'color': '#F7FFBB'});
				
				fxDescription.start({'background-color': '#CC0033', 'color': '#F7FFBB'});
				
				fxUnitDescr.start({'background-color': '#CC0033', 'color': '#F7FFBB'});
				*/
			}
		});		
		el.addEvent('mouseleave', function(){
			if(el.className != 'cords'){
				typ.className = 'cords';
				description.className = 'cords';
				unitDescr.className = 'cords';
				el.className = 'crosshair';
				
				fx.options.duration = 800;
				fx.start({'background-color': '#fffff', 'color': '#723838'});
				/*
				fxTyp.start({'background-color': '#FBD7B6', 'color': '#CC0033'});
				
				fxDescription.start({'background-color': '#FBD7B6', 'color': '#CC0033'});
				
				fxUnitDescr.start({'background-color': '#FBD7B6', 'color': '#CC0033'});
				*/
			}
		});			
	});
};

function tooltipsinit(){
	var Ttips = new Tips($$('.ttips'), {
	maxTitleChars: 30,
	
	initialize:function(){
		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
	},
	onShow: function(toolTip) {
		this.fx.start(0.9);
	},
	onHide: function(toolTip) {
		this.fx.start(0);
	}
});	
}

Window.onDomReady(function(){
	fadeinit('#footer a',0.5);
	fadeinit('#breadcrumbs a',0.6);
	fadeinit('#pictures img',0.6);
	fadeinit('.img-models-gallery img',0.6);
	fadeinlang('#languages a');
	subnavinit();
	tooltipsinit();
	scrollinaccordion('span.nav');
	techDataTableSelect('#techdatatable td', 'x');
	techDataTableSelect('#techdatatableEN13384 td', 'y');
});