// initPage
$(function(){
	VSA_initScrollbars();
	initCarousel();
	initFadeGallery();
});

//initCarusel
function initCarousel(){
	jQuery('div.slide-gall').scrollGallery({
		btnPrev:'a.prev',
		btnNext:'a.next',
		sliderHolder: '.holder',
		pagerLinks:'div.switcher ul li',
		generatePagination:'div.switcher',
		autoRotation:true,
		switchTime:3000
	});
}

// initFadeGallery
function initFadeGallery(){
	$('div.fade-gall').fadeGallery({
		slideElements:'.slides >li',
		pagerGener: false,
		autoRotation:true,
		autoHeight:false,
		switchTime:4000
	});
}

// slideshow plugin
jQuery.fn.fadeGallery = function(_options){
	var _options = jQuery.extend({
		slideElements:'div.slides > div.slide',
		pagerGener: false,
		pagerHold: false,
		pagerLinks:'ul.nav-list li',
		btnNext:'a.btn-next',
		btnPrev:'a.btn-prev',
		btnPlayPause:'a.play-pause',
		btnPlay:'a.play',
		btnPause:'a.pause',
		pausedClass:'paused',
		disabledClass: 'disabled',
		playClass:'playing',
		activeClass:'active',
		currentNum:false,
		allNum:false,
		startSlide:null,
		noCircle:false,
		caption:'ul.caption > li',
		pauseOnHover:false,
		autoRotation:false,
		autoHeight:false,
		onChange:false,
		switchTime:3000,
		duration:650,
		event:'click'
	},_options);

	return this.each(function(){
		// gallery options
		var _this = jQuery(this);
		var _slides = jQuery(_options.slideElements, _this);
		var _btnPrev = jQuery(_options.btnPrev, _this);
		var _btnNext = jQuery(_options.btnNext, _this);
		var _btnPlayPause = jQuery(_options.btnPlayPause, _this);
		var _btnPause = jQuery(_options.btnPause, _this);
		var _btnPlay = jQuery(_options.btnPlay, _this);
		var _pauseOnHover = _options.pauseOnHover;
		var _autoRotation = _options.autoRotation;
		var _activeClass = _options.activeClass;
		var _disabledClass = _options.disabledClass;
		var _pausedClass = _options.pausedClass;
		var _playClass = _options.playClass;
		var _autoHeight = _options.autoHeight;
		var _duration = _options.duration;
		var _switchTime = _options.switchTime;
		var _controlEvent = _options.event;
		var _currentNum = (_options.currentNum ? jQuery(_options.currentNum, _this) : false);
		var _allNum = (_options.allNum ? jQuery(_options.allNum, _this) : false);
		var _startSlide = _options.startSlide;
		var _noCycle = _options.noCircle;
		var _onChange = _options.onChange;
		var _pagerGener = _options.pagerGener;
		var _pagerHold = jQuery(_options.pagerHold,_this);
		var _caption = jQuery(_options.caption,_this);
		var _paging = '';
		if(_pagerGener){
			for(var i=0; i< _slides.length; i++){
				_paging += '<li><a href="#">'+(i+1)+'</a></li>';
			}
			_pagerHold.html('<ul>'+_paging+'</ul>');
		}
		var _pagerLinks = jQuery(_options.pagerLinks, _this);
		// gallery init
		var _hover = false;
		var _prevIndex = 0;
		var _currentIndex = 0;
		var _slideCount = _slides.length;
		var _timer;
		if(_slideCount < 2) return;

		_prevIndex = _slides.index(_slides.filter('.'+_activeClass));
		if(_prevIndex < 0) _prevIndex = _currentIndex = 0;
		else _currentIndex = _prevIndex;
		if(_startSlide != null) {
			if(_startSlide == 'random') _prevIndex = _currentIndex = Math.floor(Math.random()*_slideCount);
			else _prevIndex = _currentIndex = parseInt(_startSlide);
		}
		_slides.hide().eq(_currentIndex).show();
		_caption.hide().eq(_currentIndex).show();
		if(_autoRotation) _this.removeClass(_pausedClass).addClass(_playClass);
		else _this.removeClass(_playClass).addClass(_pausedClass);

		// gallery control
		if(_btnPrev.length) {
			_btnPrev.bind(_controlEvent,function(){
				prevSlide();
				return false;
			});
		}
		if(_btnNext.length) {
			_btnNext.bind(_controlEvent,function(){
				nextSlide();
				return false;
			});
		}
		if(_pagerLinks.length) {
			_pagerLinks.each(function(_ind){
				jQuery(this).bind(_controlEvent,function(){
					if(_currentIndex != _ind) {
						_prevIndex = _currentIndex;
						_currentIndex = _ind;
						switchSlide();
					}
					return false;
				});
			});
		}

		// play pause section
		if(_btnPlayPause.length) {
			_btnPlayPause.bind(_controlEvent,function(){
				if(_this.hasClass(_pausedClass)) {
					_this.removeClass(_pausedClass).addClass(_playClass);
					_autoRotation = true;
					autoSlide();
				} else {
					_autoRotation = false;
					if(_timer) clearTimeout(_timer);
					_this.removeClass(_playClass).addClass(_pausedClass);
				}
				return false;
			});
		}
		if(_btnPlay.length) {
			_btnPlay.bind(_controlEvent,function(){
				_this.removeClass(_pausedClass).addClass(_playClass);
				_autoRotation = true;
				autoSlide();
				return false;
			});
		}
		if(_btnPause.length) {
			_btnPause.bind(_controlEvent,function(){
				_autoRotation = false;
				if(_timer) clearTimeout(_timer);
				_this.removeClass(_playClass).addClass(_pausedClass);
				return false;
			});
		}
		// gallery animation
		function prevSlide() {
			_prevIndex = _currentIndex;
			if(_currentIndex > 0) _currentIndex--;
			else {
				if(_noCycle) return;
				else _currentIndex = _slideCount-1;
			}
			switchSlide();
		}
		function nextSlide() {
			_prevIndex = _currentIndex;
			if(_currentIndex < _slideCount-1) _currentIndex++;
			else {
				if(_noCycle) return;
				else _currentIndex = 0;
			}
			switchSlide();
		}
		function refreshStatus() {
			if(_pagerLinks.length) _pagerLinks.removeClass(_activeClass).eq(_currentIndex).addClass(_activeClass);
			if(_currentNum) _currentNum.text(_currentIndex+1);
			if(_allNum) _allNum.text(_slideCount);
			_slides.eq(_prevIndex).removeClass(_activeClass);
			_slides.eq(_currentIndex).addClass(_activeClass);
			if(_noCycle) {
				if(_btnPrev.length) {
					if(_currentIndex == 0) _btnPrev.addClass(_disabledClass);
					else _btnPrev.removeClass(_disabledClass);
				}
				if(_btnNext.length) {
					if(_currentIndex == _slideCount-1) _btnNext.addClass(_disabledClass);
					else _btnNext.removeClass(_disabledClass);
				}
			}
			if(typeof _onChange === 'function') {
				_onChange(_this, _currentIndex);
			}
		}
		function switchSlide() {
			_slides.eq(_prevIndex).stop().animate({opacity:0},{duration: _duration, queue: false,complete:function(){
				jQuery(this).css({display:'none'});
			}})
			_slides.eq(_currentIndex).stop().css({display:'block',opacity:0}).animate({opacity:1},{duration: _duration, queue: false,complete:function(){
				jQuery(this).css({opacity:''});
			}})
			_caption.eq(_prevIndex).fadeOut();
			_caption.eq(_currentIndex).fadeIn();
			if(_autoHeight) _slides.eq(_currentIndex).parent().animate({height:_slides.eq(_currentIndex).outerHeight(true)},{duration:_duration,queue:false});
			refreshStatus();
			autoSlide();
		}

		// autoslide function
		function autoSlide() {
			if(!_autoRotation || _hover) return;
			if(_timer) clearTimeout(_timer);
			_timer = setTimeout(nextSlide,_switchTime+_duration);
		}
		if(_pauseOnHover) {
			_this.hover(function(){
				_hover = true;
				if(_timer) clearTimeout(_timer);
			},function(){
				_hover = false;
				autoSlide();
			});
		}
		refreshStatus();
		autoSlide();
	});
};

