var Common = {
	
	btnHide:null,
	btnScroll:null,
	contWelcome:null,
	contScroll:null,
	scrolled:0,
	
	init : function(){
		
		if(document.getElementById("newarticle")) {
			$('#newarticle').wysiwyg();
		}
		
		
		if (document.getElementById("welcome_hide")) {
			Common.btnHide = document.getElementById("welcome_hide");
			Common.btnScroll = document.getElementById("scroll");
			Common.contWelcome = document.getElementById("welcome_container");
			Common.contScroll = document.getElementById("content_top");
			
			Common.btnHide.onclick = function(){
				if (Common.contWelcome.style.display == "none") {
					Common.btnHide.style.backgroundImage = "url('images/btn_hide.png')";
				}
				else {
					Common.btnHide.style.backgroundImage = "url('images/btn_show.png')";
				}
				
				$(Common.contWelcome).slideToggle("slow");
			}
			
			Common.btnScroll.onclick = function(){
				Common.scrolled = document.documentElement.scrollTop;
				Common.scroll(Common.contScroll);
			}
			
		}
		
	},
	
	scroll : function(){
		//alert(div.offsetTop + Common.scrolled);
		
		offTop = Common.contScroll.offsetTop;
		offTopParent = Common.contScroll.offsetParent;
		while(offTopParent != null){
			offTop += offTopParent.offsetTop;
			offTopParent = offTopParent.offsetParent;
		}
		
		if(offTop > Common.scrolled + 10){
			window.scrollBy(0,10);
			Common.scrolled += 10;
			setTimeout('Common.scroll()', 10);
		}else{
			Common.scrolled = 0;
			
		}
	}
	
}

window.onload = Common.init;
