$(document).ready(function(){
	/* MenÃº */
	var currentActive = $("#menu li.active");
	
	$("#menu li.nivel-1").hover(function(e){
		currentActive.removeClass("active");
		$(this).addClass("active");
		if($(this).children('ul').length > 0){
			//alert($(this).children('ul'));
			$("#breadcrumbs").hide();
			$(this).children('ul').show();
		}
	},function(e){
		if($(this).children('ul').length > 0){
			$(this).children('ul').hide();
			$("#breadcrumbs").show();
		}
		$(this).removeClass("active");
	});

	$("#menu").hover(function(){
		//
	}, function(){
		currentActive.addClass("active");
		if(currentActive.children('ul').length > 0){
			currentActive.children('ul').hide();
			$("#breadcrumbs").show();
		}
	});

	/* Sidebar */ 
	//if($("#col-2").height() < $("#col-1").height()) {
//		$("#col-2").css('position','absolute');
//		if($.browser.version=="6.0"&&$.browser.msie) $("#col-2").css('height',$("#col-1").height());
//	}
	
	

	/* Ampliar - Reducir texto */
	$("#aumentar-texto").click(function(){
		var size = $("div#content-container").css('font-size');
		var temp = size.split("px");
		
		size = parseInt(temp[0]) + 1;
		if(size<15) $("div#content-container").css('font-size',size);
	});
	
	$("#reducir-texto").click(function(){
		var size = $("div#content-container").css('font-size');
		var temp = size.split("px");
		
		size = parseInt(temp[0]) - 1;
		if(size>9) $("div#content-container").css('font-size',size);
	});
	
	/* Imprimir pÃ¡gina */
	$(".imprimir").click(function(){
		window.print();
		
		return false;
	});
	
	/* Limpiar - Todos formularios y recordar valor inicial */ 
	// Comentado por tarea 18809 - 17/10/2011
	/*$('input[type="text"], textarea').focus(function() {
		if (this.value == this.defaultValue){ 
	    	this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('input[type="text"], textarea').blur(function() {
	    if ($.trim(this.value) == ''){
	    	this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});*/
	//Igualar les columnes a la mateixa alçada.
	setTimeout(function() {
		var highestCol = Math.max($('#col-1').height(),$('#col-2').height());
		//alert($('#col-1').height()+'**'+$('#col-2').height()+'**'+highestCol);
		$('#two-cols').height(highestCol);
	},500);
});

/**** COLUMNAS IGUAL ALTURA ****/
//(function(jQuery) {
//	jQuery.fn.equalHeight = function(options) {
//		var defaults = {			
//			colNumber: 2 //num de cols
//		};
//				
//		this.each(function() {
//			
//			var obj = jQuery(this);
//			var settings = jQuery.extend(defaults, options);
//			var totalListElements = jQuery(this).children().size();
//	
//			var i,j,k,auxH,fila;
//			
//			i=fila=0;
//			
//			while(i<totalListElements) {
//				auxH = 0;
//				for(j=0; j<settings.colNumber; j++) {
//					k=i+j;
//					
//					if(k>=totalListElements) return;
//					
//					if(obj.children().eq(k).height() >auxH) {
//						auxH = obj.children().eq(k).height();
//					}
//					
//					obj.children().eq(k).addClass("fila"+fila);
//				}
//				jQuery(".fila"+fila).height(auxH);
//				i=i+settings.colNumber;
//				fila++;
//			}
//		});
//	};
//})(jQuery);

/**** CENTRADO VERTICAL ****/
//(function(jQuery) {
//	jQuery.fn.centradoVertical = function(options) {
//		this.each(function() {
//			
//			var obj = jQuery(this);
//			var parentH = obj.parent().height();
//			var mtop = Math.round((parentH/2) - (obj.height()/2));
//			
//			obj.css('margin-top',mtop);
//		});
//	};
//})(jQuery);

