jQuery(document).ready(function(){
    jQuery('.upcoming li').hover(
        function(){
            jQuery(this).addClass('agenda_hover');
        },
        function(){
            jQuery(this).removeClass('agenda_hover');
        });



    alto = jQuery('#container').height();
    alto_secondary = jQuery('#secondary').height();
    alto_widget = jQuery('#secondary #events-list-widget-3').height();
    if (alto>alto_widget){
        jQuery('#secondary #events-list-widget-3').css({
            'height': (alto-364)+'px' //temporal
        });
    }

    alto_primary = jQuery('#primary').height();
    if (alto>alto_primary){
        jQuery('#primary').css({
            'height': alto+'px'
        });
        if(jQuery('#secondary').size()){
            alto +=300;
            jQuery('#primary').css({
                'height': alto+'px'
            });
        }
    }

    var showSubmenu = false;

    jQuery('#primary .secondary_categories ul li.submenuOpen a.submenu').click(function(){
        menu = jQuery(this).parent();
        submenu = menu.find('ul');
        if(showSubmenu == false){
            submenu.slideDown();
            menu.addClass('submenuClose');
            showSubmenu = true;
        }
        else if(showSubmenu == true){
            submenu.slideUp();
            menu.removeClass('submenuClose');
            showSubmenu = false;
        }
        return false;
    });


    jQuery('#primary .search_form #searchform #s').watermark('Buscar...');
    jQuery('#comments #author').watermark('Nombre');
    jQuery('#comments #email').watermark('E-mail');
    jQuery('#comments #url').watermark('Página web');
    jQuery('#comments #comment').watermark('Comentario');
    jQuery('#dni').watermark('DNI');

    jQuery("#enviar").click(function(e){
        e.preventDefault();
        var consultaPadronDiv = jQuery("<div/>").append("<div class='loading'></div>");
        var consultaPadronDialog = consultaPadronDiv.dialog({
            modal:true,
            autoOpen:false,
            width:528,
            height:"auto",
            title:"Consulta de Padrón"
        });
        consultaPadronDialog.dialog("open");
        jQuery.post("http://www.ramonmestre.com/consulta.php",{
            dni: jQuery("#dni").val(),
            genero: jQuery("#genero").val()
        },
        function(data){
            consultaPadronDialog.empty();
            consultaPadronDialog.append(data);
        //console.log(data);
        //consultaPadronDialog.dialog("open");

        });
    });

jQuery("#header_left, #header_right").cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});


});

