zooming = Class.create();
Object.extend(zooming.prototype,DragHandler);
Object.extend(zooming.prototype, {
	initialize : function (zoomScroller) {
		this.zs = $(zoomScroller);
		this.zb = this.zs.childNodes[0];
		this.observeDrag(this.zs);
		this.leftx = Position.cumulativeOffset($('header'))[0];					
	},
	mouseDownAction : function (e) {
		this.positionBar();
	},
	mouseMoveAction : function (e) {
		this.positionBar();
	},
	mouseUpAction : function (e) {
		var scalex = this.positionBar();
		
		var inf = $('param_info');
		var param_str = 'size='+ Math.round(80/Math.max(2,scalex)*2);
		if (inf) {
			$A(inf.getElementsByTagName('A')).each(function(x){ param_str += '&'+x.id.replace('current_','')+'='+x.name.replace(/[^0-9]+/,'') });
		}
		new Ajax.Request('retrieveVideoList.php', {
						 method:'get',
						 parameters:param_str,
						 onComplete:this.onReceiveLoad.bind(this)
						 })
		
	},
	positionBar : function (e) {
		this.zb.style.left = Math.min(90, Math.max(0, this.posx - this.leftx - 590 )) + 'px';
		return this.posx - this.leftx - 590;
	},
	onReceiveLoad : function (xmlHTTP) {
		var p = this.zb.parentNode;
		while (p.parentNode && p.className != 'video-listings-wrapper') {
			p = p.parentNode;
		}
		if (p.className == 'video-listings-wrapper') {
			document.getElementsByClassName('video-listings',p)[0].innerHTML = xmlHTTP.responseText;
		}
	}
});

$A(document.getElementsByClassName('zoomScroller')).each(function(x){new zooming(x); })
