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)});$$(".freightLink").each(function(a){a.observe("click",pp.showFreightInfo)})},openInLightView:function(b,f,c,a,e,d){if(e){document.observe("lightview:opened",function(){e();document.stopObserving("lightview:opened")})}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:[]},showFreightInfo:function(a){pp.openInLightView("/freightInfo.html","id="+Event.findElement(a,"span").id.substring(8),340,330,function(){$$(".priceTag").each(function(c){c.lastChild.firstChild.data=pp.formatCurrency(Number(c.firstChild.firstChild.data))});$("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"})},showPrintPrices:function(a){pp.openInLightView("/priceInfo.do","id="+Event.findElement(a,"span").id.substring(1),330,360,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""},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.getPriceAndFreightCostForQuantity(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[0]+'</span><span class="fmtPrice">'+pp.formatCurrency(f[0])+"</span></span>"},function(f){return'<span class="priceTag"><span class="rawPrice">'+f[0]*Number(dwr.util.getValue("priceInfoInput"))+'</span><span class="fmtPrice">'+pp.formatCurrency(f[0]*Number(dwr.util.getValue("priceInfoInput")))+"</span></span>"},function(f){return'<span class="priceTag"><span class="rawPrice">'+f[1]+'</span><span class="fmtPrice">'+pp.formatCurrency(f[1])+"</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(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1 ").replace(".",":").replace(/:00$/," kr")},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);
