// - Text rotator functions
function rotatorStart(idx, id, cls, timer) {
	
	var tick = $$(id + ' ' + cls)
	tick.each(function(e) {
		if ($(e).visible)
			$(e).hide();
	});
		
	setTimeout(function() {
		Effect.Appear(tick[idx]);
	}, 400);
	
	var nextIdx;
	if (idx == tick.length -1)
		nextIdx = 0;
	else
		nextIdx = idx+1;	

	setTimeout(
		"rotatorStart(#{1}, '#{2}', '#{3}', #{4})".interpolate({ 1: nextIdx, 2: id, 3: cls, 4: timer}),
		timer
	);
}


function clickhandler(e){
   
    var img = Event.element(e);
	var popHeight = Element.getHeight(img) * 3;
	src = img.getAttribute('src');
    if (src == null) {
	    src = img.down('img').getAttribute('src');
	}
    window.open(src, 'imagewindow', 'width=' + (screen.width * .5) + ',height=' + popHeight + ',menubar=no,status=no,scrollbars=yes');
	return false;			
}

/* Any div's with the enlarge class should open a new window when clicked */
Event.observe(window, 'load', function() { 
	$$('div.enlarge').each( function(e) { 
		Event.observe(e, 'click', clickhandler.bindAsEventListener(e));
	});
});

