var Product={map:null,directions:null,ChangeListingStyle:function(A){$("listing_blockR").hide();$("listing_blockR").removeClassName("listing_blockR_inlinetxt");$("listing_blockR").removeClassName("listing_blockR");$("listing_blockR").removeClassName("listing_blockR_inline");$("listing_blockR").addClassName(A);new Effect.Appear($("listing_blockR"));new Ajax.Request("/StoreProductListDisplayStyle.ashx",{parameters:{ProductsListDisplayStyle:A},method:"get"});},setProductNote:function(B){var A=$(B);var C=$(B).previousSiblings();var D=$(B).nextSiblings();$("note_value").value=A.readAttribute("note");A.setAttribute("src","/images_beta2/ico_star_10x10.gif");C.each(function(F,E){F.setAttribute("src","/images_beta2/ico_star_10x10.gif");});D.each(function(F,E){F.setAttribute("src","/images_beta2/ico_stargray_10x10.gif");});},displayProduct:function(C,B,A){if(C==""){return ;}new Ajax.Updater("container-body","/ProductDetailInfo.ashx",{method:"get",evalScripts:true,parameters:{prodId:C,displayContext:B,displayContextKey:A}});},DisplayProductInWidget:function(C,B,A){$("popup_overlay").show();$("loading").show();new Ajax.Updater("container-body","/ProductDetailInfo.ashx",{method:"get",evalScripts:true,parameters:{prodId:C,displayContext:B,displayContextKey:A},onComplete:function(){$("loading").hide();Effect.Appear("prod_widget");}});},CloseProductWidget:function(){$("popup_overlay").hide();Effect.Fade("prod_widget");},showProductLargePhoto:function(A,B){if(B==""){return ;}if(A==""){return ;}new Ajax.Updater("img_ficheprod","/getProductImage.ashx",{method:"get",parameters:{prodId:B,photoId:A},onSuccess:function(C){new Effect.Opacity("img_ficheprod",{duration:0.8,transition:Effect.Transitions.linear,from:0.1,to:1});}});},switchTab:function(C){var B=$(C);B.addClassName("detailprod_menu_on");var A=$(C).siblings();A.each(function(E,D){E.removeClassName("detailprod_menu_on");});},openTabGeoLocalisation:function(A,D,C){if(A==""){return ;}if(D==""){return ;}if(C==""){return ;}$(C).show();var B=$(C).siblings();B.each(function(F,E){F.hide();});new Ajax.Updater(C,"/geolocalisationProduct.ashx",{method:"get",parameters:{merchantProdId:A},evalScripts:true,onComplete:function(){Product.showGoogleMap();}});},openTabComments:function(B){if(B==""){return ;}$("fiche-prod-rub_content_comments").show();var A=$("fiche-prod-rub_content_comments").siblings();A.each(function(D,C){D.hide();});new Ajax.Updater("fiche-prod-rub_content_comments","/ProductDetailComments.ashx",{method:"get",parameters:{prodId:B}});},openTabSyndication:function(B){var C=$("fiche-prod-rub-content-syndication");var A=C.siblings();A.each(function(E,D){E.hide();});C.show();new Ajax.Updater(C,"/ProductDetailSyndication.ashx",{method:"get",parameters:{product:B}});},createSyndicationTag:function(B,A){new Ajax.Updater(B,"/CreateNewSyndicationTag.ashx",{method:"get",parameters:{product:A}});},openTabInfo:function(B){$(B).show();var A=$(B).siblings();A.each(function(D,C){D.hide();});},refuseEnterKey:function(A){if(!A&&window.event){A=window.event;}if(A.KeyCode==13){A.returnValue=false;A.cancelBubble=true;}if(A.which==13){A.preventDefault();A.stopPropagation();}},sendComment:function(A){if(A==""){return ;}if($F("textarea_comment")==""){$("comment_error").innerHTML="Avant de valider, entrez un commentaire dans le champs ci-dessus";return ;}if($F("note_value")==""){$("comment_error").innerHTML="Indiquez une note pour  le produit";return ;}if($F("captcha_value")==""){$("comment_error").innerHTML="Vous devez entrer un code de vérification pour valider le commentaire";return ;}new Ajax.Request("/checkCaptcha.ashx",{method:"get",parameters:{code:$F("captcha_value")},onSuccess:function(C){var B=C.responseText.evalJSON();if(B.status=="OK"){new Ajax.Updater("comments-list","/AddCommentToProduct.ashx",{method:"post",parameters:{comment:$F("textarea_comment"),prodId:A,note:$F("note_value"),code:$F("captcha_value")},insertion:Insertion.Top,onSuccess:function(D){$("comment_error").innerHTML="";$("textarea_comment").value="";$("captcha_value").value="";}});}else{$("comment_error").innerHTML="Le code entré est incorrect";}}});},showGoogleMap:function(){if(A==""){return ;}var C;var D=$("user_address").value+" "+$("user-city").value+" "+$("user-postcode").value;var A=$("merchant-address").value+" "+$("merchant-city").value+" "+$("merchant-postcode").value;map=new GMap2($("map"));G_END_ICON.iconSize.height=88;G_END_ICON.iconSize.width=88;map.scrollWheelZoomEnabled();$("my_textual_div").innerHTML="";C=$("my_textual_div");map.setCenter(new GLatLng(48.9,2.35),9);map.enableScrollWheelZoom();directions=new GDirections(map,C);directions.load("from:"+D+" to:"+A);var B=directions.getNumRoutes();GEvent.addListener(directions,"addoverlay",function(){$("geo-response").hide();map.setCenter(directions.getMarker(0).getLatLng(),11);});GEvent.addListener(directions,"error",function(){$("geo-response").show();$("geo-response").innerHTML="Aucun itinéraire trouvé ";});},zoomIn:function(A){A.zoomIn();},zoomOut:function(A){A.zoomOut();},SignInProductPage:function(B,A){new Ajax.Request("/Login.ashx",{method:"get",parameters:{login:$F("login_product_page"),password:$F("password_product_page")},onSuccess:function(D){var C=D.responseText.evalJSON();if(C.status=="OK"){if(B=="comments"){Product.openTabComments(A);}else{if(B=="syndication"){Product.openTabSyndication(A);}else{new Effect.Appear("span_errormessage_product_page");}}}}});},clearText:function(A,B){if($(A).value==B){$(A).value="";}},resetText:function(A,B){if($(A).value==""){$(A).value=B;}},sendFriendMail:function(C){var A=$("friend_mail").value;var B=new RegExp("^[.a-zA-Z0-9_-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}$");if(!B.test(A)){$("friend_email_msg").update("Format non valide");return ;}else{new Ajax.Request("/ProductDetailMailFriend.ashx",{method:"get",parameters:{mail:A,merchantProductId:C},onSuccess:function(E){var D=E.responseText.evalJSON();if(D.status=="OK"){$("friend_email_msg").update("Votre mail a bien été envoyé.");}else{$("friend_email_msg").update("Problème lors de l'envoi du mail. L'équipe d'Ayamee est informée de ce problème.");}}});}},sendToClipBoard:function(){var A=$("syndication_text").innerHTML.unescapeHTML();Product.copy(A);},copy:function(A){if(window.clipboardData){window.clipboardData.setData("Text",A);}else{if(!$("flashcopier")){document.body.insert(new Element("div",{id:"flashcopier"}));}$("flashcopier").update('<embed src="/_clipboard.swf" FlashVars="clipboard='+escape(A)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>');}},addComment:function(E,B,C,D,A){new Ajax.Request("/Widgets/Products/Products.ashx",{method:"post",parameters:{action:"addcomment",mood:E,pid:B,mpid:C,comment:D},onSuccess:A});}};var addProductToSpace={TARGET:"popaddtospace",TARGET_CONTENT:"pop_addtospace_content",STEP1:null,OVERLAY:"popup_overlay",TABACTIVE:".tabactive",TABINACTIVE:".tabunactive",merchantproduct:null,ShowStep1:function(A){this.merchantproduct=A;var B=new SPopup(100,"",{overlay:"popup_overlay",name:"addtospace",contentUrl:"/AddProductToSpace.ashx?action=uishowstep1&mpid="+A});B.show();},ShowStep2:function(B,A){new Ajax.Request("/AddProductToSpace.ashx",{method:"post",parameters:{action:"uishowstep2",tabid:B},onSuccess:function(C){$("pop_addtospace_widgets").update(C.responseText);addProductToSpace.ToggleTab(A);addProductToSpace.STEP1=true;addProductToSpace.ShowWidgets();}});},AddProduct:function(A,B){new Ajax.Request("/AddProductToSpace.ashx",{method:"post",parameters:{action:"addproduct",wid:A,mpid:B},onSuccess:function(C){$("pop_addtospace_content").update(C.responseText);}});},ToggleTab:function(B){var A=$("pop_addtospace_tabs").select("a.tabactive").last();if(A){A.removeClassName("tabactive");A.down("img").src="/Images_beta2/img_onglet_88x88.gif";}$(B).addClassName("tabactive");$(B).down("img").src="/Images_beta2/img_onglet_on_88x88.gif";},ShowWidgets:function(){if(this.STEP1){$("pop_addtospace_widgets").show();$("pop_addtospace_tabs").hide();}},ShowTabs:function(){$("pop_addtospace_widgets").hide();$("pop_addtospace_tabs").show();}};var mood={mpid:null,jaimePopup:function(A){this.mpid=A;var B=new SPopup(600,"J'aime",{overlay:"popup_overlay",name:"addtospace",contentUrl:"/AddProductToSpace.ashx?action=moodpopup&mood=jaime&mpid="+A,callbackAfterContentInitialized:function(){$("textarea-jaime-text").observe("focus",function(C){if(!$("textarea-jaime-text").hasClassName("focused")){$("textarea-jaime-text").clear();$("textarea-jaime-text").addClassName("focused");}});}});B.show();},jaimepasPopup:function(A){this.mpid=A;var B=new SPopup(600,"J'aime pas",{overlay:"popup_overlay",name:"addtospace",contentUrl:"/AddProductToSpace.ashx?action=moodpopup&mood=jaimepas&mpid="+A,callbackAfterContentInitialized:function(){$("textarea-jaime-text").observe("focus",function(C){if(!$("textarea-jaime-text").hasClassName("focused")){$("textarea-jaime-text").clear();$("textarea-jaime-text").addClassName("focused");}});}});B.show();},push:function(B,A){new Ajax.Request("/AddProductToSpace.ashx",{method:"post",parameters:{action:"moodpush",mood:A,mpid:this.mpid,comment:B},onSuccess:function(C){$("popjaime_b1").update(C.responseText);}});}};function PopupProdDetail(){var A=(document.viewport.getDimensions().height-document.viewport.getDimensions().height)+document.viewport.getScrollOffsets().top;$("prod_widget").setStyle("top:"+A+"px;");$("prod_widget").show();}