// scrolling gallery plugin
jQuery.fn.scrollGallery = function(_options){
	var _options = jQuery.extend({
		sliderHolder: '>div',
		slider:'>ul',
		slides: '>li',
		pagerLinks:'div.pager a',
		btnPrev:'a.link-prev',
		btnNext:'a.link-next',
		activeClass:'active',
		disabledClass:'disabled',
		generatePagination:'div.pg-holder',
		curNum:'em.scur-num',
		allNum:'em.sall-num',
		circleSlide:true,
		pauseClass:'gallery-paused',
		pauseButton:'none',
		pauseOnHover:false,
		autoHeight:false,
		autoRotation:false,
		stopAfterClick:false,
		switchTime:5000,
		duration:650,
		easing:'swing',
		event:'click',
		splitCount:false,
		afterInit:false,
		vertical:false,
		step:false
	},_options);
	return this.each(function(){
		// gallery options
		var _this = jQuery(this);
		var _sliderHolder = jQuery(_options.sliderHolder, _this);
		var _slider = jQuery(_options.slider, _sliderHolder);
		var _slides = jQuery(_options.slides, _slider);
		var _btnPrev = jQuery(_options.btnPrev, _this);
		var _btnNext = jQuery(_options.btnNext, _this);
		var _pagerLinks = jQuery(_options.pagerLinks, _this);
		var _generatePagination = jQuery(_options.generatePagination, _this);
		var _curNum = jQuery(_options.curNum, _this);
		var _allNum = jQuery(_options.allNum, _this);
		var _pauseButton = jQuery(_options.pauseButton, _this);
		var _pauseOnHover = _options.pauseOnHover;
		var _pauseClass = _options.pauseClass;
		var _autoHeight = _options.autoHeight;
		var _autoRotation = _options.autoRotation;
		var _activeClass = _options.activeClass;
		var _disabledClass = _options.disabledClass;
		var _easing = _options.easing;
		var _duration = _options.duration;
		var _switchTime = _options.switchTime;
		var _controlEvent = _options.event;
		var _step = _options.step;
		var _vertical = _options.vertical;
		var _circleSlide = _options.circleSlide;
		var _stopAfterClick = _options.stopAfterClick;
		var _afterInit = _options.afterInit;
		var _splitCount = _options.splitCount;
		// gallery init
		if(!_slides.length) return;
		if(_splitCount) {
			var curStep = 0;
			var newSlide = jQuery('<slide>').addClass('split-slide');
			_slides.each(function(){
				newSlide.append(this);
				curStep++;
				if(curStep > _splitCount-1) {
					curStep = 0;
					_slider.append(newSlide);
					newSlide = jQuery('<slide>').addClass('split-slide');
				}
			});
			if(curStep) _slider.append(newSlide);
			_slides = _slider.children();
		}
		
		var _currentStep = 0;
		var _sumWidth = 0;
		var _sumHeight = 0;
		var _hover = false;
		var _stepWidth;
		var _stepHeight;
		var _stepCount;
		var _offset;
		var _timer;
		_slides.each(function(){
			_sumWidth+=jQuery(this).outerWidth(true);
			_sumHeight+=jQuery(this).outerHeight(true);
		});
		// calculate gallery offset
		function recalcOffsets() {
			if(_vertical) {
				if(_step) {
					_stepHeight = _slides.eq(_currentStep).outerHeight(true);
					_stepCount = Math.ceil((_sumHeight-_sliderHolder.height())/_stepHeight)+1;
					_offset = -_stepHeight*_currentStep;
				} else {
					_stepHeight = _sliderHolder.height();
					_stepCount = Math.ceil(_sumHeight/_stepHeight);
					_offset = -_stepHeight*_currentStep;
					if(_offset < _stepHeight-_sumHeight) _offset = _stepHeight-_sumHeight;
				}
			} else {
				if(_step) {
					_stepWidth = _slides.eq(_currentStep).outerWidth(true)*_step;
					_stepCount = Math.ceil((_sumWidth-_sliderHolder.width())/_stepWidth)+1;
					_offset = -_stepWidth*_currentStep;
					if(_offset < _sliderHolder.width()-_sumWidth) _offset = _sliderHolder.width()-_sumWidth;
				} else {
					_stepWidth = _sliderHolder.width();
					_stepCount = Math.ceil(_sumWidth/_stepWidth);
					_offset = -_stepWidth*_currentStep;
					if(_offset < _stepWidth-_sumWidth) _offset = _stepWidth-_sumWidth;
				}
			}
		}
		// gallery control
		if(_btnPrev.length) {
			_btnPrev.bind(_controlEvent,function(){
				if(_stopAfterClick) stopAutoSlide();
				prevSlide();
				return false;
			});
		}
		if(_btnNext.length) {
			_btnNext.bind(_controlEvent,function(){
				if(_stopAfterClick) stopAutoSlide();
				nextSlide();
				return false;
			});
		}
		if(_generatePagination.length) {
			_generatePagination.empty();
			recalcOffsets();
			var _list = jQuery('<ul />');
			for(var i=0; i<_stepCount; i++) jQuery('<li><a href="#">'+(i+1)+'</a></li>').appendTo(_list);
			_list.appendTo(_generatePagination);
			_pagerLinks = _list.children();
		}
		if(_pagerLinks.length) {
			_pagerLinks.each(function(_ind){
				jQuery(this).bind(_controlEvent,function(){
					if(_currentStep != _ind) {
						if(_stopAfterClick) stopAutoSlide();
						_currentStep = _ind;
						switchSlide();
					}
					return false;
				});
			});
		}
		// gallery animation
		function prevSlide() {
			recalcOffsets();
			if(_currentStep > 0) _currentStep--;
			else if(_circleSlide) _currentStep = _stepCount-1;
			switchSlide();
		}
		function nextSlide() {
			recalcOffsets();
			if(_currentStep < _stepCount-1) _currentStep++;
			else if(_circleSlide) _currentStep = 0;
			switchSlide();
		}
		function refreshStatus(ind) {
			if(_pagerLinks.length) _pagerLinks.removeClass(_activeClass).eq(_currentStep).addClass(_activeClass);
			if(!_circleSlide) {
				_btnPrev.removeClass(_disabledClass);
				_btnNext.removeClass(_disabledClass);
				if(_currentStep == 0) _btnPrev.addClass(_disabledClass);
				if(_currentStep == _stepCount-1) _btnNext.addClass(_disabledClass);
			}
			if(_curNum.length) _curNum.text(_currentStep+1);
			if(_allNum.length) _allNum.text(_stepCount);
			
			// autoHeight
			
			var heightSlide;
			
			if(_autoHeight){
				heightSlide = _slides.eq(_currentStep).outerHeight();
				if(ind != 0){
					_slider.animate({height: heightSlide}, {queue: false, duration: _duration});
				}else{
					_slider.css({height: heightSlide});
				}
			}
		}
		function switchSlide() {
			recalcOffsets();
			if(_vertical) _slider.animate({marginTop:_offset},{duration:_duration,queue:false,easing:_easing});
			else _slider.animate({marginLeft:_offset},{duration:_duration,queue:false,easing:_easing});
			refreshStatus();
			autoSlide();
		}
		// autoslide function
		function stopAutoSlide() {
			if(_timer) clearTimeout(_timer);
			_autoRotation = false;
		}
		function autoSlide() {
			if(!_autoRotation || _hover) return;
			if(_timer) clearTimeout(_timer);
			_timer = setTimeout(nextSlide,_switchTime+_duration);
		}
		if(_pauseOnHover) {
			_this.hover(function(){
				_hover = true;
				if(_timer) clearTimeout(_timer);
			},function(){
				_hover = false;
				autoSlide();
			});
		}
		recalcOffsets();
		refreshStatus(0);
		autoSlide();
		// pause buttton
		if(_pauseButton.length) {
			_pauseButton.click(function(){
				if(_this.hasClass(_pauseClass)) {
					_this.removeClass(_pauseClass);
					_autoRotation = true;
					autoSlide();
				} else {
					_this.addClass(_pauseClass);
					stopAutoSlide();
				}
				return false;
			});
		}
		if(_afterInit && typeof _afterInit === 'function') _afterInit(_this, _slides);
	});
}

