var timer;
var wWidth;
var wHeight;
function start(){
	check('submen', 'scrollingMenu');
	 var resize = function(){
		wWidth = document.documentElement.clientWidth || window.innerWidth;
		wHeight = document.documentElement.clientHeight || window.innerHeight;
		var ref = document.getElementById('hScroller');
		var gal = document.getElementById('picGalerie');
		if(ref!=null && gal!=null){
			
			
			ref.style.width = '3000px';
			
			
			gal.style.position = 'absolute';
			
			gal.style.width = gal.offsetWidth+'px';
			gal.style.position = 'static';
			
			ref.style.width = wWidth-285+'px';
			
			check('hScroller', 'scrollingPics');
		}
	}
	window.onresize = resize;
	resize();
}
function chPic(loc){
	var url = loc.firstChild.src.split("/");
	document.getElementById('mainPic').src = path+'co/asset/img/'+url[url.length-1];
}
function scrollIt(dir, id){
	var _root = document.getElementById(id);
	if(_root==null){
		if(typeof this.parentNode!="undefined")
			this.parentNode.parentNode.style.display = "none";
		return false;
	}
	dscrollIt();
	var scroll = function(){
		var y = _root.scrollTop;
		var x = _root.scrollLeft;
		if (dir == 'up') {
			if (y > 0) {
				y = y - 5;
				_root.scrollTop = y;
				timer = window.setTimeout(scroll, 30);
			}
		}
		else if (dir == 'down') {
			if (y < _root.scrollHeight - _root.offsetHeight) {
				y = y + 5;
				_root.scrollTop = y;
				timer = window.setTimeout(scroll, 30);
			}
		}else if (dir == 'left') {
			if (x < _root.scrollWidth-(wWidth-285) ) {
				x = x + 5;
				_root.scrollLeft = x;
				timer = window.setTimeout(scroll, 15);
			}
		}else if (dir == 'right') {
			if (x > 0) {
				x = x - 5;
				_root.scrollLeft = x;
				timer = window.setTimeout(scroll, 15);
			}
		}
	}
	scroll();
}
function dscrollIt(){
	window.clearTimeout(timer);
}

function check(contentid, scrollid){
	var _root = document.getElementById(contentid);
	if (document.getElementById(scrollid) != null) {
		if (_root != null && (_root.scrollHeight > _root.offsetHeight || _root.scrollWidth > _root.offsetWidth)) {
			document.getElementById(scrollid).style.display = 'block';
		}
		else {
			document.getElementById(scrollid).style.display = 'none';
		}
	}
}

