
window.addEvent('domready', function() {
		

		var imagewidth;
		var contentPos = "show";
		var scrolled = "left";
		var speed=0;
		var scroll;
		var contentheight;
		var sidebarheight;
		var contentfx = new Fx.Tween("content");
		var sidebarfx = new Fx.Tween("sidebar");
		contentheight=$("content").getStyle("height");
		sidebarheight=$("sidebar").getStyle("height");
		startmoving();
		
		
		
		function startmoving(){
			
			imagewidth=$("backgroundjs").getWidth();
			divWidth=$("bigImg").getWidth();
			if(imagewidth<divWidth){
				imagewidth=divWidth
			}
			speed = imagewidth/0.05;
			
			scroll = new Fx.Scroll('bigImg', {
					wait: 1000,
					duration: speed,
					//offset: {'x': -200, 'y': -50},
					transition:Fx.Transitions.linear
			});
			
			$('botFade').style.width = imagewidth+"px";
			$('topShado').style.width = imagewidth+"px";
			if(scrolled=="left"){
				scroll.toRight().chain(function(){
						scrolled = "right";
						startmoving();
				});
			}
			else if(scrolled=="right"){
				scroll.toLeft().chain(function(){
						scrolled = "left";
						startmoving();
				});
			}
			
		}
		
		
		
				
		$("toggleclick").addEvent("click", function(e) {
				new Event(e).stop();
				
				if(contentPos=="show"){
					
					
					contentfx.start("opacity",0).chain(function(){
							this.start("height","1px");
					});
					sidebarfx.start("opacity",0).chain(function(){
							this.start("height","1px");
					});

					contentPos="hide";
					
				}
				
				
		});	
		
		$("toggleclick1").addEvent("click", function(e) {
				new Event(e).stop();
				contentfx.start("height",contentheight+"px").chain(function(){
						this.start("opacity",1);
				});
				sidebarfx.start("height",sidebarheight+"px").chain(function(){
						this.start("opacity",1);
				});

				contentPos="show";
				
		});	
		
		
		
});