// initScrollBars
var VSA_scrollAreas = new Array();
var VSA_default_imagesPath = "images";
var VSA_default_btnUpImage = "button-up.gif";
var VSA_default_btnDownImage = "button-down.gif";
var VSA_default_scrollStep = 5;
var VSA_default_wheelSensitivity = 10;
var VSA_default_scrollbarPosition = 'right';//'left','right','inline';
var VSA_default_scrollButtonHeight = 20;
var VSA_default_scrollbarWidth = 20;
var VSA_resizeTimer = 2000;
var VSA_touchFlag = isTouchDevice(); // true/false - move scroll with scrollable body

function VSA_initScrollbars() {
	if(!document.body.children) return;
	var scrollElements = VSA_getElements("vscrollable", "DIV", document, "class");
	for (var i=0; i<scrollElements.length; i++)
	{
		VSA_scrollAreas[i] = new VScrollArea(i, scrollElements[i]);
	}
}

function isTouchDevice() {
	try {
		document.createEvent("TouchEvent");
		return true;
	} catch (e) {
		return false;
	}
}

function touchHandler(event) {
	var touches = event.changedTouches, first = touches[0], type = "";
	switch(event.type) {
		case "touchstart": type = "mousedown"; break;
		case "touchmove":  type = "mousemove"; break;
		case "touchend":   type = "mouseup"; break;
		default: return;
	}
	var simulatedEvent = document.createEvent("MouseEvent");
	simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null);
	first.target.dispatchEvent(simulatedEvent);
	event.preventDefault();
}

function VScrollArea(index, elem) //constructor
{
	this.index = index;
	this.element = elem;

	var attr = this.element.getAttribute("imagesPath");
	this.imagesPath = attr ? attr : VSA_default_imagesPath;

	attr = this.element.getAttribute("btnUpImage");
	this.btnUpImage = attr ? attr : VSA_default_btnUpImage;

	attr = this.element.getAttribute("btnDownImage");
	this.btnDownImage = attr ? attr : VSA_default_btnDownImage;

	attr = Number(this.element.getAttribute("scrollStep"));
	this.scrollStep = attr ? attr : VSA_default_scrollStep;

	attr = Number(this.element.getAttribute("wheelSensitivity"));
	this.wheelSensitivity = attr ? attr : VSA_default_wheelSensitivity;

	attr = this.element.getAttribute("scrollbarPosition");
	this.scrollbarPosition = attr ? attr : VSA_default_scrollbarPosition;
	
	attr = this.element.getAttribute("scrollButtonHeight");
	this.scrollButtonHeight = attr ? attr : VSA_default_scrollButtonHeight;

	attr = this.element.getAttribute("scrollbarWidth");
	this.scrollbarWidth = attr ? attr : VSA_default_scrollbarWidth;

	this.scrolling = false;

	this.iOffsetY = 0;
	this.scrollHeight = 0;
	this.scrollContent = null;
	this.scrollbar = null;
	this.scrollup = null;
	this.scrolldown = null;
	this.scrollslider = null;
	this.scroll = null;
	this.enableScrollbar = false;
	this.scrollFactor = 1;
	this.scrollingLimit = 0;
	this.topPosition = 0;

	//functions declaration
	this.init = VSA_init;
	this.scrollUp = VSA_scrollUp;
	this.scrollDown = VSA_scrollDown;
	this.createScrollBar = VSA_createScrollBar;
	this.scrollIt = VSA_scrollIt;

	this.init();
}

