function checkReview(div){
var errors = 0,
message = [];
if($(div+" #name").val() != '') errors++;
if($(div+" #firstname").val() != 'Paul') errors++;
if($(div+" #pseudo").val() == '') { errors++; message.push("- Identify yourself with a username."); }
if($(div+" #comment").val() == '') {errors++; message.push("- No message written"); }
if($(div+" #note").val() == '') errors++;
if(errors > 0) {
jalert(message.join('
'),"Errors! : ");
return false;
} else {
return true;
}
}
function reviewForm(div){
this.div = div;
this.nbShown = 10; // Les 10 premiers sont chargés en dur dans la page (SEO)
this.nbShowMore = 10;
this.page = false;
this.id = false;
this.total = 0;
var p = this;
this.init = function(){
$(div+' form .starrating em').mouseover(function(){
var num = parseInt($(this).attr("data-rel"));
p.visibleNote(num);
});
$(div+' form .starrating em').mouseout(function(){
var num = parseInt($(div+' #note').val());
p.visibleNote(num);
});
$(div+' form .starrating em').click(function(){
var note = $(this).attr("data-rel");
$(div+' #note').val(note);
p.visibleNote(note);
});
// PREMIER CHARGEMENT : note par défaut
$(div+' form .starrating em:first').trigger('mouseout');
// ON AFFICHE LES 10 DERNIERS
$(p.div+" article").show();
p.fillNotes();
p.nextButton();
$(p.div+" #plusReviews").click(function(){p.showMore();});
}
this.nextButton = function(){
if(p.total <= p.nbShown){
$(p.div+" #plusReviews").slideUp();
}
}
this.visibleNote = function(note){
$(div+' form .starrating em').removeClass('on');
for(var i = 1; i<=note; i++){
$(div+' form .starrating em[data-rel='+i+']').addClass('on');
}
}
this.showMore = function(){
$.post('/_scripts/modules/reviews/ajax.php', {'action':'loadReviews', 'page':p.page, 'id':p.id, start:p.nbShown, limit:p.nbShowMore}, function(data){
$("#reviewList").append(data);
var delay = 0;
$(p.div+" article").each(function(){
if($(this).is(":hidden")) {
delay+=100;
$(this).delay(delay).slideDown();
}
p.fillNotes();
});
p.nbShown += p.nbShowMore;
p.nextButton();
});
}
this.fillNotes = function(){
$(".starrating.show").each(function(){
$(this).empty();
var note = parseInt($(this).attr("data-rel"));
for(var i = 1; i<=5; i++){
var cls = (i<=note ? 'on' : '');
$(this).append('');
}
});
}
}