$(document).ready(function(){
    $('#logo-estoy').flash({
		src: '/img/layout-2010/header/estoy.swf',
		width: 450,
		height: 90      
    });
    
    var months = new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');
    
    $.datepicker.regional['es'] = {clearText: 'Limpiar', clearStatus: '',
		closeText: 'Cerrar', closeStatus: '',
		prevText: '&lt;Ant', prevStatus: '',
		nextText: 'Sig&gt;', nextStatus: '',
		currentText: 'Hoy', currentStatus: '',
		monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
		'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
		monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
		'Jul','Ago','Sep','Oct','Nov','Dic'],
		monthStatus: '', yearStatus: '',
		weekHeader: 'Sm', weekStatus: '',
		dayNames: ['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'],
		dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
		dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
		dayStatus: 'DD', dateStatus: 'D, M d',
		dateFormat: 'yy-mm-dd', firstDay: 1, 
		yearRange: '2009:+10',
		initStatus: '', isRTL: false
		};
		
    $.datepicker.setDefaults($.datepicker.regional['es']);

    $(".show-calendar").click(function(){
	$(".datepicker").datepicker("show");
    })

    $(".datepicker").datepicker({
	regional: 'es',
	onSelect: function(dateText, inst) {	    
	    var newdate = dateText.split("-");	       
	    mydate = newdate[2] + " " + months[(newdate[1])-1] + " " + newdate[0];
	   
	    $.ajax({
		type: "POST",
		url: '/events/calendar_ajax/'+dateText+'/'+$('#DateSelectedday').attr('rel'),
		dataType: 'text',
		beforeSend: function(xhr){
			xhr.setRequestHeader('Content-type', 'text/plain');
			$('#calendar-container').html('<center><img src="/img/layout/facebook/preload.gif" alt="loading" style="margin-top:50px"></center>');
		},
		success: function(data){
			$('#calendar-container').html(data);
			$('.show-date').html(mydate);
		}
	    });
	}
    });
    
    $("#EventTitle").click(function(){
	if($("#EventTitle").val() == "Buscar una actividad"){
	    $("#EventTitle").val("");
	}
    });
    
    $("#EventTitle").blur(function(){
	if($("#EventTitle").val() == ""){
	    $("#EventTitle").val("Buscar una actividad");
	}
    });
    
    $("#search-image").click(function(){
	$("#search-form").submit();
    });
    
});

function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}