function VSA_init() {
	this.scrollContent = document.createElement("DIV");
	this.scrollContent.style.position = "absolute";
	this.scrollContent.style.overflow = "hidden";
	this.scrollContent.style.width = this.element.offsetWidth + "px";
	this.scrollContent.style.height = this.element.offsetHeight + "px";

	while(this.element.childNodes.length) this.scrollContent.appendChild(this.element.childNodes[0]);

	this.element.style.overflow = "hidden";
	this.element.style.display = "block";
	this.element.style.visibility = "visible";
	this.element.style.position = "relative";
	this.element.appendChild(this.scrollContent);

	this.scrollContent.className = 'scroll-content';

	this.element.index = this.index;
	this.element.over = false;
	
	var _this = this;

	if(document.all && !window.opera) {
		this.element.onmouseenter = function(){_this.element.over = true;};
		this.element.onmouseleave = function(){_this.element.over = false;}
	} else {
		this.element.onmouseover = function(){_this.element.over = true;};
		this.element.onmouseout = function(){_this.element.over = false;}
	}

	if (document.all)
	{
		this.element.onscroll = VSA_handleOnScroll;
		this.element.onresize = VSA_handleResize;
	}
	else
	{
		window.onresize = VSA_handleResize;
	}
	
	this.createScrollBar();
	
	if (window.addEventListener) {
		/* DOMMouseScroll is for mozilla. */
		this.element.addEventListener('DOMMouseScroll', VSA_handleMouseWheel, false);
	}
	/* IE/Opera. */
	this.element.onmousewheel = document.onmousewheel = VSA_handleMouseWheel;

	// move content by touch
	if(VSA_touchFlag) {
		_this.scrollContent.onmousedown = function(e) {
			var startY = e.pageY-getRealTop(_this.scrollContent);
			var origTop = _this.scrollContent.scrollTop;
			_this.scrollContent.onmousemove = function(e) {
				var moveY = e.pageY-getRealTop(_this.scrollContent);
				var iNewY = origTop-(moveY-startY);
				if(iNewY < 0) iNewY = 0;
				if(iNewY > _this.scrollContent.scrollHeight) iNewY = _this.scrollContent.scrollHeight;
				_this.scrollContent.scrollTop = iNewY;
				_this.scrollslider.style.top =  1 / _this.scrollFactor * Math.abs(_this.scrollContent.scrollTop) + _this.scrollButtonHeight + "px";
			}
		}
		_this.scrollContent.onmouseup = function(e) {
			_this.scrollContent.onmousemove = null;
		}
		this.scrollContent.addEventListener("touchstart", touchHandler, true);
		this.scrollContent.addEventListener("touchmove", touchHandler, true);
		this.scrollContent.addEventListener("touchend", touchHandler, true);
	}
}

function VSA_createScrollBar()
{
	if (this.scrollbar != null)
	{
		this.element.removeChild(this.scrollbar);
		this.scrollbar = null;
	}
	
	if (this.scrollContent.scrollHeight <= this.scrollContent.offsetHeight)
		this.enableScrollbar = false;
	else if (this.element.offsetHeight > 2*this.scrollButtonHeight)
		this.enableScrollbar = true;
	else
		this.enableScrollbar = false;

	if (this.scrollContent.scrollHeight - Math.abs(this.scrollContent.scrollTop) < this.element.offsetHeight)
		this.scrollContent.style.top = 0;

	if (this.enableScrollbar)
	{
		this.scrollbar = document.createElement("DIV");
		this.element.appendChild(this.scrollbar);
		this.scrollbar.style.position = "absolute";
		this.scrollbar.style.top = "0px";
		this.scrollbar.style.height = this.element.offsetHeight+"px";
		this.scrollbar.style.width = this.scrollbarWidth + "px";

		this.scrollbar.className = 'vscroll-bar';

		if(this.scrollbarWidth != this.scrollbar.offsetWidth)
		{
			this.scrollbarWidth = this.scrollbar.offsetHeight;
		}
		
		this.scrollbarWidth = this.scrollbar.offsetWidth;

		if(this.scrollbarPosition == 'left')
		{
			this.scrollContent.style.left = this.scrollbarWidth + 5 + "px";
			this.scrollContent.style.width = this.element.offsetWidth - this.scrollbarWidth - 5 + "px";
		}
		else if(this.scrollbarPosition == 'right')
		{
			this.scrollbar.style.left = this.element.offsetWidth - this.scrollbarWidth  + "px";
			this.scrollContent.style.width = this.element.offsetWidth - this.scrollbarWidth - 5 + "px";
		}

		//create scroll up button
		this.scrollup = document.createElement("DIV");
		this.scrollup.index = this.index;
		this.scrollup.onmousedown = VSA_handleBtnUpMouseDown;
		this.scrollup.onmouseup = VSA_handleBtnUpMouseUp;
		this.scrollup.onmouseout = VSA_handleBtnUpMouseOut;
		
		if(VSA_touchFlag) {
			this.scrollup.addEventListener("touchstart", touchHandler, true);
			this.scrollup.addEventListener("touchend", touchHandler, true);
		}
		
		this.scrollup.style.position = "absolute";
		this.scrollup.style.top = "0px";
		this.scrollup.style.left = "0px";
		this.scrollup.style.height = this.scrollButtonHeight + "px";
		this.scrollup.style.width = this.scrollbarWidth + "px";
		
		this.scrollup.innerHTML = '<img src="' + this.imagesPath + '/' + this.btnUpImage + '" border="0"/>';
		this.scrollbar.appendChild(this.scrollup);

		this.scrollup.className = 'vscroll-up';

		if(this.scrollButtonHeight != this.scrollup.offsetHeight)
		{
			this.scrollButtonHeight = this.scrollup.offsetHeight;
		}
		
		//create scroll down button
		this.scrolldown = document.createElement("DIV");
		this.scrolldown.index = this.index;
		this.scrolldown.onmousedown = VSA_handleBtnDownMouseDown;
		this.scrolldown.onmouseup = VSA_handleBtnDownMouseUp;
		this.scrolldown.onmouseout = VSA_handleBtnDownMouseOut;
		
		if(VSA_touchFlag) {
			this.scrolldown.addEventListener("touchstart", touchHandler, true);
			this.scrolldown.addEventListener("touchend", touchHandler, true);
		}
		
		this.scrolldown.style.position = "absolute";
		this.scrolldown.style.left = "0px";
		this.scrolldown.style.top =  this.scrollbar.offsetHeight - this.scrollButtonHeight + "px";
		this.scrolldown.style.width = this.scrollbarWidth + "px";
		this.scrolldown.innerHTML = '<img src="' + this.imagesPath + '/' + this.btnDownImage + '" border="0"/>';
		this.scrollbar.appendChild(this.scrolldown);

		this.scrolldown.className = 'vscroll-down';

		//create scroll
		this.scroll = document.createElement("DIV");
		this.scroll.index = this.index;
		this.scroll.style.position = "absolute";
		this.scroll.style.zIndex = 0;
		this.scroll.style.textAlign = "center";
		this.scroll.style.top = this.scrollButtonHeight + "px";
		this.scroll.style.left = "0px";
		this.scroll.style.width = this.scrollbarWidth + "px";
		
		var h = this.scrollbar.offsetHeight - 2*this.scrollButtonHeight;
		this.scroll.style.height = ((h > 0) ? h : 0) + "px";
		
		this.scroll.innerHTML = '';
		this.scroll.onclick = VSA_handleScrollbarClick;
		this.scrollbar.appendChild(this.scroll);
		this.scroll.style.overflow = "hidden";

		this.scroll.className = "vscroll-line";

		//create slider
		this.scrollslider = document.createElement("DIV");
		this.scrollslider.index = this.index;
		this.scrollslider.style.position = "absolute";
		this.scrollslider.style.zIndex = 1000;
		this.scrollslider.style.textAlign = "center";
		this.scrollslider.innerHTML = '<div id="vscrollslider' + this.index + '" style="padding:0;margin:0;"><div class="scroll-bar-top"></div><div class="scroll-bar-bottom"></div></div>';
		this.scrollbar.appendChild(this.scrollslider);
		
		this.subscrollslider = document.getElementById("vscrollslider"+this.index);
		this.subscrollslider.style.height = Math.round((this.scrollContent.offsetHeight/this.scrollContent.scrollHeight)*(this.scrollbar.offsetHeight - 2*this.scrollButtonHeight)) + "px";
		
		this.scrollslider.className = "vscroll-slider";
		
		this.scrollHeight = this.scrollbar.offsetHeight - 2*this.scrollButtonHeight - this.scrollslider.offsetHeight;
		this.scrollFactor = (this.scrollContent.scrollHeight - this.scrollContent.offsetHeight)/this.scrollHeight;
		this.topPosition = getRealTop(this.scrollbar) + this.scrollButtonHeight;
		/* this.scrollbarHeight = this.scrollbar.offsetHeight - 2*this.scrollButtonHeight - this.scrollslider.offsetHeight; */

		this.scrollslider.style.top = /* 1 / this.scrollFactor * Math.abs(this.scrollContent.offsetTop) +*/ this.scrollButtonHeight + "px";
		this.scrollslider.style.left = "0px";
		this.scrollslider.style.width = "100%";
		this.scrollslider.onmousedown = VSA_handleSliderMouseDown;
		if(VSA_touchFlag) {
			this.scrollslider.addEventListener("touchstart", touchHandler, true);
		}
		if (document.all)
			this.scrollslider.onmouseup = VSA_handleSliderMouseUp;
	}
	else
		this.scrollContent.style.width = this.element.offsetWidth + "px";
}

