﻿// Attache l evenement de roll-over avec changement d image
$(document).ready(function() {
    $("form#form_vote").ajaxForm({
        success: function(responseXML, statusXML) {
            $("div#votecontainer").html(responseXML);
        }
    });
    $(".heart").bind("mouseover", function() {
    var src = _heart_filled;
    var src2 = _heart_empty;
        var itop = (this).id.replace("heart_", "");

        for (i = 1; i <= 4; i++) {
            (i <= itop) ? $("img#heart_" + i).attr("src", src) : $("img#heart_" + i).attr("src", src2);
        }
    });
//    $("span#heartscontainer").bind("mouseleave", function() {
//        for (i = 1; i <= 4; i++) {
//            $("img#heart_" + i).attr("src", _heart_empty);
//        }
//    });
});

// Declenche le submit apres l animation
function doSubmit(){
    $("form#form_vote").submit();
}

// Recupere les valeurs necessaires au votes charge l animation
function vote(myvote) {
    $("div.loader").fadeIn('slow');
    $("input#note").val(myvote);
    $("input#post").val(_post_Id);
    setTimeout("doSubmit()", 2000);
}

//surligne les elements provenant d une recherche
function highlight(str) {
    if ((str != null) && (str != "")) {
        $('div.pitch').highlight(str);
        $('div.content').highlight(str);
        $('input#search').attr('defaultValue', str);
        $('input#search').attr('value', str);
    }
}
