var client = {
		  viewportWidth: function() {
			return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
		  },
		
		  viewportHeight: function() {
			return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
		  },
		
		  viewportSize: function() {
			return { width: this.viewportWidth(), height: this.viewportHeight() };
		  }
		};
			window.addEvent('domready', function(){
				var scrollobject = new Fx.Scroll(window, {duration: 500, wait: false, transition: Fx.Transitions.quadInOut});
				$$('a[href^=#]').addEvent('click', function(){
					var target = $$(this).getProperty('href')[0];
					scrollobject.toElement(target.substring(1));
					return false;
					});
				checkScroll();

				addScrollbar();
			});
			window.onresize = function(){
				checkScroll();
			}
		function checkScroll(){
			 var viewportwidth;
			 var viewportheight;
			 
			 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
			 if (typeof window.innerWidth != 'undefined')
			 {
				  viewportwidth = window.innerWidth,
				  viewportheight = window.innerHeight
			 }
			 
			// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
			 else if (typeof document.documentElement != 'undefined'
				 && typeof document.documentElement.clientWidth !=
				 'undefined' && document.documentElement.clientWidth != 0)
			 {
				   viewportwidth = document.documentElement.clientWidth,
				   viewportheight = document.documentElement.clientHeight
			 }
			if(viewportwidth>800 && viewportheight>550){
					$$('html').addClass('noscroll');
				}else{
					$$('html').removeClass('noscroll');
				}
			}

function addScrollbar(){
	var scrollareas = $$('.autoscroll');
	for(var i=0;i<scrollareas.length;i++){
		if(scrollareas[i].clientHeight<scrollareas[i].scrollHeight){
			$(scrollareas[i]).setStyles({
				overflow: 'hidden',
				padding: '0 30px 0 0'
				});
			var currenthtml = scrollareas[i].innerHTML;
			//scrollareas[i].innerHTML=currenthtml+'<img style="position:absolute;top: 0px; right: 0px;" alt="scrollup" src="_images/arrow-up.png" />');
			scrollareas[i].innerHTML='<img class="arrowup" onmousedown="scroll(this,\'up\');" src="_images/arrow_up.png" />\
			<img class="arrowdown" onmousedown="scroll(this,\'down\');"  src="_images/arrow_down.png" />\
			<div class="autoscrollchild">'+currenthtml+'</div>';
			}
		}
	}
function scroll(element,dir){
	var div = $(element).getParent().getElement('.autoscrollchild');
	var divscrollobject = new Fx.Scroll(div, {duration: 500, wait: false, transition: Fx.Transitions.quadInOut});
	var scrolldistance = div.getParent().clientHeight-100;
	if(dir=='down'){
		divscrollobject.start(0,div.scrollTop+scrolldistance);
		}
	if(dir=='up'){
		divscrollobject.start(0,div.scrollTop-scrolldistance);
		}
	}
