

 $.noConflict();
 jQuery(document).ready(function($) {
	
	/* History bar scrolling */
	var historyscrolling = false;

	$('#netvsvsheader_historybar_wrapper .control').click(function() {
		if(historyscrolling==false){
			var obj = $('#netvsvsheader_historybar_wrapper .whiteboard');
			historyscrolling = true;			
			var $firstImg = obj.find('img:first');
			var anim_width = $firstImg.attr('width')+parseFloat($firstImg.css('margin-left'))+parseFloat($firstImg.css('margin-right'));
			obj.animate({"margin-left":"-="+anim_width}, anim_width, function(){ 
				obj.find('img:first').appendTo(obj);
				obj.css('margin-left',(parseFloat(obj.css('margin-left'))+anim_width)) + "px";
				historyscrolling = false;
			});
		}
	});

	/* historybar overlay */
	$('#netvsvsheader_historybar').hover(
		function(){
			$('#netvsvsheader_historybar .overlay-image').attr("src","/fileadmin/templates/sv-stiftung/htmltmpl/images/stiftung/header-overlay_light.png");
		},
		function(){
			if ($('#netvsvsheader_historybar_wrapper').css('z-index') < 100){ // layer is in background
				$('#netvsvsheader_historybar .overlay-image').attr("src","/fileadmin/templates/sv-stiftung/htmltmpl/images/stiftung/header-overlay.png");
			}
		}
	);
	
	$('#netvsvsheader_historybar').click(
		function(){
			$('#netvsvsheader_historybar_wrapper').css('z-index','100');
			$('#netvsvsheader_valuebar .overlay-image').attr("src","/fileadmin/templates/sv-stiftung/htmltmpl/images/stiftung/header-overlay.png");
			$('#netvsvsheader_valuebar .overlay').show();
			$('#netvsvsheader_historybar .overlay').hide();
			$('#netvsvsheader_valuebar_wrapper .control').hide();
			$('#netvsvsheader_historybar_wrapper .control').show();
		}
	);
	
	
	
	/* Valuebar scroll control */
	var valuescrolling = false;
	
	$('#netvsvsheader_valuebar_wrapper .control').click(function() {
		if(valuescrolling==false){
			var obj = $('#netvsvsheader_valuebar_wrapper .whiteboard');
			valuescrolling = true;			
			var old_width = obj.css('width');
			var $firstImg = obj.find('img:first');
			var anim_width = $firstImg.attr('width')+parseFloat($firstImg.css('margin-left'))+parseFloat($firstImg.css('margin-right'));
			obj.animate({"width": "+="+anim_width}, anim_width, function(){ // animation speed calculated in consideration of image width
				obj.find('img:first').appendTo(obj);
				obj.find('br').appendTo(obj);
				obj.css('width',old_width);
				valuescrolling = false;
			});
		}
	});
	
	/* Valuebar overlay */
	
	$('#netvsvsheader_valuebar').hover(
		function(){
			$('#netvsvsheader_valuebar .overlay-image').attr("src","/fileadmin/templates/sv-stiftung/htmltmpl/images/stiftung/header-overlay_light.png");
		},
		function(){
			if ($('#netvsvsheader_historybar_wrapper').css('z-index') >= 100){ // valuebar in background
				$('#netvsvsheader_valuebar .overlay-image').attr("src","/fileadmin/templates/sv-stiftung/htmltmpl/images/stiftung/header-overlay.png");
			}
		}
	);

	
	$('#netvsvsheader_valuebar').click(
		function(){
			$('#netvsvsheader_historybar_wrapper').css('z-index','0');
			$('#netvsvsheader_historybar .overlay-image').attr("src","/fileadmin/templates/sv-stiftung/htmltmpl/images/stiftung/header-overlay.png");
			$('#netvsvsheader_historybar .overlay').show();
			$('#netvsvsheader_valuebar .overlay').hide();
			$('#netvsvsheader_valuebar_wrapper .control').show();
			$('#netvsvsheader_historybar_wrapper .control').hide();
		}
	);

	
	
 });
 // Code that uses other library's $ can follow here.
