var viewermap = [];

var xrules = {
	'a.anonroot' : function(el) {
		el.onmouseover = function() {
			if ($$('.userclick').length == 0) {
				//hidden all displays
				$$('#middle_content .second').each(function(div) {
					Element.hide(div);
				});
				
				var href = el.href;
				var id = href.substring(href.lastIndexOf('?id=') + 4, href.length);
				Element.show(id);
			}
		}
		el.onmouseout = function() {
			if ($$('.userclick').length == 0) {
				//hidden all displays
				$$('#middle_content .second').each(function(div) {
					Element.hide(div);
				});
	
				Element.show('nonsol-1');
			}
		}
		el.onclick = function() {
			Element.addClassName(el, 'userclick');
		}
	},
	'.slide': function(el) {
		var ul = el.getElementsByTagName('ul')[0];
		
		viewermap[ul.id] = new PhotoViewer();
		
		$('href' + ul.id).onclick = function() {
			viewermap[ul.id].show(0);
			return false;
		};
		
		$A(el.getElementsByTagName('img')).each(function(img, i) {
			viewermap[ul.id].add(img.parentNode.href, img.alt);
			
			img.parentNode.onclick = function() {
				viewermap[ul.id].show(i);
				
				return false;
			}
		});
	}
};

Behaviour.register(xrules);
