var pp={inklMoms:"ja",init:function(){$("exklMomsSwitch").observe("click",pp.switchMoms);$$(".priceTag").each(function(A){A.lastChild.firstChild.data=pp.formatCurrency(Number(A.firstChild.firstChild.data))});$$(".priceLink").each(function(A){A.observe("click",pp.showPrintPrices)})},openInLightView:function(B,F,C,A,E,D){if(E){document.observe("lightview:opened",function(){E();document.stopObserving("lightview:opened")})}$$(".lv_External")[0].setStyle({overflow:"auto",width:C+"px",height:A+"px"});Lightview.show({href:B+"?"+F,rel:"ajax",title:D?D:"",options:{width:C,height:A}})},PromptDialog:{wrapupPrompt:function(A){var B=$("promptField").value;$("promptField").value="";$("promptDialog").style.display="none";$("promptBlackout").style.display="none";if(A){B=null}pp.PromptDialog.promptCallback(B);pp.PromptDialog.promptCallback=function(){alert("promptCallback not overridden")};pp.PromptDialog.valueHolder=[]},promptUser:function(D,A){if(!$("promptDialog")){var B=document.body.appendChild(document.createElement("div"));var E=document.body.appendChild(document.createElement("div"));B.id="promptDialog";E.id="promptBlackout";var C='<div style="width:100%;background-color:blue;color:white;"';C+='font-family:verdana;font-size:10pt;font-weight:bold;height:20px">&nbsp;TrycksaksTorget</div>';C+='<div style="padding:10px"><span id="promptMessage"></span><br><br>';C+='<form action="javascript:;" onsubmit="return pp.PromptDialog.wrapupPrompt()">';C+='<input id="promptField" name="promptdata" type="text" size="46" value="">';C+="<br><br><center>";C+='<input type="submit" value="&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;">';C+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";C+='<input type="button" onclick="pp.PromptDialog.wrapupPrompt(true)" value="&nbsp;Cancel&nbsp;">';C+="</form></div>";B.innerHTML=C}$("promptDialog").style.top=parseInt(document.documentElement.scrollTop+(screen.height/3))-100+"px";$("promptDialog").style.left=parseInt((document.body.offsetWidth-315)/2)+"px";dwr.util.setValue("promptMessage",D);$("promptField").value=A;$("promptBlackout").style.height=(document.body.offsetHeight<screen.height)?screen.height+"px":document.body.offsetHeight+20+"px";$("promptBlackout").style.display="block";$("promptDialog").style.display="block";$("promptField").focus();$("promptField").select()},promptCallback:function(){alert("promptCallback not overridden")},valueHolder:[]},showPrintPrices:function(A){pp.openInLightView("/priceInfo.do","id="+Event.findElement(A,"span").id.substring(1),330,330,function(){$$(".priceTag").each(function(C){C.lastChild.firstChild.data=pp.formatCurrency(Number(C.firstChild.firstChild.data))});$("priceInfoInput").observe("click",function(C){pp.PromptDialog.valueHolder[0]=Event.element(C).id;pp.PromptDialog.promptCallback=function(D){if(D!=null&&D!=$(pp.PromptDialog.valueHolder[0]).value){if(isNaN(D)){D=1}else{if(D<1){D=1}else{if(D>99999){D=99999}}}$(pp.PromptDialog.valueHolder[0]).value=D;$("priceInfoTable_2").parentNode.style.display="";dwr.util.removeAllRows("priceInfoTable_2");dwr.util.addRows("priceInfoTable_2",["Hämtar pris..."],[function(E){return E},function(){return""},function(){return""}],{rowCreator:function(E){var F=document.createElement("tr");F.className="d"+(E.rowNum%2);return F},cellCreator:function(E){var F=document.createElement("td");F.className="col"+(E.cellNum+1);return F}});ajaxFacade.getPriceForQuantity(dwr.util.getValue("priceInfoProductId"),Number(D),{callback:function(E){dwr.util.removeAllRows("priceInfoTable_2");dwr.util.addRows("priceInfoTable_2",[E],[function(){return dwr.util.getValue("priceInfoInput")},function(F){return'<span class="priceTag"><span class="rawPrice">'+F+'</span><span class="fmtPrice">'+pp.formatCurrency(F)+"</span></span>"},function(F){return'<span class="priceTag"><span class="rawPrice">'+F*Number(dwr.util.getValue("priceInfoInput"))+'</span><span class="fmtPrice">'+pp.formatCurrency(F*Number(dwr.util.getValue("priceInfoInput")))+"</span></span>"}],{rowCreator:function(F){var G=document.createElement("tr");G.className="d"+(F.rowNum%2);return G},cellCreator:function(F){var G=document.createElement("td");G.className="col"+(F.cellNum+1);return G},escapeHtml:false})}})}};pp.PromptDialog.promptUser("Ange antal:",Event.element(C).value)});$("priceInfo_"+(pp.inklMoms=="ja"?"exkl":"inkl")).observe("click",pp.switchPriceInfoMoms);$("priceInfo_"+(pp.inklMoms!="ja"?"exkl":"inkl")).style.fontWeight="bold";var B=$("priceInfo_"+(pp.inklMoms=="ja"?"exkl":"inkl"));B.style.color="blue";B.style.textDecoration="underline";B.style.cursor="pointer"})},formatCurrency:function(A,B){if(!B){A=A*(pp.inklMoms=="ja"?1.25:1)}return(A.toFixed(2)+"").replace(".",":")},switchPriceInfoMoms:function(){var B=(pp.inklMoms!="ja");var A=$("priceInfo_"+(B?"inkl":"exkl"));var C=$("priceInfo_"+(B?"exkl":"inkl"));A.setStyle({cursor:"default",color:"#000",textDecoration:"none",fontWeight:"bold"});C.setStyle({cursor:"pointer",color:"#00f",textDecoration:"underline",fontWeight:"normal"});A.stopObserving("click",pp.switchPriceInfoMoms);C.observe("click",pp.switchPriceInfoMoms);pp.switchMoms()},switchMoms:function(){pp.inklMoms=pp.inklMoms=="ja"?"nej":"ja";var B=(pp.inklMoms=="ja");var A=$((B?"inkl":"exkl")+"MomsSwitch");var C=$((B?"exkl":"inkl")+"MomsSwitch");A.setStyle({cursor:"default",color:"#000",textDecoration:"none",fontWeight:"bold"});C.setStyle({cursor:"pointer",color:"#00f",textDecoration:"underline",fontWeight:"normal"});A.stopObserving("click",pp.switchMoms);C.observe("click",pp.switchMoms);window.setTimeout("pp.updatePrices()",0)},updatePrices:function(){$$(".momsTxt").each(function(A){A.innerHTML=A.innerHTML.replace(pp.inklMoms=="ja"?"exkl":"inkl",pp.inklMoms=="ja"?"inkl":"exkl")});$$(".priceTag").each(function(A){A.lastChild.firstChild.data=pp.formatCurrency(Number(A.firstChild.firstChild.data))})}};document.observe("dom:loaded",pp.init);