	function AbrirPopup(content){
		$('#popup_background').fadeIn('fast');
		$('#popup_content').fadeIn('fast');
		$('#popup_content').html(content);
		$('#popup_content').css('max-width',($(window).width()-200) + 'px');
		$('#popup_content').css('max-height',($(window).height()-50) + 'px');
		$('#popup_content').draggable();
		centrarAbsoluto($('#popup_background'));
		centrarAbsoluto($('#popup_content'));
	}
	
	function CerrarPopup(){
		$('#popup_background').fadeOut('fast');
		$('#popup_content').fadeOut('fast');
		$('#popup_content').html('');
	}
	
	function AbrirPopupCatador(id){
		$.get('/FichaItem/VerOpinion/'+id+'/portada',{},
				function(response){
					AbrirPopup(response);
				}
		);
	}

	$('.form_encuesta').submit(function(){
		$(this).ajaxSubmit({
			success:function(response){
				if(response == 'OK'){
					alert('Muchas gracias por su voto');
				} else {
					alert(response);
				}
			}
		});
		return false;
	});
	
	$(function(){
		$('.contenido_medio .central .mason').masonry({
		  itemSelector: '.item_articulo',
		  columnWidth: 173
		  //isFitWidth: true
		});
	
		$('.bt_elige').click(function(){
			$('.bg_ciudades').slideToggle('slow',function(){
				var src;
				if ($(this).hasClass('baja')){
					$(this).removeClass('baja').addClass('sube');
					src = $('#btn_elige').attr('src').replace('ciudad_sube.png','ciudad.png');
					$('#btn_elige').attr('src',src);
				} else {
					$(this).removeClass('sube').addClass('baja');
					src = $('#btn_elige').attr('src').replace('ciudad.png','ciudad_sube.png');
					$('#btn_elige').attr('src',src);
				}
			});
		});	
		
		$('.cficha').hover(
			function(){
				$item = $(this).parent(); 
				$item.find('.bg_contenedor').slideDown();
				var src = $item.find('.img_flecha').attr('src');
				src = src.replace('_ar_','_ab_');
				$item.find('.img_flecha').attr('src',src);
			},
			function(){
				$item = $(this).parent(); 
				$item.find('.bg_contenedor').slideUp();
				var src = $item.find('.img_flecha').attr('src');
				src = src.replace('_ab_','_ar_');
				$item.find('.img_flecha').attr('src',src);
			}
		);
	
		$('.cycle_item').cycle();
		$('.tipsed').tipsy({gravity: 's',offset: '100px',html: true});
	});
