/**
 * @author roger
 */
//funcions de càrrega a l'inici
$(document).ready(function(){
    //carreguem ranking 'os gusta' al sidebar
    $('#osgustalist').load('http://www.muntablog.com/wp-content/themes/muntanyola_3/ranking_osgusta.php');
});

function loadContent(elm, rate, postID){
    var ids = {
        id: postID,
        rating: rate
    };
    jQuery.ajax({
        type: "post",
        url: "http://www.muntablog.com/wp-content/themes/muntanyola_3/megusta.php",
        data: ids,
        beforeSend: function(){
            jQuery("#osgusta_" + postID).fadeTo(200, 0);
        },
        success: function(html){
            jQuery("#osgusta_" + postID).css("background-image", "url(http://www.muntablog.com/wp-content/themes/muntanyola_3/images/btn_megusta2.png)");
            jQuery("#osgusta_" + postID).fadeTo(400, 1);
            jQuery("#osgusta_" + postID).css("cursor", "default");
            jQuery("#osgusta_" + postID).html("");
            jQuery("#osgustalist").load('http://www.muntablog.com/wp-content/themes/muntanyola_3/ranking_osgusta.php');
            
        }
    });
}

/* funció per a mostrar la icona individual de cada post segons sigui la categoria */
function getIconaPost(cat){
    var resposta;
    if (cat == "ESPEJO") {
        resposta = "espejo";
    }
    else 
        if (cat == "VATER") {
            resposta = "vater";
        }
        else 
            if (cat == "PAPELERA") {
                resposta = "papelera";
            }
            else 
                if (cat == "REVISTERO") {
                    resposta = "revistero";
                }
                else 
                    if (cat == "PUERTA") {
                        resposta = "puerta";
                    }
                    else 
                        if (cat == "BLASTELINA") {
                            resposta = "blastelina";
                        }
                        else 
                            if (cat == "RADIO") {
                                resposta = "radioMunta";
                            }
                            else 
                                if (cat == "JABONERA") {
                                    resposta = "jabonera";
                                }
    return ('<div class="post ' + resposta + '" id="post-<?php the_ID(); ?>">');
}

/* funció per a mostrar la capçalera de cada pagina segons sigui la categoria */
function getCapPag(cat){
    var resposta = "index";
    if (cat == "ESPEJO") {
        resposta = "espejo";
    }
    else 
        if (cat == "VATER") {
            resposta = "vater";
        }
        else 
            if (cat == "PAPELERA") {
                resposta = "papelera";
            }
            else 
                if (cat == "REVISTERO") {
                    resposta = "revistero";
                }
                else 
                    if (cat == "PUERTA") {
                        resposta = "puerta";
                    }
                    else 
                        if (cat == "BLASTELINA") {
                            resposta = "blastelina";
                        }
                        else 
                            if (cat == "RADIO_MUNTA" || cat == "MÚSICA") {
                                resposta = "radio";
                            }
                            else 
                                if (cat == "JABONERA") {
                                    resposta = "jabonera";
                                }
    return ('<img src="http://www.muntablog.com/wp-content/themes/muntanyola_3/images/cap_' + resposta + '.png" width="520" height="180" alt="Cap" /><br />');
}
