function rowHeight(c) { 	
	if ($('text') && $('vert')) {
		var rh	= 150;	// row height.
		var th	= $('text').getHeight(); // container height.
		var vh	= $('vert').getHeight(); // content height.

		var r	= th % rh;

		if (vh > th) {
			while(th < vh) {
				th += rh;
			}

		} else if (r) {
			th += (rh - r);
		}
		
		$('text').setStyle({
			height: th + 'px'
		});
	}
}

function project() {
	var thumbs = $$('img.thumb');
	
	thumbs.each(function(thumb) {
	
		thumb.observe('mouseover', function(ev) {
			var id	= thumb.up().readAttribute('id');
			var img = $('main').select('img[name=' + id + ']').first();
			if (img) {
				img.setStyle({
					'position':	'absolute',
					'top':		'0px',
					'left':		'0px'
				});
			}
		});	
		
		thumb.observe('mouseout', function(ev) {
			var id	= thumb.up().readAttribute('id');
			var img = $('main').select('img[name=' + id + ']').first();
			if (img) {
				img.setStyle({
					'left':		'450px'
				});
			}
		});	
	});
}

function news() {
	var toggles = $('vert').select('small a');

	toggles.each(function(toggle) {
		toggle.observe('click', function(ev) {
			
			var article = toggle.up().up().up();
			
			if (toggle.innerHTML == 'Read') { // open article.
				article.addClassName('open');
				toggle.innerHTML = 'Close';
				
			} else {  // close article.
				article.removeClassName('open');
				toggle.innerHTML = 'Read';
			}
/*			
			toggles.each(function(t) { // close other articles.
				if (t != toggle) {
					var a = t.up().up().up();

					a.removeClassName('open');
					t.innerHTML = 'Read';
				}
			});
*/
			$('text').setStyle({
				height: '150px'
			});
		
			rowHeight();
		});		
	});
}

document.observe('dom:loaded', function() {
	rowHeight();
	project();
	news();
});
