<!--

var sliding_tabs = new Class({
	initialize:function(tabs, options){
		this.options = {
			tab_margin_left: '0px',
			tab_margin_right: '0px',
			event:'click'
		}
		$extend(this.options,options);
		this.tabs = tabs;
		/*this.tabs.setStyles({
			'position':'relative',
			'float':'left'
		});
		*/
		this.tab_overflow = $('tab_overflow');// new Element('div').setProperty('class','tab_overflow');
		//this.tab_overflow.injectBefore(this.tabs[0]);
	
		this.tab_container = $('tab_container');//new Element('div').setProperty('class','tab_container');
		//this.tab_container.injectInside(this.tab_overflow);
				
		this.tab_items = [];
		this.tabs_dim = 0;
		
		this.tabs.each(function(el,i){
			var w = el.getStyle('width').toInt();
			this.tabs_dim += 160;
			//el.injectInside(this.tab_container);
			//el.setStyle('left',this.options['tab_margin_left']);
			this.tab_items[i] = new tab_item(el,this);
		}.bind(this));
		var tab_container_width = this.tabs_dim+this.options['tab_margin_left'].toInt()+this.options['tab_margin_right'].toInt();
		this.tab_container.setStyle('width', tab_container_width+'px'); 
		
		this.tab_fx = new Fx.Scroll(this.tab_overflow,{
			duration:800,
			link:'cancel',
			onComplete:function(){
				//this.tab_overflow.addEvent('mousemove',this.mouse_move.bind(this));
				var myCookie1  = Cookie.write('position', this.tab_overflow.getScroll().x, {duration: 1});
			}.bind(this)
		});
		
		
		$('scrollLeft').addEvent('click',function(e){
			e = new Event(e).stop();
			this.tab_fx.start(this.tab_overflow.getScroll().x-800,0);
		}.bind(this));
		
		$('scrollRight').addEvent('click',function(e){
			e = new Event(e).stop();
			this.tab_fx.start(this.tab_overflow.getScroll().x+800,0);
		}.bind(this));
		/*
		this.tab_overflow.addEvent('mouseenter',function(e){
			e = new Event(e).stop();
			this.tab_fx.start(this.get_position(e));
		}.bind(this));
		
		this.tab_overflow.addEvent('mouseleave',function(){
			this.tab_overflow.removeEvents('mousemove');
			var myCookie1  = Cookie.write('position', this.tab_overflow.getScroll().x, {duration: 1});
		}.bind(this));
		*/
		var myCookie = Cookie.read('position');
		if($chk(myCookie) && myCookie.toInt() > 0) {
			new Fx.Scroll(this.tab_overflow,{link:'cancel',duration:0}).start(myCookie.toInt(),0);
		}
		else
		{
			new Fx.Scroll(this.tab_overflow,{link:'cancel',duration:0}).toElement(this.tab_items[0].item);
		}
	},
	mouse_move:function(e){
		e = new Event(e).stop();
		this.tab_fx.cancel();
		this.tab_overflow.scrollLeft = this.get_position(e);

	},
	get_position:function(e){
		var pos = this.tab_overflow.getPosition();
		var scroll = this.tab_overflow.getScroll();
		var scrollPos = Window.getScroll()['x']+e.client['x']-(pos['x']+scroll['x']);
		var position = scrollPos*(this.tab_container.getStyle('width').toInt())/this.tab_overflow.getStyle('width').toInt() - scrollPos;
		//$('log').set('html', 'pos:' + pos['x'] + '<br> scroll:' + scroll['x'] + '<br> scrollPos:' + scrollPos + '<br> position:' + position.toInt());
		return position;
	}
});

var tab_item = new Class({
	initialize:function(item,tab_obj){
		this.item = item;
		this.tab_obj = tab_obj;
		this.item.addEvent(this.tab_obj.options.event,this.on_event.bind(this));
	},
	on_event:function(e){
		//e = new Event(e).stop();
	}
});

function load_content(id)
{
    var queryString = [];
    
    $('right').set('text', '');
    $('right').set('html', '<div style="text-align:center;"><br /><br /><img src="' + abs_cms_path + 'backend/images/loading_bar.gif" alt="" /></div>');
    queryString.push('sid=' + SID);
    queryString.push('content_id=' + id);
    var data =  queryString.join('&');

    var a = new Request({ url: abs_cms_path + 'ajax.php?module=sliding_gallery_ajax&method=get_content', method: 'post', data: data });
    a.addEvent('success', function(response, xml) {
        $('right').set('text', '');
        $('right').set('html', response);
		Slimbox.scanPage();
		//var myFx = new Fx.Scroll(window).toElement('right');

    });
    a.send();
	return false;
}

onload_functions.push('sliding_gallery()');
function sliding_gallery() 
{
	if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) 
	{
		var gal = $('bilderbox');
		if(gal)
		{
			gal.setStyle('overflow','hidden');
				new sliding_tabs($$('#bilderbox .bilderbox_contents'),{
					tab_margin_right:'0px',
					tab_margin_left:'0px',
                    initial_tab:0
				});

		}
	}
}
//-->
