window.addEvent('domready',function(ev){
	setupScrollers();
	parts = window.location.pathname.split('/');
	if (!parts[2] || parts[2] == "industry" || parts[2] == "style" || parts[2] == "" || parts[2] == "clients" || (parts[2] == "process" && !parts[3])) {
		$$("#content .work_subnav a").each(function(n){
			n.addEvent('click',function(ev){
				ev = new Event(ev);
				ev.preventDefault();
				var node = $(ev.target);
				new Request.HTML({url: node.get('href') + '/ajax', update: $E('#content_ajax'), onComplete: function(){ajaxSifr();setupScrollers();}}).get();
				n.getParent('ul').getElements('a').removeClass('active');
				n.addClass('active');
			});
		});
	} else {
		$$('.cat_nav li a').each(function(n){
			n.addEvent('click',function(ev){
				new Event(ev).preventDefault();
				$E('.nav').empty();
				$E('.nav').adopt($('ssp_gallery_list').getChildren('#'+n.get('text').toLowerCase()).clone().getChildren());
				CHANGEffect.doList();
				changeAlbum(n.get('text').toLowerCase());
				n.getParent('ul').getElements('li').removeClass('active');
				n.getParent().addClass('active');
			})
		});
		
		if($('ssp_gallery_list')) {
			$E('.nav').adopt($('ssp_gallery_list').getFirst().clone().getChildren());
			CHANGEffect.doList();
		}
	}
	
});

function setupScrollers() {
	var ie = (Browser.Engine.name == "trident" && Browser.Engine.version == 4);
	$$('.style .wrap, .industry .wrap, .process_type .wrap').each(function(n){
		n.adopt(new Element('div').set({
				styles: {
					height: '23px',
					width: '100%',
					position: 'absolute',
					left: 0,
					bottom: 0
				}
		}));
		if (!ie) {
			n.getLast().setStyle('background',"url(/media/images/layout/list_fade.png) left bottom repeat-x");
		} else {
			n.getLast().setStyle('filter','progid:DXImageTransform.Microsoft.AlphaImageLoader(src="/media/images/layout/list_fade.png",sizingMethod="scale")');
		}
		
		n.set({
			styles: {
				'height': '8em',
				'overflow': 'hidden',
				'position': 'relative'
			}
		}).doScroll = function(multiplier) {
			var node = this.getFirst();
			node.set({
				styles: {
					top: ((isNaN(node.getStyle('top').toInt()) ? 0 : node.getStyle('top').toInt())+(multiplier*4)).
					limit(-node.getSize().y+this.getSize().y-20,0) + 'px'
				}
			});
		}
		n.getFirst().setStyle('position','relative');
		n.getNext().getElement('.up').addEvent('mousedown',function(ev){
			n.doScrollTimer = n.doScroll.periodical(10,n,1);
		}).addEvent('mouseup',function(ev){
			$clear(n.doScrollTimer);
		}).addEvent('click',function(ev){
			new Event(ev).preventDefault();
		});
		
		n.getNext().getElement('.down').addEvent('mousedown',function(ev){
			n.doScrollTimer = n.doScroll.periodical(10,n,-1);
		}).addEvent('mouseup',function(ev){
			$clear(n.doScrollTimer);
		}).addEvent('click',function(ev){
			new Event(ev).preventDefault();
		});
	});
}