function VSA_handleBtnUpMouseDown()
{
	var sa = VSA_scrollAreas[this.index];
	sa.scrolling = true;
	sa.scrollUp();
}

function VSA_handleBtnUpMouseUp()
{
	VSA_scrollAreas[this.index].scrolling = false;
}

function VSA_handleBtnUpMouseOut()
{
	VSA_scrollAreas[this.index].scrolling = false;
}

function VSA_handleBtnDownMouseDown()
{
	var sa = VSA_scrollAreas[this.index];
	sa.scrolling = true;
	sa.scrollDown();
}

function VSA_handleBtnDownMouseUp()
{
	VSA_scrollAreas[this.index].scrolling = false;
}

function VSA_handleBtnDownMouseOut()
{
	VSA_scrollAreas[this.index].scrolling = false;
}

function VSA_scrollIt()
{
	this.scrollContent.scrollTop = this.scrollFactor * ((this.scrollslider.offsetTop + this.scrollslider.offsetHeight/2) - this.scrollButtonHeight - this.scrollslider.offsetHeight/2);
}

function VSA_scrollUp()
{
	if (this.scrollingLimit > 0)
	{
		this.scrollingLimit--;
		if (this.scrollingLimit == 0) this.scrolling = false;
	}
	if (!this.scrolling) return;
	if ( this.scrollContent.scrollTop - this.scrollStep > 0)
	{
		this.scrollContent.scrollTop -= this.scrollStep;
		this.scrollslider.style.top = 1 / this.scrollFactor * Math.abs(this.scrollContent.scrollTop) + this.scrollButtonHeight + "px";
	}
	else
	{
		this.scrollContent.scrollTop = "0";
		this.scrollslider.style.top = this.scrollButtonHeight + "px";
		return;
	}
	setTimeout("VSA_Ext_scrollUp(" + this.index + ")", 30);
}

function VSA_Ext_scrollUp(index)
{
	VSA_scrollAreas[index].scrollUp();
}

function VSA_scrollDown()
{
	if (this.scrollingLimit > 0)
	{
		this.scrollingLimit--;
		if (this.scrollingLimit == 0) this.scrolling = false;
	}
	if (!this.scrolling) return;


	this.scrollContent.scrollTop += this.scrollStep;
	this.scrollslider.style.top =  1 / this.scrollFactor * Math.abs(this.scrollContent.scrollTop) + this.scrollButtonHeight + "px";

	if (this.scrollContent.scrollTop >= (this.scrollContent.scrollHeight - this.scrollContent.offsetHeight))
	{
		this.scrollContent.scrollTop = (this.scrollContent.scrollHeight - this.scrollContent.offsetHeight);
		this.scrollslider.style.top = this.scrollbar.offsetHeight - this.scrollButtonHeight - this.scrollslider.offsetHeight + "px";
		return;
	}

	setTimeout("VSA_Ext_scrollDown(" + this.index + ")", 30);
}

function VSA_Ext_scrollDown(index)
{
	VSA_scrollAreas[index].scrollDown();
}

function VSA_handleMouseMove(evt)
{
	var sa = VSA_scrollAreas[((document.all && !window.opera) ? this.index : document.documentElement.scrollAreaIndex)];
	var posy = 0;
	if (!evt) var evt = window.event;
	
	if (evt.pageY)
		posy = evt.pageY;
	else if (evt.clientY)
		posy = evt.clientY;
			
		if (document.all && !window.opera)
		{
			if(!document.addEventListener) {
				posy += document.documentElement.scrollTop;
			}
		}

	var iNewY = posy - sa.iOffsetY - getRealTop(sa.scrollbar) - sa.scrollButtonHeight;
		iNewY += sa.scrollButtonHeight;
		
	if (iNewY < sa.scrollButtonHeight)
		iNewY = sa.scrollButtonHeight;
	if (iNewY > (sa.scrollbar.offsetHeight - sa.scrollButtonHeight) - sa.scrollslider.offsetHeight)
		iNewY = (sa.scrollbar.offsetHeight - sa.scrollButtonHeight) - sa.scrollslider.offsetHeight;

	sa.scrollslider.style.top = iNewY + "px";

	sa.scrollIt();
}

function VSA_handleSliderMouseDown(evt)
{
	if (!(document.uniqueID && document.compatMode && !window.XMLHttpRequest))
	{
		document.onselectstart = function() { return false; }
		document.onmousedown = function() { return false; }
	}

	var sa = VSA_scrollAreas[this.index];
	if (document.all && !window.opera)
	{
		sa.scrollslider.setCapture()
		sa.iOffsetY = event.offsetY;
		sa.scrollslider.onmousemove = VSA_handleMouseMove;
		if(VSA_touchFlag) {
			sa.scrollslider.addEventListener("touchmove", touchHandler, true);
		}
	}
	else
	{
		if(window.opera)
		{
			sa.iOffsetY = event.offsetY;
		}
		else
		{
			sa.iOffsetY = evt.layerY;
		}
		document.documentElement.scrollAreaIndex = sa.index;
		document.documentElement.addEventListener("mousemove", VSA_handleMouseMove, true);
		document.documentElement.addEventListener("mouseup", VSA_handleSliderMouseUp, true);
		if(VSA_touchFlag) {
			document.documentElement.addEventListener("touchmove", touchHandler, true);
			document.documentElement.addEventListener("touchend", touchHandler, true);
		}
	}
	return false;
}

