function mbr_addEvent(obj, evType, fn)
{
	if (obj.addEventListener)
	{
		obj.addEventListener(evType, fn, false);
		return true;
	}
	else if (obj.attachEvent)
	{
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else
	{
		return false;
	}
}

mbr_addEvent(window, 'load', fixMenuBar);
mbr_addEvent(window, 'load', fixBoxes);

function fixMenuBar() {
	fix = 0;
	if ($('menu').clientHeight != $('contenedorMenu').clientHeight) {
		if ((384 - $('contenedorMenu').clientHeight) > 0) {
			fix = -(384 - $('contenedorMenu').clientHeight);
		}else {
			fix = -100; //Para agrandar la ventana cuando el contenido es chico
		}
	}
	else {
		fix = -250; //Para agrandar la ventana cuando el contenido es chico
	}
	
	if (navigator.appName.indexOf("Microsoft") != -1) {
		$('fixBar').style.borderBottom = '11px solid white';
	}
	else {
		$('fixBar').style.borderBottom = '11px solid white';
	}
	
	$('fixBar').style.height = '0px';
	$('fixBar').style.height = ($('contenedorMenu').clientHeight - fix - 11) + 'px';
	
	setTimeout("fixDelay();",1000);
}

function fixDelay() {
	$('fixBar').style.height = ($('contenedorMenu').clientHeight - fix - 11) + 'px';
}

function fixBoxes() {
	var news = $('novedades');
	var prensas = $('prensas');
	var mNews = $('moreNovedades');
	var mPrensas = $('morePrensas');
	
	if (news && prensas && mNews && mPrensas) {
		if (prensas.clientHeight > news.clientHeight) {
			var dif = prensas.clientHeight - news.clientHeight + 11;
			news.style.height = (prensas.clientHeight + 1) + 'px';
			mNews.style.marginTop = dif + 'px';
		}
		else {
			var dif = news.clientHeight - prensas.clientHeight + 11;
			prensas.style.height = news.clientHeight + 'px';
			mPrensas.style.marginTop = dif + 'px';
		}
	}
}

function formToPage(formUsed, page) {
	$('page').value = page;
	$(formUsed).submit();
}

function OpenPopUp () 
{
	window.open('htmlformenviaraunamigo.php?id=',
	'',
	'width=620,height=400,toolbar=no,resizable=no,fullscreen =No'
	);
}



function ToogleOver(src,id) 
{	
	$(id).src = src;
}

function verBoletin(id)
{
	url = '/verBoletin.php?id=' + id;
	
	new Ajax.Request(url, {
	  method: 'get',
	  onSuccess: function(transport) {
	    var solapa = $('detalleBoletin');
	    solapa.innerHTML = '';
	    solapa.innerHTML = transport.responseText;
	    
	  }, 
	  onComplete: function(){
	  	fixMenuBar();
	  }
	});
}

function productoBoletin(id)
{
	url = '/productoBoletin.php?id=' + id;
	
	new Ajax.Request(url, {
	  method: 'get',
	  onSuccess: function(transport) {
	    var solapa = $('solapaBoletines');
	    $('detalleBoletin').innerHTML = '';
	    solapa.innerHTML = '';
	    solapa.innerHTML = transport.responseText;
	    
	  }, 
	  onComplete: function(){
	  	fixMenuBar();
	  }
	});
}