PM.PrdQA=function(B,C,E,D){this.identifier=B;this.productId=C;this.parentId=(typeof (E)=="undefined")?null:E;this.type=this.parentId?PM.PrdQA.Type.ANSWER:PM.PrdQA.Type.QUESTION;this.isMainQuestionAndSwitchActive=(typeof (D)=="undefined")?null:D;var A=(this.type==PM.PrdQA.Type.QUESTION)?"Question":"Reponse";this.xitiSubmissionPage="FPA::QuestionProduit::Soumission"+A;PM.Event.add($j("a",$("link_qa_form_"+B))[0],"click",this.isMainQuestionAndSwitchActive?PM.PrdQA.displaySwitchForm.bindObjWithEvent(null,true):this.displayForm.bindObj(this,true),true)};PM.PrdQA.prototype.displayForm=function(C,B,A){if(typeof (A)!="undefined"&&A==true){new PM.UI.SmoothScroll("q_and_a")}if(!this.form){this.form=new PM.PrdQA.Form(this)}if(!(typeof (C)=="boolean"&&C==false)){this.form.show(B)}};PM.PrdQA.Type={QUESTION:0,ANSWER:1};PM.PrdQA.Form=function(D){this.prdQA=D;var E=($("qa_submit_template")).cloneNode(true).innerHTML;E=PM.Util.variableReplace(PM.Util.variableReplace(E,"referrerId",this.prdQA.identifier),"type",(this.prdQA.type==PM.PrdQA.Type.ANSWER)?"Reponse":"Question");var C=$("qa_form_ctner"+this.prdQA.identifier);C.innerHTML=E;var B=(this.prdQA.type==PM.PrdQA.Type.ANSWER)?"A_":"Q_";$s("div.frm_fldset legend span",C)[0].innerHTML=PM.PrdQA.Constants.Form[B+"TITLE"];$s("p.frm_lgnd span",C)[0].innerHTML=PM.PrdQA.Constants.Form[B+"TITLE"];if(this.prdQA.type==PM.PrdQA.Type.ANSWER){var A=$s("div.question_ctn h3",PM.Dom.parent(PM.Dom.parent(C)))[0].innerHTML;$s("div.frm_edito",C)[0].innerHTML=PM.PrdQA.Constants.Form[B+"EDITO"]+A}$s("div.fld_txtarea label span",C)[0].innerHTML=PM.PrdQA.Constants.Form[B+"CONTENT"];$s("p.notice",C)[0].innerHTML=PM.PrdQA.Constants.Form[B+"NOTICE"];PM.Forms.Check.setConstraints(qaChecks,this.prdQA.identifier);this.isSubmitEnabled=true;this.formElt=$("qa_form"+this.prdQA.identifier);this.notification=this.prdQA.isMainQuestionAndSwitchActive?$("notification_global"):$("qa_notification"+this.prdQA.identifier);this.linkShowForm=$("link_qa_form_"+this.prdQA.identifier);this.buyerTargetBlock=$("qatarget_"+this.prdQA.identifier);this.buyerTargetInputName=PM.PrdQA.Constants.Fields.IS_OLD_BUYER_CONTACTABLE+"_"+this.prdQA.identifier;this.contentElt=$(PM.PrdQA.Constants.Fields.CONTENT+this.prdQA.identifier);PM.Forms.Focus.init(this.formElt);if(this.prdQA.type==PM.PrdQA.Type.QUESTION){PM.Assistance.init(this.formElt)}var F=$("link_cancel_qa_form"+this.prdQA.identifier);PM.Event.add(F,"click",this.prdQA.isMainQuestionAndSwitchActive?PM.PrdQA.getSwitchForm().hide.bindObj(PM.PrdQA.getSwitchForm(),true,true):this.hide.bindObjWithEvent(this,true),true);this.xiti=new PM.Statistics.Criteria();PM.Forms.registerAction(this.formElt,PM.Forms.Check.perform.bindObj({checks:qaChecks,noticeCtner:this.notification,idSuffix:this.prdQA.identifier,xiti:this.xiti,replaceStr:{type:(this.prdQA.type==PM.PrdQA.Type.QUESTION)?PM.PrdQA.Constants.TYPE_QUESTION:PM.PrdQA.Constants.TYPE_ANSWER}}));PM.Event.add(this.formElt,"submit",this.submit.bindObj(this));PM.Event.add($("link_submit_qa"+this.prdQA.identifier),"click",this.submit.bindObj(this))};PM.PrdQA.Form.prototype.show=function(B){B=(typeof (B)=="undefined")?true:B;if(this.isSubmitEnabled){this.linkShowForm.style.display="none";if(B){new Effect.SlideDown(this.formElt,{duration:0.5,afterFinish:PM.Event.eventReached.bindObj(null,PM.Event.Type.REDRAW),afterUpdate:PM.Event.eventReached.bindObj(null,PM.Event.Type.REDRAW)})}else{PM.UI.show(this.formElt);PM.Event.eventReached(PM.Event.Type.REDRAW)}}if(this.prdQA.type==PM.PrdQA.Type.QUESTION){PM.Dom.Class.remove(PM.Dom.parent($(this.formElt)),"empty")}if(this.buyerTargetBlock!=null){if(this.prdQA.type==PM.PrdQA.Type.QUESTION){PM.UI.show(this.buyerTargetBlock)}else{PM.UI.hide(this.buyerTargetBlock)}}var A=(this.prdQA.type==PM.PrdQA.Type.QUESTION)?"Question":"Reponse";PM.Statistics.tagView("31",this.prdQA.xitiSubmissionPage+"Formulaire")};PM.PrdQA.Form.prototype.hide=function(C,B,A){if(typeof (C)!="undefined"&&C!=null){PM.Util.preventDefault(C)}if(typeof (A)=="undefined"){A=true}if(typeof (B)!=undefined&&B==true){this.reset()}var D=function(){if(this.isSubmitEnabled){PM.UI.show(this.linkShowForm)}else{PM.UI.hide(this.linkShowForm)}};if($(this.formElt).style.display!="none"){if(A){new Effect.SlideUp($(this.formElt),{duration:0.5,afterFinish:function(){D.apply(this);PM.Event.eventReached(PM.Event.Type.REDRAW)}.bindObj(this),afterUpdate:PM.Event.eventReached.bindObj(null,PM.Event.Type.REDRAW)})}else{PM.UI.hide(this.formElt);PM.Event.eventReached(PM.Event.Type.REDRAW);D.apply(this)}}else{D.apply(this)}if(this.prdQA.type==PM.PrdQA.Type.QUESTION){PM.Dom.Class.add(PM.Dom.parent($(this.formElt)),"empty")}};PM.PrdQA.Form.prototype.reset=function(A){PM.Forms.Check.hideError(this.contentElt.id);this.contentElt.value="";if(this.buyerTargetBlock!=null){if(this.prdQA.type==PM.PrdQA.Type.QUESTION){PM.Forms.Radio.unselect(this.buyerTargetInputName)}}PM.Notice.hide(this.notification);PM.PrdQA.mainQuestion.parentId=null};PM.PrdQA.Form.prototype.submit=function(B){var E=false;if(typeof (B)=="boolean"){E=B}else{if(typeof (B)!="undefined"){PM.Util.preventDefault(B)}}if(PM.Forms.preSubmitCheck(this.formElt)){var D="";D+="&"+PM.PrdQA.Constants.Fields.CONTENT+"="+PM.Forms.ajaxPostEncode(this.contentElt.value);if(this.prdQA.parentId){D+="&"+PM.PrdQA.Constants.Fields.PARENT_ID+"="+this.prdQA.parentId}D+="&productid="+this.prdQA.productId;if(this.buyerTargetBlock!=null){var A=$s(".ipt_chk",this.buyerTargetBlock);var C=PM.Forms.getElementChecked(A);if(typeof (C)!="undefined"){D+="&"+PM.PrdQA.Constants.Fields.IS_OLD_BUYER_CONTACTABLE+"="+PM.Forms.ajaxPostEncode(C.value)}}PM.Ajax.request(PM.PrdQA.Constants.SUBMIT_URL,this.submitComplete.bindObj(this),{urlParams:D,method:PM.Ajax.POST,preventMultipleCalls:"qa_frm_fldset"+this.prdQA.identifier,requestHeaders:{referer:window.location.href},showButtonAfterSubmit:E,errorCallback:this.submitError.bindObj(this)})}else{PM.Statistics.tagView("31",this.prdQA.xitiSubmissionPage+"KO"+this.xiti.tag);this.xiti.reset()}};PM.PrdQA.Form.prototype.submitComplete=function(options){eval("var res = "+options.responseText);if(res&&res.action=="ProductQuestionSubmit"){switch(res.code){case 0:var message="<p>"+res.values.message+"<br />"+res.values.pendingMessage+"</p>";if(res.values.redirectMessageReview){message=message+"<p>"+res.values.redirectMessageReview+"</p>"}this.isSubmitEnabled=options.showButtonAfterSubmit?true:false;if(this.prdQA.isMainQuestionAndSwitchActive){PM.PrdQA.getSwitchForm().hide(false,true);this.reset()}else{this.hide(null,true)}PM.Notice.show(this.notification,PM.Notice.Type.SUCCESS,message,false);break;case 1:this.beforeAuthentication();PM.Ajax.authenticate(res.values.options);break;case 2:this.isSubmitEnabled=options.showButtonAfterSubmit?true:false;if(this.prdQA.isMainQuestionAndSwitchActive){PM.PrdQA.getSwitchForm().hide(false,true)}else{this.hide(null,true)}PM.Notice.show(this.notification,PM.Notice.Type.ERROR,res.values.message);break;case 3:var errorLines=new Array();for(i=0;i<res.values.fields.length;i++){errorLines[errorLines.length]=PM.Forms.Check.showError(res.values.fields[i].id+this.prdQA.identifier,res.values.fields[i].message)}var errorNotice=PM.Forms.Check.computeGlobalMessage(qaChecks.globalErrorMessage,errorLines);PM.Notice.show(this.notification,PM.Notice.Type.ERROR,errorNotice);break;case -1:default:PM.Notice.show(this.notification,PM.Notice.Type.ERROR,res.values.message);break}}};PM.PrdQA.Form.prototype.submitError=function(){PM.Notice.show(this.notification,PM.Notice.Type.ERROR,PM.Review.Labels.ERROR_UNKNOWN)};PM.PrdQA.Form.prototype.beforeAuthentication=function(){var C="qa_"+((this.prdQA.type==PM.PrdQA.Type.QUESTION)?"p":"q")+this.prdQA.identifier;PM.Cookie.set(C,"");PM.Cookie.setParam(C,PM.PrdQA.Constants.Fields.CONTENT,this.contentElt.value);if(this.buyerTargetBlock!=null){var A=$s(".ipt_chk",this.buyerTargetBlock);var B=PM.Forms.getElementChecked(A);if(typeof (B)!="undefined"){PM.Cookie.setParam(C,PM.PrdQA.Constants.Fields.IS_OLD_BUYER_CONTACTABLE,B.value)}}if(this.prdQA.type==PM.PrdQA.Type.ANSWER){PM.Cookie.setParam(C,PM.PrdQA.Constants.Fields.PARENT_ID,this.prdQA.parentId)}};PM.PrdQA.afterAuthentication=function(B){PM.PrdQA.moveMonetBlock();PM.PrdQA.mainQuestion.displayForm(false);var E="qa_"+B;if(PM.Cookie.get(E)){PM.PrdQA.mainQuestion.form.contentElt.value=PM.Cookie.getParam(E,PM.PrdQA.Constants.Fields.CONTENT);var C=PM.Cookie.getParam(E,PM.PrdQA.Constants.Fields.IS_OLD_BUYER_CONTACTABLE);if(typeof (C)!="undefined"&&C){var A=($s(".ipt_chk",$("qatarget_"+PM.PrdQA.mainQuestion.identifier)))[0];PM.Forms.checkInput(A)}PM.PrdQA.mainQuestion.parentId=PM.Cookie.getParam(E,PM.PrdQA.Constants.Fields.PARENT_ID);PM.Cookie.erase(E);var D=(PM.PrdQA.mainQuestion.parentId!=null);if(!D){PM.UI.hide("link_qa_form_"+PM.PrdQA.mainQuestion.identifier)}PM.PrdQA.mainQuestion.form.submit(D)}setTimeout("PM.PrdQA.scrollTo();",2000)};PM.PrdQA.showRedirectNotification=function(){PM.Notice.show("notification_global",PM.Notice.Type.SUCCESS,PM.PrdQA.Constants.Form.Q_REDIRECT_ADVERT_SUCCESS,false);var A=$s(".ask_question",$("q_and_a"))[0];PM.UI.hide(A);setTimeout("PM.PrdQA.scrollTo();",2000)};PM.PrdQA.moveMonetBlock=function(){var B=$("offer_body_inside");var A=$("after_prdqa");if(B&&A){PM.Dom.parent(B).removeChild(B);B.className="after_reviews";PM.Dom.parent(A).insertBefore(B,A)}};PM.PrdQA.moveMonetBlockFromMailAndAdvert=function(){PM.PrdQA.moveMonetBlock();setTimeout("PM.PrdQA.scrollTo();",2000)};PM.PrdQA.scrollTo=function(){PM.UI.scrollTo("q_and_a")};PM.PrdQA.initAnswersForm=function(D,C){var H=$s("div.question_answers",$("q_and_a_all"));for(var E=0;E<C.length;E++){var I=PM.Dom.parent(C[E].elt);var G=$s("p.reply_question",I)[0];var B=PM.Util.variableReplace(G.id,"link_qa_form_","",true);var F=new PM.PrdQA(B,D,B);var A=$s("div.question_ctn",I)[0];PM.Event.add(A,"click",PM.PrdQA.showFormWithCondition.bindObjWithEvent(null,A,F,C[E]))}};PM.PrdQA.showFormWithCondition=function(A,E,F,B){var D=PM.Dom.parent(E);var C=$s("div.answers_ctn div.item",D).length;if(C==0){if($s("div.all_answers_ctn",D)[0].style.display=="none"){F.displayForm(true,false)}}B.swap(A,E)};PM.PrdQA.initForPage=function(A,D){var B=null;var B=A;var C=PM.ExpandTree.init.apply(null,B);var E=new Array();E[0]=D;E[1]=C;PM.PrdQA.initAnswersForm.apply(null,E)};PM.PrdQA.expandTreeAction=function(A){if(A){PM.Statistics.tagView("31","FPA::QuestionProduit::DepliageQuestion")}};PM.PrdQA.isEnableToChangePage=function(A,B){this.paginateObj=A;acceptLoadPage=true;contentElts=$s(".fld_txtarea textarea",this.paginateObj.globalContainer);for(i=0;i<contentElts.length&&acceptLoadPage;i++){if(contentElts[i].value.length>0){acceptLoadPage=false}}if(!acceptLoadPage){PM.PrdQA.repQuestChClemUp.show(null,{btn1Action:function(C,D){PM.Util.preventDefault(C);PM.Alert.close();A.load(D,true)}.bindObjWithEvent(this.paginateObj,B),btn2Action:function(C){PM.Util.preventDefault(C);PM.Alert.close()}})}else{A.load(B,true)}};PM.PrdQA.switchForm=null;PM.PrdQA.getSwitchForm=function(){if(PM.PrdQA.switchForm==null){PM.PrdQA.switchForm=new PM.PrdQA.Switch()}return PM.PrdQA.switchForm};PM.PrdQA.displaySwitchForm=function(C,B,A){if(typeof (A)!="undefined"&&A==true){new PM.UI.SmoothScroll("q_and_a")}PM.PrdQA.getSwitchForm().show(B)};PM.PrdQA.Switch=function(){this.isOpened=false;this.displayedEdito=null;this.contentToDisplay=null;var B="qa_switchform_";PM.Event.add($j("p.fld_rdio input",$(B+"advert"))[0],"change",this.selectContent.bindObj(this,PM.PrdQA.Switch.Type.ADVERT));PM.Event.add($j("p.fld_rdio input",$(B+"product"))[0],"click",this.selectContent.bindObj(this,PM.PrdQA.Switch.Type.PRODUCT));PM.Event.add($j("p.fld_rdio input",$(B+"order"))[0],"click",this.selectContent.bindObj(this,PM.PrdQA.Switch.Type.ORDER));PM.Event.add($j("p.fld_rdio input",$(B+"price"))[0],"click",this.selectContent.bindObj(this,PM.PrdQA.Switch.Type.PRICEMINISTER));PM.Event.add($j("li a",$(B+"continue"))[0],"click",this.display.bindObjWithEvent(this),true);var A=$j("#qa_switchform li.lnk_cancel, #qa_form_advert li.lnk_cancel, #qa_form_order li.lnk_cancel, #qa_form_price li.lnk_cancel");for(i=0;i<A.length;i++){PM.Event.add(A[i],"click",this.hide.bindObj(this,true,true),true)}};PM.PrdQA.Switch.Type={ADVERT:"advert",PRODUCT:"product",ORDER:"order",PRICEMINISTER:"price"};PM.PrdQA.Switch.prototype.display=function(B,A){if(typeof (A)=="undefined"){A=this.contentToDisplay}if(A==null){PM.Notice.show("notification_global",PM.Notice.Type.ERROR,PM.PrdQA.Constants.SWITCH_FORM_ERROR,true);return false}PM.Notice.hide("notification_global");PM.Forms.checkInput($j("p.fld_rdio input",$("qa_switchform_"+A))[0]);PM.UI.hide("qa_switchform_continue");if(A==PM.PrdQA.Switch.Type.PRODUCT){PM.PrdQA.mainQuestion.displayForm(B,true)}else{new Effect.SlideDown("qa_form_"+A,{duration:0.5})}this.displayedEdito=A;switch(A){case PM.PrdQA.Switch.Type.ADVERT:PM.Statistics.tagView("31","FPA::QuestionProduit::AideQuestionAnnonce");break;case PM.PrdQA.Switch.Type.ORDER:PM.Statistics.tagView("31","FPA::QuestionProduit::AideQuestionArticle");break;case PM.PrdQA.Switch.Type.PRICEMINISTER:PM.Statistics.tagView("31","FPA::QuestionProduit::AideQuestionPM");break}};PM.PrdQA.Switch.prototype.selectContent=function(A){if(this.contentToDisplay!=A){this.contentToDisplay=A;if(this.displayedEdito!=null){if(this.displayedEdito==PM.PrdQA.Switch.Type.PRODUCT){PM.PrdQA.mainQuestion.form.isSubmitEnabled=false;PM.PrdQA.mainQuestion.form.hide(null,true,false);PM.PrdQA.mainQuestion.form.isSubmitEnabled=true}else{PM.UI.hide("qa_form_"+this.displayedEdito)}this.displayedEdito=null;PM.UI.show("qa_switchform_continue")}}};PM.PrdQA.Switch.prototype.show=function(A){if(!this.isOpened&&(!PM.PrdQA.mainQuestion.form||PM.PrdQA.mainQuestion.form.isSubmitEnabled)){this.isOpened=true;PM.UI.hide("link_qa_form_"+PM.PrdQA.mainQuestion.identifier);PM.UI.show("qa_switchform_continue");(A)?new Effect.SlideDown("qa_switchform",{duration:0.5}):PM.UI.show("qa_switchform");var B=$j("p.fld_rdio input",$("qa_switchform_advert"))[0];B.checked="checked";B.checked="";PM.Statistics.tagView("31","FPA::QuestionProduit::Choix")}};PM.PrdQA.Switch.prototype.hide=function(B,A){if(this.isOpened){if(this.displayedEdito!=null){if(this.displayedEdito==PM.PrdQA.Switch.Type.PRODUCT){PM.PrdQA.mainQuestion.form.hide(null,true,true)}else{new Effect.SlideUp("qa_form_"+this.displayedEdito,{duration:0.5})}this.displayedEdito=null}this.isOpened=false;var C="";if(B){C=function(){PM.UI.show("link_qa_form_"+PM.PrdQA.mainQuestion.identifier)}}(A)?new Effect.SlideUp("qa_switchform",{duration:0.5,afterFinish:C}):PM.UI.hide("qa_switchform");var D=$j("p.fld_rdio input",$("qa_switchform_advert"))[0];D.checked="checked";D.checked="";PM.UI.hide("qa_switchform_continue");this.contentToDisplay=null;PM.Notice.hide("notification_global")}};