function VSA_handleSliderMouseUp()
{
	if (!(document.uniqueID && document.compatMode && !window.XMLHttpRequest))
	{
		document.onmousedown = null;
		document.onselectstart = null;
	}

	if (document.all && !window.opera)
	{
		var sa = VSA_scrollAreas[this.index];
		sa.scrollslider.onmousemove = null;
		sa.scrollslider.releaseCapture();
		sa.scrollIt();
	}
	else
	{
		var sa = VSA_scrollAreas[document.documentElement.scrollAreaIndex];
		document.documentElement.removeEventListener("mousemove", VSA_handleMouseMove, true);
		document.documentElement.removeEventListener("mouseup", VSA_handleSliderMouseUp, true);
		if(VSA_touchFlag) {
			document.documentElement.removeEventListener("touchmove", touchHandler, true);
			document.documentElement.removeEventListener("touchend", touchHandler, true);
		}
		sa.scrollIt();
	}
	return false;
}

function VSA_handleResize()
{
	if (VSA_resizeTimer)
	{
		clearTimeout(VSA_resizeTimer);
		VSA_resizeTimer = 0;
	}
	VSA_resizeTimer = setTimeout("VSA_performResizeEvent()", 100);
}

function VSA_performResizeEvent()
{
	for (var i=0; i<VSA_scrollAreas.length; i++)
		VSA_scrollAreas[i].createScrollBar();
}
function VSA_handleMouseWheel(event){
	if (this.index != null) {
		var sa = VSA_scrollAreas[this.index];
		if (sa.scrollbar == null) return;
		sa.scrolling = true;
		sa.scrollingLimit = sa.wheelSensitivity;

		var delta = 0;
		if (!event) /* For IE. */
			event = window.event;
		if (event.wheelDelta) { /* IE/Opera. */
			delta = event.wheelDelta/120;
			/*if (window.opera) delta = -delta;*/
		} else if (event.detail) { /* Mozilla case. */
			delta = -event.detail/3;
		}

		if (delta && sa.element.over) {
			if (delta > 0) {
				sa.scrollUp();
			} else {
				sa.scrollDown();
			}
			if (event.preventDefault) {
				event.preventDefault();
			}
			event.returnValue = false;
		}
	}
}

function VSA_handleSelectStart()
{
	event.returnValue = false;
}

function VSA_handleScrollbarClick(evt)
{
	var sa = VSA_scrollAreas[this.index];
	var offsetY = (document.all ? event.offsetY : evt.layerY);

	if (offsetY < (sa.scrollButtonHeight + sa.scrollslider.offsetHeight/2))
		sa.scrollslider.style.top = sa.scrollButtonHeight + "px";
	else if (offsetY > (sa.scrollbar.offsetHeight - sa.scrollButtonHeight - sa.scrollslider.offsetHeight))
		sa.scrollslider.style.top = sa.scrollbar.offsetHeight - sa.scrollButtonHeight - sa.scrollslider.offsetHeight + "px";
	else
	{
		sa.scrollslider.style.top = offsetY + sa.scrollButtonHeight - sa.scrollslider.offsetHeight/2 + "px";
	}
	sa.scrollIt();
}

function VSA_handleOnScroll()
{
	//event.srcElement.doScroll("pageUp");
}

//--- common functions ----

function VSA_getElements(attrValue, tagName, ownerNode, attrName) //get Elements By Attribute Name
{
	if (!tagName) tagName = "*";
	if (!ownerNode) ownerNode = document;
	if (!attrName) attrName = "name";
	var result = [];
	var nl = ownerNode.getElementsByTagName(tagName);
	for (var i=0; i<nl.length; i++)
	{
	//	if (nl.item(i).getAttribute(attrName) == attrValue)
//		result.push(nl.item(i));
		if (nl.item(i).className.indexOf(attrValue) != -1)
		result.push(nl.item(i));
	}
	return result;
}

function getRealTop(obj) {
	if (obj.getBoundingClientRect) {
		var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
		var clientTop = document.documentElement.clientTop || document.body.clientTop || 0;
		return Math.round(obj.getBoundingClientRect().top + scrollTop - clientTop);
	} else {
		var posTop = 0;
		while (obj.offsetParent) {posTop += obj.offsetTop; obj = obj.offsetParent;}
		return posTop;
	}
}

