window.addEvent('domready', function(){
	//divs
	var FiEle = $('FiEle');
	var SeEle = $('SeEle');
	var ThEle = $('ThEle');
	
	//content elements
	var FiEleCon = $('FiEleCon');
	var SeEleCon = $('SeEleCon');
	var ThEleCon = $('ThEleCon');
	
	//banner elements
	var FiEleBan = $('FiEleBan');
	var SeEleBan = $('SeEleBan');
	var ThEleBan = $('ThEleBan');

	var bannertrans = new Fx.Elements($$('.banner'));
	var contenttrans = new Fx.Elements($$('.content'));
	var elementtrans = new Fx.Elements($$('.element'));
	
	function first() {
		$('videocon').morph({width: 640, height: 360, bottom:55});
		$('antrieb').morph({width: 487, height: 94});
		$('head1').fade('in');
		$('subhead1').fade('in');
		if (SeEleBan.getStyle('opacity') == 1 && ThEleCon.getStyle('opacity') == 1) {
			elementtrans.start ({
				'1': {
					'left': [640]
				},
				'2': {
					'left': [800]
				}			
			}),
			bannertrans.start({
				'0': {
					'opacity': [0]
				},
				'2': {
					'opacity': [1]
				}
				
			});
			contenttrans.start({
				'2': {
					'opacity': [0]
				}
			});
		}
		if (SeEleCon.getStyle('opacity') == 1) {
			elementtrans.start ({
				'1': {
					'left': [640]
				}
			}),
			bannertrans.start({
				'0': {
					'opacity': [0]
				},
				'1': {
					'opacity': [1]
				}
			});
			contenttrans.start({
				'1': {
					'opacity': [0]
				}
			});
		}
		$('control').setStyle('display', 'block');
	}
	
	function second() {
		if (ThEleBan.getStyle('opacity') == 1) {
			elementtrans.start({
				'1': {
					'left': [640, 160],
					'width': [160,640]
				}
			});
			bannertrans.start({
				'0': {
					'width': [0,160],
					'opacity': [1]
				},
				'1': {
					'opacity': [0]
				}
			});
			contenttrans.start({
				'1': {
					'left': [160,0],
					'width': [620,620],
					'opacity': [0,1]
				}
			});
		} else {
			elementtrans.start({
				'1': {
					'width': [640]
				},
				'2': {
					'left': [320, 800],
					'width': [640,160]
				}
			});
			bannertrans.start({
				'0': {
					'width': [0,160],
					'opacity': [0,1]
				},
				'1': {
					'opacity': [0]
				},
				'2': {
					'opacity': [0,1]
				}
			});
		}
		contenttrans.start({
			'1': {
				'opacity': [1]
			},
			'2': {
				'left': [160]
			}
		});	
		if (antriebtext != '1') {
			$('videocon').morph({width: 160, height: 90, bottom:295});
		} else 	{
			$('videocon').morph({width: 160, height: 90, bottom:55});
		}
		$('antrieb').morph({width: 0, height: 94});
		$('head1').fade('out');
		$('subhead1').fade('out');
		$('control').setStyle('display', 'none');
	}


	function third() {
		if (SeEleBan.getStyle('opacity') == 1) {
			elementtrans.start({
				'1': {
					'left': [640,160]
				},
				'2': {
					'left': [800,320],
					'width': [160,640]
				}				
			});
			bannertrans.start({
				'0': {
					'width': [0,160],
					'opacity': [0,1]
				},
				'2': {
					'opacity': [0]
				}				
			});
			contenttrans.start({
				'2': {
					'left': [160,0],
					'opacity': [0,1]
				}				
			});
		}
		if (SeEleBan.getStyle('opacity') == 0) {
			elementtrans.start({
				'1': {
					'width': [640,160]
				},
				'2': {	
					'left': [800,320],
					'width': [160,640]
				}
			}),
			bannertrans.start({
				'0': {
					'width': [0,160],
					'opacity': [0,1]
				},
				'1': {
					'opacity': [1]
				},
				'2': {
					'opacity': [0]
				}
			});
			contenttrans.start({
				'1': {
				'opacity': [0]
				},
				'2': {
					'left': [0],
					'opacity': [1]
				}				
			});

		}
		if (antriebtext != '1') {
			$('videocon').morph({width: 160, height: 90, bottom:295});
		} else 	{
			$('videocon').morph({width: 160, height: 90, bottom:55});
		}
		$('antrieb').morph({width: 0, height: 94});
		$('head1').fade('out');
		$('subhead1').fade('out');
		$('control').setStyle('display', 'none');
		
	}

	
	var myURI = new URI(location.href);
	//console.log(myURI);
	var section = myURI.getData('sec','query');

	//console.log(section);

	//alert(section);
	var etrackerUrl = new URI();
	//console.log(etrackerUrl);
	$('FiEleBan').addEvent('click', function(e){
		first();
		et_eC_Wrapper( etrackerCode, etrackerPagename1, etrackerArea, 0, etrackerUrl, '', '', '','','','','','');
	});

	$('SeEleBan').addEvent('click', function(e){
		second();
		et_eC_Wrapper( etrackerCode, etrackerPagename2, etrackerArea, 0, etrackerUrl+'?sec=2', '', '', '','','','','','');
	});

	$('ThEleBan').addEvent('click', function(e){
		third();
		et_eC_Wrapper( etrackerCode, etrackerPagename3, etrackerArea, 0, etrackerUrl+'?sec=3', '', '', '','','','','','');
	});
	if (section == 2) {
		$('SeEleBan').fireEvent('click');
	}
	
	if (section == 3) {
		$('ThEleBan').fireEvent('click');
	}
	
	var actionclick = $$('a.actionclick');
	actionclick.each(function(item, i) {
		actionclick[i].addEvent('click', function(e){
			e.stop();
			$('ThEleBan').fireEvent('click');
		});
	});
});


