$(document).ready(function(){
    $('a[rel^="external"]').attr({ target: "_blank", title: "Abre en una nueva p\u00E1gina" });
    equal_height();
    
    $('form[name="buscador"]').submit(function(){
		if ($('input[name="termino-busqueda"]').val() != '') {
			location.href = 'http://www.google.com/search?q=OACDH panama ' + $('input[name="termino-busqueda"]').val();
		};
		return false;
	});
    
});

var equal_height = function () {
	
	/* set the starting bigestHeight variable */
	var biggestHeight = 0;
	
	/* check each of them */
	$('.equal_height').each(function(){
		
		/*
			if the height of the current element is bigger 
			then the current biggestHeight value
		*/
		
		if($(this).height() > biggestHeight){
			/* update the biggestHeight with the height of the current elements */
			biggestHeight = $(this).height();
		}
	});
	
	/* when checking for biggestHeight is done set that height to all the elements */
	$('.equal_height').css('height', biggestHeight + 'px');
}
