var previewVisible=false;function numberFormat(n){if(!n)return"";return n.match(/\.(\d+)/)?(n.replace(/\B(?=(...)*\.)/g," ")).replace(/\./,","):n.replace(/\B(?=(...)*$)/g," ")}function trim(s){return s.replace(/^\s+/,"").replace(/\s+$/,"")}function updatePanier(params){$.get("",params,function(panier){var p=eval(panier);$("#panier")[0].innerHTML=(typeof p.texte=="string"?p.texte:" ");$("select").each(function(){var idMatch=this.id.match(/^\D+(\d+)$/);if(idMatch==null||idMatch.length<2)return;var checkboxId="#checkbox_"+idMatch[1];$(checkboxId).removeAttr("checked");for(var i=0;i<p.moIds.length;i++)if($(this).containsOption(p.moIds[i].toString())){$(this).selectOptions(p.moIds[i].toString(),true);$(checkboxId).attr("checked","checked");break}})})}function swap_cmd(o,oeuvreId){var moId=$("#type_mo_"+oeuvreId).val();var prix=$("#prix_mo_id_"+moId).val();var action=o.checked==true?"add":"remove";updatePanier({"action":"cmd_update","ordre":action,"quantite":1,"mo_id":moId,"prix":prix})}function type_mo_change(oeuvreId){var moId=$("#type_mo_"+oeuvreId).val();var prix=$("#prix_mo_id_"+moId).val();var stock=$("#stock_mo_id_"+moId).val();if(stock=="0"){$("#checkbox_"+oeuvreId).attr("disabled","disabled");$("#prix_"+oeuvreId).attr("class","vendu");$("#prix_"+oeuvreId).text("VENDU")}else{$("#checkbox_"+oeuvreId).removeAttr("disabled");$("#prix_"+oeuvreId).attr("class","prix");$("#prix_"+oeuvreId).text(numberFormat(prix)+" €")}if(!$("#checkbox_"+oeuvreId).attr("checked"))return;updatePanier({"action":"cmd_update","ordre":"change_type_mo","quantite":1,"mo_id":moId,"prix":prix})}$(document).ready(function(){$(".do_showPreview").each(function(){this.href="javascript:showPreview('"+this.href+"');"});$("option").each(function(){if(this.className=="i")return;var formatPrix=trim(this.text).match(/(^[^-]+) - (.+)$/);var format,prix="";if(formatPrix!=null){format=formatPrix[1];prix=formatPrix[2]}this.text=format;if(this.selected){var parentId=$(this).parents().map(function(){return this.id}).get()[0];var oeuvreIdMatch=parentId.match(/^\D+(\d+)$/);if(oeuvreIdMatch!=null&&oeuvreIdMatch.length>1){var oeuvreId=oeuvreIdMatch[1];if($("#stock_mo_id_"+this.value).val()=="0"){$("#checkbox_"+oeuvreId).attr("disabled","disabled");$("#prix_"+oeuvreId).attr("class","vendu");$("#prix_"+oeuvreId).text("VENDU")}else{$("#checkbox_"+oeuvreId).removeAttr("disabled");$("#prix_"+oeuvreId).attr("class","prix");$("#prix_"+oeuvreId).text(prix)}}}});$("#panier-update-button").remove()});function showPreview(previewUri){var size=or=="1248x832"?"&width=720&height=560":"";previewUri=previewUri+"&format=div"+size;if(previewUri.match(/target=right/)){hideDesc();$.get(previewUri,"",function(fragment){$(".vue-gauche-apercu")[0].innerHTML=fragment;adjustCSSClasses()})}else{previewVisible=true;if(navigator.userAgent.match(/MSIE [^7]/))$("select").css("visibility","hidden");$.get(previewUri,"",function(fragment){$("#vue-preview")[0].innerHTML=fragment;adjustCSSClasses();var h=$("#preview").css("height");$("#preview").css("height",0);$('#preview').animate({"height":h},{"duration":1024,"easing":"easeOutExpo"})})}}function hideVuePreview(){previewVisible=false;hideDesc();$("#vue-preview").empty();if(navigator.userAgent.match(/MSIE [^7]/))$("select").css("visibility","visible")}function hidePreview(){$("#preview-object").remove();$(".vue-gauche-apercu").empty();var h=$("#preview").css("height");if(navigator.userAgent.match(/Opera/i))hideVuePreview();else $('#preview').animate({"height":0},1024,"easeOutExpo",hideVuePreview)}function openPreview(previewUri){$("#vue-preview").empty();$(".vue-gauche-apercu").empty();window.open(previewUri.replace(/&#38;/,"&"));void 0}function removeMo(moId){$.get("",{"action":"cmd_update","ordre":"remove","mo_id":moId},function(){history.go(0)})}function resize(img){var maxWidth=628;var maxHeight=416;if(or=="1248x832"){maxWidth=980;maxHeight=570}if(img.height>maxHeight)img.height=maxHeight;if(img.width>maxWidth)img.width=maxWidth;$("#wait-message").hide();img.style.visibility="visible"}function showDesc(nom,desc){if(desc=="")return;$("#page-desc").hide();$("#item-desc")[0].innerHTML=("<h3><em>"+nom+"</em></h3><p>"+desc+"</p>");$("#item-desc").show()}function hideDesc(){if(previewVisible)return;$("#item-desc").hide();$("#page-desc").show()}