
var Recette= new function(){
this.frmProposerData= null;
var RZ_ID="recette-index-zone-droite";
var noPage= 0;
var r_courante="";
var frmHelper= null;
this.rate= function(id, cote){
var url="/plugin.php";
var postData="&plugin=recette&action=noter&note="+cote+"&id="+id;
var request=blockingXmlCall(url,postData);
var data= request.responseText;
if(data=="OK" ){
$j(".rar_"+id).parent().find(".votre-vote").remove();
$j(".rar_"+id).after("<p class=\"votre-vote\">"+_TR("photovideo.votre_votre","Votre vote : {0}" , cote)+"</p>");} else{
alert(data);}}
this.index= function(lettre){
setRecherche("&action=index&lettre="+lettre);}
this.recherche= function(){
var query= $w("query").value;
var categorie= $w("categorie").value;
Tracking.event("Recherche","Recette" , query);
setRecherche("&action=recherche&query="+ query+"&categorie="+ categorie);}
this.top5= function(id){
setRecherche("&action=getTop5&id="+id);}
function dataFetched(data){
var dz= new DynamicZone(RZ_ID);
dz.setContenu(data);}
function updateRecherche(){
var dz= new DynamicZone(RZ_ID);
$j('#onglet_contenu_106_0 .zone-droite').append('<img class="loading-img" style="position: absolute; top: 34px; left: -36px;" src="/images/loading.gif" />');
var url="/plugin.php?plugin=recette"+ r_courante+"&nopage="+ noPage;
jQuery.get(url, dataFetched);}
function setRecherche(rech){
r_courante= rech;
noPage= 0;
updateRecherche();}
this.setPage= function(no){
if(no< 0){
no= 0;}
if(no != noPage){
noPage= no;
updateRecherche();}}
this.next= function(){
this.setPage(noPage+ 1);}
this.back= function(){
this.setPage(noPage- 1);}
function recetteReceived(oid, data){
var nav= OngletNavigateurs.getCurItem();
nav.replaceContent(oid, data);
var t= jQuery(nav.get(oid).getNode()).find(".zone-centre h3").text();
document.title= t+" | "+ _TR("all.titre_site","Plus loin, plus sport" );}
this.set= function(cato, rid){
if((cato>= 1) &&(cato<= 5)){
var m=[0, 1, 4, 5, 3, 2];
var oid= m[cato];
var citem= OngletNavigateurs.getCurItem();
citem.setIndex(oid);
var conglet= citem.getCurItem();
$j(conglet.getNode()).find('.zone-gauche').append('<img class="loading-img" style="position: absolute; top: 28px; left: 12px;" src="/images/loading.gif" />');
var url="/plugin.php?plugin=recette&action=recette&categorie="+cato+"&recette="+rid;
jQuery.get(url, function(data){
recetteReceived(oid, data);});}}
function commentairePosted(rid, data){
$j(".b-soumettre").show();
if(data=="OK"){
$j("#frm_com_"+rid+" ol").hide();
$j("#frm_com_"+rid+" p").show();
setTimeout(function(){
$j("#frm_com_"+rid+" ol").show();
$j("#frm_com_"+rid+" p").hide();}, 30*1000);} else{
$j.each(data, function(i, n){
$j("#frm_com_"+rid+" :input").filter(function(){
return(this.name== n[0]);} ).tooltip(n[3]);});}}
this.commentaire= function(rid){
var url="/plugin.php";
var f= $w("frm_com_"+ rid)
var v= formToJSON(f);
v.plugin="commentaire";
v.action="soumettre_commentaire";
$j(".b-soumettre").hide();
jQuery.post(url, v, function(data){
commentairePosted(rid, data);},"json" );}
function apresSoumettre(data){
$j("#b-soumettre").show();
if(data=="OK"){
$j("#frmSoumRecette ol").hide();
$j("#frmSoumRecette p").show();
setTimeout(function(){
$j("#frmSoumRecette ol").show();
$j("#frmSoumRecette p").hide();
$j("#frmSoumRecette :input").val("");
$j("#frmSoumRecette dl .dropdown_toggle").empty().append("<span>"+_TR("pvp.faites un choix","faites un choix" )+"</span>");}, 30*1000);} else{
$j.each(data, function(i, n){
var i= $j("#"+n[0]);
if(i.css("display")=="none"){
i=i.parent();}
i.tooltip(n[3]);});}}
this.soumettre= function(){
var url="/plugin.php";
var f= $w("frmSoumRecette");
var v= formToJSON(f);
v.plugin="recette";
v.action="inserer";
$j("#b-soumettre").hide();
$j.clearTooltips();
$j.post(url, v, apresSoumettre,"json" );}

function initIndex(){
Recette.index('');
enhanceSelects();
$j('.m-index-recherche .liste-complete a:first').css({'text-decoration':'none','color' :'#000','cursor' :'default'});
$j('.m-index-recherche .liste-complete a').click(function(){
$j('.m-index-recherche .liste-complete a').attr('href','#' ).css({'text-decoration':'underline','color' :'#00416D','cursor' :'pointer'});
$j(this).attr('href','' ).css({'text-decoration':'none','color' :'#000','cursor' :'default'});});
$j('#form-rechercher .b-rechercher').click(function(){
$j('.m-index-recherche .liste-complete a').attr('href','#' ).css({'text-decoration':'underline','color' :'#00416D','cursor' :'pointer'});});
$j('#art-top-image img, #contenu .fond-vert-recettes, #zone-titre img, #zone-contenu, #top-image-pomme').ifixpng();}

function initOngletRecette(){
$j('#art-top-image img, #contenu .fond-vert-recettes, #zone-titre img, #zone-contenu, #top-image-pomme').ifixpng();}

function initProposer(){
enhanceSelects();
$j('#art-top-image img, #contenu .fond-vert-recettes, #zone-titre img, #zone-contenu, #top-image-pomme').ifixpng();}
function setUpOnglet(index, init){
var nav= OngletNavigateurs.getCurItem();
var o= nav.get(index);
if(o.getNode()){
init();} else{
nav.get(index).onCreate= init;}}
this.setUpOnglets= function(){
var nav= OngletNavigateurs.getCurItem();
nav.get(6).onHide= function(){
$j.clearTooltips();}
setUpOnglet(0, initIndex);
setUpOnglet(1, initOngletRecette);
setUpOnglet(2, initOngletRecette);
setUpOnglet(3, initOngletRecette);
setUpOnglet(4, initOngletRecette);
setUpOnglet(5, initOngletRecette);
setUpOnglet(6, initProposer);}}
var z= 40;
checkExternalClick= function(event){
if($j(event.target).parents('.activedropdown').length=== 0){
$j('.activedropdown').removeClass('activedropdown');
$j('.options').hide();}}
function enhanceSelects(){
$j('select').each(function(){
if(!$j(this).parent().hasClass('enhanced')){
targetselect= $j(this);
targetselect.hide();
var target= targetselect.parent();
target.addClass('enhanced');
target.append('<dl id="'+targetselect.attr('id')+'-enhanced" class="dropdown"><dt><a class="dropdown_toggle" href="#"></a></dt><dd><div class="options"><ul></ul></div></dd></dl>');
target.find('.dropdown').css('z-index',z);
z--;
target.find('.options').hide();
var i= 0;
targetselect.find('option').each(function(){
target.find('.options ul').append('<li><a href="#" onclick="return false;"><span class="value">'+ $j(this).text()+'</span><span class="hidden index">'+ i+'</span></a></li>' );
$j('.options ul li:first', target).css('display','none');
if($j(this).attr('selected')== true){
target.find('a.dropdown_toggle').append('<span></span>').find('span').text($j(this).text());}
i++;});
var dblProtect=new Date().getTime();
function openCombobox(){
var theseOptions= $j(this).parent().parent().find('.options');
if(theseOptions.css('display')=='block'){
if((new Date().getTime()- dblProtect)> 100){
$j('.activedropdown').removeClass('activedropdown');
theseOptions.hide();}} else{
theseOptions.parent().parent().addClass('activedropdown');
theseOptions.show();}
dblProtect=new Date().getTime();
return false;}
var opentarget= $j('#'+targetselect.attr('id')+'-enhanced a.dropdown_toggle, label[for$="'+targetselect.attr('id')+'"]');
opentarget.mousedown(openCombobox);
opentarget.focus(openCombobox);
opentarget.blur(function(){
var theseOptions= $j(this).parent().parent().find('.options');
if(theseOptions.css('display')=='block'){
setTimeout(function(){
$j('.activedropdown').removeClass('activedropdown');
theseOptions.hide();}, 300);}});
opentarget.click(function(){ return false;});
target.find('.options a').click(function(e){
target.find('.options').hide();
var enhanced= target;
var realselect= targetselect;
realselect[0].selectedIndex= $j(this).find('span.index').text();
enhanced.find('.dropdown_toggle').empty().append('<span></span>').find('span').text($j(this).find('span.value').text());
return false;});}});}
$j(document).ready(function(){
Recette.setUpOnglets();
$j('#main-body').animate({
backgroundPosition:"("+bgYPos+")"}, 800,"easeOutBack" , function(){
if($j.support.opacity){
$j('#container').css({opacity: 0, display:'block'});
var cssPos=-25;
$j('#liste-onglets li').each(function(i){
$j(this).css({'left': cssPos+"px"});
cssPos+= $j(this).width();});
$j('head').append('<style type="text/css">#menu-onglet .selected a {padding: 0 19px 12px 18px;} #menu-onglet .selected a .box {padding: 16px 33px 12px 32px;}</style>');
$j('#container').animate({opacity: 1}, 400);} else{
$j('#container').css({display:'block'});
var cssPos=-25;
$j('#liste-onglets li').each(function(i){
$j(this).css({'left': cssPos+"px"});
cssPos+= $j(this).width();});
$j('head').append('<style type="text/css">#menu-onglet .selected a {padding: 0 19px 12px 18px;} #menu-onglet .selected a .box {padding: 16px 31px 12px 30px;}</style>');}});
$j(document).mousedown(checkExternalClick);});