/*
 * ByRei dynDiv 1.0 RC1 - dynamic Div Script
 *
 * Copyright (c) 2008 Markus Bordihn (markusbordihn.de)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2009-07-10 19:00:00 +0100 (Fri, 10 Jul 2009) $
 * $Rev: 1.0 RC1 $
 */

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('y h={3r:{3s:"3t 3u",3v:"1.0 3w",3x:"3y 3z (3A://3B.3C)",3D:"3E 3F 3G\'s"},19:{2i:z,2j:z,L:z,2k:z,p:z},M:[],1t:{C:"3H",26:{2L:"3I"},1L:{Q:/(\\d+)Q/,1S:/2M|2N/}},j:{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.I(a.X,\'3J\'));1V=h.n.Q(h.I(a.X,\'1V\'))}b={m:(c>0)?1W-c:1W,l:(1V>0)?1X-1V:1X}}T b}},u:v(a,b,c){k(a){1n(y i=0;i<5;i++){k(b.1Y(a.1c)){k(c){a=a.X}P{t}}P{k(c){t}P{a=a.X}}}T a}},r:{1w:v(a){y i,1e={1Z:A,1M:""},U=h.B.1v;k(a){1n(i=0;i<U;i++){k(a===\'1a\'){k(h.B[i][3]!==\'1j\'){k(h.B[i][3]>1e.1M){1e.1Z=O;1e.1M=h.B[i][3]}}}P k(h.B[i][0]===a){1e.1Z=O;1e.1M=i;t}}}T 1e}},2Y:v(a,b,c){y d=A;k(a&&b){y e={o:h.n.o.1A(a),G:a.1h,H:a.1i},17={o:h.n.o.1A(b),G:b.1h,H:b.1i},j={1N:e.o.l+e.H,1D:17.o.l+17.H,2a:e.o.m+e.G,21:17.o.m+17.G};Y(c){q"2Z":q"30":k(((e.o.m>17.o.m&&e.o.m<j.21)&&((e.o.l>17.o.l&&e.o.l<j.1D)||(j.1N>17.o.l&&j.1N<j.1D)))||((j.2a>17.o.m&&j.2a<j.21)&&((e.o.l>17.o.l&&e.o.l<j.1D)||(j.1N>17.o.l&&j.1N<j.1D)))){d=O}t;2q:k((e.o.m>17.o.m&&e.o.m<j.21&&j.2a<j.21)&&(e.o.l>17.o.l&&e.o.l<j.1D&&j.1N<j.1D)){d=O}t}}T d}},S:{Z:v(a){k(h.j.p){h.n.1u(a);k(h.n.r.1w(\'1a\').1Z){h.I(h.j.p,\'1a\',h.n.r.1w(\'1a\').1M+1)}k(h.j.V){k(h.19.2k){h.19.2k()}Y(h.j.V){q"1o":q"1k":q"1l":q"1m":h.15();t;q"Z":q"2b":h.Z();t;2q:t}}k(h.j.1T){a.3K=A}}},1p:v(){k(!h.j.p){h.16(W,\'31\',h.S.Z);h.16(W,\'32\',h.S.2r)}},2r:v(){k(h.r(0)){k(h.r(6)){y i,M={p:A},U=h.M.1v;1n(i=0;i<U;i++){k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j)\':\'36(1j 1j \'+(2u)+\'Q 1j)\')}},15:v(a,b){y i,22=(a.1E||a.2d)?(a.1E?a.1E:a.2d):(a),K=22.1c.1b(\' \'),2e=(h.n.C.D(K,"2w")&&22.X)?22.X.2x(\'2y\'):22.2x(\'2y\'),U=2e.1v;1n(i=0;i<U;i++){k(h.n.C.D(2e[i].1c.1b(\' \'),"37",1)){h.I(2e[i],\'38\',(b)?\'1O\':\'39\')}}}},F:{3a:v(){y i=0,1F=W.2x(\'2y\'),U=1F.1v;1n(y a=0;a<U;a++){k(h.n.C.D(1F[a].1c.1b(\' \'),"",1)){k(h.n.C.D(1F[a].1c.1b(\' \'),"37",1)&&h.n.C.D(1F[a].X.1c.1b(\' \'),"Z",1)===\'\'){h.2z(1F[a].X,i++,1)}h.2z(1F[a],i++)}}},1p:v(a,b){k(a){k(a.3b){a.3b()}k(h.j.1T){a.3N=O}k(a.3c){a.3c()}y c=a.1E?a.1E:a.2d;k(c.1c.2P(\'2M\')===-1){h.n.1u(a);h.S.1p();Y(b){q"Z":h.j.p=h.19.p=h.n.u(c,/3O/);t;q"2b":h.j.p=h.19.p=h.n.u(c,/2N/).X;t;q"1l":q"1k":q"1m":q"1o":h.j.p=h.19.p=c.X;t;2q:h.j.p=h.19.p=c;t}h.j.L=h.19.L=h.n.r.1w(h.j.p).1M;h.j.1a=h.I(h.j.p,\'1a\');h.n.E(h.j.p);h.j.V=b;k(h.r(1)&&h.j.p){y d={o:h.n.o.1A(h.j.p)},x={o:h.n.o.1A(h.r(1))};h.x.N.m=x.o.m-d.o.m;h.x.1d.m=(h.r(1).1h+x.o.m)-(h.j.p.3P+d.o.m);h.x.N.l=x.o.l-d.o.l;h.x.1d.l=(h.r(1).1i+x.o.l)-(h.j.p.3Q+d.o.l)}k(h.19.2i){h.19.2i()}Y(b){q"Z":q"2b":k(h.r(9)===\'Z\'||h.r(9)===\'2A\'){h.J.1O(A)}t;q"1l":q"1k":q"1m":q"1o":k(h.r(9)===\'15\'||h.r(9)===\'2A\'){h.J.1O(A)}t}k(h.j.L!==h.j.R.L&&(h.j.R.L||h.j.R.L===0)){k(h.B[h.j.R.L][10]){h.S.15(h.j.R.p,A)}}k(h.r(10)===\'3R\'||h.r(10)===\'1P\'){h.S.15(h.j.p,O)}}}}},2t:{33:v(){k(h.B){y i,U=h.B.1v;1n(i=0;i<U;i++){k(h.B[i][12]!==A&&h.B[i][0].1w){y a=\'\',l=\'\',G=\'\',H=\'\';Y(h.B[i][12]){q"2B":a=h.B[i][4];l=h.B[i][5];t;q"2C":G=h.B[i][13];H=h.B[i][14];t;q"2D":a=h.B[i][4];l=h.B[i][5];G=h.B[i][13];H=h.B[i][14];t}k((23(a)!==\'2f\'&&23(l)!==\'2f\')||(G>0&&H>0)){k(3d.3e){y b=2v 3f();b.3S((2v 3f()).3T(b.3U())+23(h.1t.26.2L));W.26="3g"+h.B[i][0].1w+"="+a+\'1Q\'+l+\'1Q\'+G+\'1Q\'+H+"; 3V="+b.3W()}}}}}},2E:v(a){y b=A;k(3d.3e&&a){y c=W.26;k(/; /.1Y(c)){c=c.1b("; ")}P k(/, /.1Y(c)){c=c.1b(", ")}k(c){y i,U=c.1v;1n(i=0;i<U;i++){k(c[i]){k((/h/).1Y(c[i])){y d=(/3g(\\w+)=(\\d*)\\1Q(\\d*)\\1Q(\\d*)\\1Q(\\d*)/).3X(c[i]);k(1B d!==\'1C\'&&d!==z){k(1B d[1]!==\'1C\'){k(d[1]===a){b={m:d[2],l:d[3],G:d[4],H:d[5]};t}}}}}}}}T b}},J:{1O:v(a){y i,U=h.B.1v;1n(i=0;i<U;i++){k(h.B[i]!==h.B[h.j.L]){h.I(h.B[i][0],\'38\',(a)?\'1O\':\'39\')}}},m:v(a,b){h.I(a,\'m\',b+"Q")},l:v(a,b){h.I(a,\'l\',b+"Q")},G:v(a,b){h.I(a,\'G\',b+"Q")},H:v(a,b){h.I(a,\'H\',b+"Q")}},15:v(){k(h.j.p&&h.j.V){y a=20,1r=0,1s=0,1R=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F.E.l;k(b<h.x.N.m){a=h.r(4)+h.x.N.m}P k(b>h.x.1d.m){a=h.r(4)+h.x.1d.m}k(2G<h.x.N.l){1g=h.r(5)+h.x.N.l}P k(2G>h.x.1d.l){1g=h.r(5)+h.x.1d.l}}k(!3h(a)){h.J.m(h.j.p,a)}k(!3h(1g)){h.J.l(h.j.p,1g)}}},r:v(i,a){y b=A;k(h.j.L>=0){k(h.B[h.j.L]){k(1B h.B[h.j.L][i]!==\'1C\'){k(1B a!==\'1C\'){h.B[h.j.L][i]=a;b=O}P{b=h.B[h.j.L][i]}}}}T b},2z:v(b,i,c){k(b){y d=\'1j\',K=b.1c.1b(\' \'),2H=v(a,i){T(h.I(a,\'1a\')||h.I(a,\'1a\',i))};k(h.n.C.D(K,"",1)||c){y f=z,2g=A,2I=A,24=A,2h=A,18=A,1J=A,u=b,V=h.n.C.D(K,"",1),1x=u.X;k(V){Y(V){q"3i":h.I(u,\'1K\',\'Z\');h.16(u,\'1q\',v(e){h.F.1p(e,\'Z\')});d=2H(u,i);t;q"2w":h.I(u,\'1K\',\'Z\');h.16(u,\'1q\',v(e){h.F.1p(e,\'2b\')});u=u.X;d=2H(u,i);t;q"3Y":h.I(u,\'1K\',\'3Z-15\');h.16(u,\'1q\',v(e){h.F.1p(e,\'1l\')});t;q"40":h.I(u,\'1K\',\'41-15\');h.16(u,\'1q\',v(e){h.F.1p(e,\'1k\')});t;q"42":h.I(u,\'1K\',\'43-15\');h.16(u,\'1q\',v(e){h.F.1p(e,\'1m\')});t;q"44":h.I(u,\'1K\',\'45-15\');h.16(u,\'1q\',v(e){h.F.1p(e,\'1o\')});t;q"46":h.I(u,\'1K\',\'47\');h.16(u,\'1q\',v(e){h.S.1S(e)});t;q"M":h.M.2J([u,\'3j\']);t}}k(h.n.C.D(K,"M-",1)){h.M.2J([u,h.n.C.D(K,"M-",1)])}2X(1x){k(1x.1c){k(h.n.C.D(1x.1c.1b(\' \'),"48")){k(u!==1x){f=1x}t}}1x=1x.X}k(!f){k(h.n.C.D(K,"3k")||h.n.C.D(u.X.1c.1b(\' \'),"3k")){f=W.2n}}k(h.n.C.D(K,"2K")){2g=\'3j\'}P k(h.n.C.D(K,"2K-",1)){2g=h.n.C.D(K,"2K-",1)}k(h.n.C.D(K,"3l-",1)){2I=h.n.C.D(K,"3l-",1)}k(h.n.C.D(K,"3m")&&h.n.C.D(K,"3n")){24=\'2A\'}P{k(h.n.C.D(K,"3m")){24=\'Z\'}P k(h.n.C.D(K,"3n")){24=\'15\'}}k(h.n.C.D(K,"18")){k(u.1h&&u.1i){18=49.4a(u.1h/u.1i)}}k(h.n.C.D(K,"3o-",1)){2h=h.n.C.D(K,"3o-",1);h.S.15(u,A);k(2h===\'4b\'){h.16(u,\'4c\',v(e){h.S.15(e,O)})}}Y(h.n.C.D(K,"1J-",1)){q"2B":1J="2B";t;q"2C":1J="2C";t;q"2D":1J="2D";t}k(1J&&!h.j.2l){h.j.2l=h.16(1U,\'2s\',h.S.2s)}k(h.n.C.D(K,"4d")){y g=h.2t.2E(u.1w);k(g){k(23(g.m)!==\'2f\'&&23(g.l)!==\'2f\'){h.J.m(u,g.m);h.J.l(u,g.l)}k(g.G>0&&g.H>0){h.J.G(u,g.G);h.J.H(u,g.H)}}}k(h.n.C.D(K,"2w")||h.n.C.D(K,"3i")||c){k(!h.n.r.1w(u).1Z){h.B.2J([u,f,A,d,h.n.o.1f(u).m,h.n.o.1f(u).l,2g,2I,A,24,2h,18,1J,u.1h,u.1i])}}}}},I:v(a,b,c){k(a&&b){k(a.25){k(1B a.25[b]!==\'1C\'){k(c){4e{T(a.25[b]=c)}4f(e){T A}}P{T(a.25[b]===\'\')?((a.3p)?a.3p[b]:((1U.3q)?1U.3q(a,\'\').4g(b):A)):a.25[b]}}}}},2c:v(a,b,c){k(a&&b&&c){k(h.j.1T){a.2O("S"+b,c)}P{a.4h(b,c,A)}}},16:v(a,b,c){k(a&&b&&c){k(h.j.1T){T a.4i("S"+b,c)}P{T a.4j(b,c,A)}}}};h.16(1U,\'2E\',h.F.3a);',62,268,'|||||||||||||||||ByRei_dynDiv||cache|if|top|left|get|offset|obj|case|db||break|parent|function||limit|var|null|false|divList|prefix|value|pos|init|width|height|_style|set|classNames|elem|dropArea|min|true|else|px|last|on|return|il|modus|document|parentNode|switch|move||||||resize|set_eventListener|obj2|keepAspect|api|zIndex|split|className|max|result|relative|new_top|clientWidth|clientHeight|auto|tr|tl|bl|for|br|action|mousedown|new_size_x|new_size_y|config|mouse|length|id|l_parent|browser|support|absolute|typeof|undefined|o2t_o2h|target|div_list|reachLimit|mouse_diff_left|mouse_diff_top|saveSettings|cursor|regExp|data|o1t_o1h|visible|focus|_|new_left|minmax|ie|window|borderTop|offsetLeft|offsetTop|test|found||o2l_o2w|evt_src|Number|hideaction|style|cookie|page|client|offsetParent|o1l_o1w|moveparent|del_eventListener|srcElement|resize_list|NaN|droplimiter|showresize|drag|drop|alter|unloadHandler|match|body|marginLeft|marginTop|default|stop|unload|settings|minmaxHeight|new|moveParentDiv|getElementsByTagName|div|add|move_resize|position|size|position_size|load|pos_top|pos_y|func_z_index|dropmode|push|dropLimit|expire|dynDiv_minmaxDiv|dynDiv_moveParentDiv|detachEvent|indexOf|pageX|pageY|clientX|clientY|scrollLeft|documentElement|scrollTop|while|hit|fit|center|mousemove|mouseup|save|minmax_src|clip|rect|resizeDiv_|visibility|hidden|main|preventDefault|stopPropagation|navigator|cookieEnabled|Date|ByRei_dynDiv_|isNaN|moveDiv|global|bodyLimit|dropMode|hideMove|hideResize|showResize|currentStyle|getComputedStyle|info|Name|ByRei|dynDiv|Version|RC1|Author|Markus|Bordihn|http|markusbordihn|de|Description|Simple|dynamic|DIV|dynDiv_|2678400|borderLeft|returnValue|minmax_Height|RegExp|cancelBubble|dynDiv_moveDiv|offsetWidth|offsetHeight|active|setSeconds|setTime|getSeconds|expires|toGMTString|exec|resizeDiv_tl|nw|resizeDiv_tr|ne|resizeDiv_bl|sw|resizeDiv_br|se|minmaxDiv|pointer|setLimit|Math|abs|dbclick|dblclick|loadSettings|try|catch|getPropertyValue|removeEventListener|attachEvent|addEventListener'.split('|'),0,{}))
