$(document).ready( function() 
{
	// Desplegables del menu de productos
	$('#productMenu .top').click( function() {
		var parent = $(this).parent();
		if(parent.hasClass('seeing')) {
			$(this).parent().find('ul').slideUp('slow', function(){ $(this).parent().removeClass('seeing'); });
		}
		else {
			$(this).parent().find('ul').slideDown('slow', function(){ $(this).parent().addClass('seeing'); });
		}
		return false;
	});
	
	// -- Tabs del menu
	$('#tabs a').click( function(e) {
		var rel = $(this).attr('rel');
		$('#tabs .seeing').removeClass('seeing');
		$(this).addClass('seeing');
		$('#menu ul').hide();
		$('#menu #'+rel).show();
		e.preventDefault();
	});
	
	// -- Check/uncheck all
	$('#checkAll').click( function() {
		if($(this).is(':checked')) {
			$('table .check input').attr('checked', true);
		}
		else {
			$('table .check input').attr('checked', false);
		}
	});
	
	// -- delete object confirm
	$('a.delete').click(function(){
	  var answer = confirm($(this).attr('title'));
	  return answer // answer is a boolean
	}); 
	
	// -- Mostrar/ocultar busqueda
	$('#searchLink').click( function(e) {
		$("#search").slideToggle();
		e.preventDefault();
	});
	
	// -- Mostrar/ocultar mensajes de ok o de error
	$(function() {
		var msg = $('.msg');
		if(msg.size()>0) {
			msg.delay(500).slideDown(600).delay(5000).slideUp(600);
		}
	});
	
	// -- Mostrar/ocultar tooltips
	$('img.tip').hover( function() {
			var tip = $(this).attr('alt');
			var pos = $(this).offset();
			tooltip = document.createElement('div');
			tooltip.className = 'tooltip';
			tooltip.innerHTML = tip;
			tooltip.style.left = pos.left+35+'px';
			tooltip.style.top = pos.top+'px';
            $('body').append(tooltip);
		},
		function() {
			$('.tooltip').remove();
	});

});


/* popups */
function popUp(url,name,ancho,alto)
{
	var propiedades = "toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=1,top=50,left=50,resizable=1,width="+ancho+",height="+alto;
	window.open(url,name,propiedades);	
}

