// <![CDATA[
var full_width = 1201;

	var morph = function() {
		var width = $('bar_inner').down('li').getWidth();
		var left = $('bar_inner').down('li').positionedOffset()[0];

		$('bar_inner').effect = new Effect.Morph('bar_inner', {
			style:'margin-left:-' + width + 'px',
			duration:Math.ceil((width + left) / 30),
			transition: Effect.Transitions.linear,
			afterFinish:function() {
				$('bar_inner').style.marginLeft = '0px';
				$('bar_inner').insert( { bottom:$('bar_inner').down('li') } );
				morph();
			}
		} );
	}
	Event.observe(window, 'load', function(event_) {
		if (full_width > 980) morph();

		window.div_modal = new Element('div', { 'id':'bar_overlay' } ).hide();
		$(document.body).insert( { bottom:window.div_modal } );
		window.div_modal_resize = function() {
			var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
			var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
			var dsoctop=document.all? iebody.scrollTop : pageYOffset;

			var size = document.viewport.getDimensions();
			if (window.div_modal) window.div_modal.setStyle( {
				width:$(document.body).getWidth() + 'px',
				height:size.height,
				top:dsoctop + 'px'
			} );
		}
		window.div_modal_resize();
		window.div_modal.setOpacity(0.6);
		Event.observe(window, 'resize', window.div_modal_resize);
		Event.observe(window, 'scroll', window.div_modal_resize);
		window.popup = new Element('div', { 'id':'popup' } ).hide();
		$(document.body).insert( { bottom:window.popup } );
		Event.observe($('bar_inner'), 'click', function(event_) {
			var a = event_.element().up('a');
			if ($('bar_inner').effect) $('bar_inner').effect.cancel();
			window.div_modal_resize();
			Effect.Appear(window.div_modal, {
				to:0.6,
				duration:0.3,
				afterFinish:function() {
					new Ajax.Updater(window.popup, 'div.foto.php?rn=' + Math.random(), {
						parameters:'foto_id=' + a.getAttribute('foto_id'),
						method:'post',
						onComplete:function() {
							var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
							var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
							var dsoctop=document.all? iebody.scrollTop : pageYOffset;
							var size = document.viewport.getDimensions();
							var top = Math.max(0, Math.ceil(dsoctop + (size.height / 2) - (window.popup.getHeight() / 2)));
							var left = Math.max(0, Math.ceil(dsocleft + (size.width / 2) - (window.popup.getWidth() / 2)));
							window.popup.setStyle( {
								left:left + 'px',
								top:top + 'px'
							} );
							Event.observe(window.popup.down('a.ix'), 'click', function(event_) {
								window.popup.hide();
								Effect.Fade(window.div_modal, {
									duration:0.3
								} );
								event_.stop();
								if (full_width > 980) morph();
							} );
						}
					} );
					window.popup.show();
					return false;
				}
			} );
			event_.stop();
		} );
	} );
// ]]>
