
window.addEvent('domready', function() {
		var contentPos = "show";
		var contenthight;
		var sidebarheight;
		var picturexy;
		var imagewidth;
		var myTimer;
		
		contentheight=$("content").getStyle("height");
		sidebarheight=$("sidebar").getStyle("height");
		
		var contentfx = new Fx.Tween("content");
		var sidebarfx = new Fx.Tween("sidebar");
		var scrolled = "left";
		var scroll
		$("revive").style.opacity = 0;
		$("revive").style.display = "none";
		
		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();
				});
			}
			
		}
		
		$("content-slider").addEvent("click", function(e) {
				new Event(e).stop();
				
				if(contentPos=="show"){
					contentPos="hide";
					
					contentfx.start("opacity",0).chain(function(){
							this.start("height","1px");
					});
					sidebarfx.start("opacity",0).chain(function(){
							this.start("height","1px");
					});
					$("revive").style.opacity = 1;
					$("revive").style.display = "block";
					contentPos="hide";
					startmoving();
				}
				
		});	
		
		function pause(){
			myTimer = $clear(myTimer); //Cancels myFunction.
		}
		
		$("sidebar-slider").addEvent("click", function(e) {
				new Event(e).stop();
				
				if(contentPos=="show"){
					contentPos="hide";
					
					contentfx.start("opacity",0).chain(function(){
							this.start("height","1px");
					});
					sidebarfx.start("opacity",0).chain(function(){
							this.start("height","1px");
					});
					$("revive").style.opacity = 1;
					$("revive").style.display = "block";
					contentPos="hide";
					startmoving();
				}
		});	
		
		$("revive").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);
				});
				$("revive").style.opacity = 0;
				$("revive").style.display = "none";
				contentPos="show";
				pause();
				
				
		});	
		
		
});