/**
 * Tommy Brière (Adaptation Stephane Ouimet)
 * Production Vic Pelletier tous droit réservées
 * 2009
**/
var cacheupd= 1;
function onErreur(msgErreur){
alert(msgErreur);}
function toggleFormModif(nomdivform){
$j("#"+nomdivform).toggle();}(function(){

function PageNavigateur(zoneId){
this.dz= new DynamicZone(zoneId, DynamicZoneJavascriptEval);
var me= this;
this.dataRCV= function(data){
me.dz.setContenu(data);
me.afterDataRCV();}
this.afterDataRCV= function(){}
this.setPage= function(no){
me.page= no;
me.update();}
this.suivant= function(){
this.setPage(me.page+ 1);}
this.precedent= function(){
this.setPage(me.page- 1);}}

	
function NavigateurProduit(iRech, iCat, iCatSub, dResult, vId, callBack){
PageNavigateur.call(this, dResult);
var rech="";
var cat="";
var catsub="";
var me= this;
this.chercher= function(){
rech= $w(iRech).value;
cat= $w(iCat).value;
catsub= $w(iCatSub).value;
if(rech=="Rechercher" || rech=="Search" ) rech="";
this.setPage(0);}
this.update= function(){
$j(function(){
me.dz.setContenu("<p>"+_TR("adc.pjc.chargement","Chargement en cours...")+"</p>");
var up={plugin:"produit" , action:"ListeProduitAcc" , noPage: me.page, rech: rech, vId: vId, cat: cat, catsub: catsub, callBack: callBack, mycacheupd:cacheupd};
$j.get("/plugin.php", up, me.dataRCV);});}
this.setPage(0);}
var P= window.Produit= new function(){
var LP;
this.cleartext= function(thisfield){
thisfield.value="";}
this.init= function(vId){
$j(function(){
LP= P.LesProduits= new function(){
NavigateurProduit.call(this,"rch_mesproduits_mot" ,"rch_lesproduits_cat" ,"rch_lesproduits_catsub" ,"secBottom" , vId,"Produit.LesProduits" );
function remplirCatSub1(catid){
var catsub= $j("#rch_lesproduits_catsub");
catid= parseInt(catid);
if($j("#rch_lesproduits_catsub:visible").length== 0){
catsub.show().prev().die().remove();
catsub.prev().die().remove();}
catsub.html("");
if(catid<= 0 || isNaN(catid) ){
catsub.append($j('<option></option').val("").html(_TR("acc.CboxCategorieSub","Toutes sous-catégories")));}
$j.each(lstCatSub, function(n,sub){
if(sub["FK_IDCategorie"]==catid){
catsub.append($j('<option></option').val(sub["id"]).html(sub["nom"]));}});
if(catsub.children().size()==0){} else{
if(catid> 0){
catsub.prepend( $j('<option></option').val("").html(_TR("acc.CboxCategorieSub","Toutes sous-catégories")));}
try{
catsub.val("");} catch(e){}
catsub.slideDown("fast");
$j('.lbl-rch-lesproduits-catsub').slideDown("fast");}
if( $j.browser.msie &&( parseFloat($j.browser.version)< 7 ) ){} else{
catsub.selectbox();}}
$j('#rch_lesproduits_cat').append($j('<option></option').val("").html(_TR("acc.CboxCategorie","Toutes catégories")));
$j.each(lstCategorie, function(n,categorie){
$j('#rch_lesproduits_cat').append($j('<option></option').val(categorie["id"]).html(categorie["nom"]));});
remplirCatSub1($j('#rch_lesproduits_cat').attr("value"));
$j("#rch_lesproduits_cat").change(function(){
remplirCatSub1($j(this).val());});
function sbpchange(){
remplirCatSub1($j("#rch_lesproduits_cat").val());}
if( $j.browser.msie &&( parseFloat($j.browser.version)< 7 ) ){} else{
$j("#rch_lesproduits_cat").selectbox({}, sbpchange);}}
P.update= function(){
LP.update();}});}
this.rate= function(id, cote, nbVote){
var url="/plugin.php";
var postData="&plugin=produit&action=noter&note="+cote+"&id="+id;
var request=blockingXmlCall(url,postData);
var data= request.responseText;
var nbVotePlus= nbVote+1;
if(data=="OK" ){
postData="&plugin=produit&action=getNbVote&pid="+id;
request= blockingXmlCall(url,postData);
var newCote= request.responseText;
$j(".star"+id).remove();
$j(".rar_"+id).css("display","block");
$j(".rar_"+id).removeAttr("onmouseover");
$j("span.votreVote_"+id).removeAttr("style");
if(nbVotePlus< 2){
$j(".nbVote_"+id).html(nbVotePlus+" "+_TR("all.liste_url_vote","vote" )+" ");}
else{
$j(".nbVote_"+id).html(nbVotePlus+" "+_TR("all.liste_url_votes","votes")+" ");}
$j(".votreVote_"+id).html(_TR("pjc.votre_vote","Votre vote : {0}" ,"<span class='yellow'>"+cote+"</span>"));
$j("#currentrating"+id).css("width", newCote+"%");} else alert(data);}
this.detail= function(id){
if($j('#detail_'+id).css('display')!='block'){
safeSearch("containerDetails", function(n){
$j(n).slideUp(300);});
safeSearch("details", function(n){
$j(n).show();});
safeSearch('detailsOpen', function(n){
$j(n).hide();});
$j('#detail_'+id).slideDown(300);
$j('#lnkdetails_'+id).hide();
$j('#lnkdetailsOpen_'+id).show();
if($j.browser.opera){
$j(".specs li p").css("margin-top","20px");}} else{
$j('#detail_'+id).slideUp(300);
$j('#lnkdetails_'+id).show();
$j('#lnkdetailsOpen_'+id).hide();}}}})();