var novica = '';
var nov_vsi = $A();
function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}
addLoadEvent(initNovice);	// run initLightbox onLoad
function initNovice() {
	nov_vsi = $('right').select('.novica')
	$('right').select('.novica').each(function(element) {
		Event.observe(element.down(), "click", showHide);
		Event.observe($(element.id+'href'), "click", cela);
		el = element.down().down()
		Event.observe(el, "mouseover", highlight);
		Event.observe(el, "mouseout", highlight);
	});
}
function highlight(e) {
	var obj = Event.element(e);
	evt = e.type || window.event.type
	if (evt == "mouseover") { 
		obj.style.background = "#fff68f";
	} else {
		obj.style.background = "";
	}
}
function showHide(e) {
	ele = Event.element(e);
	el = ele.up().next()
	nov_vsi.each(function(element) {element.down('div').hide()});
	if (novica != el) { el.appear();novica = el;}
	else { el.hide(); novica = ''; }
}
function cela(e) {
	ele = Event.element(e);
	id = ele.up().up().id;
	new Ajax.Updater(ele.previous(), "http://www.vegasmetisce.com/martin/index.php?action=home&sa=novica&id="+id);
}
