$(function(){

	// Add target _blank to external links
	$('a[rel=external]').live('click', function(){
		$(this).attr('target', '_blank');
	});


	// Popup links
	$('.legal').popupWindow({
		height:600,
		width:772,
		top:50,
		left:50,
		resizable:0,
		scrollbars:1
	});
	$('.autorizacionVirtual').popupWindow({
		height:580,
		width:385,
		top:50,
		left:50,
		resizable:0,
		scrollbars:0
	});

	// Sección de buscador
	 $("#search").focus(function () {
         $(this).attr("value","");
    });
	 
	// Sección de tags
	 $("#post-tags").focus(function () {
         $(this).attr("value","");
    });

	// Sección de buscador de tags home y entry
	$('.post-tags a').click(function(){
		$(this).next().submit();
		return false;
	});
	
	$('#popup_condicionesLegales').popupWindow({
		height:600,
		width:540,
		top:50,
		left:50,
		resizable:0,
		scrollbars:1
	});


});

	// Limitación de caracteres en los campos.
	function limitChars(textid, limit) {
		var text = $(textid).val();
		var textlength = text.length;

		if(textlength >= limit){
			$(textid).val(text.substr(0,limit));
			return false;
		}
			return true;
 	}
