PageSourceSearch

https://cosmetics.nl/contents/sf.js?lmd=45971.550000

js cosmetics.nl collected 2026-10-08 11:06:11 UTC 211,347 bytes, 6,260 lines download raw bytes

1// <script>
2var tf=tf||this,LD=tf,tfc=tf.content||this,tfcd=tfc.document,$=tfc.$;
3if(tf.isInSF()){
4var wx=window.external,arrLoad=[];
5function addEvent(e,f,t){if(!t)var t=window;if (t.addEventListener)t.addEventListener(e.replace(/^on/,''),f,false);else if (t.attachEvent)t.attachEvent(e,f);}
6}
7var isIEBefore7=parseFloat(navigator.appVersion.split('MSIE')[1])<7;
8if ($) { (function($) { $.support.placeholder = ('placeholder' in document.createElement('input')); })(jQuery); }
9var prpgmap={
10pgMap:{},
11prMap:{},
12requested:{},
13loaded:{},
14onloadPgMap:function(oResp,fn){
15tf.merge(this.pgMap,tf.sfJSON.parse(oResp.req.responseText));
16if(fn)fn.call(this);
17},
18onloadPrMap:function(oResp,fn){
19tf.merge(this.prMap,tf.sfJSON.parse(oResp.req.responseText));
20if(fn)fn.call(this);
21},
22getParentPage:function(prid,pgid,fn){
23if(!pgid){pgid=tf.content.pgid;}
24pgid=pgid.toLowerCase();
25prid=prid.toLowerCase();
26var pridNum=parseInt(prid.substr(1)),pgidNum=parseInt(pgid.substr(1)),pgidFound=0;
27if(pgid.indexOf('/'+tf.enterFilename)!=-1||pgid=='/')pgidNum=-2;
28var prmapURL='prpgmap/prmap_'+Math.floor(pridNum/2000)+'.js';
29if(isNaN(pridNum)||this.prMap[pridNum]){
30if(isNaN(pridNum))pgidFound=pgidNum;
31else {
32var a=this.prMap[pridNum];
33if(typeof(a.length)=='number'&&typeof(a)!='string'){
34pgidFound=a[0];
35for(var n=1,num=a.length;n<num;n++){
36if(a[n]==pgidNum||a[n].toString().indexOf(pgidNum+'_')==0){
37pgidFound=a[n];
38break;
39}
40}
41}
42else pgidFound=a;
43}
44var pgidSplit=(isNaN(pgidFound)?pgidFound.split('_'):[pgidFound]);
45if(typeof(this.pgMap[pgidSplit[0]])!='undefined'){
46var s=this.pgMap[pgidSplit[0]], internalURL=((s==''||s.indexOf('_')==0)||unescape(s).indexOf('://')==-1),specialPage=(parseInt(pgidSplit[0])<0&&parseInt(pgidSplit[0])>-10000);
47if(parseInt(pgidSplit[0])==-2&&pgid.indexOf('/'+tf.enterFilename)!=-1)s=tf.enterFilename.replace(/\.[^.]*$/,'');
48var f=(internalURL&&!specialPage?'d'+pgidSplit[0]:'')+s+(pgidSplit[1]?'_'+pgidSplit[1]:'')+(internalURL||(specialPage&&internalURL)?'.html':'');
49if(parseInt(pgidSplit[0])==-2&&pgid=='/')f=pgid;
50return fn(f,prid,'d'+pgidSplit[0]);
51}
52else{
53var pgmapURL='prpgmap/pgmap_'+Math.floor(Math.abs(pgidSplit[0])/2000)+'.js';
54if(!tf.utils.prpgmap.requested[pgmapURL]){
55tf.utils.prpgmap.requested[pgmapURL]=true;
56new net.ContentLoader(
57tf.wm.url(pgmapURL,'-'),
58function(){tf.utils.prpgmap.onloadPgMap.call(tf.utils.prpgmap,this,function(){this.loaded[pgmapURL]=true;this.getParentPage(prid,pgid,fn);});},
59null, null, 'GET', '');
60}
61else if(tf.utils.prpgmap.loaded[pgmapURL])return fn('',prid,pgid);
62else setTimeout(function(){tf.utils.prpgmap.getParentPage(prid,pgid,fn)},0);
63}
64}
65else{
66if(!tf.utils.prpgmap.requested[prmapURL]){
67tf.utils.prpgmap.requested[prmapURL]=true;
68new net.ContentLoader(
69tf.wm.url(prmapURL,'-'),
70function(){tf.utils.prpgmap.onloadPrMap.call(tf.utils.prpgmap,this,function(){this.loaded[prmapURL]=true;this.getParentPage(prid,pgid,fn);});},
71null, null, 'GET', '');
72}
73else if(tf.utils.prpgmap.loaded[prmapURL])return fn('',prid,pgid);
74else setTimeout(function(){tf.utils.prpgmap.getParentPage(prid,pgid,fn)},0);
75}
76}
77};
78if ($) {
79var mobileMenusLoaded = false;
80function loadMobileMenu() {
81$('.idx-menu').each(function(){
82var o = $(this);
83$.get(tf.wm.url(o.data('deptid')+'.html','-',true),function(data){
84o.html(data.replace(/<img[^>]*?>/g,''));
85if(o.data('branchid')){
86$('> ul:first',o).replaceWith($('[id^=idx][id$='+o.data('branchid')+']',o).next('ul'));
87}
88o.find('.idx1List,.idx1,.idx2List,.idx2').removeClass('idx1List idx1 idx2List idx2');
89if(o.data('folding')!==false){
90o.find('li a').each(function(){
91$(this).parent().clone(true).prependTo($(this).next('ul')).find('ul,i').remove();
92if ($(this).next('ul').length > 0) {
93$(this)
94.attr('name',$(this).attr('href'))
95.click(function(event){
96event.preventDefault();
97event.stopPropagation();
98return true;
99})
100;
101}
102});
103}
104if(tf.isEntryPage){
105o.find('a[href]').not('a[href^=http]').each(function(){
106if(this.id.match(/D-2$/)) this.href=tf.wm.url((tf.lang==tf.baseLang?'../../':'../../'+tf.lang+'/')+this.href.replace(/.*\//,''),'-');
107else this.href=tf.wm.url(this.href.replace(/.*\//,''),'-',true);
108});
109}
110o.find('a[href]').each(function(){
111if(o.data('folding')!==false){
112if($(this).next('ul').get(0)) $(this).append('<i class="icon-arrow-down3"></i>');
113}
114});
115$('#Index1 #idx1D-2').parents('body').find('#idx2D-2', o).parent('li').remove();
116$('#Index2 #idx2D-2').parents('body').find('#idx1D-2', o).parent('li').remove();
117o.find('[class^=GC]').each(function(){this.className=this.className.replace(/GC\d+ ?/,'');});
118o.find('li a:has(i)').click(function(event){
119event.preventDefault();
120event.stopPropagation();
121if (!$(this).hasClass('active')){
122if (!$(this).parents('ul').prev().hasClass('active')) {
123$('li ul', o).slideUp('fast');
124$('li a', o).removeClass('active')
125;
126}
127$(this)
128.addClass('GC32 active').next().slideToggle('fast')
129.end()
130;
131}
132else {
133$(this)
134.removeClass('GC32 active').next().slideToggle('fast')
135.end()
136;
137}
138});
139o.find('li a').not(':has(i)')
140.removeClass('idx1 idx1Sub idx2 idx2Sub')
141.click(function(event){
142$.sidr('close','Sidemap');
143});
144o.find('[id$='+tf.pgid+']').addClass('selected').parents('ul').prev().find('i').click();
145mobileMenusLoaded = true;
146o.trigger('load');
147});
148});
149}
150$(document).ready(function(){
151$(document).on('keypress', 'input.prd_qty', function(e){
152if(e.which==13){
153e.preventDefault();
154e.stopPropagation();
155$(this).parents('.product').find('.calculate').click();
156}
157});
158$('.ProductQuantity > input[id*=_Quantity]').on('keypress', function(e){
159if(e.which==13){
160e.preventDefault();
161e.stopPropagation();
162$(this).parents('.Product').find('.AddToBasketButton,.AddToBasketButton > *').click();
163}
164});
165function applysidr() {
166if(!$('#sidemap-button').sidr) {setTimeout(applysidr,100); return;}
167$('#sidemap-button').sidr({ name:'Sidemap', displace:false,
168onOpen:function() {
169if (mobileMenusLoaded) $('.idx-menu').trigger('load'); else loadMobileMenu();
170$('html').css('overflow-x','');
171},
172onOpenEnd:function() {
173mobile_fallbackColours();
174}
175});
176}
177applysidr();
178$('#sidemap-button').click(function(e){
179e.preventDefault();
180e.stopPropagation();
181$('#Sidemap').css('visibility','visible').animate({'left':'0'});
182$.sidr('open', 'Sidemap');
183});
184$('#sidemap-close').click(function(e){
185e.preventDefault();
186e.stopPropagation();
187$.sidr('close','Sidemap');
188return false;
189});
190function mobile_fallbackColours(){
191$('.header.mobile,.footer.mobile,#Sidemap').each(function(){
192var GC=this.className.replace(/.*(GC\d+).*/,'$1');
193if($(this).css('background-color')=='transparent'||$(this).css('background-color')=='rgba(0, 0, 0, 0)'){
194$(this).css('background-color',tf.autoText.lightText);
195}
196if($(this).css('color')==$(this).css('background-color')||typeof(tf.autoText.GCUsesAutoText[GC])=='undefined'){
197$(this).add('*',this).css('color',tf.autoText.isColorDark(tf.content.document,this)?tf.autoText.lightText:tf.autoText.darkText);
198}
199});
200}
201mobile_fallbackColours();
202$('#gototop-button').click(function(e){
203e.preventDefault();
204tf.content.document.body.scrollTop = 0;
205tf.content.document.documentElement.scrollTop = 0;
206return false;
207});
208showMobileUtils = function(){
209$(window).scroll(function(){
210if ($(window).scrollTop() >= 50) {
211$('.utils.group').addClass('fixed-header');
212$('.utils.group').addClass('visible-title');
213}
214else {
215$('.utils.group').removeClass('fixed-header');
216$('.utils.group').removeClass('visible-title');
217}
218});
219};
220retractMobileUtils = function() {
221if ($('.header.mobile:visible').length == 0) return;
222if ($('#mobile_search input:focus').length > 0) return;
223if ($(tf.content).height() >= $(tf.content.document).height()) return;
224if (($(tf.content).scrollTop() == 0) || ($(tf.content).scrollTop() + $(tf.content).height() >= $(tf.content.document).height() - $('.footer.mobile:visible').height())) {
225$('html').css({'margin-top':0, 'margin-bottom':0});
226}
227$('.header.mobile:visible').css({top:-($('.header.mobile:visible').height())}, 'fast', 'swing', function(){$(tf.content).bind('scroll', showMobileUtils)});
228$('.footer.mobile:visible').css({bottom:-($('.footer.mobile:visible').height())}, 'fast');
229$(tf.content).data({'mobile-utils-scrolltop':$(tf.content).scrollTop()});
230}
231$(tf.content).data({'mobile-utils-scrolltop':$(tf.content).scrollTop()}).bind({'scroll resize':showMobileUtils});
232$('#sidemap-close').click(showMobileUtils);
233if(!tf.isInSF()&&!tf.SF_disableYT) {
234$('iframe[sf_ytsrc]').each(function(){
235var src=$(this).attr('sf_ytsrc');
236$(this).removeAttr('sf_ytsrc').attr('src',src);
237});
238}
239});
240}
241var tmplParser = {
242parse:function(tmplName, vars) {
243var el=(typeof(tmplName)=='string'?tf.extra.document.getElementById(tmplName):tmplName);
244if(!el)return false;
245var result=el.innerHTML.replace('<!--','').replace('-->','').replace('<![CDATA[','').replace(']]>','');
246if(vars){
247for(var param in vars){
248var reg=eval('/__'+param+'__(?:="")?/gi'),val=new String(vars[param]);
249result=result.replace(reg, val.replace(/\$/g,'&#36;'));
250}
251}
252var reg = /__(LD_.+?)__/g;
253result = result.replace(reg,
254function($0, $1) {
255var str = eval('tf.'+$1);
256if (str) return str;
257else return $1;
258}
259);
260return result;
261}
262};
263var sfMediaBox={
264closeBox:function(redirectTo){
265this.unrender('sfLightBox');
266this.unrender('sfLightBoxOverlay');
267this.showDropDowns(true);
268tfc.document.body.style.overflow='';
269tfc.document.documentElement.style.overflow='';
270tfcd.body.className=tfcd.body.className.replace(' mobileBox','');
271tf.delEvent('onkeydown',this.keyHandler,tfcd.body);
272tf.delEvent('onresize',this.centerBox);
273if(this.fnAfterClose)this.fnAfterClose();
274if(typeof redirectTo === "string") {
275tf.wm.rld(tf.content,redirectTo,'-',1);
276}
277},
278centerBox:function(o,custW,custH){
279var meme=tf.utils.sfMediaBox;
280if(custW)meme.cacheW=custW;
281if(custH)meme.cacheH=custH;
282var w=tf.innerWidth,h=tf.innerHeight;
283var elLB=gl('sfLightBox');
284if(elLB){
285if(tf.isMobile_SmallLandscape||tf.isMobile_SmallPortrait||tf.isMobile_Small||tf.isMobile_LargePortrait){
286if(tfcd.body.className.indexOf('mobileBox')==-1)tfcd.body.className+=' mobileBox';
287elLB.style.marginLeft=(-w/2)+'px';
288elLB.style.marginTop=(-h/2)+'px';
289w-=(parseInt(elLB.style.paddingLeft)+parseInt(elLB.style.paddingRight));
290h-=(parseInt(elLB.style.paddingTop)+parseInt(elLB.style.paddingBottom));
291if(meme.useOffsetTop)h-=24;
292}
293else{
294tfcd.body.className=tfcd.body.className.replace(' mobileBox','');
295var rc=elLB.getBoundingClientRect(),rc2=gl('sfLightBoxTopBar').getBoundingClientRect();
296var padh=(parseInt(elLB.style.paddingTop)+parseInt(elLB.style.paddingBottom));
297w=meme.getVirtualWidth(meme.cacheW);
298h=meme.getVirtualHeight(meme.cacheH);
299var sflbc=gl('sfLightBoxContents');
300sflbc.style.overflowX='';
301sflbc.style.overflowY='';
302if(rc2.width>0&&rc2.height>0){
303if(meme.cacheH<=(rc.height-rc2.height-((rc2.top-rc.top)*2))) {
304if(meme.cacheH>=sflbc.scrollHeight)sflbc.style.overflowY='hidden';
305}
306else w+=22;
307if(meme.cacheW<=rc2.width){}// sflbc.style.overflowX='hidden';
308else h+=22;
309}
310elLB.style.marginLeft=(-w/2)+'px';
311elLB.style.marginTop=((-(h+(rc2.bottom-rc2.top)+padh))/2)+'px';
312}
313var IDs={'sfLightBoxBody':[w+'px',null],'sfLightBoxContents':[w+'px',h+'px'],'sfLightBoxLoading':[w+'px',h+'px'],'sfPopupFrame':[w+'px',h+'px']};
314for(var n in IDs){
315var el=gl(n);
316if(el){
317if(IDs[n][0]!=null)el.style.width=IDs[n][0];
318if(IDs[n][1]!=null)el.style.height=IDs[n][1];
319}
320}
321IDs=['sfLightBoxNavLeft','sfLightBoxNavRight'];
322for(var n=0;n<IDs.length;n++){
323var el=gl(IDs[n]);
324if(el){
325el.style.height=h+'px';
326}
327}
328}
329},
330hide:function(id){ if(gl(id))gl(id).style.display='none'; },
331show:function(id){ if(gl(id))gl(id).style.display='block'; },
332showDropDowns:function(show){
333function looper(a,show){
334for(var i=0,num=a.length;i<num;i++){
335a[i].style.visibility=(show?'visible':'hidden');
336}
337}
338if(tf.isIE6)looper(tfcd.getElementsByTagName('SELECT'),show);
339looper(tfcd.getElementsByTagName('OBJECT'),show);
340looper(tfcd.getElementsByTagName('EMBED'),show);
341looper(tfcd.getElementsByTagName('IFRAME'),show);
342},
343content_onload:function(o){
344var $el2=$(o).parents('#sfLightBoxContents'),oi1=o.getAttribute('index'),oi2=$el2.attr('index');
345if(oi1!=oi2)return;
346if(o.width==0||o.height==0)return;
347$el2.parent().find('#sfLightBoxLoading').hide();
348},
349render:function(o,a,isMM){
350var el=tfcd.createElement('div');
351el.innerHTML=(typeof(a)=='function'?a(o):a);
352for(var i=0,num=el.childNodes.length;i<num;i++){
353if(tf.isIE&&!el.childNodes[0].style){el.removeChild(el.childNodes[0]);continue;}
354if(tf.isIE&&isMM)el.childNodes[0].style.visibility='hidden';
355var elNew=o.tfcdb().appendChild(el.childNodes[0]);
356if(tf.isIE6&&elNew.currentStyle.position=='fixed')elNew.style.position='absolute';
357if(tf.isIE&&isMM)setTimeout(function(){elNew.style.visibility='visible';},20);
358}
359},
360unrender:function(id){ var el=gl(id); if(el)el.parentNode.removeChild(el); },
361scale:function(mW, mH, cW, cH){
362if(cW<mW&&cH<mH)return[cW,cH];
363var r=cH/cW,cx=mW,cy=parseInt((mW*r)+0.5);
364if(cy>mH){ r=cW/cH; cx=parseInt((mH*r)+0.5); cy=mH; }
365return [cx,cy];
366},
367getVirtualWidth:function(w){ return Math.max(100,Math.min(w,tf.innerWidth * 0.9)); },
368getVirtualHeight:function(h){ return Math.max(100,Math.min(h,tf.innerHeight * 0.85)) + 5; },
369mw:-1,
370mh:-1,
371useOffsetTop:true,
372useLargestSize:true,
373gl:function(s){try{return tf.extra.document.getElementById(s);}catch(e){return null;}},
374fnAfterClose:null,
375tfcdb:function(){return (tf.isSafari?tfcd.documentElement:tfcd.body);},
376relPrefix:(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../'),
377close_onclick:'tf.utils.sfMediaBox.closeBox();return false;',
378prevnext_onmouseover:function(el,dir){
379el.style.backgroundImage='url('+(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../')+'media/mediabox_large_'+dir+'.png)';
380},
381prevnext_onmouseout:function(el){
382el.style.backgroundImage='url('+(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../')+'media/trans.gif)';
383},
384aHTML:[
385function(o){ return tmplParser.parse(o.gl('tmplSFLightBoxOverlay'), { height:'100%', close_onclick:o.close_onclick, className:'', contents:'' }); },
386function(o){ return tmplParser.parse(o.gl('tmplSFLightBox'), o.data); }
387],
388aRef:[],
389aPrefetch:[],
390hasTitle:false,
391hasDescription:false,
392currIdx:-1,
393onMobile:tf.isMobile,
394cacheW:-1,
395cacheH:-1,
396useFlickity:true,
397keyHandler:function(evt){
398var me=tf.utils.sfMediaBox;
399switch(evt.keyCode){
400case 27: me.closeBox(); break;
401case 37: me.showContents(me.currIdx==0?me.aRef.length-1:me.currIdx-1); break;
402case 39: me.showContents(me.currIdx==me.aRef.length-1?0:me.currIdx+1); break;
403}
404},
405init:function(names,jumptoid){
406this.closeBox();
407this.fnAfterClose=null;
408this.aRef=[];
409this.aPrefetch=[];
410this.mw=this.mh=-1;
411var a=tfcd.querySelectorAll('a[rel^=sfMediaBox]'),jumptoidx=0;
412for(var m=0,mm=names.length;m<mm;m++){
413for(var n in a){
414if(a[n].rel=='sfMediaBox['+names[m]+']'&&(a[n].href||a[n].getAttribute('src'))!=unescape(tf.wm.host)){
415this.aRef.push(a[n]);
416if(a[n].title)this.hasTitle=true;
417if(a[n].getAttribute('description'))this.hasDescription=true;
418if(a[n].id==jumptoid)jumptoidx=this.aRef.length-1;
419if(this.useLargestSize){
420var mw=parseInt(a[n].getAttribute('mw')),mh=parseInt(a[n].getAttribute('mh'));
421if(mw>this.mw)this.mw=mw;
422if(mh>this.mh)this.mh=mh;
423}
424}
425}
426}
427if(this.aRef.length>0 && this.aRef[0].mediaType!='MM'){
428this.render(this, this.aHTML[0]);
429var me=this;
430this.aPrefetch[jumptoidx]=new Image();
431this.aPrefetch[jumptoidx].onload=function(){
432this.loaded=true;
433if(me.aRef.length==1){
434me.showContents(jumptoidx);
435tf.addEvent('onkeydown',me.keyHandler,tfcd.body);
436}
437if(!me.useFlickity){
438for(var n=0,nn=me.aRef.length;n<nn;n++){
439if(!me.aPrefetch[n]){
440var img=new Image();
441img.loaded=false;
442img.onload=function(){this.loaded=true;}
443img.src=me.aRef[n].href||me.aRef[n].getAttribute('src');
444me.aPrefetch[n]=img;
445}
446}
447}
448}
449this.aPrefetch[jumptoidx].src=this.aRef[jumptoidx].href||this.aRef[jumptoidx].getAttribute('src');
450if(me.aRef.length>1){
451this.showContents(jumptoidx);
452tf.addEvent('onkeydown',this.keyHandler,tfcd.body);
453}
454}
455},
456showContents:function(n){
457this.currIdx=n;
458var el=gl('sfLightBox');if(el)el.parentNode.removeChild(el);
459var o=this.aPrefetch[n],oo=this.aRef[n];
460if(!o){this.aPrefetch[0].onload();o=this.aPrefetch[n];}
461var type=oo.getAttribute('mediaType'),isMM=(type=='MM'),isHTML=(type=='HTML'),w=o.width,h=o.height;
462if(isMM){w=oo.getAttribute('mw');h=oo.getAttribute('mh');}
463if(this.useLargestSize&&this.mw>-1&&this.mh>-1){w=this.mw;h=this.mh;}
464var vw=this.getVirtualWidth(w), vh=this.getVirtualHeight(h);
465this.cacheW=w;this.cacheH=h;
466this.useOffsetTop=true;
467this.data={
468navdisplay:(this.aRef.length>1?'block':'none'), captiondisplay:oo.title||oo.getAttribute('description')?'block':'none', relprefix:this.relPrefix,
469close_onclick:this.close_onclick,
470prev_visible:(this.aRef.length==1?'hidden':'visible'), next_visible:(this.aRef.length==1?'hidden':'visible'),
471count:this.aRef.length, index:n+1,
472prev_onclick:'tf.utils.sfMediaBox.showContents('+(n==0?this.aRef.length-1:n-1)+');return false;',
473next_onclick:'tf.utils.sfMediaBox.showContents('+(n==this.aRef.length-1?0:n+1)+');return false;',
474prev_onmouseover:'tf.utils.sfMediaBox.prevnext_onmouseover(this,\'left\');',
475prev_onmouseout:'tf.utils.sfMediaBox.prevnext_onmouseout(this);',
476next_onmouseover:'tf.utils.sfMediaBox.prevnext_onmouseover(this,\'right\');',
477next_onmouseout:'tf.utils.sfMediaBox.prevnext_onmouseout(this);',
478width:vw+'px', height:vh+'px',
479overflow:'auto',
480title:(oo.title?oo.title:(this.hasTitle?'&nbsp;':'')), description:(oo.getAttribute('description')?oo.getAttribute('description'):(this.hasDescription?'&nbsp;':'')),
481loadingdisplay:(o.loaded||isMM||isHTML?'none':'block'),loadingmessage:'',
482position:'fixed',
483marginleft:(-vw/2+this.tfcdb().scrollLeft)+'px', margintop:(-vh/2+this.tfcdb().scrollTop)+'px',
484decorationborder:'5px',
485className:'',
486imagecontrols:'',
487contents:''
488};
489if(this.useFlickity){
490for(var i=0;i<this.aRef.length;i++){
491var _o=this.aPrefetch[i],_oo=this.aRef[i];
492var type=_oo.getAttribute('mediaType'),isMM=(type=='MM'),isHTML=(type=='HTML'),w=0,h=0;
493if(!_o){
494var img=null;
495if(!isMM&&!isHTML){
496img=new Image();
497img.loaded=false;
498img.onload=function(){this.loaded=true;}
499img.src=this.aRef[i].href||this.aRef[i].getAttribute('src');
500}
501this.aPrefetch[i]=img;
502if(this.aPrefetch[i])this.aPrefetch[i].onload();
503_o=this.aPrefetch[i];
504}
505if(!isMM&&!isHTML){w=_o.width;h=_o.height;}
506if(isMM){w=_oo.getAttribute('mw');h=_oo.getAttribute('mh');}
507this.data['captiondisplay']=_oo.title||_oo.getAttribute('description')?'block':'none';
508this.data['title']=(_oo.title?_oo.title:(this.hasTitle?'&nbsp;':''));
509this.data['description']=(_oo.getAttribute('description')?_oo.getAttribute('description'):(this.hasDescription?'&nbsp;':''));
510this.data['loadingdisplay']=(isMM||isHTML||_o.loaded?'none':'block');
511this.data['contents']+=tmplParser.parse(this.gl('tmplSFLightBoxFlickityItem'),
512{
513code:(isMM?this.getMMHTML(_oo.id,_oo.href||_oo.getAttribute('src'),_oo.getAttribute('filetype'),w,h,_oo.title):
514(isHTML
515?this.getMMHTMLUsingExtraction(_oo.id,unescapeUTF8(_oo.getAttribute('href')),vw,vh)
516:'<img src="'+_o.src+'" class="slide-item" '+(vw<w?'width="100%"':'')+' index="'+(i+1)+'" border="0" onload="'+(_o.loaded?'':'tf.utils.sfMediaBox.content_onload(this);')+'" />'
517)
518),
519title:this.data['title'],
520description:this.data['description']
521}
522);
523}
524this.data['title']='';
525this.data['description']='';
526this.data['contents']=tmplParser.parse(this.gl('tmplSFLightBoxFlickity'), this.data);
527}
528else{
529this.data['contents']=(isMM?
530this.getMMHTML(oo.id,oo.href||oo.getAttribute('src'),oo.getAttribute('filetype'),w,h,oo.title):
531(isHTML?
532this.getMMHTMLUsingExtraction(oo.id,oo.href,vw,vh):
533tmplParser.parse(this.gl('tmplSFLightBoxImage'),
534{ wh:'height:'+vh+'px;', src:o.src, wide:(vw<w)?'width="100%"' : '', index:n+1, onload:(o.loaded?'':'tf.utils.sfMediaBox.content_onload(this);') }
535)
536)
537);
538this.data['imagecontrols']=tmplParser.parse(this.gl('tmplSFLightBoxImageControls'), this.data);
539}
540this.showDropDowns(false);
541this.render(this, this.aHTML[1], isMM);
542this.centerBox();
543tf.$(tfc).on('resize',this.centerBox);
544tfc.document.body.style.overflow='hidden';
545if(this.useFlickity){
546var $=tf.$;
547var $lightBoxCarousel = $('.LightBoxCarousel .gallery-box').flickity({
548wrapAround: true,
549autoPlay: false,
550draggable: true,
551freeScroll: false,
552setGallerySize: false,
553prevNextButtons: true,
554pageDots: true
555});
556$lightBoxCarousel
557.flickity('resize')
558.on('cellSelect', function() {
559$lightBoxCarousel.flickity('bindDrag');
560var flkty = $(this).data('flickity');
561$('#sfLightBoxBottomBar .title').html($('.title', flkty.selectedElement).html());
562$('#sfLightBoxBottomBar .description').html($('.introduction', flkty.selectedElement).html());
563$('object,embed',flkty.selectedElement).each(function(){
564var w=$(this).attr('width'),h=$(this).attr('height');
565if(w&&h){
566var ratio=h/w;
567w=$(this).parents('.box').width();
568h=w*ratio;
569$(this).attr({'width':w,'height':h});
570}
571});
572})
573.flickity('select',n,true,true)
574;
575$('#sfLightBoxContents,#sfLightBoxContents > div:last-child').css('overflow','');
576$(tfc).on('resize',function(){
577var $coll=$lightBoxCarousel.add($('.box',$lightBoxCarousel)).add($('#sfLightBoxContents'));
578if(tf.isMobile_SmallLandscape||tf.isMobile_SmallPortrait||tf.isMobile_Small||tf.isMobile_LargePortrait){
579$('#sfLightBox').attr('style',$('#sfLightBox').attr('style')+'height:100%!important;');
580$coll.height($('#sfLightBox').height()-$('#sfLightBoxTopBar').outerHeight(true)-$('#sfLightBoxBottomBar').outerHeight(true));
581}
582else{
583$('#sfLightBox').height('');
584$coll.height('');
585}
586}).trigger('resize');
587tfc.Flickity.prototype._dragPointerDown=function(event,pointer){
588this.pointerDownPoint=tfc.Unipointer.getPointerPoint(pointer);
589var isTouchstart = event.type == 'touchstart';
590var targetNodeName = event.target.nodeName;
591if ( !isTouchstart && targetNodeName != 'SELECT' && targetNodeName != 'OBJECT' && targetNodeName != 'EMBED') {
592event.preventDefault();
593}
594}
595}
596},
597getMMHTML:function(id,s,t,w,h,title){
598if((typeof(isInLL)=='undefined'||!isInLL)&&s.indexOf('http')!=0){if(s.indexOf('file:/')==0)s=unescape(s.replace(/^file:\/+/,'').replace(/\//g,'\\'));if(!tf.wm.online){s=tf.wm.url(unescape(s),'-');s=s.replace(/\\/g,'/').replace(/^(?:file:\/+)?(.*)$/,'file:///$1');}}
599var src=unescape(s);
600return sfMM([id,'',t,src,w,h,w,h,title]);
601},
602getMMHTMLUsingExtraction:function(id,s,mw,mh){
603var w=this.mw,h=this.mh,src='',html='';
604if(s.match(/width=['"](.*?)['"]/i))w=RegExp.$1;
605if(s.match(/height=['"](.*?)['"]/i))h=RegExp.$1;
606var dim=this.scale(mw,mh,w,h);
607w=dim[0];h=dim[1];
608html=s.replace(/ width="(.*?)"/,' width="'+w+'"').replace(/ height="(.*?)"/,' height="'+h+'"');
609return html;
610}
611}
612function populatePrice(arr,idx){
613var a=arr||tfc.ppriceArr;if(!a||!tf.core.region){setTimeout('tf.utils.populatePrice()',1000);return;}
614$(tfc).trigger('_sfEvt_PopulatePrice_Begin');
615for(var i=0,l=a.length;i<l;i++){
616if(typeof(idx)!='undefined'&&a[i][0]!=idx)continue;
617var p=tf.wm.pProp(a[i][0]);
618if(!p)continue;
619var el=gl('ProductPrice-'+a[i][0]);
620if($('input[name=ProductPriceLayout]').length>0){tf.core.ppriceTemplateLayout(el,a[i]);$('.ShippingChargeForProduct',el).html($('.ShippingChargeForProduct',el).html());}
621else if(el||a[i][1]!=''){var s=tf.core.pprice(el,a[i]);if(el&&s)el.innerHTML=s;}
622if(p['optWeight']){
623el=gl('ProductWeightFormatted-'+a[i][0]);
624var wgt=(p['optWeight']+parseFloat(p[10])).toString();
625if(el)el.innerHTML=core.nfmt.display(wgt,3,'');
626}
627el=gl('Product-'+a[i][0]);
628}
629if(tf.content.pgid.indexOf('P')==0)populateCrossPromotionPrice();
630else {
631if(tfc.equalHeight)tfc.equalHeight();
632if($) {$(tf.content.document).trigger('domChanged');}
633}
634$(tfc).trigger('_sfEvt_PopulatePrice_End');
635}
636function populateCrossPromotionPrice(arr,idx){
637var a=arr||tfc.ppriceCrossPromotionArr;if(!a||!tf.core.region){setTimeout('tf.utils.populateCrossPromotionPrice()',1000);return;}
638var changed=false;
639for(var i=0,l=a.length;i<l;i++){
640if(typeof(idx)!='undefined'&&a[i][0]!=idx)continue;
641if(!tf.wm.pProp(a[i][0]))continue;
642var el=gl('ProductCrossPromotionPrice-'+a[i][0]);
643if(el&&tf.wm.pProp(a[i][0])){
644if($('input[name=ProductPriceLayout]').length>0) {
645tf.core.ppriceTemplateLayout(el,a[i],'CrossPromotion');
646$('.ShippingChargeForProduct',$(el).parent()).each(function(){
647$(this).html($('.Product .ShippingChargeForProduct').filter(function(){return $(this).parents('.ProductCrossPromotion').length==0;}).html().replace('add_'+tf.pgid,'add_'+a[i][0]));
648});
649changed = true;
650}
651else{
652var s=tf.core.pprice(el,a[i],'CrossPromotion');
653if(s){if(s!=el.innerHTML)changed=true;el.innerHTML=s;}
654}
655el=gl('ProductCrossPromotion-'+a[i][0]);
656}
657}
658a=tfc.bpriceCrossPromotionArr;
659if(a&&a.length){
660for(var i=0,l=a.length;i<l;i++){
661if(typeof(idx)!='undefined'&&a[i][0]!=idx)continue;
662var p=tf.wm.pProp(a[i][0]);
663if(!p)continue;
664var el=gl('ProductCrossPromotionBasePrice-'+a[i][0]);
665if(el){
666if(!a[i][3]){a[i][1]=p[18];a[i][2]=p[19];a[i][3]=p[20];}
667if(a[i][3]){
668var s=core.bprice(a[i]);
669if(s!=el.innerHTML)changed=true;
670el.innerHTML=s;
671}
672else el.style.display='none';
673}
674}
675}
676if(changed) {
677if(tf.content.equalHeight)tf.content.equalHeight();
678if($) {$(tf.content.document).trigger('domChanged');}
679}
680}
681function populatedata(){
682tfc.specialLoading=true;
683if(wx&&typeof(wx.getPageID)=='function'&&(wx.getPageID()=='D-34'||wx.getPageID()=='D-33'))return;
684$(tfc).trigger('_sfEvt_PopulateData_Begin');
685if(!tf.conf){tf.load('conf.html','conf',true);}
686core=tf.core;
687if(!tfc.ppriceArr||!tf.bskLoaded||!tf.conf||!core||!core.confLoaded||!tf.coreLoaded||!core.tsI||!tf.core.BTax){setTimeout('populatedata()',50);return;}
688if(tfc.timedDiscountsExist&&(!window.SFOrderForm||!window.SFOrderForm.verifying)){tf.core.active_servers=[];tf.core.ping.go(false);tf.core.currTime.getTime();}
689populatePrice();
690a=tfc.weightArr;for(var i=0,l=a.length;i<l;i++){var s=a[i][1].toString(),el=gl('ProductWeightFormatted-'+a[i][0]);if(el)el.innerHTML=core.nfmt.display(s,s.length-s.indexOf('.')-1,'');}
691a=tfc.bpriceArr;for(var i=0,l=a.length;i<l;i++){var el=gl('ProductBasePrice-'+a[i][0]);if(el)el.innerHTML=core.bprice(a[i]);}
692populateOpt();
693if(tf.core.loadPricesForIDs&&tfc.ppriceCrossPromotionArr)tf.core.loadPricesForIDs(tfc.ppriceCrossPromotionArr);
694tfc.specialLoading=false;
695displayProductQuantityDiscounts();
696$(tfc).trigger('_sfEvt_PopulateData_End');
697}
698function populateOpt(origA, idx, optid) {
699$(tfc).trigger('_sfEvt_PopulateOpt_Begin');
700var a = tfc.crFFldArr || [], origa = origA || tf.wm._pArr, optHTML = { length : 0 };
701for (var i = 0, l = a.length; i < l; i++) {
702var choicesOnly= typeof(optid) != 'undefined', id = a[i][8];
703if(typeof(idx) != 'undefined' && id != idx)
704continue;
705if (typeof(optid) != 'undefined' && a[i][2] != optid)
706continue;
707if (!tf.wm.pProp(id))
708continue;
709if (!optHTML[id]) {
710optHTML[id] = '';
711optHTML.length++;
712}
713optHTML[id] += tf.core.crFFld(a[i], origa[id]);
714}
715for (var i in optHTML) {
716var el = gl(choicesOnly ? ('ProductOptionInner-' + optid) : ('ProductOptions-' + i));
717if (el) {
718var lock=(!choicesOnly && !$(el).data('initialised'));
719el.innerHTML = optHTML[i];
720if (lock) {
721$(el).find('.locker').remove().end().css('position','relative').append(_
721sfEvt_htmlLocker.replace(/title=""/g,'title="'+((LD&&LD.LD_LOADING)||'').replace(/"/g,'&quot;')+'"'));
722var removeLocker = debounce2(function(){
723$('.ProductOptions').data('initialised',true).find('.locker').remove();
724$('.ProductIcons').find('.locker').remove();
725}, 2000);
726$(tfc).off('_sfEvt_PopulateOpt.locker').on('_sfEvt_PopulateOpt.locker', removeLocker);
727}
728}
729}
730$(tfc).off('_sfEvt_PopulateOpt.hash').on('_sfEvt_PopulateOpt.hash', function(){
731if(location.hash)location.hash=location.hash;
732});
733function fnEqualWidth() {
734tf.equalWidth('.ProductOptionInner[data-option-type=radio], .ProductOptionInner[data-option-type=checkbox]', '.ProductChoiceName', 185, 5, true);
735if(tf.equalHeight)tf.equalHeight();
736}
737var fnPopulateOpt=tfc['fnPopulateOpt']||fnEqualWidth;
738fnPopulateOpt();
739$(tfc).off('resize.populateOpt imageLoaded.populateOpt');
740$(tfc).on('resize.populateOpt imageLoaded.populateOpt', function() {
741setTimeout(function(){fnPopulateOpt();},20);
742});
743$(tfc).trigger('_sfEvt_PopulateOpt');
744$(tfc).trigger('_sfEvt_PopulateOpt_End');
745setTimeout(displaySelectedOpt, 20);
746}
747var _sfEvt_htmlLocker='<div class="locker" style="position:absolute;overflow:hidden;left:0;right:0;top:0;bottom:0;width:100%;height:100%;background-color:#ffffff;opacity:.5;z-index:1;" title=""></div><progress class="locker" style="height:5px;top:0;width:100%;position:absolute;left:0;right:0;z-index:1;"></progress>';
748if ($) {
749$(function () {
750$('.ProductIcons').each(function () {
751productIconsLocker($(this).attr('id').replace('ProductIcons-', ''));
752});
753});
754}
755function displaySelectedOpt(){
756var tfc=tf.content,core=tf.core;
757if(typeof(tfc.pgid)=='undefined'||tfc.pgid.substr(0,1)!='P')return;
758var el=gl('ProductSelectedOptions-'+tf.pgid);
759if(!el||!tf.wm.pProp(tf.pgid))return;
760var s='',itm=core.Basket.createTemp(tfc.pgid,tfc.document,tfc.opt,1,'','','','','',tfc.ppriceArr[0][2],'',false,true);
761if (typeof(itm)!='object'||!itm){
762el.innerHTML='';
763return;
764}
765var opt=itm.options.start();
766while (opt!=null) {
767if (opt.choice()!=='') {
768s+='<div class="ProductSelectedOptionsItem"><div class="ProductSelectedOptionsName">'+opt.title+':</div>'+opt.choice()+'</div>';
769}
770opt=itm.options.next();
771}
772if(s){
773s='<div class="ProductSelectedOptions"><div class="ProductSelectedOptionsHead">'+tf.LD.LD_SELECTEDOPTIONS+'</div><div class="ProductSelectedOptionsBody">'+s+'</div></div>';
774el.innerHTML=s;
775}
776}
777function displayProductQuantityDiscounts(prid){
778var tfc=tf.content, core=tf.core;
779if(prid)displayProductQuantityDiscountsWorker(prid);
780else if(typeof tfc._sfProductsInPage!='undefined'){
781for(var n=0,nn=tfc._sfProductsInPage.length;n<nn;n++){
782displayProductQuantityDiscountsWorker(tfc._sfProductsInPage[n]);
783}
784}
785}
786function displayProductQuantityDiscountsWorker(prid){
787var elPQD = gl('ProductQuantityDiscounts-'+prid);
788if(!elPQD)return;
789var tfc=tf.content, core=tf.core;
790if(!tf.core||!tf.wm.pProp(prid)||tfc.specialLoading){setTimeout(function(){tf.utils.displayProductQuantityDiscountsWorker(prid);},100);return;}
791var bsk=core.Basket, outstr='', bskqnty=1, p=tf.wm.pProp(prid);
792bsk.disc.eAdd(prid,[p[5], p[6], p[7]]);
793var disc=bsk.disc.get(prid),ranges=disc.rg.cnt(),qtyUnit=p[22];
794var itm=bsk.createTemp(prid,tfc.document,tfc.opt,1,'','','','','',tfc.ppriceArr[0][2],'',false);
795if (typeof(itm) != 'object' || !itm){
796elPQD.innerHTML = '';
797return;
798}
799for (var n=0;n<ranges;n++){
800var range=disc.getNextRange(bskqnty), nmin=parseFloat(range.min);
801if(nmin==0) continue;
802if(typeof(range)=='object'){
803if (disc.getData(nmin)) {
804outstr+='<div class="ProductQuantityDiscountsRange" id="ProductQuantityDiscountsRange-'+prid+'R'+range.idtag+'">';
805itm.quantity=nmin;
806var atagB = '<div>', atagE = '</div><div><div class="GC14 sf-button"><a href="#" onclick="if(isInSF())return;cancelBuble(event);var elQty=tf.content.document.getElementById(\''+prid+'_Quantity\');elQty.value=\''+nmin+'\';sfAddPop();if(add_'+prid+'()!=0){sfAddUnpop();}return false;">'+LD.LD_OK+'</a></div></div>';
807switch (disc.type.toString()) {
808case '4': case '5':
809var adprice=itm.calc('pur',null,0)/nmin;
810var a=[nmin,qtyUnit,'<strong>'+core.showPrc(adprice)+'</strong>',qtyUnit];
811outstr+=atagB;
812outstr+=(tf.content.ld('LD_BUY_FOR','',a)).replace(/\s+\.$/, '.');
813outstr+=atagE;
814break;
815case '2': if (!bsk.fbsk.checkBasket(tf.pgid)) {
816var a=[nmin,qtyUnit,disc.getData(nmin),qtyUnit];
817outstr+=atagB;
818outstr+=(bskqnty>0)?tf.content.ld('LD_BUY_MORE_AND_GET_FREE','',a):tf.content.ld('LD_BUY_AND_GET_FREE','',a);
819outstr+=atagE;
820}
821break;
822case '3': if (!bsk.fbsk.checkBasket(tf.pgid)) {
823var a=[nmin,qtyUnit,bsk.fbsk.getTitles(disc.getData(nmin))];
824outstr+=atagB;
825outstr+=(bskqnty>0)?tf.content.ld('LD_BUY_MORE_AND_GET_FREE','',a):tf.content.ld('LD_BUY_AND_GET_FREE','',a);
826outstr+=atagE;
827}
828break;
829}
830outstr+='</div>';
831}
832bskqnty=parseFloat(range.min);
833}
834}
835elPQD.innerHTML=outstr;
836}
837function sfMM(a){
838var wm, id=a[0],lmd=a[1],t=a[2],src=a[3],w=parseInt(a[4]),h=parseInt(a[5]),mw=parseInt(a[6]),mh=parseInt(a[7]),alt=a[8];
839if(src.toLowerCase().lastIndexOf(t)==src.length-t.length){
840if(typeof(isInLL)=='undefined'||!isInLL){src=tf.wm.url(src,'-');src=src.replace(/\\/g,'/');if(!tf.wm.online)src=src.replace(/^(file:\/\/)?(.*)$/,'file://$2');}
841src=unescape(src); w=(w>0?w:mw); h=(h>0?h:mh);
842var dim=' width="'+w+'" height="'+h+'"',s='';
843switch(t){
844case 'mp4': case 'webm':case 'ogg':
845s+='<video controls><source src="'+src+'" type="audio/'+t+'"></video>';
846break;
847case 'mp3': case 'wav':case 'ogg':
848s+='<audio controls><source src="'+src+'" type="audio/'+t+'"></audio>';
849break;
850case 'mov': case 'avi': case 'mpg':
851s+='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="//www.apple.com/qtactivex/qtplugin.cab" '+dim+' title="'+alt+'"> <param name="src" value="'+src+'" /> <param name="autoplay" value="false" /> <param name="controller" value="true" /> <param name="scale" value="aspect" /> <param name="wmode" value="opaque" /> <embed type="video/mpeg" src="'+src+'" '+dim+' title="'+alt+'" autoplay="false" scale="aspect" controller="true" wmode="opaque" pluginspage="//www.apple.com/quicktime/download/" /> </object>';
852break;
853case 'wmv':
854s+='<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" type="video/x-ms-wmv" '+dim+' title="'+alt+'"> <param name="URL" value="'+src+'" /> <param name="AutoStart" value="false" /> <param name="ShowTracker" value="true" /> <param name="ShowControls" value="true" /> <param name="ShowGotoBar" value="false" /> <param name="ShowDisplay" value="false" /> <param name="ShowStatusBar" value="false" /> <param name="AutoSize" value="false" /> <param name="StretchToFit" value="true" /> <param name="wmode" value="transparent" /> <object type="application/x-ms-wmp" '+dim+' title="'+alt+'"> <param name="URL" value="'+src+'" /> <param name="AutoStart" value="true" /> <param name="ShowTracker" value="true" /> <param name="ShowControls" value="true" /> <param name="ShowGotoBar" value="false" /> <param name="ShowDisplay" value="false" /> <param name="ShowStatusBar" value="false" /> <param name="AutoSize" value="false" /> <param name="StretchToFit" value="true" /> <param name="wmode" value="transparent" /> <a></a><!--IE workaround--> </object></object>';
855break;
856case 'swf':
857s+='<object classid="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '+dim+' title="'+alt+'">	<param name="movie" value="'+src+'" /> <param name="src" value="'+src+'" /> <param name="wmode" value="opaque" /> <param name="menu" value="false" /> <embed src="'+src+'" '+dim+' title="'+alt+'"  type="application/x-shockwave-flash" wmode="opaque" pluginspage="//www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" menu="false" /> </object>';
858break;
859default:
860s+='<embed src="'+src+'" quality="high" '+dim+' title="'+alt+'"></embed>';
861}
862}
863return s;
864}
865function sfMMDraw(){var a=tfc.aMM;if(a){for(var i=0,num=a.length;i<num;i++){if(a[i]){var aa=a[i],el=gl(aa[0]);if(el){if(tf.isIE)el.style.visibility='hidden';el.innerHTML=sfMediaBox.getMMHTML(aa[0],aa[3],aa[2],aa[4],aa[5],aa[8]);a[i]=null;if(tf.isIE)setTimeout('gl("'+aa[0]+'").style.visibility="visible"',20);}}}}}
866function rmvwmode(){
867var d=tfc.document,a=d.embeds;
868for(var i=0,ii=a.length;i<ii;i++){ if (a[i].id.indexOf('DSObject_') == 0)a[i].setAttribute('wmode','window'); }
869var els = d.getElementsByTagName('object'),obj = [];
870for(var i = 0; i < els.length; i++){ if (els[i].getElementsByTagName('param').length==0)continue; obj.push(els[i]); }
871for(var i = 0; i < obj.length; i++){
872var html = obj[i].outerHTML;
873var wrapper = d.createElement('div');
874obj[i].parentNode.appendChild(wrapper);
875obj[i].parentNode.removeChild(obj[i]);
876wrapper.innerHTML = html.replace(/<param name="wmode" value="[^"]*?"[^>]*?>/gi,'<param name="wmode" value="window" />');
877}
878}
879function embwmode(d){ d=d?d:tfc.document,a=d.embeds; for(var i=0,ii=a.length;i<ii;i++){ a[i].setAttribute('wmode','transparent'); } }
880function imgs(){sfMMDraw();if(tf.isInSF()&&navigator.userAgent.indexOf('Trident/6.0')!=-1)rmvwmode();else embwmode();}
881function imgEntryPageFix(ss){if(tf.isEntryPage)ss=ss.replace(/\.\.\/media\//g,(tf.lang!=tf.baseLang?'../':'')+'contents/media/');return ss;}
882function applyms(){
883if(typeof(ms)=='function'&&(!tf.extra||tf.extra.loadInProgress<1)){
884var aMS=tf.content.aMS;
885if(aMS){
886var cnt=aMS.length,a;
887for(var n=0;n<cnt;n++){a=aMS[n];ms(a[0],a[1],a[2],a[3]);}
888}
889}
890else{setTimeout('applyms()',100);}
891}
892var ms_rv,ms_lv,ms_dv,ms_uv,ms_oldn,ms_n,ms_sp=3,ms_sp2=20;
893function ms_rt(id){var el=gl('ms_'+id),x=el.offsetLeft;if(x>(ms_n-ms_oldn-(tf.isChrome?36:0)))el.style.left=(x-ms_sp)+'px';ms_rv=setTimeout('ms_rt(\''+id+'\')',ms_sp2);}
894function ms_lt(id){var el=gl('ms_'+id),x=el.offsetLeft;if(x<0)el.style.left=(x+ms_sp)+'px';ms_lv=setTimeout('ms_lt(\''+id+'\')',ms_sp2);}
895function ms_dn(id){var el=gl('ms_'+id),y=el.offsetTop;if(y>(ms_n-ms_oldn-(tf.isChrome?18:0)))el.style.top=(y-ms_sp)+'px';ms_dv=setTimeout('ms_dn(\''+id+'\')',ms_sp2);}
896function ms_up(id){var el=gl('ms_'+id),y=el.offsetTop;if(y<0)el.style.top=(y+ms_sp)+'px';ms_uv=setTimeout('ms_up(\''+id+'\')',ms_sp2);}
897var ms_right=ms_rt,ms_left=ms_lt,ms_down=ms_dn;
898function ms_stop(dir){clearTimeout(eval('ms_'+dir.substr(0,1)+'v'));}
899function ms_set(oldn,n,sp,sp2){ms_oldn=oldn;ms_n=n;
899if(typeof(sp)!='undefined')ms_sp=sp;if(typeof(sp2)!='undefined')ms_sp2=sp2;}
900function applyFlickityToIndex(idxNum){
901var $idxSlider = $('#Index'+idxNum+' > .idx'+idxNum+'List');
902$('> li', $idxSlider)
903.each(function(){ $(this).outerHeight($(this).outerHeight()); })
904.last().clone().appendTo($idxSlider).children().remove()
905;
906function setIdxSlider() {
907$idxSlider.parent().width('100%').css('float','none');
908$idxSlider
909.on('cellSelect', function(){
910var flkty = $(this).data('flickity');
911if (flkty) {
912if (flkty.selectedIndex == $(this).data('selectedIndex')) return;
913if ($(this).data('translateX') == $('.flickity-slider', this).css('transform')) {
914if (flkty.selectedIndex > $(this).data('selectedIndex')) flkty.selectedIndex = $(this).data('selectedIndex');
915else if (flkty.selectedIndex < $(this).data('selectedIndex')) flkty.selectedIndex--;
916}
917$(this).data({'selectedIndex':flkty.selectedIndex, 'translateX':$('.flickity-slider', this).css('transform')});
918}
919})
920.on('settle', function(){
921var $last = $('.flickity-slider > li', this).last(), shifted = $('.flickity-slider', this).css('transform').match(/matrix\((.+)\)/) || $('.flickity-slider', this).css('transform').match(/matrix3d\((.+)\)/), shiftedpx = 0;
922if (shifted && shifted.length > 1) shiftedpx = parseFloat((shifted[1].split(', ')[12]) || (shifted[1].split(', ')[4]));
923if (parseFloat($last.css('left')) + $last.outerWidth(true) <= $('.flickity-slider', this).width() + Math.abs(shiftedpx)) $('.next', this).attr('disabled', 'disabled');
924else $('.next', this).removeAttr('disabled');
925})
926.flickity({
927cellAlign: 'left',
928contain: true,
929wrapAround: false,
930autoPlay: false,
931draggable: true,
932freeScroll: true,
933setGallerySize: false,
934prevNextButtons: true,
935pageDots: false,
936percentPosition: false
937})
938.flickity('resize')
939.find('.flickity-viewport')
940.find('.flickity-slider').addClass('idx'+idxNum+'List')
941.end()
942.parentsUntil('[id^=WebSite]').each(function(){
943var zIndex = $(this).css('z-index');
944if (zIndex == 'auto' || parseInt(zIndex) <= 0) $(this).css('z-index', idxNum == 2 ? 1000 : 1001);
945})
946;
947}
948function unsetIdxSlider() {
949if ($idxSlider.hasClass('flickity-enabled')) {
950$idxSlider
951.flickity('destroy')
952;
953}
954$idxSlider.parent().css({'float':''});
955}
956$(window).on('resize', function () {
957unsetIdxSlider(); $idxSlider.parent().css({'width':'', 'float':'none'});
958if ($('#WebSite').width() > 619) {
959var w = 0, wContainer = ($idxSlider.parent().outerWidth(true)||$idxSlider.outerWidth(true))+1;
960$('> li, .flickity-slider > li', $idxSlider).each(function(){ w += $(this).outerWidth(true); $(this).css('height',''); if($(this).outerHeight()>0)$(this).outerHeight($(this).outerHeight()); });
961if (w-1 > wContainer) {
962setIdxSlider();
963$idxSlider.flickity('resize');
964setTimeout(function(){$idxSlider.flickity('reposition');}, 200);
965}
966else if (w < wContainer) unsetIdxSlider();
967}
968});
969$(window).trigger('resize');
970}
971function searchload(url,force){
972var tfcd=tfc.document;
973if(tf.isMobile && $('.mobile').is(':visible')) {
974tf.searchPhrase=(tf.searchPhrase||tfcd.mobile_search.phrase.value);
975}
976else {
977if(tfcd.search.phrase)tf.searchPhrase=tfcd.search.phrase.value;
978else{
979for(var n=0;n<tfcd.search.length&&!tf.searchPhrase;n++)tf.searchPhrase=tfcd.search[n].phrase.value;
980}
981}
982tf.searchPhrase=tf.searchPhrase.toLowerCase();
983if (tf.searchPhrase==''&&!force) return;
984var searchStringLength = $.trim(tf.searchPhrase).length;
985if (searchStringLength > 0 && searchStringLength < 2){
986alert (LD.LD_SEARCH_ENTER2CHARACTERS);
987return false;
988}
989tf.nametag.add('searchPhrase',tf.searchPhrase);
990if(encodeURIComponent)url+='?searchphrase='+encodeURIComponent(tf.searchPhrase);
991else url+='?searchphrase='+window.encodeURI(tf.searchPhrase);
992url+='&limitResultsPerPage=25';
993tfc.location=tf.wm.url(url,'-');
994}
995function search(){searchload(tf.lang+'/search.php')}
996function search_all(advanced)
997{
998if ( (tf.loc.hostname=='localhost' && tf.loc.port!='') || tf.loc.hostname=='')
999{
1000alert(tf.LD.LD_PHPSEARCH_ONLY_WHEN_PUBLISHED);
1001}
1002else
1003{
1004tf.searchAdvanced=advanced;
1005if(typeof(tf.searchAdvanced)!='undefined')tf.nametag.add('searchAdvanced',tf.searchAdvanced);
1006searchload(tf.lang+'/search.php',false);
1007}
1008}
1009var varShowShippingChargesAfterAddToBasket={};
1010function showShippingChargesAfterAddToBasket(){
1011var prid=varShowShippingChargesAfterAddToBasket['prid'];
1012tf.content.sfAddPop('shipping_charge',true);
1013tf.content.sfAddRef['core']={};
1014tf.utils.sfMediaBox.fnAfterClose=function(){
1015if(tf.content['add_'+prid]){
1016varShowShippingChargesAfterAddToBasket['disponly']=true;
1017tf.content.sfAddPop();
1018tf.content['add_'+prid]();
1019}
1020else if(tf.pgid=='D-10'&&tf.content.add){ // Favorites page
1021varShowShippingChargesAfterAddToBasket['disponly']=true;
1022var itm=tf.core.Favorite.items.get(prid);
1023if(itm){
1024var idx=tf.core.Favorite.items.idx(itm.idtag);
1025tf.content.add(idx);
1026}
1027}
1028};
1029varShowShippingChargesAfterAddToBasket={};
1030}
1031function showPopup(url, width, height, useOverlay, showdecorations, delay, className, HTML){
1032function gl(s){try{return tf.extra.document.getElementById(s);}catch(e){return null;}}
1033var tfcd=tfc.document,tfcdb=(tf.isSafari?tfcd.documentElement:tfcd.body);
1034var w=width||640, h=height||480;
1035sfMediaBox.cacheW=w;sfMediaBox.cacheH=h;
1036showdecorations=typeof(showdecorations)=='undefined'||showdecorations;
1037delay=typeof(delay)!='undefined'&&delay;
1038sfMediaBox.fnAfterClose=null;
1039sfMediaBox.useOffsetTop=false;
1040var contents='';
1041if(url){
1042if(url.match(/^[#.]/)&&$(url).length>0){
1043contents=tmplParser.parse(gl('tmplSFLightBoxHTMLCode'),{'HTML':$(url).html()});
1044}
1045else{
1046contents=tmplParser.parse(gl('tmplSFLightBoxFrame'),
1047{
1048src:url,
1049height:showdecorations==true?'height="'+h+'px"':'100%',
1050onload:showdecorations==true?'tf.utils.sfMediaBox.centerBox();tf.utils.sfMediaBox.hide(\'sfLightBoxLoading\');return false;':''
1051});
1052}
1053}
1054else if(!url&&HTML){
1055contents=tmplParser.parse(gl('tmplSFLightBoxHTMLCode'),{'HTML':HTML});
1056}
1057var a=[
1058(useOverlay?tmplParser.parse(gl('tmplSFLightBoxOverlay'), { height:tfcdb.
1058scrollHeight+'px', close_onclick:'return false;', className:className, contents:'' }):''),
1059tmplParser.parse(
1060gl('tmplSFLightBox'),
1061{
1062relprefix:(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../'),
1063captiondisplay:'none', navdisplay:'none', counterdisplay:'none',
1064loadingdisplay:(delay||(!url&&HTML)?'none':'block'), loadingmessage:(delay?'':tf.LD.LD_LOADING),
1065overflow:(delay?'auto':'hidden'),
1066cssborder:'border:1px #999999 solid;',
1067contents:contents,
1068close_onclick:tf.utils.sfMediaBox.close_onclick,
1069width:w+'px', height:h+'px',
1070position:'fixed',
1071marginleft:(-w/2+tfcdb.scrollLeft)+'px', margintop:(-h/2+tfcdb.scrollTop)+'px',
1072cssborder:showdecorations==true?'border:1px #999999 solid;':'border:1px #000000 solid;',
1073decorationborder:showdecorations==true?'5px':'0',
1074displaybottompart:showdecorations==true?'display:block;':'display:none;',
1075className:' '+className,
1076title:'',
1077description:'',
1078imagecontrols:''
1079}
1080)
1081];
1082sfMediaBox.showDropDowns(false);
1083for(var n=0,nn=a.length;n<nn;n++){
1084sfMediaBox.render(sfMediaBox,a[n]);
1085}
1086sfMediaBox.centerBox();
1087tf.addEvent('onresize',sfMediaBox.centerBox);
1088if(delay){
1089sfMediaBox.hide('sfLightBox');
1090sfMediaBox.hide('sfLightBoxOverlay');
1091}
1092tfc.document.body.style.overflow='hidden';
1093}
1094var dlgModal={
1095win:null,
1096w:-1,h:-1,
1097fnClose:function(){},
1098init:function(url,name,options,width,height,fnCreate,fnClose,fnComplete){
1099options=options||('scrollbars,resizable,width='+width+',height='+height);
1100this.win=(tf.external&&tf.external.IsInSF?null:window.open(url,name,options));
1101if(this.win){
1102this.w=width;
1103this.h=height;
1104sfMediaBox.render(sfMediaBox,
1105tmplParser.parse(tf.extra.document.getElementById('tmplSFLightBoxOverlay'),{
1106height:tfc.document.body.scrollHeight+'px',
1107close_onclick:'',
1108className:'',
1109contents:tmplParser.parse(tf.extra.document.getElementById('tmplSFPurchaseOverlayContents'),{})
1110})
1111);
1112var me=this;
1113$('#sfLightBoxOverlay')
1114.focus()
1115.on('click focus',function(){
1116setTimeout(function(){me.win.focus();}, 200);
1117me.win.focus();
1118}
1119);
1120tf.$(window)
1121.on('focus',function(){
1122$('#sfLightBoxOverlay').focus().click();
1123}
1124);
1125if(fnClose)this.fnClose=fnClose;
1126function close(){
1127clearInterval(interval);
1128if(fnClose)fnClose();
1129}
1130this.win.focus();
1131tf.$(window).on('beforeunload',function(){me.win.close();});
1132if(fnCreate)fnCreate();
1133var leftDomain=false;
1134var interval=window.setInterval(function(){
1135try {
1136if(me.win==null||me.win.closed){ close(); }
1137else if(me.win.document.domain===document.domain){
1138if(leftDomain){
1139if(fnComplete)fnComplete();
1140close();
1141}
1142}
1143else leftDomain=true;
1144}
1145catch(e){
1146if(me.win.closed){ close(); return; }
1147leftDomain=true;
1148}
1149},500);
1150}
1151return this.win;
1152},
1153center:function(){
1154if(!this.win||this.win.closed)return;
1155var l=Math.max((this.win.opener.outerWidth-this.w)/2,0)+this.win.opener.screenLeft,
1156t=Math.max((this.win.opener.outerHeight-this.h)/2,0);
1157this.win.moveTo(l,t);
1158}
1159};
1160var equalDivPoll=[];
1161var equaldiv = function (c) {
1162if(!c)c='EqualHeight';
1163clearTimeout(equalDivPoll[c]);
1164equalDivPoll[c] = setTimeout(function(){
1165equaldivCall(c);
1166equalDivPoll[c] = null;
1167}, 500);
1168};
1169function equaldivCall(c) {
1170var tfcd=tfc.document,coll=[],t=tfcd.querySelectorAll('.'+c);
1171for (var x = 0, cnt=t.length; x<cnt; x++) {
1172if (t[x].scrollHeight > 0) {
1173t[x].style.height='auto';
1174coll.push(t[x]);
1175}
1176}
1177if(coll.length>0){
1178equaldivWorker(coll);
1179}
1180}
1181function equaldivWorker(coll) {
1182var maxh=0;
1183if(typeof(tf.content.fnEqualDivGetHeight)=='function'){
1184for (x=0,cnt=coll.length; x<cnt; x++) {
1185maxh = Math.max(maxh, tf.content.fnEqualDivGetHeight(coll[x]));
1186}
1187}
1188else {
1189for (x=0,cnt=coll.length; x<cnt; x++) {
1190maxh = Math.max(maxh, $(coll[x]).outerHeight());
1191}
1192}
1193for (x=0,cnt=coll.length; x<cnt; x++) {
1194$(coll[x]).outerHeight(maxh);
1195}
1196}
1197var cookieWarning = {
1198_loadOptInOut:function(){
1199var $=tfc.$;
1200function handleData($o, data){
1201var js='',HTML=data.replace(/(<scr\ipt[^>]*>)((?:[\n\r]|.)*?)(<\/scr\ipt>)/gim,
1202function($0, $1, $2, $3){js+=$2;return $1+''+$3;}
1203);
1204$o.empty().html(HTML);
1205eval(js);
1206$(window).trigger('cookieOptInApprovedLoaded.cookiewarning');
1207}
1208if($('#optinout_dept').length>0&&tf.pgid){
1209$.get(tf.wm.url(pgid.toLowerCase()+'_optinout.html',lmd['optinout'],true), function(data){
1210handleData($('#optinout_dept'),data);
1211});
1212}
1213},
1214_optInApproved:function(){
1215var $=tfc.$;
1216tf.nametag.add('cookieOptInApproved',true);
1217tf.savCookStr('cookieOptInApproved',true,-1);
1218$(function () {
1219tf.cookieWarning['_loadOptInOut']();
1220});
1221},
1222_optOut:function(){
1223var $=tfc.$;
1224tf.nametag.del('cookieOptInApproved');
1225tf.delCookStr('cookieOptInApproved');
1226tf.nametag.add('cookieOptInApproved',false);
1227tf.savCookStr('cookieOptInApproved',false,-1);
1228$('[name=optinout]').empty();
1229$('#optinout_dept').empty();
1230},
1231show:function(){
1232if (tf.getCookStr('cookieOptInApproved')=='false') return;
1233$(function () {
1234tf.cookieWarning['_loadOptInOut']();
1235});
1236}
1237}
1238if(!tf.isInSF()){
1239if (tf.getCookStr('showCookieWarning')=='') {
1240tf.savCookStr('showCookieWarning',false);
1241tf.cookieWarning['_optInApproved']();
1242}
1243$(function () { tf.cookieWarning['show'](); });
1244}
1245var sfIFramer = {
1246iframeHandler: null,
1247fnReceive:null,
1248msgHandlers:{},
1249pingQualifier:'',
1250iframeInit: function(name,fnReceive,initNotifyData){
1251sfIFramer.iframeHandler = gl(name);
1252if (sfIFramer.iframeHandler) {
1253if(fnReceive)sfIFramer.fnReceive=fnReceive;
1254tf.addEvent("onmessage", sfIFramer.embedReceiveMessage);
1255tf.addEvent("onresize", sfIFramer.embedNotifyResize);
1256sfIFramer.embedPing();
1257if(initNotifyData)sfIFramer.sendInitNotifyData(initNotifyData);
1258}
1259},
1260embedReceiveMessage: function (e) {
1261e = e || window.event();
1262if (e.data.indexOf && e.data.indexOf('santuiframe') == 0) {
1263var dt = e.data.split('|');
1264if (!dt[1] || dt[1].indexOf('h') == -1) return;
1265var dth = dt[1].split('='),height=dth[1];
1266if(sfIFramer.iframeHandler&&(sfIFramer.iframeHandler.height!=height||sfIFramer.iframeHandler.getAttribute('origheightattribute')!=height)){
1267if(sfIFramer.iframeHandler.style.height)sfIFramer.iframeHandler.style.height='';
1268sfIFramer.iframeHandler.height = height;
1269if(sfIFramer.iframeHandler.getAttribute('height')!=sfIFramer.iframeHandler.getAttribute('origheightattribute'))sfIFramer.iframeHandler.setAttribute('origheightattribute',he
1269ight);
1270tf.content.equalHeight();
1271if($) {$(tf.content.document).trigger('domChanged');}
1272gl('WebSiteContent').style.height='auto';
1273gl('WebSite').style.height='auto';
1274var tfc=tf.content.document;
1275tfc.body.style.height='auto';
1276tfc.documentElement.style.height='auto';
1277tfc.body.style.overflowY='auto';
1278tfc.documentElement.style.overflowY='auto';
1279if (tf.isMobile) setTimeout(function(){sfIFramer.iframeHandler.height = height;},1000);
1280if(sfIFramer.fnReceive)sfIFramer.fnReceive();
1281}
1282sfIFramer.pingQualifier='?lmd='+Math.random();
1283}
1284if (e.data.split) {
1285var edata = e.data.split('|'), emsg = edata[0], emsgdata = edata[1] || '';
1286if (sfIFramer.msgHandlers[emsg]) sfIFramer.msgHandlers[emsg](emsgdata);
1287}
1288},
1289embedNotifyResize: function () {
1290if (sfIFramer.iframeHandler)sfIFramer.iframeHandler.contentWindow.postMessage('resize', sfIFramer.iframeHandler.domain||sfIFramer.iframeHandler.src);
1291},
1292embedPing: function () {
1293setInterval(function () {
1294if (sfIFramer.iframeHandler && sfIFramer.iframeHandler.src.indexOf('http')==0)
1295sfIFramer.iframeHandler.contentWindow.postMessage('ping|' + document.location.href+sfIFramer.pingQualifier, sfIFramer.iframeHandler.domain||sfIFramer.iframeHandler.src);
1296}, 200);
1297},
1298sendInitNotifyData: function (data) {
1299setInterval(function () {
1300if (sfIFramer.iframeHandler && sfIFramer.iframeHandler.src.indexOf('http')==0)
1301sfIFramer.iframeHandler.contentWindow.postMessage(data, sfIFramer.iframeHandler.domain||sfIFramer.iframeHandler.src);
1302}, 800);
1303},
1304addMsgHandler: function(msg, fn) {
1305this.msgHandlers[msg] = fn;
1306}
1307};
1308tf.addEvent('onload',
1309function(){
1310try {
1311var aIfr = tf.content.document.getElementsByTagName('IFRAME');
1312for (var n = 0; n < aIfr.length; n++) {
1313if (aIfr[n].src && aIfr[n].src.indexOf('santu.com') != -1) tf.utils.sfIFramer.iframeInit(aIfr[n].id);
1314}
1315}
1316catch(e){}
1317}, tf.content
1318);
1319if (!tf.isInSF() && tf !== window.top) { // Iframe!
1320var iframeholderdomain= false;
1321var iframeresize = function () {
1322if (iframeholderdomain) {
1323tf.parent.postMessage("santuiframe|h=" + $('html').height() + "|w=" + $('html').width(), iframeholderdomain);
1324}
1325};
1326var receiveMessage = function (event) {
1327if (event.data && event.data=='resize') {
1328iframeresize();
1329}
1330if (event.data && event.data.indexOf) {
1331if(event.data.indexOf('ping|')==0) {
1332var iframeholderdomain2 = event.data.substr(5,512);
1333if(iframeholderdomain!= iframeholderdomain2){
1334iframeholderdomain = iframeholderdomain2;
1335setTimeout(iframeresize,1000);
1336}
1337}
1338if (event.data.indexOf('getheight=') == 0) {
1339$('html').css('height','auto');
1340var domain = event.data.substr(10, 512);
1341tf.parent.postMessage("santuheight=" + $('html').height(), domain);
1342}
1343}
1344};
1345tf.addEventListener ? tf.addEventListener("message", receiveMessage, false) : tf.attachEvent("onmessage", receiveMessage);
1346}
1347if(!tf.isInSF() && $){
1348$(document).ready(function(){
1349if(tf.content.pgid && tf.content.pgid.indexOf('P')==0&&!tf.isTablet&&!tf.isMobile){
1350$('.ProductImage a img:not(.pici)')
1351.wrap('<span style="display:inline-block"></span>')
1352.css('display', 'block')
1353.parent()
1354.on('imageLoaded', function(e){
1355$(this).zoom({
1356duration:250,
1357callback:function(){$(this).attr('title',$(this).parent().find('img:first').attr('title'));},
1358onZoomIn:function(){$(this).prev('img').stop().animate({'opacity':'0'},'fast');},
1359onZoomOut:function(){$(this).siblings('img').stop().animate({'opacity':'1'},'fast');$(this).siblings('img.zoomImg').remove();}
1360});
1361})
1362;
1363$('a.ThumbnailSliderItem[onclick]')
1364.click(function(){
1365function waitForRealImage(el){
1366if($(el).attr('src')&&$(el).attr('src').indexOf('media/progress')==-1&&$(el).attr('src')!=$(el).next('.zoomImg').attr('src')){
1367$(el).trigger('zoom.destroy').parent().zoom();
1368}
1369else{
1370setTimeout(function(){waitForRealImage(el);},250);
1371}
1372}
1373waitForRealImage($(this).parents('.ProductImageContainer').find('.ProductImage a img').get(0));
1374})
1375;
1376}
1377});
1378}
1379if ($) {
1380$(document).ready(function(){
1381if(!tf.isInSF()) {
1382$('#Content div[id^="WebSite"] table, #Content div[id^="Shop"] table, #Content div[id^="Page"] table, #Content div[id^="Product"] table, .WebSiteFootnote table, #Content div[id^="Htmlcode"] table, #Content div[id^=IndexCode] table').not('.sf-scrollbar-table, #Content div[id^="Page"] table.PageImage, #Content div[id^="ProductIcons"] table').wrap('<div class="sf-scrollbar-table"></div>');
1383} else {
1384while($('div.sf-scrollbar-table > table').length > 0) {
1385$('div.sf-scrollbar-table > table').unwrap();
1386}
1387}
1388});
1389}
1390var layoutModer = {
1391_modeNone:0,
1392_modeDesktop:1,
1393_modeMobile:2,
1394switchTo: function(mode) {
1395var oSS = $('#global-responsive-css');
1396if (oSS) {
1397var $mainContentArea=tfc.$('#SideBar_L').next('[class*=content], #Content');
1398switch (mode) {
1399case this._modeNone:
1400case this._modeDesktop:
1401oSS.attr('disabled', true);
1402if (parseFloat($mainContentArea.css('min-width')) != 0) $mainContentArea.width($mainContentArea.css('min-width'));
1403tf.nametag.add('layoutMode', this._modeDesktop);
1404if(tf.content.makeResponsive)tf.content.makeResponsive();
1405break;
1406case this._modeMobile:
1407oSS.attr('disabled', false);
1408$mainContentArea.width('');
1409tf.nametag.add('layoutMode', this._modeMobile);
1410break;
1411}
1412if (tf.content.equalHeight) setTimeout(tf.content.equalHeight);
1413}
1414},
1415init: function() {
1416$('#mobile_switchview a.mobile-xor, #util_switchview a.mobile-xor').click(function(){
1417tf.utils.layoutModer.switchTo(tf.utils.layoutModer._modeDesktop);
1418return false;
1419});
1420$('#mobile_switchview a.desktop-xor, #util_switchview a.desktop-xor').click(function(){
1421tf.utils.layoutModer.switchTo(tf.utils.layoutModer._modeMobile);
1422return false;
1423});
1424var mode = parseInt(tf.nametag.get('layoutMode'))||parseInt('2');
1425tf.nametag.add('layoutMode', mode);
1426this.switchTo(mode);
1427}
1428}
1429if ($) {
1430$(document).ready(function () {
1431if (!$.support.placeholder) {
1432$('[placeholder]')
1433.focus(function () { if ($(this).val() == $(this).attr('placeholder')) $(this).val(''); })
1434.blur(function () { if ($(this).val() == '') $(this).val($(this).attr('placeholder')); })
1435.blur();
1436$('[placeholder]').parents('form').submit(function () {
1437$(this).find('[placeholder]').each(function() {
1438if ($(this).val() == $(this).attr("placeholder")) {
1439$(this).val('');
1440}
1441});
1442});
1443}
1444var makeResponsivPoll=0;
1445tf.content.makeResponsiveCall = function(){
1446$('img:not([src=""])').each(function(){
1447var img = $(this);
1448if(this.getAttribute('data-echo')) return;
1449img.toggleClass('responsive',false);
1450if(img.parents('.sf-scrollbar-table, .no-responsive, .ThumbnailSlider, .ProductIcons').length > 0 || img.hasClass('zoomImg')) return;
1451if(img.parents('#Content').length == 0 || $(this.offsetParent).parents('#Content').length == 0) return;
1452var w = img.width(), h = img.height();
1453if (typeof(img.data('origwidth')) == 'undefined') {
1454img.data('origwidth', w);
1455img.data('origheight', h);
1456}
1457var w=img.data('origwidth')||w;
1458if(w!=0){
1459var $offsetParent=$(this.offsetParent);
1460if($offsetParent.hasClass('ProductImage')){
1461if($offsetParent.css('display').indexOf('inline')!=-1){
1462$offsetParent.css('display','block');
1463img.css({'margin-left':'auto','margin-right':'auto'});
1464}
1465if(w >= $offsetParent.width()) img.toggleClass('responsive',true);
1466}
1467else{
1468if(w > $offsetParent.width()) img.toggleClass('responsive',true);
1469}
1470}
1471});
1472if (tf.content.equalHeight) tf.content.equalHeight();
1473if($) {$(tf.content.document).trigger('domChanged');}
1474}
1475tf.content.makeResponsive = function(){
1476clearTimeout(makeResponsivPoll);
1477makeResponsivPoll = setTimeout(function(){
1478tf.content.makeResponsiveCall();
1479makeResponsivPoll = null;
1480}, 500);
1481}
1482$(tf.content.window).resize(tf.content.makeResponsive);
1483tf.content.makeResponsive();
1484layoutModer.init();
1485$('.SwitchCurrencyLink').attr('href', tf.wm.url('changecurrency.html',null,true));
1486$('.SwitchLangLink').on('click', function(e){
1487e.preventDefault();
1488tf.utils.change_lang($(this).data('langparm'));
1489});
1490if($('#Search #phrase ~ [class*=cross-icon]').length==0)$('#Search #phrase').after('<span class="cross-icon-1234" title="LD_CANCEL"><i class="icon-cross"></i></span>');
1491$('.SearchButton').each(function(){
1492if ($(this).attr('href') == '#') {
1493if ($(this).hasClass('SearchButtonAdvanced')) $(this).on('click', function(){tf.utils.search_all(1); });
1494else $(this).on('click', function(e){
1495e.stopPropagation();
1496e.preventDefault();
1497tf.utils.search_all();
1498});
1499}
1500});
1501$('.SearchTextField').parents('form').on('submit', function(e){
1502e.preventDefault();
1503tf.utils.search_all();
1504});
1505$(document).on('click', '[class^=cross-icon-123]', function (e) {
1506e.stopPropagation();
1507$(this).parent().children('input').val('').focus();
1508});
1509});
1510}
1511/* net.js begin */
1512var net={};
1513net.READY_STATE_UNINITIALIZED=0;
1514net.READY_STATE_LOADING=1;
1515net.READY_STATE_LOADED=2;
1516net.READY_STATE_INTERACTIVE=3;
1517net.READY_STATE_COMPLETE=4;
1518net.ContentLoader=function(url,onload,onerror,onupdate,method,params,contentType){
1519this.req=null;
1520this.onload=onload;
1521this.onerror=(onerror?onerror:this.defaultError);
1522this.onupdate=onupdate;
1523this.loadXMLDoc(url,method,params,contentType);
1524}
1525net.ContentLoader.prototype.loadXMLDoc=function(url,method,params,contentType){
1526if(!method){method="GET";}
1527if(!contentType&&method=="POST"){contentType='application/x-www-form-urlencoded; charset=utf-8;';}
1528if(!tf.isInSF()&&window.XMLHttpRequest&&(!isIE||url.indexOf('file:')==-1)){this.req=new XMLHttpRequest();}
1529else if(window.ActiveXObject){
1530try{this.req=new ActiveXObject("Microsoft.XMLHTTP");}
1531catch(e){this.req=null;}
1532}
1533if(this.req){
1534try{
1535var loader=this;
1536this.req.onreadystatechange=function(){net.ContentLoader.onReadyState.call(loader);}
1537this.req.open(method,url,true);
1538if(contentType){this.req.setRequestHeader('Content-Type', contentType);}
1539this.req.send(params);
1540}
1541catch(err){this.onerror.call(this);}
1542}
1543}
1544net.ContentLoader.onReadyState=function(){
1545var req=this.req,ready=req.readyState;
1546if(ready==net.READY_STATE_COMPLETE){
1547var httpStatus=req.status;
1548if(httpStatus==200||httpStatus==0){this.onload.call(this);}
1549else{this.onerror.call(this);}
1550}
1551}
1552net.ContentLoader.prototype.defaultError=function(){
1553alert("error fetching data!"+"\n\nreadyState:"+this.req.readyState
1554+"\nstatus: "+this.req.status+"\nheaders: "+this.req.getAllResponseHeaders());
1555}
1556net.cmdQueues=[];
1557net.CommandQueue=function(id,url,data,freq,immediate,onLoad,onError,onUpdate){
1558this.id=id;
1559this.url=url;
1560this.data=data;
1561this.onLoad=(onLoad?onLoad:net.CommandQueue.onload);
1562this.onError=(onError?onError:net.CommandQueue.onerror);
1563this.onUpdate=(onUpdate?onUpdate:net.CommandQueue.onupdate);
1564this.lastUpdateTime=0;
1565if(immediate)this.fireRequest();
1566if(freq)this.repeat(freq);
1567net.cmdQueues[id]=this;
1568}
1569net.CommandQueue.prototype.fireRequest=function(){
1570if(!this.onUpdate){return;}
1571this.loader=new net.ContentLoader(this.url,this.onLoad,this.onError,this.onUpdate,"POST",this.data);
1572}
1573net.CommandQueue.onload=function(loader){
1574var jsonText=this.req.responseText;
1575var o=tf.sfJSON.parse(jsonText);
1576if(o){this.onupdate.call(this,o);}
1577}
1578net.CommandQueue.prototype.repeat=function(freq){
1579this.unrepeat();
1580if (freq>0){
1581this.freq=freq;
1582var cmd="net.cmdQueues['"+this.id+"'].fireRequest()";
1583this.repeater=setInterval(cmd,freq*1000);
1584}
1585}
1586net.CommandQueue.prototype.unrepeat=function(){
1587if (this.repeater){clearInterval(this.repeater);}
1588this.repeater=null;
1589}
1590/* net.js end */
1591var navRO=tf.navRO,navOvr=tf.navOvr,navOut=tf.navOut,navClk=tf.navClk;
1592if(typeof(SymRealWinOpen)!='undefined')window.open=SymRealWinOpen;
1593if(window.NS_ActualOpen){window.open=NS_ActualOpen;}
1594var str_sep1='~|`';
1595var shopName='COSMETICS.NL',shopRegion='NL';
1596var confLoaded=false;
1597var region='',regionChanged=false,method='',pmKey='--';
1598function getCoreProperties(){
1599if(voucher!=null&&voucher.type!=0)voucher['wssig']=tf.wssig;
1600return {'active_servers':active_servers,'region':region,'regionChanged':regionChanged,'method':method,'ResellerID':ResellerID,'gmtTime':gmtTime,'reseller':reseller,'voucher':voucher,'pmKey':pmKey};
1601}
1602function setCoreProperties(arr){
1603for(var s in arr){
1604if(s=='voucher'){if(arr[s].wssig==tf.wssig)tf.merge(voucher,arr[s]);}
1605else if(s=='reseller'){tf.merge(reseller,arr[s]);}
1606else this[s]=arr[s];
1607}
1608}
1609function ld(name,sf,args){var s;if(LD&&name)s=LD[name];if(!LD||!s)s=sf||'';if(args){var sa=s.split('%%');s='';for(var i=0;i<sa.length;i++)if(args[i])s+=sa[i]+args[i];else s+=sa[i];}return s.replace('%%','');}
1610var d=document;function dw(s){d.write(s);}function gl(s){return d.getElementById(s);}
1611function isInSFClassic(){try{if(window.external&&typeof(window.external.isInSF)=='number')return window.external.isInSF();else return false;}catch(e){return false;}}
1612function isInSFull(){try{if(window.external&&typeof(window.external.isFullViewEdit)=='number')return window.external.isFullViewEdit();else return false;}catch(e){return false;}}
1613function isInSF(){return isInSFClassic()||isInSFull();}
1614function isInDesigner(){try{return typeof(tf.parent.applyColorScheme)!='undefined';}catch(e){return false;}}
1615function dw(s){document.write(s);}
1616var active_servers=[],gmtTime=0;
1617var ping={
1618timer1:null,
1619timer2:null,
1620timer3:[],
1621poll:function(){
1622if(typeof(country_code)=='undefined'){ping.timer1=setTimeout("ping.poll()",100);return;}
1623if(active_servers.length>0){for(var tt in ping.timer3){clearTimeout(ping.timer3[tt]);}ping.timer3=[];}
1624clearTimeout(ping.timer2);ping.timer2=null;clearTimeout(ping.timer1);ping.timer1=null;
1625if(country_code!=''&&country_code!='A1'&&country_code!='A2'&&shopRegion.indexOf(country_code)!=0){region=country_code;regionChanged=true;}
1626else region=shopRegion;
1627tf.nametag.add('coreProperties',tf.sfJSON.stringify(getCoreProperties()));
1628if(tf.utils&&tf.core&&tf.bskLoaded){
1629if(tf.utils.populatePrice)tf.utils.populatePrice();
1630if(tf.utils.populateOpt)tf.utils.populateOpt();
1631}
1632},
1633failed:function(){
1634if(ping.timer2){
1635clearTimeout(ping.timer1);
1636if(ping.timer3.length==0)ping.go(true);
1637if(!region){
1638region=shopRegion;
1639if(tf.utils&&tf.core&&tf.bskLoaded){
1640if(tf.utils.populatePrice)tf.utils.populatePrice();
1641if(tf.utils.populateOpt)tf.utils.populateOpt();
1642}
1643}
1644}
1645},
1646go:function(all){
1647if(active_servers.length>0)return;
1648function id(n){return'ping'+servers[n].replace(/[^a-zA-Z0-9]/g,'');}
1649function url(n){return servers[n]+fake_country+'t='+tf.testShop+'&u='+escape(location.protocol+'//'+location.hostname+tf.wm.baseurl)+'&lmd='+(tf.lmd?tf.lmd['index']:'');}
1650var i=0,servers='//timecheck.shopfactory.com/ping/v7ping.js'.split(','),fake_country=(tf.parm&&tf.parm['fake_country'])?'?c='+tf.parm['fake_country']+'&':'?';
1651scr.load(id(i),url(i));
1652if(all){
1653for(i=1;i<servers.length;i++){
1654ping.timer3.push(setTimeout("scr.load('"+id(i)+"','"+url(i)+"')",1000*i));
1655}
1656}
1657else ping.timer2=setTimeout('ping.failed()',5000);
1658ping.poll();
1659}
1660};
1661if(!isInSF() && tf.nametag){
1662setCoreProperties(tf.sfJSON.parse(tf.nametag.get('coreProperties')));ping.go(false);
1663}
1664else{country_code=region=shopRegion;} // We don't ping if in SF, so we need to initialise country_code
1665if(tf.wm){
1666tf.wm.rld=function(w,u,p,h){if(w==null)return;if(u==null)w.location.reload();else setTimeout(function(){w.location.assign(tf.wm.url(u,p,h));},100);return;}
1667tf.wm.pProp=function(id,prop){if(this._pArr==null)this._pArr=[];if(prop!=null)this._pArr[id]=prop;return this._pArr[id];}
1668tf.wm.pPropStk=function(id,fld,val){if(this._pArr[id])if(typeof(val)!='undefined')this._pArr[id][fld]=val;else return this._pArr[id][fld]}
1669tf.wm.pPropMin=function(id,val){return this.pPropStk(id,2,val);}
1670tf.wm.pPropMax=function(id,val){return this.pPropStk(id,3,val);}
1671tf.wm.pPropQty=function(id,val){return this.pPropStk(id,4,val);}
1672}
1673var lang=tf.lang?tf.lang:'nl';
1674function regionalSettingsObj(rulesList) {
1675this.defDecimal='.';
1676this.defThousand=',';
1677this.defPosition=0;
1678this.regions=[];
1679this.region=function(dec,thous,pos) {
1680this.decimal=dec;
1681this.thousand=thous;
1682this.position=pos;
1683}
1684for (var i in rulesList) {
1685switch (rulesList[i].length) {
1686case 1: this.regions[rulesList[i][0]]=new this.region(this.defDecimal,this.defThousand,this.defPosition);break;
1687case 3: this.regions[rulesList[i][0]]=new this.region(rulesList[i][1],rulesList[i][2],this.defPosition);break;
1688case 4: this.regions[rulesList[i][0]]=new this.region(rulesList[i][1],rulesList[i][2],rulesList[i][3]);break;
1689}
1690}
1691this.getCurrentSettings=function() {
1692return this.getSettings(navigator.language?navigator.language.toLowerCase():navigator.userLanguage.toLowerCase());
1693}
1694this.getSettings=function(lang)  {
1695if(lang&&this.regions[lang])return this.regions[lang];
1696else if (lang&&lang.length>2&&this.regions[lang.substr(0,2)])return this.regions[lang.substr(0,2)];
1697else return this.defRegion;
1698}
1699this.getMerchantSettings=function() {
1700return this.getSettings('nl');
1701}
1702this.defRegion=new this.region(this.defDecimal,this.defThousand,this.defPosition);
1703}
1704var regionalSettings=new regionalSettingsObj([["af",".",",",2],["ar",".",",",2],
1705["az",",","",3],["be",",","",3],["bg",",","",3],["ca",",",".",3],["cs",",","",3],
1706["da",",",".",2],["de",",",".",3],["de-at",",",".",2],["de-ch",".","'",2],
1707["de-li",".","'",2],["de-lu",",",".",3],["div",".",",",3],["el",",",".",3],
1708["en"],["es",",",".",3],["es-ar",",",".",2],["es-bo",",",".",2],["es-cl",",",".",2],
1709["es-co",",",".",2],["es-cr",",",".",0],["es-do"],["es-ec",",",".",2],
1710["es-es",",",".",3],["es-gt"],["es-hn",".",",",2],["es-mx"],["es-ni",".",",",2],
1711["es-pa",".",",",2],["es-pe",".",",",2],["es-pr",".",",",2],["es-py",",",".",2],
1712["es-sv"],["es-uy",",",".",2],["es-ve",",",".",2],["et",".","",3],["eu",",",".",3],
1713["fa","/",",",2],["fi",",","",3],["fo",",",".",2],["fr",",","",3],["fr-be",",",".",3],
1714["fr-ca",",","",3],["fr-ch",".","'",2],["fr-lu",",","",3],["fr-mc",",","",3],
1715["gl",",",".",2],["gu",".",",",2],["he",".",",",2],["hi",".",",",2],
1716["hr",",",".",3],["hu",",","",3],["hy",".",",",3],["id",",",".",0],
1717["is",",",".",3],["it",",",".",2],["it-ch",".","'",2],["ja"],["ka",",","",3],
1718["kk","-","",0],["kn",".",",",2],["ko"],["kok",".",",",2],["ky","-","",3],
1719["lt",",",".",3],["lv",",","",2],["mk",",",".",3],["mn",",","",1],
1720["mr",".",",",2],["ms",",",".",0],["ms-bn",",",".",0],["nb",",","",2],
1721["nl",",",".",2],["nl-be",",",".",3],["nn-no",",","",2],["pa",".",",",2],
1722["pl",",","",3],["pt",",",".",0],["pt-pt",",",".",3],["ro",",",".",3],
1723["ru",",","",1],["sa",".",",",2],["sk",",","",3],["sl",",",".",3],
1724["sq",",",".",1],["sr",",",".",3],["sv",",",".",3],["sv-fi",",","",3],
1725["sw"],["syr",".",",",2],["ta",".",",",2],["te",".",",",2],["th"],
1726["tr",",",".",3],["tt",",","",3],["uk",",","",3],["ur"],["uz",",","",3],
1727["vi",",",".",3],["zh"]]);
1728function def(str) {return (str==null)?'':str;}
1729function ckCodeStr(obj, order, sep, str)
1730{
1731if (str==null) str = '';
1732function delim(i, s) {return (i==0)?'':s}
1733var cstr = [];
1734var arr  = str.split(sep);
1735var len  = arr.length;
1736for (var i=0,ii=order.length; i<ii; i++){
1737var val='';
1738if(typeof(arr[i])=='string'){
1739if(len>1){
1740val=unescape(arr[i]);
1741val=val.replace(/\\"/g,'"').replace(/&#44;/g,',').replace(/&#45;/g,'-');
1742}
1743else val=arr[i].replace(/"/g,'\\"').replace(/,/g,'&#44;').replace(/-/g,'&#45;');
1744}
1745else{arr[i];}
1746if(val=='false'||val=='true')val=eval(val);
1747else {
1748if (typeof(val)=='string')val=val.replace(/[\n\r]/g,' ').replace(/"/g,'\\"');
1749val = (isNaN(val)||val=='')?'"'+val+'"':parseFloat(val);
1750}
1751val	= (len>1)?'='+val:'';
1752val = eval('obj.'+order[i]+val);
1753val = (val == 'undefined'||typeof(val)=='undefined'?'':val);
1754cstr.push(delim(i,sep) + def(len>1?val:escape(val)));
1755}
1756if (typeof(obj.xcode)=='function') cstr.push(sep + obj.xcode((str!='')?arr[i]:''));
1757return cstr.join('');
1758}
1759var sym = new Array();
1760sym['yen']   = '%A5';
1761sym['pound'] = '%A3';
1762function entities(s)
1763{
1764var i=s.indexOf('&');
1765if (i==-1) return s;
1766var j=s.indexOf(';', i);
1767var s1=s.substring(0,i);
1768var s2=unescape(sym[s.substring(i+1,j)]);
1769var s3=entities(s.substring(j+1,s.length));
1770return s1+s2+s3;
1771}
1772function dCurr(val, raw, c1, c2)
1773{
1774if (isNaN(val)) return val;
1775var scurr='';
1776if (c1==null) return nfmt.display(val);
1777if (c2!=null) {
1778var val2 = val*(c2.multiplier/tf.shopCurrency.multiplier);
1779if (!raw) scurr = nfmt.display(val2, c2.decimal_places,entities(c2.abbrev));
1780scurr='<span class="SecondaryCurrencyAmount">(~'+scurr+')</span> ';
1781}
1782if (!raw) val = nfmt.display(val*(c1.multiplier/tf.shopCurrency.multiplier), c1.decimal_places,c1.abbrev);
1783return (scurr?scurr+'<span>'+val+'</span>':val);
1784}
1785function dispCurr(val, c1, c2) {return dCurr(val, 0, c1, c2);}
1786function showPrc(val, type) {
1787if (type||!tf.secondCurrency) return dCurr(val, 0, tf.currentCurrency);
1788return dCurr(val, 0, tf.currentCurrency, tf.secondCurrency);
1789}
1790function showItemCountInBasketIndicator(){
1791if (!LD||!tf.content||!tf.utils||!tf.core||!tf.core.Basket) {setTimeout(showItemCountInBasketIndicator, 100);return;}
1792var tfc=tf.content;
1793if (tf.core.Basket.items.cnt()>0&&tfc.ppriceArr&&tfc.ppriceArr.length>0) {
1794if(tf.conf&&tf.conf.greySettings)tf.conf.greySettings();else return;
1795if(confLoaded){
1796var oCachePPriceArr={},oBskItm={};
1797for (var i=0,ii=tfc.ppriceArr.length;i<ii;i++){
1798oCachePPriceArr[tfc.ppriceArr[i][0]]=tfc.ppriceArr[i];
1799}
1800for (var i=0,ii=tfc.ppriceCrossPromotionArr.length;i<ii;i++){
1801oCachePPriceArr[tfc.ppriceCrossPromotionArr[i][0]]=tfc.ppriceCrossPromotionArr[i];
1802}
1803var bsk=tf.core.Basket,itm=bsk.items.start(),idLast='';
1804while (itm!=null) {
1805if (oCachePPriceArr[itm.id]) {
1806if (oBskItm[itm.id]) oBskItm[itm.id] += itm.quantity;
1807else oBskItm[itm.id] = itm.quantity;
1808idLast = itm.id;
1809}
1810itm=bsk.items.next();
1811}
1812var vars={
1813txtItems:LD.LD_ITEMS,
1814txtCheckout:LD.LD_MYBASKET
1815};
1816for (var prid in oBskItm) {
1817vars['prid'] = prid;
1818vars['itemcount'] = oBskItm[prid];
1819vars['relprefix'] = (tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/'+tf.lang+'/':'');
1820var html = tf.utils.tmplParser.parse('tmplSFItemCountInBasket', vars);
1821var el = tfc.gl('sfItemCountInBasket-'+prid);
1822if (el) el = el.parentNode;
1823else {
1824el = tfc.gl('ProductIcons-'+prid);
1825if (el) {
1826var elNew = tfc.document.createElement(el.nodeName);
1827elNew.className = 'ProductIcons ItemCountInBasket';
1828el = el.parentNode.insertBefore(elNew, el);
1829}
1830}
1831if (el) {
1832if (prid == idLast && typeof(tfc.jQuery) != 'undefined') {
1833var elThis = el;
1834(function(){
1835tfc.$(elThis).slideUp(250, function(){tfc.$(elThis).slideDown(250, function(){if(tf.equalHeight)tf.equalHeight();});});
1836})();
1837}
1838el.innerHTML = html;
1839}
1840var elATB = tfc.gl('AddToBasketButton-'+prid);
1841if (elATB) {
1842var spans = elATB.getElementsByTagName('span');
1843if (spans && spans.length > 0) {
1844for (var n = 0; n < spans.length; n++) {
1845if (spans[n].className == 'ImgLink') {
1846var sIcon = '', oNodes = spans[n].childNodes;
1847if (oNodes && oNodes.length > 0) {
1848for (var i = 0; i < oNodes.length; i++) {
1849if (oNodes[i].className&&oNodes[i].className.indexOf('icon-') != -1) {
1850sIcon = oNodes[i].outerHTML;
1851break;
1852}
1853}
1854}
1855spans[n].innerHTML = sIcon + '<span>' + LD.LD_ADD_MORE + '</span>';
1856break;
1857}
1858}
1859}
1860}
1861}
1862if(tf.equalHeight)tf.equalHeight();
1863if(tf.isInDesigner()){tf.parent.applyColorScheme(tf);}
1864}
1865}
1866}
1867var rl_total=debounce(function() {
1868var tfcd=tf.content.document;
1869if(tf.shipping&&tf.utils&&tfcd){
1870if(tfcd.getElementById('MiniCartTotal'))Basket.refreshTotal();
1871showItemCountInBasketIndicator();
1872}
1873else setTimeout(rl_total,100);
1874}, 1000);
1875rl_total();
1876function createMap(arr) {
1877var ret=[];
1878for (var i in arr) ret[arr[i]]=1;
1879return ret;
1880}
1881var reseller = {'frship':false,'frship_am':0,'ismember':false};
1882function updateReseller(prdc,values,type){
1883if (Basket&&Basket.gdisc) {
1884for (var i=0; i<prdc.length; i++) {
1885Basket.gdisc.eAdd(prdc[i], new Array(type,values[i],''))
1886}}}
1887var ResellerID='';
1888var ResellerPasswd='';
1889function smart_unescape(s) {
1890try {
1891return unescape(s);
1892} catch (e) { return s;}
1893}
1894function smart_escape(s) {
1895if(window.encodeURI) return encodeURI(s);
1896else return escape(s)
1897}
1898var startS=0;
1899var startR=0;
1900function getStyleClass(className,d){
1901var ss;
1902try{
1903if(d.all){
1904for(var s=startS; s<d.styleSheets.length; s++){
1905startS=s+1;
1906if(!d.styleSheets[s].cssRules||d.styleSheets[s].cssRules.length==0)continue;
1907ss=d.styleSheets[s].imports[0];
1908if(!ss)continue;
1909for(var r=startR; r<ss.rules.length; r++){
1910startR=r+1;
1911if(ss.rules[r].selectorText==className||ss.rules[r].selectorText.indexOf(className+',')==0){startS=s;return ss.rules[r];}
1912}}}
1913else if(d.getElementById){
1914for (var s=startS; s<d.styleSheets.length; s++){
1915startS=s+1;
1916try{if(!d.styleSheets[s].cssRules||d.styleSheets[s].cssRules.length==0)continue;}catch(e){continue;}
1917if(d.styleSheets[s].cssRules[0].type!=3)continue;
1918ss=d.styleSheets[s].cssRules[0].styleSheet;
1919for (var r=startR; r<ss.cssRules.length; r++){
1920startR=r+1;
1921if(ss.cssRules[r].selectorText==className||ss.cssRules[r].selectorText.indexOf(className+',')==0){return ss.cssRules[r];}
1922}}}
1923}catch(e){return null;}
1924return null;
1925}
1926function getCssText(className,d) {
1927if(!d)d=tf.content.document;
1928if(!d.styleSheets)return'';
1929startS=0;
1930startR=0;
1931var prevClass=getStyleClass(className,d);
1932var curClass=prevClass;
1933var css=prevClass?prevClass.style.cssText:'';
1934while(curClass) {
1935curClass=getStyleClass(className,d);
1936if (curClass) {prevClass=curClass;css+=prevClass.style.cssText;}
1937}
1938if (!prevClass) return '';
1939css=css.replace(/rgb\((\d+), (\d+), (\d+)\)/g, function($0, $1, $2, $3) {
1940var r=parseInt($1).toString(16),g=parseInt($2).toString(16),b=parseInt($3).toString(16);
1941if(r.length==1)r='0'+r;
1942if(g.length==1)g='0'+g;
1943if(b.length==1)b='0'+b;
1944return '#'+r+g+b;
1945});
1946return css;
1947}
1948var pm={
1949busy:false,
1950persist:{ dataraw:[], currConverted:true, lang:'', xml:'' },
1951data:[],
1952dataidx:{},
1953onGet:function(xml){
1954function getSurcharge(surcharge) {
1955var surchargecurr='';
1956if(surcharge.indexOf('%')==-1){
1957surchargecurr=surcharge.replace(/[0-9\-\+\. ]/g,'');
1958surcharge=parseFloat(surcharge);
1959if(surchargecurr&&tf.shopCurrency.iso!=surchargecurr&&(!tf.currencies||!tf.currencies[surchargecurr]))pm.persist.currConverted=false;
1960}
1961return [surcharge,surchargecurr];
1962}
1963pm.persist.dataraw=[];pm.data=[];pm.dataidx={};pm.persist.xml=xml;
1964var $=tf.content.$;
1965var data = $($.parseXML(xml)).find('data');
1966pm.persist.showServiceLogo=eval($(data).find('provider_name').attr('enabled'));
1967pm.persist.showSurchargeTax=eval($(data).find('surchargetax').attr('enabled'));
1968$(data).find('method').each(function(){
1969var arrSurcharge=getSurcharge($(this).find('fees').text()),surcharge=arrSurcharge[0],surchargecurr=arrSurcharge[1];
1970pm.persist.dataraw.push({
1971'idx':pm.persist.dataraw.length,
1972'service':$(this).find('service').text(),
1973'serviceLogo':$(this).find('service_logo').text().replace(/^https?:/,''),
1974'key':$(this).find('key').text(),
1975'name':$(this).find('name').text(),
1976'currencies':$(this).find('currencies').text(),
1977'country':$(this).find('country').text(),
1978'priority':parseInt($(this).find('priority').text()),
1979'surcharge':surcharge,
1980'surchargecurr':surchargecurr,
1981'logo':$(this).find('logo').text().replace(/^https?:/,''),
1982'commentName':$(this).find('comment_name').text(),
1983'comment':$(this).find('comment').text().replace(/\&\#38\;/g,'&').replace(/\&\#60\;/g,'<').replace(/\&\#62\;/g,'>'),
1984'isSpecial':false
1985});
1986});
1987var customMethods=tf.conf.payMethod();
1988for(var nm in customMethods){
1989pm.persist.dataraw.push({
1990'idx':pm.persist.dataraw.length,
1991'service':'Custom',
1992'serviceLogo':'',
1993'key':nm,
1994'name':nm,
1995'currencies':'',
1996'country':'',
1997'priority':1,
1998'surcharge':'',
1999'surchargecurr':'',
2000'logo':'',
2001'commentName':'',
2002'comment':'',
2003'isSpecial':false
2004});
2005}
2006if(!pm.persist.currConverted){
2007pm.currConv();
2008}
2009else{
2010pm.indexate();
2011pm.busy=false;
2012}
2013},
2014currConv:function(){
2015tf.nametag.del('cratesCalled');
2016tf.load('cload.html','cdata',false,true);
2017function waitForCurr(){
2018if(!tf.currencies||!tf.currencies[tf.shopCurrency.iso]){setTimeout(waitForCurr,200);return;}
2019pm.indexate();
2020pm.busy=false;
2021}
2022waitForCurr();
2023},
2024indexate:function(){
2025if(this.persist.dataraw){
2026this.data=[];this.dataidx={};
2027var oData=null,lookupCurrency=tf.shopCurrency.iso,lookupCountry=tf.core.regi
2027on||tf.core.shopRegion;
2028for(var i=0;i<this.persist.dataraw.length;i++){
2029oData=this.persist.dataraw[i];
2030if(!oData.currencies||oData.currencies.indexOf(tf.currentCurrency.iso)!=-1){
2031lookupCurrency=tf.currentCurrency.iso;
2032break;
2033}
2034}
2035var key='',priorities={},priority=-1;
2036for(var i=0;i<this.persist.dataraw.length;i++){
2037oData=this.persist.dataraw[i];
2038key=oData.key;
2039var surchargecurr=oData.surchargecurr;
2040if(surchargecurr){
2041if(tf.shopCurrency.iso!=surchargecurr&&tf.currencies&&tf.currencies[surchargecurr]){
2042var surcharge=parseFloat(oData.surcharge)*(tf.currencies[tf.shopCurrency.iso]/tf.currencies[surchargecurr]);
2043surcharge=tf.core.nfmt.round(surcharge);
2044if(surcharge>0)surcharge='+'+surcharge;
2045oData.surcharge=surcharge;
2046oData.surchargecurr='';
2047this.persist.currConverted=true;
2048}
2049}
2050priority=oData.priority;
2051if(!priorities[key]){
2052if((!oData.currencies||oData.currencies.indexOf(lookupCurrency)!=-1)
2053&& (!oData.country||oData.country.indexOf(lookupCountry)!=-1)){
2054priorities[key]=priority;
2055this.data.push(oData);
2056this.data[this.data.length-1].idx=this.data.length-1;
2057this.dataidx[oData.key]=this.data[this.data.length-1];
2058}
2059}
2060}
2061tf.nametag.add('pmdata',tf.sfJSON.stringify(this.persist));
2062if(this.data.length==1)pmKey=this.data[0]['key'];
2063}
2064},
2065get:function(){
2066var pmstr=tf.nametag.get('pmdata'),doGet=true;
2067if(pmstr){
2068this.persist=tf.sfJSON.parse(pmstr);
2069doGet=(this.persist.lang!=tf.lang);
2070if(!doGet){
2071if(tf.conf&&tf.conf.pmdataraw&&tf.conf.pmdatasig!=this.persist.sig){
2072this.onGet(tf.conf.pmdataraw);
2073}
2074else{
2075if(!this.persist.currConverted)this.currConv();
2076else this.indexate();
2077}
2078}
2079}
2080if(doGet){
2081if(!tf.shipping||!tf.conf){setTimeout('pm.get();',500);return;}
2082if(!this.busy){
2083this.busy=true;
2084this.persist.lang=tf.lang;
2085if(tf.conf.pmdataraw){
2086this.persist.sig=tf.conf.pmdatasig;
2087this.onGet(tf.conf.pmdataraw);
2088}
2089else{
2090var pmxd=new tf.extra.xdmsg('//santu.com/webshop/getpaymentmethods.cgi?lang='+tf.lang+'&from=sf&ver=ShopFactory Gold 14.6.0 Build 23335&mid=cosmetics','pmdata',this.onGet,'_sfpmping','_sfpmdata');
2091pmxd.init();
2092}
2093}
2094}
2095}
2096};
2097function savCookStr(name,val,days) { tf.sfPersist.set(name,val,days); }
2098function delCookStr(name) { tf.sfPersist.set(name,'',0); }
2099function getCookStr(name) { return tf.sfPersist.get(name); }
2100function timeMgr(offset)
2101{
2102this.handlers={getTime:[]};
2103this.setTime = tmSetTime;
2104this.getTime = tmGetTime;
2105this.isActive = tmIsActive;
2106this.offset = tmOffset;
2107this.myTZ = (new Date()).getTimezoneOffset() / 60 * -1;
2108this.timestamp = new Date();
2109this.offset(offset);
2110return this;
2111}
2112var currTime = new timeMgr('');
2113currTime.getTime();
2114function tmGetTime(){
2115if(tf.isInSF())return;
2116if (gmtTime==0) setTimeout("currTime.getTime()", 500);
2117else{(this.setTime(gmtTime));var hl=this.handlers['getTime'];for(var n=0,num=hl.length;n<num;n++)hl[n]();}
2118}
2119function tmSetTime(ti)
2120{
2121if (ti==null) return this._cTime;
2122this._cTime = ti;
2123return this._cTime;
2124}
2125function tmOffset(os)
2126{
2127if (os!=null&&os!='') this._offset=os;
2128return this._offset;
2129}
2130function tmIsActive(fr, to, rep, freq)
2131{
2132if (fr==null || fr=='') return 1;
2133if (to==null) {
2134var a=fr.split(',');
2135if (a.length==1) return 1;
2136return this.isActive(a[0],a[1],a[2],a[3]);
2137}
2138fr=parseInt(fr);to=parseInt(to);rep=parseInt(rep);freq=parseInt(freq);
2139var now  = this.setTime();
2140if(!now)return 1;
2141for (var i=0; i<=rep; i++) {
2142var period = i*freq*86400;
2143if (fr+period <= now && now <= to+period) return 1;
2144}
2145return 0;
2146}
2147function numeric(fmt, dp)
2148{
2149this.cvt = numCvt;
2150this.fmt = numFmt;
2151this.display = numDisplay;
2152this.parse = numParse;
2153this.delim = numDelim;
2154this.round = numRnd;
2155this.toLoc = numToLoc;
2156this.fromLoc = numFromLoc;
2157this.getDecPlaces=numDecimalPlaces;
2158this.roundTotalTable=[];
2159this.roundTotal=numRndTotal;
2160this.roundTotalSetup=numRndTotalSetup;
2161this.roundTotalSetup();
2162this.fmt(fmt, dp);
2163return this;
2164}
2165function numDelim() {return this.del2};
2166function numFmt(fmt, dp)
2167{
2168if(!regionalSettings.getCurrentSettings())
2169this.settings=regionalSettings.getMerchantSettings();
2170else
2171this.settings=regionalSettings.getCurrentSettings();
2172this.del2=this.settings.decimal;
2173this.del1=this.settings.thousand;
2174this.pos=this.settings.position;
2175this.dec_sep='.';
2176this.dec_num=tf.currentCurrency.decimal_places;
2177this.dec = (!dp||isNaN(dp))?1/Math.pow(10,this.dec_num):parseFloat(dp);
2178}
2179function numCvt(val, del)
2180{
2181var len = val.length;
2182if (len <= 3) return val;
2183if (val < 0 && len <= 4) return val;
2184var rem = this.cvt(val.substring(0, len - 3), del);
2185var dig = val.substring(len - 3, len);
2186if (rem == '') del = '';
2187return rem+del+dig;
2188}
2189function numToLoc(val)
2190{
2191val=''+val;val=val.replace(/^0*/,'');
2192var a=val.split(this.dec_sep);
2193if(a.length==1)return ''+parseFloat(val.replace(this.del2,''));
2194if(a.length>1){
2195if(!a[0])a[0]='0';if(!a[1])a[1]='0';
2196return ''+parseInt(a[0])+this.del2+a[1];
2197}
2198else return val;
2199}
2200function numFromLoc(val)
2201{
2202val=''+val;val=val.replace(/^0*/,'');
2203var a=val.split(this.del2);
2204if(a.length==1)return ''+parseFloat(val.replace(this.del1,''));
2205if(a.length>1){
2206if(!a[0])a[0]='0';if(!a[1])a[1]='0';
2207return ''+parseInt(a[0])+this.dec_sep+a[1];
2208}
2209else return val;
2210}
2211function numRnd(val,dp,roff)
2212{
2213var ret=val;
2214if (dp==null){ dp = this.dec; var dn=parseFloat(this.dec_num); }
2215else var dn=(1/dp).toString().length-1;
2216if (roff) return Math.round(val/roff)*roff;
2217if(!dp)return val;
2218var pow=Math.pow(10, dn+1);
2219return Math.round((val/dp)+(dn>0?1/pow:0))/(1/dp);
2220}
2221function numDecimalPlaces(v)
2222{
2223var s=v.toString();
2224s=s.substr(s.indexOf('.')+1);
2225return 1/Math.pow(10,s.length);
2226}
2227function numDisplay(val, dp, curSym)
2228{
2229if (dp==null) dp = this.dec;
2230val = this.round(val,1/Math.pow(10,dp)).toString();
2231var idx = val.indexOf(this.dec_sep);
2232var itr = (idx == -1)?val:val.substring(0, idx);
2233var dec = (idx == -1)?'':val.substring(idx+1, idx+dp+1);
2234itr = this.cvt(itr, this.del1);
2235for (var i=dec.length;i<dp; i++) dec += '0';
2236var ret=(dp<1)?itr:itr + this.del2 + dec;
2237switch(this.pos) {
2238case 1: ret=ret+curSym;break;
2239case 2: ret=curSym+' '+ret;break;
2240case 3: ret=ret+' '+curSym;break;
2241default: ret=curSym+ret;break;
2242}
2243return ret;
2244}
2245function numParse(str,dec)
2246{
2247str=str.toString();
2248if (str=='') return 0;
2249function _chg(s,del) {
2250var idx = s.indexOf(del);
2251if (idx == -1) return s;
2252var ts = s.substring(0, idx) + _chg(s.substring(idx+1, s.length));
2253return ts;
2254}
2255var pwr = Math.pow(10, (dec==null)?1:dec);
2256return (Math.round(parseFloat(_chg(str,this.del1))*pwr)/pwr);
2257}
2258function numRndTotalSetup()
2259{
2260var a='CHF,0.05;'.split(';');
2261for(var n=0,l=a.length;n<l;++n)
2262{
2263if(a[n])
2264{
2265var nv=a[n].split(',');
2266if(nv[0]&&nv[1])this.roundTotalTable[nv[0]]=parseFloat(nv[1]);
2267}
2268}
2269}
2270function numRndTotal(val,iso)
2271{
2272var rnd=this.roundTotalTable[iso];
2273if(rnd){
2274val=Math.round(val/rnd)*rnd;
2275}
2276return val;
2277}
2278var hexdelim	= "O";
2279var chrsz	= 8;
2280var hexcase = 0;
2281var b64pad  = "";
2282function add(s) {return binb2hex(core_sha1(str2binb(s),s.length * chrsz))}
2283function core_sha1(x, len)
2284{
2285x[len >> 5] |= 0x80 << (24 - len % 32)
2286x[((len + 64 >> 9) << 4) + 15] = len
2287var w = Array(80)
2288var a =  1732584193
2289var b = -271733879
2290var c = -1732584194
2291var d =  271733878
2292var e = -1009589776
2293for(var i = 0,ii=x.length; i < ii; i += 16)
2294{
2295var olda = a,oldb = b,oldc = c,oldd = d,olde = e;
2296for(var j = 0; j < 80; j++)
2297{
2298if(j < 16) w[j] = x[i + j];
2299else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1)
2300var t = safe_add(safe_add(rol(a, 5), ft(j, b, c, d)),
2301safe_add(safe_add(e, w[j]), kt(j)))
2302e = d
2303d = c
2304c = rol(b, 30)
2305b = a
2306a = t
2307}
2308a = safe_add(a, olda)
2309b = safe_add(b, oldb)
2310c = safe_add(c, oldc)
2311d = safe_add(d, oldd)
2312e = safe_add(e, olde)
2313}
2314return Array(a, b, c, d, e)
2315function ft(t, b, c, d)
2316{
2317if(t < 20) return (b & c) | ((~b) & d);
2318if(t < 40) return b ^ c ^ d;
2319if(t < 60) return (b & c) | (b & d) | (c & d);
2320return b ^ c ^ d;
2321}
2322function kt(t)
2323{
2324return (t < 20) ?  1518500249 : (t < 40) ?  1859775393 :
2325(t < 60) ? -1894007588 : -899497514;
2326}
2327}
2328function safe_add(x, y)
2329{
2330var lsw = (x & 0xFFFF) + (y & 0xFFFF)
2331var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
2332return (msw << 16) | (lsw & 0xFFFF)
2333}
2334function rol(num, cnt)
2335{
2336return (num << cnt) | (num >>> (32 - cnt))
2337}
2338function str2binb(str)
2339{
2340var bin = Array()
2341var mask = (1 << chrsz) - 1
2342for(var i = 0,ii=str.length * chrsz; i < ii; i += chrsz)
2343bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32)
2344return bin
2345}
2346function binb2hex(binarray)
2347{
2348var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef", a = [];
2349for(var i = 0, num = binarray.length * 4; i < num; i++)
2350{
2351a.push(hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
2352hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8  )) & 0xF));
2353}
2354return a.join('');
2355}
2356function place(s) {
2357var a=[];
2358for (var x = 0, num = s.length; x < num; x++) {
2359a.push(s.charCodeAt(x).toString(16));
2360}
2361return a.join('');
2362}
2363function show(v) {
2364var a=[];
2365if((v.length%2)==0){
2366for (var x = 0, num = v.length; x < num; x+=2) {
2367a.push(String.fromCharCode(parseInt(v.charAt(x)+v.charAt(x+1),16)));
2368}
2369}
2370return a.join('');
2371}
2372function stock()
2373{
2374this.init = stkInit;
2375this.check = stkCheck;
2376this.update = stkUpd;
2377this.code = stkCode;
2378return this;
2379}
2380function stkInit(min,max,avail,prdc,manc,dstc,prcc)
2381{
2382this.min = isNaN(min)?-1:parseFloat(min);
2383this.max = isNaN(max)?-1:parseFloat(max);
2384this.avail = isNaN(avail)?-1:parseFloat(avail);
2385this.prd_cd = prdc;
2386this.man_cd = manc;
2387this.dst_cd = dstc;
2388this.prc_cd = prcc;
2389this.used  = 0;
2390}
2391function stkCheck(itm)
2392{
2393function getMsg(title,msg,min,max,avail,used){
2394if(min>0 && used<min && qnty<min){
2395rc=1;
2396msg.push(title+'\n\n'+LD.LD_MIN_ORD_QTY+' '+min);
2397}
2398if(max>0 && used>max){
2399rc=1;
2400msg.push(title+'\n\n'+LD.LD_MAX_ORD_QTY+' '+max);
2401}
2402if(avail>=0 && used>avail){
2403rc=1;
2404msg.push(title+'\n\n'+LD.LD_STOCK_ORD_QTY+' '+avail);
2405}
2406return rc;
2407}
2408var rc=0,msg=[];
2409var qnty = parseFloat(itm.quantity),itemNo=itm.getItemNo();
2410if (!qnty||qnty<=0) return 0;
2411var used = qnty + this.used;
2412var min = this.min, max = this.max, avail = this.avail;
2413rc = getMsg(itm.title+' ['+itemNo+']',msg,min,max,avail,used);
2414var optcnt=itm.options.cnt();
2415for(var n=0;n<optcnt;n++){
2416var opt=itm.options.get(n);
2417if(opt.choice()==''||opt.combine||!opt.optId())continue;
2418var itemNo=opt.prop[3],stkopt=Basket.stk.getS(itemNo);
2419if(stkopt){
2420min=stkopt.min;max=stkopt.max;avail=stkopt.avail;
2421used = qnty + stkopt.used;
2422rc = getMsg(itm.title+'/'+opt.prop[0]+' ['+itemNo+']',msg,min,max,avail,used);
2423}
2424}
2425return [rc,msg.join('\n')];
2426}
2427function stkUpd(itm, neg)
2428{
2429if(itm.temporary)return;
2430if (neg == null) this.used += itm.quantity;
2431else this.used = Math.max(0, this.used - itm.quantity);
2432var optcnt=itm.options.cnt();
2433for(var n=0;n<optcnt;n++){
2434var opt=itm.options.get(n);
2435if(opt.choice()==''||opt.combine||!opt.optId())continue;
2436var stkopt=Basket.stk.getS(opt.prop[3]);
2437if(neg==null)stkopt.used += itm.quantity;
2438else stkopt.used = Math.max(0, stkopt.used - itm.quantity);
2439}
2440}
2441var _stkArr = new Array('min','max','avail');
2442function stkCode(str)
2443{
2444return ckCodeStr(this, _stkArr, '|', str);
2445}
2446var stkQryQueue=null;
2447var stkQryState={arrQS:{},arrQSLen:0,arrQSCnt:0};
2448function stkFetchBulk(fnSuccess,fnFail){
2449function upd(data){
2450var state=tf.core.stkQryState;
2451tf.core.stkFetchUpd(data);
2452state['arrQSCnt']++;
2453if(state['arrQSCnt']>=state['arrQSLen']){
2454var bsk=tf.core.Basket,it=new SF_Iterator(bsk.items),i=it.start(),msg=[],rc=0;
2455while (i!=null) {
2456var stk=bsk.stk.getS(i.getItemNo());
2457if(stk){
2458stk.update(i,'neg');
2459var chk=stk.check(i);
2460rc+=chk[0];
2461if(chk[1].length>0)msg=msg.concat(chk[1]);
2462}
2463i=it.next();
2464}
2465if(rc==0)fnSuccess();
2466else fnFail(msg);
2467}
2468}
2469tf.core.stkQryState['arrQSCnt']=tf.core.stkQryState['arrQSLen']=0;
2470var a=tf.core.stkQryState['arrQS'];
2471for(var qs in a)tf.core.stkQryState['arrQSLen']++;
2472for(var qs in a){
2473$.ajax({method:'POST',url:tf.wm.url('stkcontrol/stkControl.php','-'),data:a[qs],dataType:'json',async:true,processData:false})
2474.done(function(data,textStatus,jqXHR){
2475var ignoreCodes = {'-2':true,'-5':true,'-7':true,'-8':true};
2476if(!ignoreCodes[data.statuscode]&&data.statuscode<0&&data.errmsg)fnFail([data.errmsg]);
2477else upd(data);
2478})
2479.fail(function(data,textStatus,jqXHR){
2480fnFail(jqXHR.responseText);
2481})
2482;
2483}
2484}
2485function stkFetchUpd(o){
2486for(var itemNo in o.data){
2487var o2=o.data[itemNo];
2488if(typeof(o2)=='object'){
2489for(var n=0,nn=o2.length;n<nn;n++){
2490var prid=o2[n]['InternalID'];
2491tf.wm.pPropQty(prid,o2[n]['Quantity']);
2492tf.wm.pPropQty(itemNo,o2[n]['Quantity']);
2493tf.wm.pPropMin(prid,o2[n]['MinOrderQuantity']);
2494tf.wm.pPropMin(itemNo,o2[n]['MinOrderQuantity']);
2495tf.wm.pPropMax(prid,o2[n]['MaxOrderQuantity']);
2496tf.wm.pPropMax(itemNo,o2[n]['MaxOrderQuantity']);
2497var stk=tf.core.Basket.stk.getS(itemNo),pstk=tf.wm.pProp(itemNo);
2498if(stk){
2499if(!pstk)pstk=tf.wm.pProp(prid);
2500stk.avail=parseFloat(pstk[4]);
2501stk.min=parseFloat(pstk[2]);
2502stk.max=parseFloat(pstk[3]);
2503}
2504if(o2[n]['ProductID']==o2[n]['InternalID'])stkDisp(o2[n]['ProductID']+','+itemNo,o2[n]['Quantity']);
2505}
2506}
2507}
2508if(tf.equalHeight)tf.equalHeight();
2509tf.core.Basket.save();
2510if(tf.wm._pArr){
2511tf.wm._pArr['wssig']=tf.wssig;
2512tf.nametag.add('_pArr',tf.sfJSON.stringify(tf.wm._pArr,null,true));
2513}
2514}
2515function stkDisp(idcsv,fetchedQty){
2516if((location.hostname=='localhost' && location.port!='')||location.hostname=='')return;
2517var tfc=tf.content,a=idcsv.split(','),productID=a[0],itemNo=(a[1]=='undefined'?a[0]:a[1]);
2518var elText=tfc.document.getElementById('ProductStockAvailabilityText-'+productID)||tfc.document.getElementById('ProductStock-'+productID);
2519if(elText){
2520var elTLight=tfc.document.getElementById('ProductStockTlight-'+productID);
2521if(elTLight)elTLight.style.display='none';
2522var oldItemNo=(a[1]=='undefined'?'':tfc.stkSelectedChoice[productID]);
2523if(productID==itemNo&&oldItemNo&&oldItemNo!=productID)itemNo=oldItemNo;
2524var qty=tf.wm.pPropQty(itemNo),stk=tf.core.Basket.stk.getS(itemNo),msg='';
2525if(typeof(qty)=='undefined'){qty=tf.wm.pPropQty(productID);stk=tf.core.Basket.stk.getS(productID);}
2526if(typeof(qty)=='undefined'){qty=fetchedQty;}
2527if(typeof(qty)=='undefined'||qty<0){elText.innerHTML='';if(typeof(qty)=='undefined')setTimeout('stkDisp("'+idcsv+'")',100);}
2528if(typeof(tf)=='undefined' || typeof((tf.conf))=='undefined'){setTimeout('stkDisp("'+idcsv+'")',100);}
2529else{
2530if(stk)qty-=stk.used;qty=parseFloat(qty);
2531if(qty>=0){
2532var msgOutStock=(tf.conf.stkMsgOutStock[itemNo]?tf.conf.stkMsgOutStock[itemNo]:tf.conf.stkShopMsg[2]);
2533var trafficIdx=1;
2534if(qty==0){msg=msgOutStock;trafficIdx=3;}
2535else if(qty<=10){msg=tf.conf.stkShopMsg[1];trafficIdx=2;}
2536else msg=tf.conf.stkShopMsg[0];
2537if(elTLight){
2538elTLight.style.display='block';
2539for(var n=0,nn=elTLight.childNodes.length;n<nn;n++){
2540var elTL=elTLight.childNodes[n];
2541if(elTL.className)elTL.innerHTML=elTL.className.indexOf('ProductStockTlight'+trafficIdx)!=-1?'<span></span>':'';
2542}
2543if(msg)elText.innerHTML=msg;
2544}
2545else if(msg)elText.innerHTML='<span>'+ld('LD_AVAILABILITY','Availability')+'</span>: '+msg;
2546}
2547tfc.stkSelectedChoice[productID]=itemNo;
2548}
2549}
2550}
2551function dynObj(gid)
2552{
2553this.gid = gid;
2554this._arr = [];
2555this._idtags = [];
2556this._idxArr = {};
2557this._cnt = 0;
2558this.cnt = dOCnt;
2559this.idx = dOIdx;
2560this.add = dOAdd;
2561this.del = dODel;
2562this.get = dOGet;
2563this.getS = dOGetS;
2564this.getById = dOGetById;
2565this.empty = dOEmpty;
2566this.start = dOStart;
2567this.next  = dONext;
2568this.replace = dOReplace;
2569this.eAdd  = dOEAdd;
2570this.eAddS = dOEAddS;
2571this.reidx = dOReidx;
2572}
2573function dOReidx()
2574{
2575this._idtags = [];
2576this._idxArr = {};
2577for(var i=0;i<this._cnt;i++){
2578this._idtags.push(this._arr[i].idtag);
2579this._idxArr[this._arr[i].idtag]=i;
2580}
2581}
2582function dOCnt()
2583{
2584return this._cnt;
2585}
2586function dOIdx(idtag)
2587{
2588var i=this._idxArr[idtag];
2589if(typeof(i)=='undefined')return -1;
2590return i;
2591}
2592function dOAdd(obj)
2593{
2594var idx = this.idx(obj.idtag);
2595if (idx!=-1) return 0;
2596if (!isNaN(obj.idtag)) obj.idtag = (obj.id&&isNaN(obj.id))?'_'+obj.id:this._cnt;
2597this._arr[this._cnt++] = obj;
2598this.reidx();
2599return 1;
2600}
2601function dODel(idx)
2602{
2603if (isNaN(idx)) {
2604idx = this.idx('_'+idx);
2605if (idx==-1) return '';
2606}
2607if (idx<0 || idx>=this._cnt) return '';
2608for (var i=idx; i<this._cnt-1; i++) this.replace(i, this._arr[i+1]);
2609this._cnt--;
2610delete this._arr[this._cnt];
2611this.reidx();
2612}
2613function dOReplace(idx, obj)
2614{
2615if (isNaN(idx)) return this.replace(this.idx('_'+idx));
2616if (idx<0 || idx>this._cnt) return this.add(obj);
2617this._arr[idx] = obj;
2618this.reidx();
2619}
2620function dOGet(idx)
2621{
2622if (isNaN(idx)){
2623var i=this._idxArr['_'+idx];
2624if(typeof(i)=='undefined')return '';
2625return this._arr[i];
2626}
2627if (idx<0||idx>=this._cnt) return '';
2628return this._arr[idx];
2629}
2630function dOGetS(idx)
2631{
2632var i=this._idxArr['_'+idx];
2633if(typeof(i)=='undefined')return '';
2634return this._arr[i];
2635}
2636function dOStart()
2637{
2638this._idx = 0;
2639return this._arr[0];
2640}
2641function dONext()
2642{
2643return this._arr[++this._idx];
2644}
2645function dOEmpty(idtag)
2646{
2647if (idtag==null) idtag = this._cnt;
2648else idtag = '_'+idtag;
2649var tmp;
2650switch(this.gid){
2651case 'range':tmp=new range();break;
2652case 'tax_regn':tmp=new tax_regn();break;
2653case 'item':tmp=new item();break;
2654case 'stock':tmp=new stock();break;
2655case 'discount':tmp=new discount();break;
2656case 'keyval':tmp=new keyval();break;
2657case 'options':tmp=new options();break;
2658default:tmp=null;break;
2659}
2660if(tmp){
2661tmp.gid = this.gid;
2662tmp.idtag = idtag;
2663}
2664return tmp;
2665}
2666function dOEAdd(idtag, a)
2667{
2668var obj = this.get(idtag);
2669if (obj!='') return obj;
2670var s='obj.init(';for (var i=0;i<a.length-1;i++) s+='a['+i+'],';s+='a['+i+'])';
2671obj=this.empty(idtag); eval(s);
2672this.add(obj);
2673return obj;
2674}
2675function dOEAddS(idtag, a)
2676{
2677var obj = this.getS(idtag);
2678if (obj!='') return obj;
2679var s='obj.init(';for (var i=0;i<a.length-1;i++) s+='a['+i+'],';s+='a['+i+'])';
2680obj=this.empty(idtag); eval(s);
2681this.add(obj);
2682return obj;
2683}
2684function dOGetById(idtag) {
2685var gd=null;
2686if (isNaN(idtag)) idtag='_'+idtag;
2687var i=this.start();
2688while(i!=null) {
2689if (i.idtag==idtag) {gd=i;break;}
2690i=this.next();
2691}
2692return gd;
2693}
2694function SF_Iterator(obj) {
2695this.obj=obj;
2696this.objarr=obj._arr
2697this.idx=0;
2698this.start=itStart;
2699this.next=itNext;
2700}
2701function itStart() {
2702this._idx = 0;
2703return this.objarr[0];
2704}
2705function itNext()
2706{return this.objarr[++this._idx];}
2707function iField(field)
2708{
2709var type = field.type;
2710var idx	= 0;
2711var value = '', origvalue = '';
2712switch (type) {
2713case 'hidden':
2714value = field.value;
2715break;
2716case 'text':
2717case 'textarea':
2718idx = 1;
2719var a = field.getAttribute('metavalue');
2720if (a) { a = a.split(str_sep1); a[0] = field.value; value = a.join(str_sep1);}
2721else { value = field.value; }
2722this.rawValue = field.value;
2723break;
2724case 'radio':
2725idx = $(field).parent().parent().children('.ProductChoiceName').index($(field).parent())+1;
2726if (field.checked) value = field.value;
2727break;
2728case 'checkbox':
2729idx = 1;
2730value = field.value;
2731this.rawValue = field.checked ? '1' : '0';
2732break;
2733case 'select-one':
2734idx = field.selectedIndex;
2735idx=(idx>0)?idx:0;
2736if(field[idx].getAttribute('data-nosel')===''){
2737idx++;
2738value = field[idx].getAttribute('origvalue');
2739}
2740else value = field[idx].value;
2741origvalue = field[idx].getAttribute('origvalue');
2742break;
2743}
2744this.ctrl   = field;
2745this.value	= value;
2746this.origValue = origvalue || field.getAttribute('origvalue');
2747this.idx	= idx;
2748this.type	= type;
2749this.name	= field.name;
2750this.display	= field.display;
2751if (!def(this.display)) this.display = '';
2752return this;
2753}
2754function iForm(form)
2755{
2756this.getField = iformGFld;
2757this.getValue = iformGVal;
2758this.getOriginalValue = iformGOrigVal;
2759this.getIdx = iformGIdx;
2760this.count = 0;
2761this.fields = new Array();
2762for (var i=0; i<form.length; i++) {
2763var fld = new iField(form[i]);
2764if (fld.value == '' && fld.type != 'radio') continue;
2765var exist = this.getField(fld.name);
2766if (exist != '') {
2767if (fld.type == 'radio') {
2768if (fld.value != '' && exist.value == '') {
2769exist.value = fld.ctrl.value;
2770exist.origValue = fld.origValue;
2771exist.idx = fld.idx;
2772}
2773}
2774else exist.value += '&&' + fld.value;
2775}
2776else this.fields[this.count++] = fld;
2777}
2778return this;
2779}
2780function iformGFld(name)
2781{
2782var str = '';
2783for (var i=0; i<this.count; i++)
2784if (this.fields[i].name == name) return this.fields[i];
2785return '';
2786}
2787function iformGVal(name)
2788{
2789var val = this.getField(name).value;
2790return def(val);
2791}
2792function iformGOrigVal(name)
2793{
2794var val = this.getField(name).origValue;
2795return def(val);
2796}
2797function iformGIdx(name)
2798{
2799var val = this.getField(name).idx;
2800return def(val);
2801}
2802function options()
2803{
2804this.prop	= new Array();
2805this.order	= _oArr;
2806this.separator	= ',';
2807this.init	= optInit;
2808this.check	= optCheck;
2809this.choiceId = optChoiceId;
2810this.choice	= optChoice;
2811this.price	= optPrice;
2812this.calcedPrice = optCalcedPrice;
2813this.weight	= optWeight;
2814this.optId	= optOptId;
2815this.internalOptId	= optInternalOptId;
2816this.code	= optCode;
2817this.idxPrc = 0;
2818return this;
2819}
2820function optInit(arr, value)
2821{
2822this.name  = arr[1];
2823this.title = arr[2];
2824this.type  = arr[3]==1;
2825this.opttype = arr[4];
2826this.combine = arr[5];
2827this.value = value;
2828this.prop  = value.split(str_sep1);
2829}
2830function optCheck()
2831{
2832if (this.prop[0] == '' && this.type) {
2833return this.title;
2834}
2835return '';
2836}
2837function optChoice()
2838{
2839return this.prop[0];
2840}
2841function optChoiceId()
2842{
2843return this.prop[7];
2844}
2845function optPrice(newPrc)
2846{
2847if (newPrc != null) {
2848this.prop[1] = newPrc;
2849}
2850else {
2851var prc = this.prop[1];
2852return (!def(prc))?0:parseFloat(prc);
2853}
2854}
2855function optCalcedPrice()
2856{
2857var prc = 0;
2858switch(this.opttype){
2859case 1:
2860case 2:
2861if (this.prop[0] != '') prc = this.prop[1];
2862break;
2863default:
2864prc = this.prop[1];
2865break;
2866}
2867return (!def(prc))?0:parseFloat(prc);
2868}
2869function optWeight()
2870{
2871var wght = this.prop[2];
2872return (!def(wght))?0:parseFloat(wght);
2873}
2874function optOptId()
2875{
2876var id = this.prop[3];
2877if (id == ' ') id = '';
2878return (!def(id))?'':id;
2879}
2880function optInternalOptId()
2881{
2882var id = this.prop[7];
2883if (id.indexOf('C')>-1) id=id.substr(0,id.indexOf('C'));
2884return (!def(id))?'':id;
2885}
2886var _oArr=['prop[0]','prop[1]','prop[2]','prop[3]','title','combine','prop[4]','prop[5]','prop[6]','prop[7]','idxPrc'];
2887function optCode(str)
2888{
2889if (this.choice() === '') return '';
2890return ckCodeStr(this, _oArr, ',', str);
2891}
2892function range()
2893{
2894this.init = rgInit;
2895this.getData = rgGetData;
2896return this;
2897}
2898function rgInit(min,max,data)
2899{
2900if (max == null) {
2901var arr = min.split(',');
2902return this.init(arr[0], arr[1], arr[2]);
2903}
2904this.min = min;
2905this.max = max;
2906this.data = data;
2907}
2908function rgGetData(value, type)
2909{
2910if (type==null) type=0;
2911if (this.min==this.max) type=1;
2912if (type==1) if (this.min <= value) return this.data;
2913if (this.min <= value && value < this.max) return this.data;
2914return '';
2915}
2916function keyval()
2917{
2918this.init = srInit;
2919this.val =  srVal;
2920}
2921function srInit(i,v,s)
2922{
2923this._id = i;
2924this.val(v);
2925this.str = (s==null)?'':s;
2926}
2927function srVal(v)
2928{
2929if (v!=null) this._val = v;
2930return this._val;
2931}
2932function discount()
2933{
2934this.rg = new dynObj('range');
2935this.init = discInit;
2936this.getData = discData;
2937this.amount = discAmount;
2938this.purchasePrice = discPurchasePrice;
2939this.purchasePriceByPrice = discPurchasePriceByPrice;
2940this.getNextRange = discGetNextRange;
2941this.free = discFree;
2942this.code = discCode;
2943this.useLimitToCode = discUseLimitToCode;
2944this.canApplyToProduct = discCanApplyToProduct;
2945return this;
2946}
2947function discInit(type, val, tlim, del1, del2, limitToCodeType, limitToCodes)
2948{
2949this.type = type;
2950this.value = val;
2951this.tlim = tlim;
2952this.del1 = (del1==null)?';':del1;
2953this.del2 = (del2==null)?',':del2;
2954this.limitToCodeType = limitToCodeType;
2955this.limitToCodes = str_sep1 + limitToCodes + str_sep1;
2956var a1 = this.value.split(this.del1);
2957for (var i=0; i<a1.length; i++) {
2958var a2 = a1[i].split(this.del2);
2959if (a2.length == 1) continue;
2960var tmp = this.rg.empty();
2961tmp.init(a2[0],a2[1],a2[2]);
2962this.rg.add(tmp);
2963}
2964}
2965function discUseLimitToCode(){
2966return this.limitToCodeType >= 0 && this.limitToCodes;
2967}
2968function discCanApplyToProduct(prd){
2969if (!this.useLimitToCode()) return true;
2970var code = prodTypeCode(this.limitToCodeType,prd);
2971var pos = this.limitToCodes.indexOf(str_sep1 + code + str_sep1);
2972return (pos != -1);
2973}
2974function discData(key,type,getO)
2975{
2976var cnt = this.rg.cnt();
2977if (!cnt) return '';
2978if (!currTime.isActive(this.tlim)||key<this.rg.get(0).min) return '';
2979for (var i=0; i<cnt; i++) {
2980var rg = this.rg.get(i);
2981if (rg == '') return '';
2982var data = rg.getData(key,type);
2983if (data!='') return (data=='-')?'':(getO)?rg:data;
2984}
2985var rg = this.rg.get(cnt-1);
2986return (getO)?rg:rg.data;
2987}
2988function discGetNextRange(key)
2989{
2990var cnt = this.rg.cnt();
2991if (!cnt) return '';
2992if (key<this.rg.get(0).min) return this.rg.get(0);
2993var flag=false;
2994for (var i=0; i<cnt; i++) {
2995var rg = this.rg.get(i);
2996if (rg == '') return '';
2997if (flag) return rg;
2998var data = rg.getData(key);
2999if (data!='') flag=true;
3000}
3001return '';
3002}
3003function discAmount(prc,qnty,oprc,prd)
3004{
3005var type=this.type.toString();
3006if (false)
3007return 0;
3008if (prd && !this.canApplyToProduct(prd)) return 0;
3009var p=0,perc = 0;
3010if (!currTime.isActive(this.tlim)) return p;
3011var prc2=prc+(type=='5'?0:oprc);
3012switch(type) {
3013case '0': p=prc-parseFloat(this.value==''||isNaN(this.value)?0:this.value); break;
3014case '1': case '10': case '11': p=prc2*(parseFloat(this.value)/100);break;
3015case '5': perc=this.getData(qnty);p=(isNaN(perc))?0:(prc2-perc);break;
3016case '4': perc=this.getData(qnty);
3017p=(isNaN(perc))?0:prc2*(perc/100);break;
3018}
3019if (p>=(type==0?prc:prc2)||p<0){if((p==(type==0?prc:prc2)&&(type=='10'||type=='11'))||(type=='1'&&prc2<0))return p;else return 0;}
3020return p;
3021}
3022function discPurchasePrice(prc) {
3023var type=this.type.toString();
3024if (type==4)return 0;
3025if (false) return 0;
3026var perc=this.getData(prc);
3027var p=(isNaN(perc))?0:(prc)*(perc/100);
3028if (p>=prc) return 0;
3029return p;
3030}
3031function discPurchasePriceByPrice(prc,discPrice) {
3032var type=this.type.toString();
3033if (type==4)return 0;
3034if (false) return 0;
3035var perc=this.getData(discPrice);
3036var p=(isNaN(perc))?0:(prc)*(perc/100);
3037if (p>=prc) return 0;
3038return p;
3039}
3040function discFree(qnty)
3041{
3042var type=this.type.toString();
3043if (false)
3044return 0;
3045switch(this.type) {
3046case '2': case '3': case '103': return this.getData(qnty);
3047case '103': return new Array(1,this.getData(qnty));
3048}
3049return '';
3050}
3051var _dArr = new Array('type','value','tlim');
3052function discCode(str)
3053{
3054return ckCodeStr(this, _dArr, '|', str);
3055}
3056var rules = new Array();
3057var taxExemptObj=new taxExempt();
3058function taxExempt()
3059{
3060this.len=new Function('x','return this.s.length==x');
3061this.chr=new Function('x','y','x=this.s.charAt(x);return y?(x==y):("A"<=x&&x<="z")');
3062this.num=new Function('x','y','x=this.s.substring(x,y);return parseInt(x.replace(/^0+/,\'\'))==x');
3063this.chk=function(s,c){
3064this.s=s.toUpperCase();
3065var rule=rules[c],len=c.length;
3066if(!rule&&len>4){rule=rules[c.substr(0,4)];}
3067if(!rule&&len>2){rule=rules[c.substr(0,2)];}
3068return rule?eval(rule):1;
3069}
3070this.euroCountries=createMap(['AT','BE','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','HU','IE','IT','LT','LU','LV','MT','NL','PL','PT','SE','SI','SK','BG','RO']);
3071}
3072rules['AT']="L(9)&&C(0,'U')&&N(1,8)";
3073rules['BE']="L(10)&&N(0,10)";
3074rules['BG']="(L(9)&&N(0,9))||(L(10)&&N(0,10))";
3075rules['CY']="L(9)&&(N(0,8)&&C(8))";
3076rules['CZ']="(L(8)&&N(0,8))||(L(9)&&N(0,9))||(L(10)&&N(0,10))";
3077rules['DE']="L(9)&&N(0,9)";
3078rules['DK']="L(8)&&N(0,8)";
3079rules['EE']="L(9)&&N(0,9)";
3080rules['ES']="L(9)&&((C(0)&&N(1,8))||(N(0,8)&&C(8))||(C(0)&&C(8)&&N(1,7)))";
3081rules['FI']="L(8)&&N(0,8)";
3082rules['FR']="L(11)&&N(2,11)";
3083rules['GR']="L(9)&&N(0,9)";
3084rules['HU']="L(8)&&N(0,8)";
3085rules['IE']="(L(8)&&C(7)&&(N(0,7)||(N(0,1)&&C(1)&&N(2,7))))||(L(9)&&N(0,7)&&C(7)&&C(8))";
3086rules['IT']="L(11)&&N(0,11)";
3087rules['LT']="(L(9)&&N(0,9))||(L(12)&&N(0,12))";
3088rules['LU']="L(8)&&N(0,8)";
3089rules['LV']="L(11)&&N(0,11)";
3090rules['MT']="L(8)&&N(0,8)";
3091rules['NL']="L(12)&&N(0,8)&&C(9,'B')&&N(10,12)";
3092rules['PL']="L(10)&&N(0,10)";
3093rules['PT']="L(9)&&N(0,9)";
3094rules['RO']="(L(2)&&N(0,2))||(L(3)&&N(0,3))||(L(4)&&N(0,4))||(L(5)&&N(0,5))||(L(6)&&N(0,6))||(L(7)&&N(0,7))||(L(8)&&N(0,8))||(L(9)&&N(0,9))||(L(10)&&N(0,10))";
3095rules['SE']="L(12)&&N(0,10)&&C(10,'0')&&C(11,'1')";
3096rules['SI']="L(8)&&N(0,8)";
3097rules['SK']="L(10)&&N(0,10)";
3098rules['UK']="C(0,'G')&&C(1,'B')&&((L(11)&&N(2,11))||(L(15)&&N(2,15))||(L(8)&&C(2,'G')&&C(3,'D')&&N(4,8))||(L(8)&&C(2,'H')&&C(3,'A')&&N(4,8)))";
3099var taxExemptCtryPre={'GR':'EL'};
3100function rplTxEx(s,f,t){
3101var i=s.indexOf(f);
3102if (i==-1) return s;
3103return rplTxEx(s.substring(0,i)+t+s.substring(i+f.length,s.length), f, t);
3104}
3105for (i in rules) {
3106rules[i] = rplTxEx(rules[i],'L(','this.len(');
3107rules[i] = rplTxEx(rules[i],'C(','this.chr(');
3108rules[i] = rplTxEx(rules[i],'N(','this.num(');
3109}
3110function tax_regn()
3111{
3112this.init = taxRInit;
3113this.calcShipAmt = taxCalcShipAmt;
3114return this;
3115}
3116function taxRInit(i,c,p,t,e,it,additive)
3117{
3118this.id	  = i;
3119this.code = c;
3120this.perc = parseFloat(p);
3121this.taxName	= t;
3122this.exempt	= e;
3123this.exNo	= '';
3124this.incTax	= it;
3125this.prodAmt = 0;
3126this.additive = additive;
3127this.cache	= 0;
3128}
3129function taxCalcShipAmt(sumRates,avgAmt) {
3130if (this.exempt && this.exNo) return 0;
3131return avgAmt*this.perc/(100*sumRates);
3132}
3133function tax()
3134{
3135this._tax = new dynObj('tax_regn');
3136this._rgn = new Array();
3137this.exNo = '';
3138this.init	= taxInit;
3139this.getDefaultReg=taxGetDefaultReg;
3140this.currRegn	= taxCurrRegn;
3141this.addArea	= taxAddArea;
3142this.regnName	= taxRegnName;
3143this.cntInc	= taxCntInc;
3144this.regnRate	= taxRegnRate;
3145this.forRegion	= taxForRegion;
3146this.rate	= taxRate;
3147this.amt	= taxAmt;
3148this.allAmt	= taxAllAmt;
3149this.singleAmt	= taxSingleAmt;
3150this.inTax	= taxInTax;
3151this.exTax	= taxExTax;
3152this.calcTax	= taxCalcTax;
3153this.disp	= taxDisp;
3154this.dispValues	= taxDispValues;
3155this.dispTexts = taxDispTexts;
3156this.taxAppliedRawAmt = taxTaxAppliedRawAmt;
3157this.list	= taxList;
3158this.allCodes	= taxAllCodes;
3159this.allIDs	= taxAllIDs;
3160this.ship	= taxShip;
3161this.isEmpty	= taxIsEmpty;
3162this.anyTaxInclCountry=taxAnyTaxInclCountry;
3163this.anyTaxForRegion=taxAnyTaxForRegion;
3164this.findMajorityTaxID=taxFindMajorityTaxID;
3165this.mapRegn	= {};
3166this.mapTax	= {};
3167this.resetCache = taxResetCache;
3168return this;
3169}
3170function taxInit(d,s)
3171{
3172this._default	= d;
3173this.showBoth	= s;
3174}
3175function taxGetDefaultReg(){
3176if (this._default) return this._default;
3177var rc=window.shopRegion;
3178var _t = this._tax.start();
3179while (_t!=null) {
3180if (rc.indexOf(_t.code)==0&&_t.code.length>this._default.length) this._default=_t.code;
3181_t  = this._tax.next();
3182}
3183if (!this._default) this._default=rc;
3184return this._default;
3185}
3186function taxCurrRegn(rc)
3187{
3188if (!rc) this._current = rc;
3189else rc=this._current;
3190if (!rc) rc=window.region;
3191if (!rc) rc=this.getDefaultReg();
3192this._current=rc;
3193return rc;
3194}
3195function taxAddArea(id,c,p,t,r,inc,additive)
3196{
3197var tr = this._tax.get(id);
3198if (tr == '') tr = this._tax.eAdd(id, new Array(id,c,p,t,r,inc,additive||false));
3199else tr.code += ','+c;
3200if(this.mapRegn[c]) {
3201if(!this.mapTax[id]) this.mapRegn[c]+=','+id;
3202} else {
3203this.mapRegn[c]=id;
3204}
3205this.mapTax[id]=tr.code;
3206return 0;
3207}
3208function taxForRegion(tax,reg,exact) {
3209if(!tax||!reg||!this.mapTax[tax])return false;
3210var tmp=this.mapTax[tax].split(',');
3211for(var i=0,num=tmp.length;i<num;i++){
3212if(exact){if(reg==tmp[i]) return true;}
3213else if(reg.indexOf(tmp[i])==0) return true;
3214}
3215return false;
3216}
3217function taxRegnName(rc,rn)
3218{
3219if (rn != null) this._rgn[rc] = rn;
3220return (this._rgn[rc]==null)?'':this._rgn[rc];
3221}
3222function taxRegnRate(tid,c,ign)
3223{
3224if (tid == '') return 0;
3225var a = tid.split(','), aAdditive = [];
3226var ret=0;
3227for (var j=0; j<a.length; j++) {
3228if(!a[j])continue;
3229var tr = this._tax.get(a[j]);
3230if (tr=='') continue;
3231if (tr.exempt && tr.exNo && !ign) continue;
3232if (c==null || c=='') c=this.currRegn();
3233if (c==-1) c=(this.anyTaxInclCountry(this.currRegn()))?this.currRegn():'NL';
3234if (tr.additive) { aAdditive.push(tr); continue; }
3235var cd=tr.code.split(',');
3236var tmpreg='',tmpval=0;
3237for (var i=0; i<cd.length; i++) {
3238if (cd[i]=='') continue;
3239if (c.indexOf(cd[i])==0) {
3240if (tmpreg.length<cd[i].length) {
3241tmpreg=cd[i];
3242tmpval=tr.perc;
3243}
3244}
3245}
3246ret+=tmpval/100;
3247}
3248for (var j=0; j<aAdditive.length; j++) {
3249var tr = aAdditive[j];
3250var cd=tr.code.split(',');
3251var tmpreg='',tmpval=0;
3252for (var i=0; i<cd.length; i++) {
3253if (cd[i]=='') continue;
3254if (c.indexOf(cd[i])==0) {
3255if (tmpreg.length<cd[i].length) {
3256tmpreg=cd[i];
3257tmpval=tr.perc/100;
3258}
3259}
3260}
3261ret=(ret*(1+tmpval))+tmpval;
3262}
3263return ret;
3264}
3265function taxAnyTaxInclCountry(regn) {
3266var it = new SF_Iterator(this._tax);
3267var _t=it.start();
3268while (_t!=null) {
3269if(_t.incTax&&this.forRegion(_t.id,regn)) return true;
3270_t = it.next();
3271}
3272return false;
3273}
3274function taxAnyTaxForRegion(regn) {
3275var it = new SF_Iterator(this._tax);
3276var _t=it.start();
3277while (_t!=null) {
3278if(this.forRegion(_t.id,regn)) return true;
3279_t = it.next();
3280}
3281return false;
3282}
3283function taxFindMajorityTaxID(regn) {
3284function findMajorityTaxIDAtSameLevel(o,rgn) {
3285var it = new SF_Iterator(o._tax),_t=it.start(),high=0,highRate=0,highID='';
3286while (_t!=null) {
3287if (o.forRegion(_t['id'],rgn,true) && typeof(_t['prodAmt'])!='undefined'){
3288var rate=_t['perc'];
3289if (_t['prodAmt']>high || (_t['prodAmt']==high && rate>highRate)) { high=_t['prodAmt']; highRate=rate; highID=_t['id']; }
3290}
3291_t = it.next();
3292}
3293return highID+(highID?',':'');
3294}
3295var highID='',rgn=regn;
3296highID+=findMajorityTaxIDAtSameLevel(this,rgn.substr(0,2));
3297if(rgn.length>2)highID+=findMajorityTaxIDAtSameLevel(this,rgn.substr(0,4));
3298if(rgn.length>4)highID+=findMajorityTaxIDAtSameLevel(this,rgn);
3299return highID;
3300}
3301function taxRate(i,c)
3302{
3303var a = i.split(',');
3304var r = 0;
3305for (var j=0; j<a.length; j++) r += this.regnRate(a[j], c);
3306return r;
3307}
3308function taxAmt(inc,i,p,c)
3309{
3310var r = this.rate(i,c);
3311var amt = p * r * 10 / 10;
3312var val = (inc)?amt/(1+r):amt;
3313return val;
3314}
3315function taxAllAmt(i,p,c)
3316{
3317if (!c) c=this.currRegn();
3318var tot=0;
3319p=this.exTax(i,p);
3320var a = i.split(',');
3321for (var j=0,jj=a.length; j<jj; j++){
3322if(!a[j])continue;
3323var t=this._tax.get(a[j]);
3324if (t && !t.additive) tot += this.amt(0,a[j],p);
3325}
3326for (var j=0,jj=a.length; j<jj; j++){
3327if(!a[j])continue;
3328var t=this._tax.get(a[j]);
3329if (t && t.additive) tot += this.amt(0,a[j],p+tot);
3330}
3331return tot;
3332}
3333function taxSingleAmt(i,p,c)
3334{
3335var r = this.regnRate(i, c)
3336var val = p * r * 10 / 10;
3337return val;
3338}
3339function taxInTax(i,p,c)
3340{
3341p = this.exTax(i,p);
3342var amt = this.amt(0,i,p,c);
3343var val = p+amt;
3344return val;
3345}
3346function taxExTax(i,p,uadd)
3347{
3348var prc = parseFloat(p);
3349var a = i.split(',');
3350var r=0;
3351uadd=uadd||false;
3352for (var j=0,jj=a.length; j<jj; j++){
3353if(!a[j])continue;
3354var t=this._tax.get(a[j]);
3355if (t&&t.additive==uadd) r += t.incTax?this.regnRate(a[j],-1,1):0;
3356}
3357prc-=prc*r/(1+r);
3358return prc;
3359}
3360function taxCalcTax(i,p,c,uadd)
3361{
3362if (!c) c=this.currRegn();
3363if (this.exempt && this.exNo) return this.exTax(i,p);
3364var a = i.split(',');
3365var d=0;
3366var exPrc=this.exTax(i,p);
3367uadd=uadd||false;
3368for (var j=0,jj=a.length; j<jj; j++){
3369if(!a[j])continue;
3370var t=this._tax.get(a[j]);
3371if (t&&t.additive==uadd) d+=t.incTax?this.singleAmt(a[j],exPrc,c):0;
3372}
3373var val = exPrc+d;
3374return val;
3375}
3376function taxDisp(i,p,co,ccr,onpage,tinc,texc,symbolClass)
3377{
3378var exT = this.exTax(i,p);
3379var inT = exT+this.allAmt(i,p);
3380if (ccr != null && ccr!=0) {
3381inT /= ccr;
3382exT /= ccr;
3383}
3384var s='';
3385if (this.isEmpty(i)||exT>=inT) { s=(onpage?dPrc(inT,1,false,true,symbolClass):'\n '+showPrc(inT));}
3386else {
3387if (this.showBoth && inT>exT) {
3388if(onpage) {
3389if(this._tax.get(i).incTax){
3390var p1t=tinc, p1a=dPrc(inT,1,false,true,symbolClass);
3391var p2t=texc, p2a=dPrc(exT,1,false,true);
3392}
3393else{
3394var p1t=texc, p1a=dPrc(exT,1,false,true,symbolClass);
3395var p2t=tinc, p2a=dPrc(inT,1,false,true);
3396}
3397s='<span class="ProductPriceGroup"><span class="ProductPriceGroupPart1"><span class="ProductPriceGroupPart1_Text">'+p1t+'</span> <span class="ProductPriceGroupPart1_Amt">'+p1a+'</span></span> <span class="ProductPriceGroupPart2"><span class="ProductPriceGroupPart2_Text">'+p2t+'</span> <span class="ProductPriceGroupPart2_Amt">'+p2a+'</span></span></span>';
3398}
3399else s='\n - '+LD.LD_INC_TOTAL_TAX+' '+showPrc(inT)+' '+LD.LD_EX_TOTAL_TAX+' '+showPrc(exT);
3400} else {
3401s=dPrc(p,1,false,true,symbolClass);
3402}
3403}
3404return s;
3405}
3406function taxDispValues(i,p,ccr,tinc,texc,symbolClass)
3407{
3408var exT = this.exTax(i,p);
3409var inT = exT+this.allAmt(i,p);
3410if (ccr != null && ccr!=0) {
3411inT /= ccr;
3412exT /= ccr;
3413}
3414var p1t='', p1a=null, p2t='', p2a=null;
3415if (this.isEmpty(i)||exT>=inT) { p1a=dPrc(inT,1,false,true,symbolClass);}
3416else {
3417if (this.showBoth && inT>exT) {
3418if(this._tax.get(i).incTax){
3419p1t=tinc;
3420p1a=dPrc(inT,1,false,true,symbolClass);
3421p2t=texc;
3422p2a=dPrc(exT,1,false,true);
3423}
3424else{
3425p1t=texc;
3426p1a=dPrc(exT,1,false,true,symbolClass);
3427p2t=tinc;
3428p2a=dPrc(inT,1,false,true);
3429}
3430} else {
3431p1a=dPrc(p,1,false,true,symbolClass);
3432p1t=(this._tax.get(i).incTax ? tinc : texc);
3433}
3434}
3435return {p1t:p1t, p1a:p1a, p2t:p2t, p2a:p2a};
3436}
3437function taxDispTexts(txids,tsI,tsIx)
3438{
3439var a=txids.split(','),tinc='',texc='',tid=txids;
3440var otinc={},otexc={};
3441for (var i=0,ii=a.length; i<ii; i++){
3442if(tsI[a[i]])otinc[tsI[a[i]]]=true;
3443if(tsIx[a[i]])otexc[tsIx[a[i]]]=true;
3444if(typeof(tsI[a[i]])!='undefined')tid=a[i];
3445}
3446for(var s in otinc){tinc+=', '+s;}
3447for(var s in otexc){texc+=', '+s;}
3448tinc=tinc.substr(2);
3449texc=texc.substr(2);
3450return [tid,tinc,texc];
3451}
3452function taxTaxAppliedRawAmt(i,p,ccr)
3453{
3454var exT = this.exTax(i,p);
3455var inT = exT+this.allAmt(i,p);
3456if (ccr != null && ccr!=0) {
3457inT /= ccr;
3458exT /= ccr;
3459}
3460var ret = 0;
3461if (this.isEmpty(i)||Math.abs(exT)>=Math.abs(inT)) { ret = inT; }
3462else {
3463if (this.showBoth && Math.abs(inT)>Math.abs(exT)) {
3464ret = this._tax.get(i).incTax ? inT : exT;
3465}
3466else {
3467ret = p;
3468}
3469}
3470return ret;
3471}
3472function taxList(taxes)
3473{
3474var a=taxes.split(',');
3475var ret = new Array();
3476for (i=0; i<a.length; i++) {
3477if (!this.regnRate(a[i])) continue;
3478var t=this._tax.get(a[i]);
3479if (t=='') continue;
3480ret[ret.length] = t;
3481}
3482return ret;
3483}
3484function taxAllCodes(uadd)
3485{
3486var s = '';
3487var _t = this._tax.start();
3488uadd=uadd||false;
3489while (_t!=null) {
3490if(_t.additive==uadd) s += _t.code + ',';
3491_t  = this._tax.next();
3492}
3493return s;
3494}
3495function taxAllIDs(uadd)
3496{
3497var s = new Array();
3498var _t = this._tax.start();
3499uadd=uadd||false;
3500while (_t!=null) {
3501if(_t.additive==uadd)s.push(_t.id);
3502_t = this._tax.next();
3503}
3504return s.join(',');
3505}
3506function taxShip(amt)
3507{
3508if (amt!=null) this._stax=amt;
3509return this._stax?this._stax:0;
3510}
3511function taxCntInc(items) {
3512var itm=items.start();
3513var a;
3514while (itm!=null) {
3515a=itm.taxes.split(',');
3516for (var j=0; j<a.length; j++)
3517if (a[j]&&this._tax.get(a[j])&&this._tax.get(a[j]).incTax&&this._tax.get(a[j]).perc>0) return true;
3518itm=items.next();
3519}
3520return false;
3521}
3522function taxIsEmpty(i,rcode) {
3523var a=i.split(',');
3524for (var j=0; j<a.length; j++) {
3525if(!a[j])continue;
3526var tax=this._tax.get(a[j]);
3527if (rcode) {
3528if (tax&&tax.perc>0){
3529var ad=false, t = tax.code.split(',');
3530for(k=0;k<t.length;k++){var lRegion = rcode.substr(0,Math.min(t[k].length,rcode.length));if(t[k].indexOf(lRegion)==0){ad=true;break}}
3531if(ad) return false;
3532}
3533} else {
3534if (tax&&tax.perc>0) return false;
3535}
3536}
3537return true;
3538}
3539function taxResetCache() {
3540for (var i = 0, tl = this._tax; i < tl.cnt(); i++) {
3541tl.get(i).cache = 0;
3542}
3543}
3544var frPrArr={};
3545frPrArr['nl']=[];
3546function freeBasket(bsk)
3547{
3548this._add	= fb_Add;
3549this.bsk	= bsk;
3550this.fqnty	= fbQnty;
3551this.fprod	= fbProd;
3552this.add	= fbAdd;
3553this.clear	= fbClear;
3554this.overall	= fbOverall;
3555this.checkBasket=fbCheckBasket;
3556this.delByPr	=fbDelByPr;
3557this.getTitles	=fbGetTitles;
3558this.clear();
3559}
3560function fbClear()
3561{
3562this.items = new dynObj('item');
3563}
3564function fb_Add(id, qnty, title, weight,price, prdc,imgid)
3565{
3566var tmp = this.items.get(id);
3567prdc=prdc.replace('%%P','');
3568if (tmp==''){
3569var prc=price;
3570this.items.eAdd(id, new Array(this.bsk,id,tf.content.document,parseFloat(qnty),prc,title,parseFloat(weight),prdc,'','','','',imgid));
3571}
3572else tmp.quantity = qnty;
3573}
3574function fbGetTitles(ids,del) {
3575var ret=''; if (!del) del=',';
3576var ids=ids.split('|'),lastOne=ids[ids.length-2];
3577for (var i=0,a=frPrArr[tf.lang],l=a.length; i<l; i++) {
3578if (lastOne != a[i][0]) continue;
3579ret+=del+a[i][1];
3580}
3581return ret.substr(1);
3582}
3583function fbQnty(val, itm, disp)
3584{
3585if (disp) return ld('LD_FREE_QUANTITY', '')+ ':  ' + val + ' x ' + itm.title;
3586this._add(itm.id+"|"+itm.id, parseFloat(val), itm.title, itm.weight(), itm.price, itm.itemNo, itm.pimg);
3587}
3588function fbProd(val,itm,disp)
3589{
3590if (!val) return '';
3591var str = ld('LD_FREE_PRODUCT', '');
3592var freeqnty=1;
3593var z=0,isForProd=typeof(itm.id)!='undefined',ids=val.split('|'),lastOne=ids[ids.length-2];
3594for (var i=0,a=frPrArr[tf.lang],l=a.length; i<l; i++) {
3595if (!isForProd && lastOne != a[i][0]) continue;
3596if ( isForProd && val.indexOf(a[i][0])==-1) continue;
3597z=1;
3598if (disp) str += '<br>  '+freeqnty+' x ' + a[i][1];
3599else {
3600if(isForProd)pid=itm.id;
3601else{pid='shop';this.delByPr('shop');}
3602this._add(pid+"|"+a[i][0], freeqnty, a[i][1], a[i][2],a[i][3],a[i][4],a[i][5]);
3603}
3604}
3605return (z)?str:'';
3606}
3607function fbAdd(itm, disc, stk, disp)
3608{
3609var qnty=(typeof(itm)=='object')?itm.quantity:0;
3610if (typeof(itm)=='number') qnty=itm;
3611var free = (disc)?disc.free(qnty):null;
3612if (!free) return '';
3613if (disp==null) disp=0;
3614if (!disp && this.checkBasket(itm.id)) return '';
3615switch(disc.type) {
3616case '2': return this.fqnty(free, itm, disp);
3617case '3': case '103': return this.fprod(free, itm, disp);
3618}
3619return '';
3620}
3621function fbOverall(type)
3622{
3623var ret = 0, useDec = 0;
3624for (var i=0; i<this.items.cnt(); i++) {
3625var itm = this.items.get(i);
3626switch (type) {
3627case 'weight':	 ret += itm.weight() * itm.quantity; break;
3628case 'quantity': ret += itm.quantity; break;
3629case 'quantityround': ret += itm.quantity; if(itm.useDec>0) useDec=1; break;
3630default: break;
3631}
3632}
3633if(type == 'quantityround')
3634ret = (useDec)?Math.round(ret*100)/100:Math.round(ret);
3635return ret;
3636}
3637function fbCheckBasket(id) {
3638var i=this.items.start();
3639while (i!=null) {
3640if (i.id.split('|')[0]==id) return 1
3641i=this.items.next();
3642}
3643return 0;
3644}
3645function fbDelByPr(id) {
3646var delArr=new Array();
3647var it=new SF_Iterator(this.items); var i=it.start();
3648while (i!=null) {
3649if (i.id.split('|')[0]==id) delArr[delArr.length]=i.id;
3650i=it.next();
3651}
3652for (var i=0; i<delArr.length; i++) {
3653this.items.del(delArr[i]);
3654}
3655}
3656function basket(name)
3657{
3658this.name  = (name!=null)?name:'';
3659this.items = new dynObj('item');
3660this.stk   = new dynObj('stock');
3661this.disc  = new dynObj('discount');
3662this.gdisc = new dynObj('discount');
3663this.ship  = new dynObj('keyval');
3664this.fbsk  = new freeBasket(this);
3665this.tax   = new tax();
3666this.cache = {};
3667this.chk_total=0;
3668this.chk_total_tax=0;
3669this.chk_total_nopmsurcharge=0;
3670this.chk_pmsurcharge=0;
3671this.chk_pmsurchargetax=0;
3672this.chk_pmsurchargeIsIncTax=0;
3673this.chk_tax_noshiptax=0;
3674this.chk_tax_ship=0;
3675this.chk_disc_novoucher=0;
3676this.decodeState = 'initialised';
3677this.parse	= bskParse;
3678this.createTemp = bskCreateTemp;
3679this.add	= bskAdd;
3680this.del	= bskDel;
3681this.save	= bskSave;
3682this.load	= bskLoad;
3683this.encode	= bskEncode;
3684this.decode	= bskDecode;
3685this.shpP	= 0;
3686this.shDisc	= bskShDisc;
3687this.updQnty	= bskUpdQnty;
3688this.total	= bskTotal;
3689this.ckOut	= bskCkOut;
3690this.hasDisc	= bskHasDisc;
3691this.overall	= bskOverall;
3692this.shipPrice	= bskShpPrice;
3693this.noShip	= bskNoShp;
3694this.shipMeths	= bskShpMeths;
3695this.pShip	= bskPShip;
3696this.searchTaxes= bskSearchTaxes;
3697this.hasTaxAtCountyLevel = bskHasTaxAtCountyLevel;
3698this.invalidate = bskInvalidate;
3699this.getTaxIDs	= bskGetTaxIDs;
3700this.refreshTotal=bskRefreshTotal;
3701this.plusTaxTexts = bskPlusTaxTexts;
3702this.plusShipTaxTexts = bskPlusShipTaxTexts;
3703this.calcTotal = bskCalcTotal;
3704this.clearBsk	= bskClearBsk;
3705this.updDecodeState = bskUpdDecodeState;
3706this.itemsTemporary = new dynObj('item');
3707this.incorporateTemp=bskIncorporateTemp;
3708this.clone=bskClone;
3709this.merge=bskMerge;
3710this.hasOnlyRequests = bskHasOnlyRequests;
3711this.groupByCode = bskGroupByCode;
3712}
3713function bskParse(id,doc,qnty,title,weight,itemNo,useDec,esd,taxes,opts,prdc,manc,dstc,prcc,ship,restoring,temp,type)
3714{
3715var price=0;
3716function cf(i,d,sd,s,t,st){
3717currentItem	= i;
3718var dcf		= doc.cf_popup;
3719tf.load('conf.html','conf',true);
3720tf.load('grey.html','shipping');
3721var wnd=tf.content;
3722wnd.sfAddRef={core:window,item:i,stock:st,options:opts,pdoc:doc}
3723return false;
3724}
3725var stkEn=1,p=tf.wm.pProp(id);
3726if(!p)return alert('Error: 0x00CEFF');
3727if(temp){
3728var itm=this.createTemp(id,doc,opts,qnty,title,weight,itemNo,useDec,esd,taxes,prdc,true);
3729if(!itm)return 0;
3730var disc = Basket.disc.eAdd(itm.id,[p[5], p[6], p[7]]);
3731this.itemsTemporary.del(0);
3732this.itemsTemporary.add(itm);
3733if(title!=''&&!cf(itm, disc, this.shDisc(), null, this.tax, null)) return 0;
3734return 1;
3735}
3736var price=parseFloat(p[1]);
3737if(!weight)weight=parseFloat(p[10]);
3738var itm=this.items.empty();
3739itm.init(this,id,doc,qnty,price,title,weight,itemNo,useDec,esd,taxes,prdc);
3740itm.makeRequest(type);
3741var chk=itm.addOpt(opts,doc);
3742if(chk!=''){
3743tf.content.sfAddUnpop();
3744if(chk!=' ')return alert(LD.LD_OPTION_ERROR_FIELDS+'\n'+chk);
3745if(!confirm(LD.LD_CHOOSE_OPTIONS))return -1;
3746}
3747else{
3748itm.optPrice = p['optPrice']||0;
3749}
3750var stkItm=this.items.empty();
3751stkItm.init(this,id,doc,qnty,price,title,weight,itemNo,useDec,esd,taxes,prdc);
3752stkItm.addOpt(opts,doc);
3753var stkItmNo=stkItm.getItemNo(),pstk=tf.wm.pProp(stkItmNo);
3754if(typeof(pstk)=='undefined')pstk=p;
3755var smin=pstk[2],smax=pstk[3],savail=pstk[4],st='';
3756if (stkItmNo){
3757var stk=Basket.stk.eAddS(stkItmNo,[smin,smax,savail,prdc,manc,dstc,prcc]);
3758stk.avail=useDec>0?parseFloat(savail):parseInt(savail);
3759var stkopts=stkItm.options;
3760for (var i=0;i<stkopts.cnt();i++){
3761var opt=stkopts.get(i);
3762if(opt.choice()==''||opt.combine||!opt.optId())continue;
3763var pstkopt=tf.wm.pProp(opt.optId());
3764if(pstkopt){
3765var stkopt=Basket.stk.eAddS(opt.optId(),[pstkopt[2],pstkopt[3],pstkopt[4],manc,dstc,prcc]);
3766stkopt.avail=useDec>0?parseFloat(pstkopt[4]):parseInt(pstkopt[4]);
3767}
3768}
3769if(this.name == ''){ // Only check stock level for adding to basket, not for adding to favourites
3770var re=stk.check(stkItm);
3771if (re[0]==1&&!temp){tf.content.sfAddUnpop();alert(re[1]);return -1;}
3772st=re[1].replace(/\n/g,'<br>');
3773}
3774}
3775var disc = Basket.disc.eAdd(itm.id,[p[5], p[6], p[7]]);
3776if (!opts && doc && disc) {
3777disc.type = p[5];
3778disc.value = p[6];
3779disc.tlim = p[7];
3780}
3781var ship = Basket.ship.eAdd(itm.id,[itm.id, p[8]]);
3782if(this.name != ''){
3783if(title!=''){if(tf.nametag.get('showCookieWarning')=='false'||confirm(LD.LD_FAVOURITES_CONFIRM)){tf.nametag.add('showCookieWarning',false);tf.core.savCookStr('showCookieWarning',false, -1);this.add(itm);}}
3784else this.add(itm);
3785return null;
3786}
3787if (title!='' && !cf(itm, disc, this.shDisc(), stk, this.tax, st)) return 0;
3788if (!this.add(itm)) return 0;
3789return 1;
3790}
3791function bskCreateTemp(id,doc,opts,qnty,title,weight,itemNo,useDec,esd,taxes,prdc,showAlert,forcecreate){
3792var p=tf.wm.pProp(id);
3793if(!p)return alert('Error: 0x00CEFF');
3794var price=parseFloat(p[1]);
3795if(!weight)weight=parseFloat(p[10]);
3796var itm=this.itemsTemporary.empty();
3797itm.init(this,id,doc,qnty,price,title,weight,itemNo,useDec,esd,taxes,prdc,null,true);
3798var chk=itm.addOpt(opts,doc);
3799if(chk!=''){
3800tf.content.sfAddUnpop();
3801if(showAlert){
3802if(chk!=' ')return alert(LD.LD_OPTION_ERROR_FIELDS+'\n'+chk);
3803if(!confirm(LD.LD_CHOOSE_OPTIONS))return -1;
3804}
3805else if(!forcecreate){
3806return null;
3807}
3808}
3809else itm.optPrice = p['optPrice']||0;
3810return itm;
3811}
3812function bskAdd(itm)
3813{
3814var stk=this.stk.getS(itm.getItemNo());
3815var items=this.items,l=items.cnt();
3816for (var i=0; i<l; i++) {
3817var tmp = items.get(i);
3818if (!itm.isSame(tmp)) continue;
3819if(this.name==''&&stk)stk.update(tmp,'neg');
3820tmp.transfer(itm);
3821items.del(i)
3822break;
3823}
3824items.add(itm);
3825if(this.name==''&&stk){
3826stk.update(itm);
3827tf.core.stkQryState['arrQS'][tf.pgidx]=tf.qsStkQry;
3828tf.nametag.add('stkQryState',tf.sfJSON.stringify(tf.core.stkQryState));
3829}
3830itm.cache=[];
3831this.cache['itmGrp']={};
3832if (tf.shipping)tf.shipping.upsprice=0;
3833tf.nametag.del('orderProps');
3834voucher.invalidate();
3835if(this.decodeState=='complete'){
3836if(this.name==''){
3837this.calcTotal(tf.ship_obj);
3838rl_total();
3839}
3840this.save();
3841}
3842$(this).trigger('Add', [itm.getItemNo(), itm]);
3843return 1;
3844}
3845function bskDel(idx)
3846{
3847var itm = this.items.get(idx);
3848if (itm == '') return '';
3849var stk=this.stk.getS(itm.getItemNo());
3850if(this.name==''&&stk) {
3851stk.update(itm, 'neg');
3852}
3853this.items.del(idx);
3854this.tax.resetCache();
3855this.cache['itmGrp']={};
3856tf.nametag.del('orderProps');
3857voucher.invalidate();
3858if (this.fbsk&&this.name=='') {
3859this.fbsk.delByPr(itm.id);
3860this.fbsk.delByPr('shop');
3861this.fbsk.add(this.total(), this.shDisc(), null, 0);
3862}
3863if(this.name==''){
3864this.calcTotal(tf.ship_obj);
3865rl_total();
3866}
3867this.save();
3868}
3869function bskUpdQnty(idx, qnty)
3870{
3871var itm = this.items.get(idx);
3872var tmp = itm.quantity,qty=(itm.useDec>0?parseFloat(qnty):parseInt(qnty));
3873if (isNaN(qty)||qty<0) qty=tmp;
3874if (qty==0) {this.del(idx); return;}
3875var stk=this.stk.getS(itm.getItemNo());
3876if(stk)stk.update(itm,'neg');		// Subtract old quantity from stock
3877itm.quantity=qty;
3878if(stk){
3879var re=stk.check(itm);
3880if (re[0]==1) {alert(re[1]);itm.quantity = tmp; }
3881else {st=re[1]; if(st!='') alert(st);}
3882stk.update(itm);
3883}		// Update new quantity to stock
3884voucher.invalidate();
3885itm.cache=new Array();
3886this.cache['itmGrp']={};
3887if (tf.shipping)tf.shipping.upsprice=0;
3888tf.nametag.del('orderProps');
3889if(this.name==''){
3890this.calcTotal(tf.ship_obj);
3891rl_total();
3892}
3893this.save();
3894this.ckOut();
3895}
3896function bskTotal(type, nocache, incAll)
3897{
3898var apply_voucher=true;
3899if(type=='novoucher'){apply_voucher=false;type='';}
3900var apply_dsc=true;
3901if (type=='orig') {apply_dsc=false; type=''}
3902if (type==null) type='';
3903this.groupByCode(this.shDisc.limitToCodeType);
3904var idxs = null, includeAll = (typeof(incAll) == 'undefined'  || incAll);
3905if (nocache && (!type||type=='pur'||type=='exc')) idxs = core.voucher.getGroupByCodeItmIdxs();
3906var tot=0,prprice=0,purtot=0,n=0;
3907var items=this.items,i=items.start();
3908while (i!=null) {
3909var include = includeAll;
3910include = include && (!idxs || idxs.indexOf(i) == -1);
3911if (!include) {
3912i = items.next();
3913n++;
3914continue;
3915}
3916var tot1 = i.calc(type, null, nocache);
3917if (!i.requestQuote&&!i.requestSample) tot += tot1;
3918purtot+=i.cache['pur'+i.quantity];
3919if (type=='tax') prprice+=(i.getGDsc()||i.parent.shDisc()?i.calc('dsc', null, nocache):i.calc('ndc', null, nocache));
3920i = items.next();
3921n++;
3922}
3923var shDisc=this.shDisc();
3924if((type==''||type=='pur'||type=='inc')&&apply_dsc&&this._shDisc){tot-=shDisc.purchasePrice(tot);
3925if(core.voucher.type!=0){core.voucher.purtot=tot;core.voucher.newtot=core.voucher.calcRaw(tot);}}
3926if((type=='exc'||type=='exc_noround')&&apply_dsc&&this._shDisc)tot-=shDisc.purchasePriceByPrice(tot,purtot);
3927if(type=='tax'&&apply_dsc&&this._shDisc) {
3928tot-=shDisc.purchasePriceByPrice(tot,prprice);
3929}
3930if(tot>0&&apply_dsc&&apply_voucher&&!core.voucher.isAppliesToTotal()){tot=core.voucher.calc(tot);}
3931return tot;
3932}
3933function bskHasDisc()
3934{
3935return this.total('damt');
3936}
3937function bskShDisc(type, val, tLim, del1, del2, limitToCodeType, limitToCodes)
3938{
3939if (type==null||type=='') return this._shDisc;
3940if (this._shDisc==null) this._shDisc=this.disc.eAdd('shop', [type,val,tLim,null,null,limitToCodeType,limitToCodes]);
3941return this._shDisc;
3942}
3943function bskOverall(type, ckOut, incAll)
3944{
3945var ret = 0, useDec = 0, includeAll = (typeof(incAll) == 'undefined' || incAll);
3946if(type=='pmsurcharge'){
3947ret=this.chk_pmsurcharge
3948return ret;
3949}
3950else if(type=='pmsurchargetax'){
3951if(this.chk_pmsurchargeIsIncTax)ret=this.chk_pmsurchargetax;
3952else ret=0;
3953return ret;
3954}
3955var idxs = null;
3956if (!includeAll) idxs = core.voucher.getGroupByCodeItmIdxs();
3957for (var i=0; i<this.items.cnt(); i++) {
3958var itm = this.items.get(i), p = tf.wm.pProp(itm.id);
3959var include = includeAll || ((!itm.requestQuote && !itm.requestSample) || (itm.requestSample && p && parseInt(p[21/*requestSample_IncludeShippingCost*/])));
3960include = include && (!idxs || idxs.indexOf(i) == -1);
3961switch (type) {
3962case 'weight'  :
3963if (include) ret += itm.weight() * itm.quantity;
3964break;
3965case 'quantity':
3966if (include) ret += itm.quantity;
3967break;
3968case 'quantityround':
3969if (include) ret += itm.quantity; if(itm.useDec>0) useDec=1;
3970break;
3971default: break;
3972}
3973}
3974if (ckOut != null) return ret;
3975this.ckOut();
3976ret += this.fbsk.overall(type);
3977if(type == 'quantityround')
3978ret = (useDec)?Math.round(ret*100)/100:Math.round(ret);
3979return ret;
3980}
3981function bskCkOut()
3982{
3983this.fbsk.clear();
3984for (var i=0; i<this.items.cnt(); i++) {
3985var itm = this.items.get(i);
3986var dsc = this.disc.get(itm.id);
3987var stk = this.stk.getS(itm.getItemNo());
3988this.fbsk.add(itm, dsc, stk);
3989}
3990this.fbsk.add(this.total(), this._shDisc);
3991}
3992function bskShpPrice(shp_obj, ckOut, inc)
3993{
3994if (shp_obj && typeof(shp_obj)=='object')this.shp_obj=shp_obj;
3995if (shp_obj!=null) {
3996if (shp_obj.cost==null) return 0;
3997if (core.voucher.fs && !core.voucher.dscc) return 0;
3998var e = 0;
3999var t = this.total('tax', true);
4000var p = this.total('exc', true, !core.voucher.fs);
4001var pur = this.total(null, true, !core.voucher.fs);
4002var w = this.overall('weight', ckOut, !core.voucher.fs);
4003var q = this.overall('quantity', ckOut, !core.voucher.fs);
4004var s = 0;
4005if (pur != 0 || w != 0 || q != 0)	s = (inc?shp_obj.cost(pur, w, q, region, method):shp_obj.calc(pur, p, w, q, region, method));
4006this.shpP = (s==null||s<0)?0:s+this.pShip(shp_obj.cLink.mid,inc);
4007this.tax.ship(shp_obj.tax(this.shpP, p));
4008}
4009return parseFloat(this.shpP);
4010}
4011function bskNoShp()
4012{
4013var itm = this.items.start();
4014var ps  = new Array();
4015while (itm) {
4016var tmp = itm.shipMth();
4017for (var i in tmp) if (i) ps[i]=(typeof(ps[i])=='undefined'?(!parseInt(tmp[i])):(ps[i]&&!parseInt(tmp[i])));
4018itm = this.items.next();
4019}
4020return ps;
4021}
4022function bskShpMeths()
4023{
4024if (!tf.shipping || !tf.shipping.ship) return;
4025var ps = [], fap = tf.shipping.ship.forAllProds;
4026for (var i in fap) {
4027ps[i] = 0;
4028}
4029var itm = this.items.start(), high = 0;
4030while (itm) {
4031var itmMth = itm.shipMth(), yes = 0;
4032for (var i in fap) {
4033if (typeof(itmMth[i]) == 'undefined') yes = fap[i];
4034else if (parseInt(itmMth[i]) == 1) yes = 1;
4035else yes = 0;
4036ps[i] += yes;
4037if (ps[i] > high) high = ps[i];
4038}
4039itm = this.items.next();
4040}
4041for (var i in ps) {
4042if (ps[i] < high) delete ps[i];
4043}
4044return ps;
4045}
4046function bskPShip(mid,inc)
4047{
4048if(!mid)return 0;
4049var loc=-1;
4050if (tf.core&&tf.core.region){
4051var cnt=this.shp_obj.links.length,code=core.region;
4052if(code.length>4)code=code.substring(0,4);
4053var rgnLen=Math.min(core.shopRegion.length,code.length);
4054for(var i=0;i<cnt;i++){
4055var lk=this.shp_obj.links[i];
4056if(lk.mid==mid&&lk.zip[code]!=null){
4057loc=(core.shopRegion.indexOf(code.substr(0,rgnLen))==0?2:3);
4058break;
4059}
4060}
4061}
4062if(loc==-1)return 0;
4063var e	= 0;
4064var itm = this.items.start();
4065while (itm) {
4066var n=itm.shipMth(mid, loc);
4067if(typeof(inc)=='undefined'){
4068var rgnCde=core.region;len=rgnCde.length-(rgnCde.length%2);
4069for(var l=len;l>0;){
4070if(typeof(core.STax.mapRegn[rgnCde])!='undefined'){e+=n;break;}
4071l-=2;
4072rgnCde=rgnCde.substring(0,l);
4073}
4074if(l==0)e+=core.STax.exTax(itm.taxes,n);
4075}
4076else{e+=(inc?n:core.STax.exTax(itm.taxes,n));}
4077itm = this.items.next();
4078}
4079return e;
4080}
4081function bskSearchTaxes(rcode)
4082{
4083var it = new SF_Iterator(this.items),i=it.start();
4084while (i!=null) {
4085if (i.taxes!='') {
4086if (!this.tax.isEmpty(i.taxes,rcode)) return true;
4087}
4088i = it.next();
4089}
4090return false;
4091}
4092function bskHasTaxAtCountyLevel(statecode)
4093{
4094var it = new SF_Iterator(this.items),i=it.start(),has=false;
4095while (i!=null&&i.taxes!='') {
4096var a=i.taxes.split(',');
4097for (var j=0,jmax=a.length; j<jmax; j++) {
4098if(!a[j])continue;
4099var tax=this.tax._tax.get(a[j]);
4100if (tax&&tax.perc>0){
4101var t=tax.code.split(',');
4102for(var k=0,kmax=t.length;k<kmax;k++){if(t[k].indexOf(statecode)==0 && t[k].length>statecode.length){has=true;break;}}
4103}
4104}
4105i = it.next();
4106}
4107return has;
4108}
4109function bskGetTaxIDs()
4110{
4111var it	= new SF_Iterator(this.items),i=it.start(),ret=new Array();
4112while (i!=null) {
4113var a=i.taxes.split(',');
4114for (var j=0;j<a.length;j++) {
4115if(ret.join(',').indexOf(a[j])==-1) ret[ret.length]=a[j];
4116}
4117i=it.next();
4118}
4119return ret.join(',');
4120}
4121function bskInvalidate() {
4122this.cache={};
4123var it=new SF_Iterator(this.items),i=it.start();
4124while (i!=null) {
4125i.cache=[];
4126i=it.next();
4127}
4128}
4129function bskCalcTotal(shipObj){
4130var ppur,ppur_ex,shp,ttax,shp_asis,shtaxex,taxonshp,tax,t,bsk=this;
4131if(shipObj){
4132ppur=bsk.total();
4133ppur_ex=bsk.total('exc');
4134shp=bsk.shipPrice(shipObj);
4135ttax=(ppur>0.001)?bsk.total('tax'):0;
4136shp_asis=bsk.shipPrice(shipObj,null,1);
4137var tid=tf.core.STax.allIDs();
4138if(shipObj._ttype==1)tid=tf.core.BTax.findMajorityTaxID(core.BTax.currRegn())||tid;
4139shtaxex=tf.core.STax.exTax(tid,shp_asis);
4140taxonshp=(ppur>0.001)?shipObj.tax(shp_asis,ppur_ex,null,shtaxex):0;
4141tax=ttax+taxonshp;
4142if(ppur_ex!=ppur){
4143t=ppur+shp+(shp_asis==shtaxex?taxonshp:0);
4144if((ppur-ppur_ex)>0.01){
4145var tmp=tax-(ppur-bsk.total('exc_noround'))-(shp_asis==shtaxex?taxonshp:shp_asis-shtaxex);
4146if(Math.abs(tmp)>=0.01)t+=Math.round(tmp);
4147}
4148}
4149else
4150t=ppur_ex+tax+shtaxex;
4151}else{
4152ppur_ex=bsk.total('exc');
4153ttax=bsk.total('tax');
4154t=ppur_ex+ttax;
4155}
4156bsk.chk_total_novoucher=core.nfmt.roundTotal(t,tf.shopCurrency.iso);;
4157if(t>0&&core.voucher.isAppliesToTotal()){t-=core.voucher.getDscAmt();}
4158t=core.nfmt.roundTotal(t,tf.shopCurrency.iso);
4159bsk.chk_total=t;
4160bsk.chk_total_tax=tax;
4161bsk.chk_total_nopmsurcharge=bsk.chk_total;
4162bsk.chk_pmsurcharge=0;
4163bsk.chk_pmsurchargetax=0;
4164bsk.chk_pmsurchargeIsIncTax=true;
4165if(core.pmKey&&core.pmKey!='--'&&pm.dataidx[core.pmKey]){
4166var surcharge=pm.dataidx[core.pmKey]['surcharge'];
4167if(surcharge){
4168if(isNaN(surcharge)&&surcharge.indexOf('%')>0)surcharge=t*parseFloat(surcharge)/100;
4169else surcharge=parseFloat(surcharge);
4170surcharge=core.nfmt.round(surcharge);
4171bsk.chk_pmsurcharge=surcharge;
4172bsk.chk_total+=bsk.chk_pmsurcharge;
4173if (pm.persist.showSurchargeTax) {
4174var oTax=core.Basket.tax,taxids=oTax.allIDs();
4175var excSurchargeTax=(oTax.calcTax(taxids,surcharge)==oTax.exTax(taxids,surcharge));
4176var surchargetax=oTax.allAmt(taxids,surcharge);
4177bsk.chk_pmsurchargetax=surchargetax;
4178bsk.chk_pmsurchargeIsIncTax=!excSurchargeTax;
4179bsk.chk_total+=(excSurchargeTax?surchargetax:0);
4180}
4181}
4182}
4183bsk.chk_tax_noshiptax=ttax;
4184bsk.chk_tax_ship=taxonshp;
4185return [ppur,shp,shtaxex,bsk.chk_total,bsk.chk_pmsurcharge,bsk.chk_pmsurchargetax];
4186}
4187function bskRefreshTotal(dd){
4188if(LD&&tf.content&&tf.utils) {
4189if(tf.conf&&tf.conf.greySettings)tf.conf.greySettings();else return;
4190if(this.items.cnt()==0&&!tf.isSFXTheme){
4191tf.sfMakeSpace.go(true,'','MiniCart');
4192}
4193else {
4194if(confLoaded){
4195function MiniCartTotalAmount(o){
4196if(!tf.shipping)return '';
4197if(showPlusDoneTax==-1)showPlusDoneTax=getShowPlusDoneTax(o);
4198var a=o.calcTotal(tf.shipping.ship), s='';
4199if(showPlusDoneTax==true){
4200s='&nbsp;'+showPrc(o.chk_total,0);
4201}
4202else {
4203s='&nbsp;'+showPrc(a[0],0);
4204}
4205return s;
4206}
4207var showPlusShipping=-1,showPlusTax=-1,showPlusDoneShipping=-1,showPlusDoneTax=-1,taxTexts=[];
4208function getShowPlusShipping(o){
4209return true;
4210}
4211function getShowPlusTax(o){
4212if(showPlusDoneTax==-1)showPlusDoneTax=getShowPlusDoneTax(o);
4213var t={};
4214o.plusTaxTexts(t,taxTexts,showPlusDoneTax)
4215return t.length > 0;
4216}
4217function getShowPlusDoneShipping(o){
4218return (tf.core.regionChanged&&(tf.core.method!='--'&&tf.core.method!=''&&tf.shipping.providerCost>0));
4219}
4220function getShowPlusDoneTax(o){
4221return tf.core.regionChanged;
4222}
4223if(!tf.core.regionChanged){
4224var regionChanged=true;
4225var itm=this.items.start(),regn=tf.core.region||this.tax.getDefaultReg();
4226while (itm!=null) {
4227var a=itm.taxes.split(',');
4228for (var j=0,jj=a.length; j<jj; j++){
4229var _t=this.tax._tax.get(a[j]);
4230if(_t&&this.tax.regnRate(_t.id,regn)&&!_t.incTax){regionChanged=false;}
4231}
4232itm=this.items.next();
4233}
4234if(regionChanged){
4235if(tf.shipping&&tf.shipping.ship&&tf.shipping.ship.method.cnt()==1&&tf.shipping.providerCost>0){
4236tf.core.method=tf.shipping.smethod;
4237}
4238}
4239}
4240var dd=dd||tf.content.document;
4241var arr={
4242MiniCartTotalAmount:function(o){return MiniCartTotalAmount(o);},
4243MiniCartTotalSummary:function(o){return o.overall('quantity')+' '+LD.LD_ITEMS+' = '+MiniCartTotalAmount(o);},
4244MiniCartTotalItemsQuantity:function(o){return o.overall('quantityround');},
4245MiniCartTotalItemsQuantity_Mobile:function(o){return o.overall('quantity');},
4246MiniCartTotalTotalText:function(o){
4247if(tf.miniCartHandler&&tf.miniCartHandler.shippingChargeHandler)return;
4248if(showPlusDoneShipping==-1)showPlusDoneShipping=getShowPlusDoneShipping(o);
4249if(showPlusDoneTax==-1)showPlusDoneTax=getShowPlusDoneTax(o);
4250return (showPlusDoneShipping==true&&showPlusDoneTax==true ? LD.LD_TOTAL : LD.LD_SUBTOTAL);
4251},
4252MiniCartTotalPlusExpenses:function(o){
4253if(tf.miniCartHandler&&tf.miniCartHandler.shippingChargeHandler)return;
4254return '<a href="#" class="ImgLink" onclick="cancelBuble(event);sfAddPop(\'shipping_charge\',true);sfAddRef[\'core\']={};return false;">' + fnMiniCartTotalPlusExpensesText(o) + '</a>';
4255},
4256MiniCartTotalPlusExpensesText:function(o){
4257if(showPlusDoneShipping==-1)showPlusDoneShipping=getShowPlusDoneShipping(o);
4258if(showPlusDoneTax==-1)showPlusDoneTax=getShowPlusDoneTax(o);
4259if(showPlusShipping==-1)showPlusShipping=getShowPlusShipping(o);
4260if(showPlusTax==-1)showPlusTax=getShowPlusTax(o);
4261if(showPlusShipping!=true&&showPlusTax!=true&&showPlusDoneShipping!=true&&showPlusDoneTax!=true)return '';
4262var HTML=[],HTML2=[];
4263if((showPlusDoneTax==true||showPlusTax==true)&&taxTexts.length>0)HTML.push(taxTexts.join(', '));
4264if(showPlusShipping==true)HTML.push((showPlusDoneShipping==true?LD.LD_INC+' ':'+')+LD.LD_SHIPPING_CHARGES);
4265if(HTML.length>0){
4266HTML2.push('<span id="PlusExpensesText">');
4267HTML2.push(HTML.join(', '));
4268HTML2.push('</span>');
4269}
4270return HTML2.join('');
4271},
4272MiniCartTotalList:function(o){
4273var HTML=[],itms=o.items,itFree=new core.SF_Iterator(o.fbsk.items);
4274for (var i=0,num=itms.cnt(); i<num; i++) {
4275var itm = itms.get(i);
4276var vars={
4277'ProductQuantity':itm.quantity,
4278'ProductTitle':itm.title,
4279'ProductPrice':showPrc(itm.calc(),0),
4280'ProductImage':'src="'+(itm.pimg!=''?itm.pimg:tf.wm.url('../media/trans.gif','-'))+'"',
4281'ProductURL':'href="'+(unescape(itm.purl).replace('#'+itm.id.toLowerCase(),''))+'#'+itm.id.toLowerCase()+'"'
4282};
4283HTML.push(tf.utils.tmplParser.parse(tfcd.getElementById('tmplMiniCartTotalList'), vars));
4284var idtag=(isNaN(itm.id)?'_':'')+itm.id,iFree=itFree.start();
4285while(iFree!=null) {
4286if(iFree.idtag.split("|")[0]==idtag) {
4287vars={
4288'ProductQuantity':iFree.quantity,
4289'ProductTitle':iFree.title,
4290'ProductPrice':LD.LD_FREE,
4291'ProductImage':'src="'+(tf.isEntryPage?'contents/media/':'')+(iFree.pimg!=''?iFree.pimg:'../media/trans.gif')+'"'
4292};
4293HTML.push(tf.utils.tmplParser.parse(tfcd.getElementById('tmplMiniCartTotalFreeList'), vars));
4294}
4295iFree=itFree.next();
4296}
4297}
4298var iFree=itFree.start();
4299while(iFree!=null) {
4300if(iFree.idtag.split("|")[0]=='_shop') {
4301vars={
4302'ProductQuantity':iFree.quantity,
4303'ProductTitle':iFree.title,
4304'ProductPrice':LD.LD_FREE,
4305'ProductImage':'src="'+(tf.isEntryPage?'contents/media/':'')+(iFree.pimg!=''?iFree.pimg:'../media/trans.gif')+'"'
4306};
4307HTML.push(tf.utils.tmplParser.parse(tfcd.getElementById('tmplMiniCartTotalFreeList'), vars));
4308}
4309iFree=itFree.next();
4310}
4311return HTML.join('');
4312}
4313};
4314var fnMiniCartTotalPlusExpensesText=arr['MiniCartTotalPlusExpensesText'];
4315for(var n in arr){
4316tf.content.$('.'+n).html(arr[n](this));
4317var el=dd.getElementById(n);
4318if(el){el.innerHTML=arr[n](this);}
4319}
4320tf.content.$('.MiniCartLink, #MiniCartLink').attr('href', tf.wm.url('basket.html','-',true));
4321}
4322tf.sfMakeSpace.go(true,'','MiniCart');
4323}
4324if(tf.miniCartHandler&&tf.miniCartHandler.refreshEnd)tf.miniCartHandler.refreshEnd();
4325if(tf.autoText)tf.autoText.apply('ancestorGC');
4326if(tf.equalHeight)tf.equalHeight();
4327if(tf.isInDesigner()){tf.parent.applyColorScheme(tf);}
4328}
4329}
4330function bskPlusTaxTexts(t,aTaxTexts,showPlusDoneTax,onlyInc,incTT) {
4331var itm=this.items.start(),regn=(showPlusDoneTax==true?null:tf.core.region||this.tax.getDefaultReg());
4332t.length=0;
4333var oaTaxTexts={},oincTT={};
4334while (itm!=null) {
4335var a=itm.taxes.split(',');
4336for (var j=0,jj=a.length; j<jj; j++){
4337var _t=this.tax._tax.get(a[j]);
4338if(_t&&typeof(t[_t.id])=='undefined'){
4339if(onlyInc&&!_t.incTax)continue;
4340if(this.tax.regnRate(_t.id,regn)){
4341t[_t.id]=1;
4342t.length++;
4343if(!showPlusDoneTax){
4344if(tf.core.tsIx[_t.id])oaTaxTexts[tf.core.tsIx[_t.id]]=true;
4345}
4346else {
4347if(_t.incTax&&tf.core.tsI[_t.id])oaTaxTexts[tf.core.tsI[_t.id]]=true;
4348if(!_t.incTax&&tf.core.tsIx[_t.id])oaTaxTexts[tf.core.tsIx[_t.id]]=true;
4349}
4350if(incTT&&tf.core.tsI[_t.id])oincTT[tf.core.tsI[_t.id]]=true;
4351}
4352}
4353}
4354itm=this.items.next();
4355}
4356for(var s in oaTaxTexts){aTaxTexts.push(s);}
4357for(var s in oincTT){incTT.push(s);}
4358}
4359function bskPlusShipTaxTexts(t,aTaxTexts,showPlusDoneTax,onlyInc,incTT) {
4360var _stax=tf.core.STax;
4361var regn=(showPlusDoneTax==true?null:tf.core.region||_stax.getDefaultReg());
4362t.length=0;
4363var oaTaxTexts={},oincTT={};
4364for (var tid in tf.core.tsshI) {
4365if(tid=='length')continue;
4366var _t=_stax._tax.get(tid);
4367if(_t&&typeof(t[_t.id])=='undefined'){
4368if(onlyInc&&!_t.incTax)continue;
4369if(_stax.regnRate(_t.id,regn)){
4370t[_t.id]=1;
4371t.length++;
4372if(!showPlusDoneTax){
4373if(tf.core.tsshIx[_t.id])oaTaxTexts[tf.core.tsshIx[_t.id]]=true;
4374}
4375else {
4376if(_t.incTax&&tf.core.tsshI[_t.id])oaTaxTexts[tf.core.tsshI[_t.id]]=true;
4377if(!_t.incTax&&tf.core.tsshIx[_t.id])oaTaxTexts[tf.core.tsshIx[_t.id]]=true;
4378}
4379if(incTT&&tf.core.tsshI[_t.id])oincTT[tf.core.tsshI[_t.id]]=true;
4380}
4381}
4382}
4383for(var s in oaTaxTexts){aTaxTexts.push(s);}
4384for(var s in oincTT){incTT.push(s);}
4385}
4386function bskClearBsk() {
4387this.stk   = new dynObj('stock');
4388this.items = new dynObj('item');
4389this.fbsk  = new freeBasket(this);
4390core.voucher.clear();
4391}
4392function load_price(args)
4393{
4394var all = args[1],inTempBsk=(args[2]!=false);
4395for (var i=0, num=all.length; i<num; i++) {
4396var itm = all[i];
4397args[0].parse(itm.id, itm, itm.quantity, '', '','',null,null,null,null,null,null,null,null,null,null,inTempBsk,itm.requestQuote?2:(itm.requestSample?3:1));
4398if (itm['optPrice'] && typeof (args[0].items.getS(itm.id)) == 'object')
4399args[0].items.getS(itm.id).optPrice = itm['optPrice'];
4400}
4401var complete=args[0].updDecodeState();
4402if(complete){
4403for(var o in tf.wm._pArr)if(tf.wm._pArr[o].optPrice)delete tf.wm._pArr[o].optPrice;
4404tf.core.stkFetchBulk(function(){}, function(){});
4405if(tf.isFavoritesPage)tf.fillBasketTable();
4406if(args[0].name==''){
4407args[0].calcTotal(tf.ship_obj);
4408rl_total();
4409}
4410args[0].save();
4411$(document).trigger('_sfEvt_bskLoad_Complete');
4412}
4413}
4414function loadPricesForIDs(is)
4415{
4416if(!tf.utils||!tf.utils.prpgmap||!tf.core){setTimeout(function(){loadPricesForIDs(is);},100);return;}
4417function _L(f,prid,pgid){
4418idcnti++;
4419var myf=f.split('_');
4420if(myf.length==3&&myf[1]=='Page')myf=f.replace(/\.html/,'_');else myf=f.replace(/(_\d\d)?\.html/,'_$1');
4421var p=tf.lang+'/'+myf.replace(/&#44;/g,',').replace(/&#45;/g,'-');
4422if (!pg[p])pg[p] = [];
4423pg[p]=pg[p].concat(f);
4424if(idcnti==expectedidcnt){
4425if(tf.isInSFClassic()){
4426for(var i in pg){tf.core.scr.load(f, i);tf.utils.populateCrossPromotionPrice();}
4427}
4428else{
4429for(var i in pg){tf.core.load_page(i, 'tf.utils.populateCrossPromotionPrice', null);}
4430}
4431}
4432}
4433var pg = [], idtmp = {}, expectedidcnt = 0, idcnti = 0;
4434for (var i=0,ii=is.length;i<ii;i++) {
4435var id=is[i][0];
4436if (!tf.wm.pProp||!tf.wm.pProp(id)) {
4437if(!idtmp[id]){expectedidcnt++;idtmp[id]=true;}
4438}
4439}
4440if(expectedidcnt==0)tf.utils.populateCrossPromotionPrice();
4441for (var id in idtmp){
4442tf.utils.prpgmap.getParentPage(id,'',_L);
4443}
4444}
4445function bskSave()
4446{
4447if(tf.isInSF())return;
4448tf.saveBskToName();
4449if (getCookStr('storebasket')!='1'&&this.name!='Favorite') return;
4450var ck = '';
4451var ckName = this.name; if (!ckName) ckName='ADDRESS';
4452if (this.items.cnt()>0) {
4453ck = this.encode();
4454var pck=place(ck);
4455ck = pck + "TEST" + add(pck);
4456}
4457if (this.name!='')savCookStr(ckName, ck, -1);
4458else savCookStr(ckName, ck, '7');
4459this.shpP = 0;
4460tf.nametag.add('askRestoreBsk','false');
4461}
4462function bskLoad()
4463{
4464if(tf.isInSF()){tf.bskLoaded=true;return;}
4465$(document).trigger('_sfEvt_bskLoad_Begin');
4466tf.loadBskFromName();
4467if(getCookStr('storebasket')!='1'&&this.name!='Favorite'){this.decodeState='complete';return;}
4468var ckName = this.name; if (!ckName) ckName='ADDRESS';
4469var arr = getCookStr(ckName).split("TEST"),askAgain=true;
4470if ((tf.nametag.get('askRestoreBsk') != 'false' || this.name) && arr.length == 2 && add(arr[0]) == arr[1]) {
4471askAgain=false;
4472if (this.name!='' || confirm(shopName+':\n\n'+LD.LD_LOAD_BASKET+'  '+this.name)){
4473var sa=show(arr[0]);
4474this.decode(sa);
4475}
4476else{
4477savCookStr(ckName, "", '7');
4478this.decodeState='complete';
4479}
4480}
4481else {
4482rl_total();
4483this.decodeState='complete';
4484$(document).trigger('_sfEvt_bskLoad_Complete');
4485}
4486if(!askAgain)tf.nametag.add('askRestoreBsk','false');
4487}
4488function bskEncode()
4489{
4490var is=[];
4491for (var i=0,ii=this.items.cnt(); i<ii; i++) {
4492var itm = this.items.get(i);
4493if(itm.temporary)continue;
4494is.push(itm.code());
4495}
4496return '['+is.join('~')+']';
4497}
4498function bskDecode(str,decodeOnly)
4499{
4500var s = str.substring(1,str.length-1), sa = s.split(']['), is = sa[0].split('~');
4501function _L(f,prid,pgid){
4502pgcnti++;
4503var myf=f.split('_');
4504if(myf.length==3&&myf[1]=='Page')myf=f.replace(/\.html/,'_');else myf=f.replace(/(_\d\d)?\.html/,'_$1');
4505var p=tf.lang+'/'+myf.replace(/&#44;/g,',').replace(/&#45;/g,'-');
4506if (!pg[p]){thisBsk.expectedpgcnt++;pg[p] = [];}
4507pg[p]=pg[p].concat(pgtmp[prid]?pgtmp[prid]:pgtmp[f]);
4508if(pgcnti==expectedpgcnt){for(var i in pg)load_page(i, 'core.load_price', [thisBsk, pg[i], false]);}
4509}
4510if(is.length>0)this.decodeState='loading';
4511var pg = [], pgtmp = {}, expectedpgcnt = 0, pgcnti = 0, thisBsk = this;
4512for (var i=0,ii=is.length; i<ii; i++) {
4513var itm = this.items.empty();
4514itm.code(this,is[i]);
4515if(decodeOnly){
4516this.disc.eAdd(itm.id,['','','']);
4517this.add(itm);
4518continue;
4519}
4520if (tf.wm.pProp(itm.id)) {		// Price already exists
4521this.parse(itm.id, itm, itm.quantity,'','');
4522if(itm['optPrice']&&typeof(this.items.getS(itm.id))=='object')this.items.getS(itm.id).optPrice=itm['optPrice'];
4523}
4524else {
4525var jfile=tf.wm.jfile(itm.purl).split('?')[0],id=jfile.replace(/[._].*/,'');
4526if(window.decodeURIComponent(jfile).substr(0,1)=='#')id=itm.id.toLowerCase();
4527if(id.substr(0,1)!='p')id=jfile;
4528if(id=='index.html'||id==='')id='front.html';
4529if(!pgtmp[id]){expectedpgcnt++;pgtmp[id]=[];}
4530pgtmp[id].push(itm);
4531}
4532}
4533if(decodeOnly)return;
4534this.pgcnti=0;
4535this.expectedpgcnt=0;
4536for (var jfile in pgtmp){
4537var id=jfile.replace(/[._].*/,'');
4538if(id.substr(0,1)=='p'){tf.utils.prpgmap.getParentPage(id,'',_L);}
4539else _L(jfile,'',id);
4540}
4541if(expectedpgcnt==0){
4542this.decodeState='complete';
4543for(var o in tf.wm._pArr)if(tf.wm._pArr[o].optPrice)delete tf.wm._pArr[o].optPrice;
4544tf.saveBskToName();
4545$(document).trigger('_sfEvt_bskLoad_Complete');
4546}
4547}
4548function bskUpdDecodeState(){
4549this.pgcnti++;
4550if(this.pgcnti>=this.expectedpgcnt){
4551this.decodeState='complete';
4552delete this.pgcnti;
4553delete this.expectedpgcnt;
4554return true;
4555}
4556return false;
4557}
4558function bskIncorporateTemp(){
4559for (var i=0;i<this.itemsTemporary.cnt();i++){
4560var tmp=this.itemsTemporary.get(i);
4561for (var i=0; i<this.items.cnt(); i++) {
4562var itm=this.items.get(i);
4563if (!itm.isSame(tmp)) continue;
4564itm.transfer(tmp);
4565this.items.del(i);
4566break;
4567}
4568tmp.cache=[];
4569tmp.parent=this;
4570var p=tf.wm.pProp(tmp.id);
4571this.disc.eAdd(tmp.id,[p[5], p[6], p[7]]);
4572this.ship.eAdd(tmp.id,[tmp.id, p[8]]);
4573this.items.add(tmp);
4574this.itemsTemporary.replace(i,tmp);
4575}
4576}
4577function bskClone(o,lvl,o2,oTop){
4578if(isNaN(lvl)){lvl=0;oTop=o;}else if(lvl>10)return;
4579lvl++;
4580var oThis=(o2?o2:this);
4581for (var i in o){
4582if(i=='parent'||i=='bsk'){oThis[i]=oTop;continue;}
4583if(typeof(o[i])=='object')
4584if(o[i]&&!isNaN(o[i].length)){oThis[i]=[];bskClone(o[i],lvl,oThis[i],oTop);}
4585else oThis[i]=new bskClone(o[i],lvl,null,oTop);
4586else
4587oThis[i]=o[i];
4588}
4589}
4590function bskMerge(o,lvl,o2,oTop){
4591if(isNaN(lvl)){lvl=0;oTop=this;}else if(lvl>10)return;
4592lvl++;
4593var oThis=(o2?o2:this);
4594for (var i in o){
4595if(i=='parent'||i=='bsk'){oThis[i]=oTop;continue;}
4596if(typeof(o[i])=='object'&&o[i])
4597if(o[i]&&!isNaN(o[i].length)){oThis[i]=[];bskMerge(o[i],lvl,oThis[i],oTop);}
4598else if(oThis[i]&&(oThis[i].gid||o[i].gid)){
4599for(var oi in o[i]._arr){
4600if(!o[i]._arr[oi])continue;
4601if(!oThis[i].getById(o[i]._arr[oi].id)){
4602var oNew=oThis[i].empty();
4603bskMerge(o[i]._arr[oi],lvl,oNew,oTop);
4604oThis[i].add(oNew);
4605}
4606else if(i=='items'&&oThis[i]._arr&&!oThis[i]._arr[oi]){
4607var oNew=oThis[i].empty(),newidtag=oNew.idtag;
4608bskMerge(o[i]._arr[oi],lvl,oNew,oTop);
4609oNew.idtag=newidtag;
4610oThis[i].add(oNew);
4611}
4612if(oThis[i]._arr[oi].gid=='item')oThis[i]._arr[oi].parent=oTop;
4613}
4614}
4615else if(i=='fbsk'||i=='tax'){
4616for(var oo in o[i]){
4617bskMerge(o[i],lvl,oThis[i],oTop);
4618}
4619}
4620else{oThis[i]=new bskMerge(o[i],lvl,null,oTop);}
4621else
4622oThis[i]=o[i];
4623}
4624}
4625function bskHasOnlyRequests(){
4626var hasOnlyRequests=true;
4627for (var i=0,ii=this.items.cnt(); i<ii; i++) {
4628var itm = this.items.get(i);
4629if(!itm.requestQuote&&!itm.requestSample){
4630hasOnlyRequests=false;
4631break;
4632}
4633}
4634return hasOnlyRequests;
4635}
4636function bskGroupByCode(type,nocache) {
4637if(type<0)return {};
4638if(!nocache&&this.cache['itmGrp']&&this.cache['itmGrp'][type])return this.cache['itmGrp'][type];
4639var itmGrp={},n=0;
4640for (var i=0,ii=this.items.cnt(); i<ii; i++) {
4641var itm=this.items.get(i);
4642var p=tf.wm.pProp(itm.id);
4643if(p){
4644var code=prodTypeCode(type,p);
4645if (code&&!itm.requestQuote&&!itm.requestSample) {
4646if(!itmGrp[code])itmGrp[code]=[0,[]];
4647itmGrp[code][0]+=itm.quantity;
4648itmGrp[code][1].push(n);
4649}
4650}
4651n++;
4652}
4653if(!this.cache['itmGrp'])this.cache['itmGrp']={};
4654this.cache['itmGrp'][type]=itmGrp;
4655return itmGrp;
4656}
4657var voucher = {
4658rawDisc:0,type:0,vtype:'',msg:'',code:'',vk:'',fnPostProcess:null,dscc:null,fs:false,
4659gl:function(id){return tf.content.gl(id);},
4660clear:function(){this.invalidate();this.msg='';this.purtot=this.newtot=0;},
4661invalidate:function(){this.code='';this.type=0;this.vtype='';this.vk='';this.rawDisc=0;this.dscc=null;this.fs=false;this.msg=''},
4662isInvalid:function(){return this.type==0&&this.vtype=='';},
4663isAppliesToTotal:function(){return this.vtype=='gift';},
4664noDiscount:function(){return (!this.isInvalid()&&(this.purtot-this.newtot)<0.001&&!this.fs);},
4665process:function(dt,vt,disc,resp,msgcode,msgtext,msgarg1,vk,dscc,fs){
4666if(msgcode=='ld_voucher_must_add_more_to_basket')msgarg1=core.showPrc(msgarg1,1);
4667if(typeof(msgtext)!='undefined')msgtext=msgtext.replace(/\$1/g,msgarg1);
4668this.dscc=(dscc?dscc.split(';'):null);
4669this.rawDisc=(disc>=0?disc:0);
4670if(this.rawDisc>0||dt==4){
4671this.type=dt;
4672this.vtype=vt;
4673this.vk=vk;
4674this.msg=msgtext;
4675this.purtot=core.Basket.total('orig');
4676if(dt==4){
4677this.newtot=this.purtot;
4678this.fs=true;
4679}
4680else{
4681this.newtot=this.calcRaw(core.Basket.total());
4682this.fs=!!fs;
4683}
4684}
4685else{this.msg=(resp?msgtext:'');this.code='';this.purtot=this.newtot=0;this.fs=false;}
4686this.dispDisc('voucherDisc');
4687this.dispCode('voucherCode');
4688this.dispMsg('voucherMsg','btnVoucher',true,true);
4689if(typeof(this.fnPostProcess) == 'function'){this.fnPostProcess();this.fnPostProcess=null;}
4690},
4691getDscAmt:function(){
4692if(this.isInvalid())return 0;
4693return this.isAppliesToTotal()?Math.min(core.Basket.chk_total_novoucher,this.rawDisc):this.purtot-this.newtot;
4694},
4695getGroupByCodeItmIdxs:function(){
4696if(!this.dscc)return null;
4697var idxs=[],itmGrp=core.Basket.groupByCode(5);
4698for(var i=0,ii=this.dscc.length;i<ii;i++){
4699var o=itmGrp[this.dscc[i]];
4700if(o){
4701for(var n=0,nn=o[1].length;n<nn;n++){
4702idxs.push(o[1][n]);
4703}
4704}
4705}
4706return idxs;
4707},
4708calcGroupTot:function(){
4709if(!this.dscc)return 0;
4710var tot=0,itmGrp=core.Basket.groupByCode(5);
4711for(var i=0,ii=this.dscc.length;i<ii;i++){
4712var o=itmGrp[this.dscc[i]];
4713if(o){
4714var itms=core.Basket.items;
4715for(var n=0,nn=o[1].length;n<nn;n++){
4716var itm=itms.get(o[1][n]);
4717tot+=itm.calc();
4718}
4719}
4720}
4721return tot;
4722},
4723calcRaw:function(tot){
4724var val=0,grpTot=this.calcGroupTot();
4725switch(this.type){
4726case 1:
4727if(this.dscc)val=(tot-grpTot)+Math.max(0, grpTot-this.rawDisc);
4728else val=tot-this.rawDisc;
4729break;
4730case 2:
4731var purtot=(this.dscc?grpTot:core.Basket.total('orig'));
4732val=this.purtot-core.nfmt.round(purtot*this.rawDisc/100.0);
4733break;
4734case 3:
4735var purtot=(this.dscc?grpTot:core.Basket.total('orig'));
4736val=this.purtot-(purtot-this.rawDisc);
4737break;
4738case 4:
4739val=tot;
4740}
4741val=Math.max(0,val);
4742if(this.dscc&&grpTot==0)this.msg=LD.LD_VOUCHER_NO_APPLICABLE_PRODUCTS;
4743return val;
4744},
4745calc:function(tot,purtot,newtot){
4746if(this.type==0||this.isAppliesToTotal())return tot;
4747purtot=(purtot?purtot:this.purtot);
4748newtot=(newtot?newtot:this.newtot);
4749var val=0,oTax=core.Basket.tax,hasTax=oTax.anyTaxForRegion(oTax.currRegn());
4750if(hasTax)val=(((tot*newtot)+0.000000000001)/purtot);
4751else{
4752var incTax=oTax.cntInc(core.Basket.items);
4753if(this.type==3&&incTax)val=core.Basket.tax.calcTax(core.Basket.tax.allIDs(),purtot)/purtot*newtot;
4754else val=this.calcRaw(tot);
4755}
4756val=Math.max(0,val);
4757return val;
4758},
4759dispMsg:function(id,idbtn,showmsg,showbtn){
4760var el=this.gl(id);
4761if(el){if(showmsg){el.style.display='inline';el.innerHTML='<br>'+this.msg;}else{el.style.display='none';}}
4762el=this.gl(idbtn);
4763if(el)el.style.visibility=(showbtn?'visible':'hidden');
4764},
4765dispDisc:function(id){if(this.type!=0&&this.getDscAmt()>0){var el=this.gl(id);if(el)el.innerHTML=core.showPrc(this.getDscAmt(),1);}},
4766dispCode:function(id){var el=this.gl(id);if(el)el.value=this.code;},
4767query:function(code,idmsg,idbtn,iddisc,fn){
4768this.fnPostProcess=fn;
4769this.msg=LD.LD_LOADING;
4770this.dispMsg(idmsg,idbtn,true,false);
4771var el=this.gl(iddisc);if(el)el.innerHTML='';
4772this.code=(code||'').trim();
4773if(!this.code){this.dispMsg(idmsg,idbtn,false,true);this.dispDisc(iddisc);return false;}
4774this.disc=0;
4775tf.load('https://santu.com/webshop/voucher_discount.cgi?lang='+tf.lang+'&lmd='+Date()+'&from=sf&url='+escape(tf.wm.online?location.protocol+'//'+location.host+tf.wm.baseurl+'provider.html':tf.wm.url('provider.html','-'))+'&tot='+core.Basket.total('orig')+'&mid=cosmetics&vc='+this.code,'voucher',false,true);
4776return false;
4777}
4778};
4779function item()
4780{
4781this.options	= new dynObj('options');
4782this.init	= itemInit;
4783this.isSame	= itemIsSame;
4784this.transfer	= itemTx;
4785this.sig	= itemSig;
4786this.code	= itemCode;
4787this.getItemNo = itemGetItemNo;
4788this.xcode	= itemXCode;
4789this.updQnty	= itemUQnty;
4790this.addOpt	= itemAddOpt;
4791this.weight	= itemWeight;
4792this.shipMth	= itemShipMth;
4793this.calc	= itemCalc;
4794this.getGDsc = itemGetGDsc;
4795this.makeRequest = itemMakeRequest;
4796this.getXData = itemGetXData;
4797return this;
4798}
4799function itemInit(prt,id,doc,qnty,price,title,weight,itemNo,useDec,esd,taxes,prdc,imgsrc,temp)
4800{
4801var loc='',img='',info='';
4802if(doc){
4803if (doc.gid=='item'){
4804var o=doc;
4805title=o.title;if(!weight)weight=o.weight;itemNo=o.itemNo;
4806useDec=o.useDec;esd=o.esd;taxes=o.taxes;loc=o.purl;img=o.pimg;
4807info=o.information;
4808}else{
4809var pcpu='data-productcrosspromotionurl-'+id.replace(/^.*\|(p\d+)(d\d+)?/i,'$1').toLowerCase();
4810if($('['+pcpu+']').length>0){
4811var pcpurl=$('['+pcpu+']').attr(pcpu);
4812loc=escape(pcpurl.indexOf('#')==0?tf.wm.hostbaseurl+pcpurl:tf.wm.url(tf.wm.host+pcpurl,'-',true));
4813}
4814else loc=tf.wm.url(escape(doc.location.toString().replace(doc.location.search,'')));
4815if(!imgsrc){
4816var i=doc.getElementById('I'+id);
4817if(i){
4818var tnreal=i.parentNode.getAttribute('tnreal');
4819if(tnreal&&tnreal!='undefined'&&tnreal.toLowerCase().indexOf('.swf')!=tnreal.length-4){
4820img=(i.getAttribute('mediatype')=='HTML'?'':tnreal);
4821}
4822else if(i.getAttribute('origsrc'))img=tf.wm.url(i.getAttribute('origsrc'));
4823else img=tf.wm.url(i.src);
4824}
4825}
4826else img=imgsrc;
4827var elIntro = doc.getElementById('ProductIntroduction-'+id);
4828if (elIntro) {
4829var info = (elIntro.innerText||elIntro.textContent||'').replace(/[\n\r]/g,' ').replace(/"/g,'\"');
4830if (info.length > 150) {
4831info = info.substring(0, 150);
4832var pos = Math.max(info.lastIndexOf(' '), info.lastIndexOf('	'), info.lastIndexOf('&nbsp;'), info.lastIndexOf('\n'), info.lastIndexOf('\r'));
4833if (pos > 0) info = info.substring(0, pos) + '...';
4834}
4835}
4836}
4837}
4838this.parent	= prt;
4839this.id		= id;
4840this.useDec	= useDec;
4841this.title	= title;
4842this.information = info;
4843this.itemNo	= itemNo;
4844this.esd	= esd;
4845this.purl	= loc;
4846this.pimg	= img;
4847this.prdc	= prdc;
4848this.quantity=0;
4849this._wght=0;
4850var p = tf.wm.pProp(this.id);
4851if (p) {
4852this.department = p[15];
4853this.category = p[16];
4854this.producttype = p[17];
4855this.xdata = p[24];
4856this.brand = p[14];
4857this.ean = p[25];
4858}
4859this.cache	= [];
4860this.price	= parseFloat(price);
4861this.optPrice = 0;
4862this.taxes	= taxes;
4863this.updQnty(qnty);
4864this.weight(weight);
4865this.handlingcosts=[];
4866this.temporary=temp;
4867this.requestQuote = false;
4868this.requestSample = false;
4869}
4870function itemGetItemNo(){
4871var s=this.itemNo;
4872for (var i=0, o=this.options;i<o.cnt();i++){
4873var opt=o.get(i);
4874if(opt.combine&&opt.optId()){
4875s=opt.optId();
4876break;
4877}
4878}
4879return s;
4880}
4881function itemTx(obj,dcp)
4882{
4883if (!dcp) {obj.quantity += this.quantity;obj.quantity=parseInt(obj.quantity*1000000+0.000001)/1000000;if(typeof(nfmt)=='object'){obj.quantity=nfmt.round(obj.quantity,null,obj.useDec?obj.quantity:1);}return obj.quantity;}
4884obj.code(this.code());
4885}
4886function itemIsSame(obj)
4887{
4888if (obj.id != this.id) return 0;
4889if (obj.requestQuote != this.requestQuote) return 0;
4890if (obj.requestSample != this.requestSample) return 0;
4891var myOpt = this.options;
4892var yrOpt = obj.options;
4893if (myOpt.cnt() != yrOpt.cnt()) return 0;
4894for (var i=0; i<myOpt.cnt(); i++) {
4895var opt = yrOpt.get(i);
4896if (opt == '' || myOpt.get(i).choice() != opt.choice()) return 0;
4897}
4898return 1;
4899}
4900var _iArr=['id','quantity','title','price','_wght','itemNo','taxes','esd','useDec','purl','pimg','optPrice','information','requestQuote','requestSample'];
4901function itemCode(prt,str)
4902{
4903if (prt) this.parent=prt;
4904return ckCodeStr(this, _iArr, '|', str);
4905}
4906function itemSig(compress)
4907{
4908var p=tf.wm.pProp(this.id);
4909if (!p) return '';
4910p[9]=p[9].replace('%%P','');
4911var op = new Array();
4912for (var i in p['opt']){
4913var s=p['opt'][i].join('~');
4914if(compress&&tf.isIE8)s=s.replace(/~~~~~/g,'~');
4915op[op.length]=s;
4916}
4917var ret=p.join('~') + ((op.length)?'/'+op.join('/'):'') + '/' + p['sig'];
4918if (!isNaN(p[9])) p[9]+='%%P';
4919return ret;
4920}
4921function itemXCode(str)
4922{
4923var s = '';
4924if (str==null||str=='') {
4925for (var i=0; i<this.options.cnt(); i++) {
4926s += (i==0)?'':';';
4927s += this.options.get(i).code();
4928}
4929} else {
4930var arr = str.split(';');
4931for (var i=0; i<arr.length; i++) {
4932var opt = this.options.empty();
4933opt.code(arr[i]);
4934this.options.add(opt);
4935}
4936}
4937return s;
4938}
4939function itemUQnty(qnty)
4940{
4941this.quantity = (this.useDec>0)?parseFloat(qnty):parseInt(qnty);
4942}
4943function itemAddOpt(allOpts, doc)
4944{
4945var opts = this.options;
4946var _f=doc.productForm;
4947if (!_f) {
4948_f=doc.options;
4949this.optPrice = 0;
4950for (var i=0; i<_f.cnt(); i++) {
4951var o = opts.empty();
4952o.code(_f.get(i).code());
4953o.price(getOPrc(doc.id, o.internalOptId(), o.idxPrc-1));
4954this.optPrice += o.price();
4955opts.add(o);
4956}
4957tf.wm.pProp(doc.id).optPrice=this.optPrice;
4958return '';
4959}
4960var len=(allOpts)?allOpts.length:0;
4961var form=new iForm(_f);
4962for (var i=0; i<len; i++) {
4963var arr = allOpts[i];
4964if (arr[0].substr(0,this.id.length)!=this.id||arr[0].substr(this.id.length,1)!='O') continue;
4965var o = opts.empty();
4966o.init(arr, form.getOriginalValue(arr[1]));
4967o.idxPrc = form.getIdx(arr[1]);
4968if(!o.prop[7])o.prop[7]=arr[0]+'C1';
4969var fld = form.getField(arr[1]);
4970if (fld){
4971if(fld.type=='text'||fld.type=='textarea'){
4972var oTmp = opts.empty();
4973oTmp.init(arr, fld.ctrl.getAttribute('metavalue'));
4974o.prop[0] = fld.rawValue==oTmp.choice() ? '' : fld.rawValue;
4975}
4976else if(fld.type=='radio'){
4977if(fld.value==''){o.prop[0]='';o.prop[1]='0';}
4978}
4979else if(fld.type=='checkbox'){
4980if(fld.rawValue=='0'){o.prop[0]='';o.prop[1]='0';}
4981}
4982}
4983opts.add(o);
4984}
4985var str  = '';
4986var warn = 0;
4987for (var i=0; i<opts.cnt();i++) {
4988var s = opts.get(i).check();
4989if (!s) continue;
4990if (s==' ') warn=1; else str+=s+'\n';
4991}
4992if (str != '') return str;
4993if (warn) return ' ';
4994return '';
4995}
4996function itemWeight(w)
4997{
4998if (w!=null) this._wght = parseFloat(w);
4999else w=this._wght;
5000if (isNaN(w)) w=0;
5001for (var i=0,o=this.options; i<o.cnt(); i++) {
5002if (o.get(i).choice()) w += o.get(i).weight();
5003}
5004return w;
5005}
5006function itemGetGDsc()
5007{
5008var prt= this.parent,gdsc=(ResellerID!='')?prt.gdisc.get(this.prdc):null;
5009if (!gdsc&&ResellerID!='') gdsc=prt.gdisc.get('ALL_OTHERS');
5010return gdsc;
5011}
5012function itemCalc(type,shMeth,nocache)
5013{
5014if (type=='cgi') {
5015if (this.requestQuote || this.requestSample) return 0;
5016type='';
5017}
5018if (!type) type='pur';
5019var qtyCache=type+this.quantity;
5020if (!nocache&&this.cache[qtyCache]) return this.cache[qtyCache];
5021var qty=this.quantity,prt= this.parent,sd = prt.shDisc();
5022var stk= prt.stk.getS(this.getItemNo());
5023var dsc = prt.disc.get(this.id),gdsc = this.getGDsc();
5024var tax = prt.tax, prc = 0, prd = tf.wm.pProp(this.id);
5025switch (type) {
5026case 'pdamt':
5027prc=0;
5028if(true)prc=dsc.amount(this.price,qty,this.calc('opt',shMeth,nocache),prd);
5029if(gdsc)prc=prc+gdsc.amount(this.price-prc,qty,this.calc('opt',shMeth,nocache),prd);
5030break;
5031case 'damt':
5032var all = this.parent.items;
5033for (var i=0,ii=all.cnt(); i<ii; i++) {
5034var itm = all.get(i);
5035if (itm==this) continue;
5036prc += (itm.calc('snd',shMeth,nocache)-itm.calc('pdamt',shMeth,nocache))*itm.quantity;
5037}
5038var iprc = this.calc('snd',shMeth,nocache) - this.calc('opt',shMeth,nocache) - this.calc('pur_pdamt',shMeth,nocache),itmGrp=this.parent.groupByCode(sd.limitToCodeType);
5039prc += qty?iprc*qty:iprc;
5040prc  = sd.amount(iprc,(itmGrp[tf.core.prodTypeCode(sd.limitToCodeType,prd)]||[0,0])[0],0,prd) + this.calc('pdamt',shMeth,nocache);
5041break;
5042case 'opt': prc+=this.optPrice;break;
5043case 'snd': prc=this.price+this.calc('opt',shMeth,nocache);break;
5044case 'sdc': prc=this.calc('snd',shMeth,nocache)-this.calc('damt',shMeth,nocache);break;
5045case 'ndc': prc=(this.price+this.calc('opt',shMeth,nocache))*qty;break;
5046case 'dsc': prc=this.calc('sdc',shMeth,nocache)*qty;break;
5047case 'tax': prc=tax.allAmt(this.taxes,this.calc('dsc'));break;
5048case 'pur': prc=tax.calcTax(this.taxes,this.calc('dsc',shMeth,nocache));break;
5049case 'exc': prc=tax.exTax(this.taxes,this.calc('dsc',shMeth,nocache)); break;
5050case 'exc_noround': prc=tax.exTax(this.taxes,this.calc('dsc',shMeth,nocache)); break;
5051case 'inc': prc=tax.calcTax(this.taxes,this.calc('dsc',shMeth,nocache)); break;
5052case 'sdp': prc=this.price-this.calc('damt',shMeth,nocache);break;
5053case 'pur_pdamt':
5054prc=0;
5055if(true)prc=dsc.amount(this.price,qty,0,prd);
5056if(gdsc)prc=prc+gdsc.amount(this.price-prc,qty,0,prd);
5057break;
5058case 'pur_damt':
5059var all = this.parent.items;
5060for (var i=0,ii=all.cnt(); i<ii; i++) {
5061var itm = all.get(i);
5062if (itm==this) continue;
5063prc += (this.price-itm.calc('pur_pdamt',shMeth,nocache))*itm.quantity;
5064}
5065var iprc = this.price - this.calc('pur_pdamt',shMeth,nocache),itmGrp=this.parent.groupByCode(sd.limitToCodeType);
5066prc += qty?iprc*qty:iprc;
5067prc  = sd.amount(iprc,(itmGrp[prodTypeCode(sd.limitToCodeType,prd)]||[0,0])[0],0,prd) + this.calc('pur_pdamt',shMeth,nocache);
5068break;
5069case 'pur_exc': prc=tax.exTax(this.taxes,this.price); break;
5070case 'pur_inc': prc=tax.calcTax(this.taxes,this.price);break;
5071case 'pur_exc+dsc': prc=this.calc('pur_exc',shMeth,nocache)-this.calc('pur_damt',shMeth,nocache); break;
5072case 'pur_inc+dsc': prc=this.calc('pur_inc',shMeth,nocache)-this.calc('pur_damt',shMeth,nocache);break;
5073case 'pur_exc+opt': prc=tax.exTax(this.taxes,this.calc('snd',shMeth,nocache)); break;
5074case 'pur_inc+opt': prc=tax.calcTax(this.taxes,this.calc('snd',shMeth,nocache));break;
5075case 'pur_exc+opt+dsc': prc=tax.exTax(this.taxes,this.calc('sdc',shMeth,nocache)); break;
5076case 'pur_inc+opt+dsc': prc=tax.calcTax(this.taxes,this.calc('sdc',shMeth,nocache));break;
5077}
5078prc=parseFloat(prc);
5079if(((type=='pur'||type=='exc')&&!tax.exempt&&qty==1)||(type=='dsc'&&qty==1)||type=='sdc')prc=nfmt.round(prc);
5080if (!nocache) this.cache[qtyCache]=prc;
5081return prc;
5082}
5083function itemShipMth(mid, cde)
5084{
5085var ps  = new Array();
5086var sh  = this.parent.ship.get(this.id);
5087var val = sh?sh.val():'';
5088if (!val) return mid?0:ps;
5089val = val.split(';');
5090for (v in val) {
5091var e = val[v].split(',');
5092if (!mid) ps[e[0]] = e[1];
5093else if (mid==e[0]) return e[cde]?parseFloat(e[cde])*this.quantity:0;
5094}
5095return mid?0:ps;
5096}
5097function itemMakeRequest(type)
5098{
5099this.requestQuote=(type==2);
5100this.requestSample=(type==3);
5101}
5102function itemGetXData(jsonPath) {
5103if(!this.xdata)return null;
5104var o=tf.sfJSON.parse(this.xdata),val=null;
5105if(o)eval('val=o.'+jsonPath);
5106return val;
5107}
5108function regPrc(arr)
5109{
5110function h2a(decode,s) {
5111var ret = '', aRet = [];
5112if(decode) {
5113var len = s.length-32;
5114for (var i=0; i<len; i+=2) {
5115if (s.charAt(i)+s.charAt(i+1) == '4x') {
5116aRet.push(String.fromCharCode(parseInt(s.charAt(i+2)+s.charAt(i+3)+s.charAt(i+4)+s.charAt(i+5),16)));
5117i += 4;
5118}
5119else aRet.push(unescape('%'+s.charAt(i)+s.charAt(i+1)));
5120}
5121aRet.push(s.substring(len,len+32));
5122ret = aRet.join('');
5123} else {
5124ret = s;
5125}
5126var arr = [];
5127if(ret){
5128arr = ret.split('/');
5129for (var i=0; i<arr.length; i++){arr[i]=arr[i].replace(/&#47;/g,'/');}
5130}
5131return arr;
5132}
5133var oOptIdx={},oOptWgtIdx={};
5134for(var i=0,ii=opt.length;i<ii;i++){
5135oOptIdx[opt[i][0]]=opt[i];
5136if(!crFFldArr[i]||!crFFldArr[i][5])continue;
5137var oOptWgt=[opt[i][0],''];
5138for(var j=0,jj=crFFldArr[i][5].length;j<jj;j++){
5139oOptWgt.push(parseFloat(crFFldArr[i][5][j][4]));
5140}
5141if(!(oOptWgtIdx[crFFldArr[i][8]]))oOptWgtIdx[crFFldArr[i][8]]=[];
5142oOptWgtIdx[crFFldArr[i][8]].push(oOptWgt);
5143}
5144var ret = 1;
5145for (var i=0; i<arr.length; i++) {
5146var sr = h2a(!isNaN(parseInt(arr[i])), arr[i]);
5147if(!sr[0])continue;
5148var prop=sr[0].split('~');
5149var discType=parseInt(prop[5]);
5150if (tf.wm.pProp(prop[0])) {
5151ret = 0;
5152continue;
5153}
5154var op=new Array();
5155for (var j=1; j<sr.length-1; j++) {
5156var tmp = sr[j].split('~');
5157op[op.length] = tmp;
5158}
5159prop['sig'] = sr[sr.length-1];
5160prop['opt'] = op;
5161prop['optWgt'] = oOptWgtIdx[prop[0]];
5162if (!isNaN(prop[9])) prop[9]+='%%P';
5163var optprcmin=getOPrcMin(prop,oOptIdx);
5164if(optprcmin!==false)prop['optprcmin']=optprcmin;
5165tf.wm.pProp(prop[0], prop);
5166}
5167$(tf).trigger('pPropUpdated');
5168return ret;
5169}
5170var sh_dobj;
5171if (this.discount) {
5172sh_dobj = new discount();
5173gd_obj = new discount();
5174sh_dobj.init('6','0.000,50.000,0;50.000,75.000,3;75.000,100.000,7;100.000,125.000,10','','','',-1,'');
5175if(!isInSF()){
5176if(window.timedDiscountsExist){
5177function shopDiscMsg(){
5178$(function () {
5179var el=tf.content.document.getElementById('ShopDiscountMessage-'+tf.content.pgid);
5180if(el)el.style.display=currTime.isActive(sh_dobj.tlim)?'block':'none';
5181});
5182}
5183currTime.handlers['getTime'].push(shopDiscMsg);
5184}
5185if(window.timedDiscountsExist)currTime.handlers['getTime'].push(function(){if(tf.bskLoaded&&tf.utils){tf.utils.populatePrice();tf.utils.populateOpt();}});
5186}
5187}
5188function getDscAmt(id, prc, usePrc, dontApplyPrdDsc, dontApplyShopDsc)
5189{
5190var p=tf.wm.pProp(id);
5191var amt=0;
5192var dsc_obj = new discount();
5193if (!p || !dsc_obj) return '';
5194if (true) {
5195if(!dontApplyPrdDsc){
5196dsc_obj.init(p[5], p[6], p[7]);
5197amt += dsc_obj.amount(prc, 1, 0);
5198}
5199if(!dontApplyShopDsc){
5200var itmGrp=core.Basket.groupByCode(sh_dobj.limitToCodeType);
5201if(sh_dobj.type!=6/* &&sh_dobj.type!=4 */)amt += sh_dobj.amount((usePrc?prc:p[1])-amt, (itmGrp[prodTypeCode(sh_dobj.limitToCodeType,p)]||[0,0])[0], 0, p);
5202}
5203}
5204if (ResellerID!='') {
5205var Basket=core.Basket;
5206var gdsc=Basket.gdisc.get(p[9]);
5207if (!gdsc) gdsc=Basket.gdisc.get('ALL_OTHERS');
5208if (gdsc) amt+=gdsc.amount(parseFloat(prc)-amt, 1, 0);
5209}
5210return amt;
5211}
5212function getPrc(id, sid, dsc)
5213{
5214var p=tf.wm.pProp(id);
5215if (p==null) return '';
5216var prcDsc=(p[5]=='0'&&parseFloat(p[6])!=0),dscAppliesToOptions=true,shdscAppliesToOptions=false;
5217var prc = parseFloat(p[1]), optprc = (p['optPrice']||0);
5218if (sid) { for (var i in p['opt']) { if (p['opt'][i][0] == sid) { prc = p['opt'][i]; break; } } return prc; }
5219var val = prc + optprc;
5220p['autoIntro'] = '';
5221if(val == 0.0&&p['optprcmin']) {
5222val = p['optprcmin'];
5223prc = p['optprcmin'];
5224p['autoIntro'] = (LD.LD_PRICEINTRO_FROM||'');
5225}
5226if (dsc) val -= (getDscAmt(id, prc, true) + getDscAmt(id, optprc, true, prcDsc ? true : !dscAppliesToOptions, !shdscAppliesToOptions));
5227if(!isNaN(val)){
5228if(nfmt.dec!=tf.currentCurrency.decimal_places)val=nfmt.round(val,nfmt.dec);
5229val=nfmt.round(val,1/Math.pow(10,tf.currentCurrency.decimal_places));
5230}
5231return val;
5232}
5233function getWgt(id, sid)
5234{
5235var p=tf.wm.pProp(id);
5236if (p==null) return '';
5237var optWgt=null;
5238if (sid) {
5239for (var i in p['optWgt']) { if (p['optWgt'][i][0] == sid) { optWgt = p['optWgt'][i]; break; } } return optWgt;
5240}
5241}
5242function getOPrc(id, sid, od, dsc, dscx)
5243{
5244if (id.indexOf('O')>-1) id=id.substr(0,id.indexOf('O'));
5245var op=getPrc(id,sid),p=tf.wm.pProp(id),ret=0,optprc=op[od*2+2]||0;
5246var prcDsc=(p[5]=='0'&&parseFloat(p[6])!=0),dscAppliesToOptions=true,shdscAppliesToOptions=false;
5247if(dscx)ret=(op==null)?0:(dsc?optprc-getDscAmt(id,Math.abs(optprc),true,prcDsc ? true : !dscAppliesToOptions, !shdscAppliesToOptions)*(optprc>0?1:-1):optprc);
5248else ret=(op==null)?0:(dsc?optprc-getDscAmt(id,optprc,true,prcDsc ? true : !dscAppliesToOptions, !shdscAppliesToOptions):optprc);
5249return ret;
5250}
5251function getOPrcMin(p,oIdx)
5252{
5253var oOptIdx=oIdx;
5254if(!oOptIdx){
5255for(var i=0,ii=opt.length;i<ii;i++)oOptIdx[opt[i][0]]=opt[i];
5256}
5257var mintot=0;
5258for(var i in p['opt']){
5259if(oOptIdx[p['opt'][i][0]]&&oOptIdx[p['opt'][i][0]][3]==0)continue;
5260var oPMin=null;
5261for(var j=2;j<p['opt'][i].length;j+=2){
5262var oP=parseFloat(p['opt'][i][j]);
5263if(oP<oPMin||oPMin==null)oPMin=(oP||0);
5264}
5265mintot+=oPMin;
5266}
5267return mintot;
5268}
5269function getOWgt(id, sid, od)
5270{
5271if (id.indexOf('O')>-1) id=id.substr(0,id.indexOf('O'));
5272var op=getWgt(id,sid),p=tf.wm.pProp(id),ret=op[od+2]||0;
5273return ret;
5274}
5275function dPrc(prc, ifscurr,dispZero,fmtCurr,symbolClass)
5276{
5277var scurr='';
5278if (!ifscurr&&tf.secondCurrency) scurr='<span class="SecondaryCurrencyAmount">('+getSCurr(prc,fmtCurr,symbolClass)+')</span> ';
5279var abbrev = tf.currentCurrency.abbrev;
5280if (fmtCurr) abbrev = '<span'+(symbolClass?' class="'+symbolClass+'"':'')+'>'+abbrev+'</span>';
5281return (prc==''&&!dispZero)?'':scurr+'<span>'+nfmt.display(prc*(tf.currentCurrency.multiplier/tf.shopCurrency.multiplier), tf.currentCurrency.decimal_places,abbrev)+'</span>';
5282}
5283function getSCurr(prc,fmtCurr,symbolClass){
5284var scCurr=tf.secondCurrency, abbrev = scCurr ? scCurr.abbrev : '';
5285if (fmtCurr) abbrev = '<span'+(symbolClass?' class="'+symbolClass+'"':'')+'>'+abbrev+'</span>';
5286return (scCurr)?nfmt.display(prc*(scCurr.multiplier/tf.shopCurrency.multiplier),scCurr.decimal_places,abbrev):'';
5287}
5288function CSS(doc)
5289{
5290this.get  = cssGet;
5291this.init = cssInit;
5292this.init(doc);
5293}
5294function cssInit(doc)
5295{
5296function docSS(arr,doc) {
5297var ds=doc.styleSheets;
5298if (ds&&ds.length>0&&ds[0].imports&&ds[0].imports.length>0){
5299ds=ds[0].imports[0];
5300for(var j=0,rl=ds.rules;rl&&j<rl.length;j++){
5301if(!rl[j].selectorText)continue;
5302var tag=rl[j].selectorText.toLowerCase();
5303arr[tag]=rl[j].style.cssText;
5304}
5305}
5306else ds=null;
5307return ds;
5308}
5309function defSS(arr,doc) {}
5310if (!doc) doc=document;
5311this._css = new Array();
5312if (!docSS(this._css, doc)) defSS(this._css,doc);
5313}
5314function cssGet(name,type)
5315{
5316switch(type){
5317case 1: name='.'+name;break;
5318}
5319return this._css[name];
5320}
5321var crFFldImager={
5322img:new Image(),
5323prgImg:null,
5324gl:function(id){return tf.content.document.getElementById(id);},
5325elParS:null,
5326outerHTML:function(el){
5327var elPar=el.parentNode;
5328var elNew=tf.content.document.createElement(elPar.nodeName);
5329elNew.appendChild(el);
5330var html=elNew.innerHTML;
5331elPar.appendChild(el);
5332return html;
5333},
5334scale:function(mW, mH, cW, cH){
5335if(cW<mW&&cH<mH)return[cW,cH];
5336var r=cH/cW,cx=mW,cy=parseInt((mW*r)+0.5);
5337if(cy>mH){ r=cW/cH; cx=parseInt((mH*r)+0.5); cy=mH; }
5338return [cx,cy];
5339},
5340replace:function(prid,id){
5341if(this.busy){setTimeout(function(){tf.core.crFFldImager.replace(prid,id);},50);return;}
5342this.busy=true;
5343var elImg=this.gl('I'+prid),elPImg=this.gl('ProductImage-'+[prid]);
5344if(elImg&&elPImg){
5345this.elParS=elPImg.style;
5346var elChImg=this.gl('ChoiceImage-'+id)||this.gl('ProductMoreImages-'+id)||this.gl('ChoiceImage-'+prid)||this.gl('ProductThumbnailImage-'+prid),isHTML=elChImg&&(elChImg.getAttribute('filetype')=='html'||elChImg.getAttribute('mediatype')=='HTML');
5347var elPar=elImg.parentNode,origw=elPImg.parentNode.offsetWidth||elImg.offsetWidth,origh=elPImg.parentNode.offsetHeight||elImg.offsetHeight;
5348if(!elImg.getAttribute('origsrc')){
5349var elPImgParS=elPImg.parentNode.style,origsrc=elImg.src||this.outerHTML(elImg);
5350elPImgParS.height=elPImg.parentNode.offsetHeight+'px';
5351elPImgParS.width=elPImg.parentNode.offsetWidth+'px';
5352if(elPImg.parentNode.className.indexOf('ImgLink')!=-1)elPImg.parentNode.style.overflow='hidden';
5353}
5354function createNew(nodeName,prid,el,elPar){
5355if(el.nodeName!=nodeName){
5356el.parentNode.removeChild(el);
5357el=tf.content.document.createElement(nodeName);
5358el.id='I'+prid;
5359el.setAttribute('origmm',true);
5360if(!el.parentNode){
5361el=elPar.insertBefore(el,elPar.childNodes[0]||null);
5362}
5363}
5364return el;
5365}
5366if(isHTML){
5367elImg=createNew('SPAN',prid,elImg,elPar);
5368}
5369else{
5370elImg=createNew('IMG',prid,elImg,elPar);
5371}
5372if(!elImg.getAttribute('origsrc')){
5373elImg.setAttribute('origsrc',origsrc);
5374}
5375elImg.setAttribute('origw',origw);
5376elImg.setAttribute('origh',origh);
5377jQuery(elImg).siblings('.zoomImg').remove();
5378if(elChImg){
5379this.elParS.margin='0 auto';
5380var elImgCap=this.gl('ProductImageCaption-'+prid);
5381if(elImgCap&&!elImgCap.getAttribute('origtext')){
5382elImgCap.setAttribute('origtext',elImgCap.innerHTML);
5383}
5384if(id||elChImg.className.indexOf('NoImage')==-1){
5385this.img=new Image();
5386this.img.onload=function(){
5387elImg.src='';
5388var cfi=tf.core.crFFldImager,newSize=cfi.scale(elImg.getAttribute('origw'),elImg.getAttribute('origh'),this.width,this.height);
5389elImg.src=this.src;
5390elImg.width=newSize[0];
5391elImg.height=newSize[1];
5392elImg.setAttribute('border','0');
5393elImg.style.marginTop='0';
5394elImg.style.top='0';
5395$(elPar).toggleClass('no-responsive', true);
5396cfi.prgImg.style.visibility='hidden';
5397cfi.elParS.width=newSize[0]+'px';
5398cfi.elParS.height=newSize[1]+'px';
5399var pici=cfi.gl('pici-'+prid);
5400if(pici){
5401pici.style.display='block';
5402pici.style.position='absolute';
5403pici.style.right='5px';
5404pici.style.bottom='5px';
5405}
5406if(elImgCap){
5407elImgCap.innerHTML=elChImg.getAttribute('title')||elChImg.getAttribute('description')||'&nbsp;';
5408if(!tf.isIE7){
5409elImgCap.style.position='relative';
5410elImgCap.style.clear='both';
5411}
5412}
5413jQuery(elImg).siblings('.zoomImg').remove();
5414cfi.busy=false;
5415}
5416this.img.onerror=function(){
5417var cfi=tf.core.crFFldImager;
5418cfi.busy=false;
5419elImg.style.visibility='hidden';
5420}
5421elPImg.setAttribute('jumptoid',elChImg.id);
5422if(!this.prgImg){
5423this.prgImg=tf.content.document.createElement('i');
5424this.prgImg.className='icon-spinner2 icon-fa-spin';
5425this.prgImg.style.position='absolute';
5426this.prgImg.style.marginTop='-0.5em';
5427this.prgImg.style.top='50%';
5428this.prgImg.style.marginLeft='-2em';
5429this.prgImg.style.left='50%';
5430this.prgImg.style.fontSize='2em';
5431this.prgImg=elPImg.parentNode.insertBefore(this.prgImg,elPImg.parentNode.childNodes[0]||null);
5432}
5433var mysrc=elChImg.getAttribute('tn')||elChImg.getAttribute('src')||elChImg.getAttribute('href');
5434if(mysrc!==''){
5435if(isHTML){
5436elImg.parentNode.style.background = '';
5437elImg.style.visibility='visible';
5438var newSize=this.scale(elImg.getAttribute('origw'),elImg.getAttribute('origh'),elChImg.getAttribute('mw'),elChImg.getAttribute('mh'));
5439newSize[1]=elImg.getAttribute('origh')-18;
5440elImg.innerHTML=tf.utils.sfMediaBox.getMMHTMLUsingExtraction('',window.decodeURIComponent(m
5440ysrc),newSize[0],newSize[1]);
5441elImg.style.display='inline-block';
5442elImg.style.width='auto';
5443elImg.style.height='auto';
5444elPImg.parentNode.style.height='auto';
5445var pici=this.gl('pici-'+prid);
5446if(pici){
5447pici.style.position='static';
5448pici.style.styleFloat='right';
5449pici.style.cssFloat='right';
5450elPar.appendChild(pici);
5451}
5452this.busy=false;
5453}
5454else{
5455elImg.parentNode.style.background = '';
5456elImg.style.visibility='visible';
5457this.prgImg.style.visibility='visible';
5458elImg.style.position='relative';
5459elImg.style.display='block';
5460if(this.gl('pici-'+prid))this.gl('pici-'+prid).style.display='none';
5461this.img.src=tf.wm.url(mysrc).replace('contents/contents/media/','contents/media/');
5462}
5463if(tf.content['ProductImageGroupSizer_'+prid])setTimeout(tf.content['ProductImageGroupSizer_'+prid],100);
5464jQuery(elImg).siblings('.zoomImg').remove();
5465} else {
5466this.busy = false;
5467}
5468}
5469else{
5470elImg.parentNode.style.background='url('+(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../')+'media/no_image.png) center no-repeat';
5471elImg.style.visibility='hidden';
5472this.busy=false;
5473}
5474}
5475else{
5476this.busy=false;
5477}
5478}
5479}
5480};
5481var tsI=[],tsIx=[];
5482function prodDiscMsg(id){
5483var p=tf.wm.pProp(id);
5484if (p&&p[7]) {
5485var	el=tf.content.document.getElementById('ProductDiscountMessage-'+id);
5486if (el) {
5487el.style.display=currTime.isActive(p[7])?'block':'none';
5488}
5489else {
5490setTimeout(function(){prodDiscMsg(id);},100);
5491}
5492}
5493}
5494function pprice(elPrice,args,apq) {
5495function applyGC(s,el){
5496var GC='';
5497if(el){
5498GC=el.className.split(' ')[0];
5499if(GC.indexOf('GC')!=0)GC='';
5500}
5501return GC?s.replace(/class="([^G][^C])/g,'class="'+GC+' $1'):s;
5502}
5503function applyGCForClassName(ss,className,GC){
5504return GC?ss.replace(new RegExp('class="(?:GC[0-9]+ )?'+className,'g'),'class="'+GC+' '+className):ss;
5505}
5506function getComputedStyle(el,prop){
5507if(el.currentStyle)var val=el.currentStyle[prop];
5508else var val=tf.content.document.defaultView.getComputedStyle(el,'')[prop];
5509return val;
5510}
5511apq=apq||'';
5512var ret=[]; var Id=args[0],pi=args[1],pt=args[2],b1=args[3],b2=args[4],b3=args[5];
5513var _prc=getPrc(Id,null),_dp=getPrc(Id,null,1),_prcStr='',_dpStr='';
5514var bsk=tf.core.Basket,discShown=(_prc-_dp>0.001);
5515function gl(id){return tf.content.document.getElementById(id);}
5516if(!elPrice)elPrice=gl('Product'+apq+'Price-'+Id);
5517var elIntro=gl('Product'+apq+'PriceIntro-'+Id);
5518if(pi){
5519if(elIntro)elIntro.innerHTML=pi;
5520else ret.push('<span class="Product'+apq+'PriceIntro" id="Product'+apq+'PriceIntro-'+Id+'">'+pi+'</span> ');
5521}
5522if(tf.conf)tf.conf.populateTSI();
5523var arrTexts=taxDispTexts(pt,tsI,tsIx);
5524var tid=arrTexts[0],tinc=arrTexts[1],texc=arrTexts[2];
5525_prcStr=bsk.tax.disp(tid,_prc,tf.shopCurrency,null,true,tinc,texc,discShown?'':'Product'+apq+'CurrencySymbol');
5526_dpStr=bsk.tax.disp(tid,_dp,tf.shopCurrency,null,true,tinc,texc,discShown?'Product'+apq+'CurrencySymbol':'');
5527var elOrig=gl('Product'+apq+'PriceOriginal-'+Id),elCalc=gl('Product'+apq+'PriceCalculated-'+Id);
5528var dontChangeDisplay=false;
5529if (discShown) {
5530if(elOrig&&elOrig.parentNode!=elPrice)elOrig.innerHTML=applyGCForClassName(applyGC(_prcStr,elOrig),'Product'+apq+'CurrencySymbol','GC77');
5531else {dontChangeDisplay=true;ret.push('<span class="Product'+apq+'PriceOriginal" id="Product'+apq+'PriceOriginal-'+Id+'">'+_prcStr+'</span> ');}
5532if(elCalc&&elCalc.parentNode!=elPrice)elCalc.innerHTML=applyGCForClassName(applyGC(_dpStr,elCalc),'Product'+apq+'CurrencySymbol',tf.content.pgid.indexOf('P')==0?'GC80':'GC82');
5533else {dontChangeDisplay=true;ret.push('<span class="GC56 Product'+apq+'PriceCalculated" id="Product'+apq+'PriceCalculated-'+Id+'">'+_dpStr+'</span>');}
5534}
5535else {
5536if(elPrice)elPrice.innerHTML=applyGCForClassName(applyGC(_prcStr,elPrice),'Product'+apq+'CurrencySymbol',tf.content.pgid.indexOf('P')==0?'GC77':'GC81');
5537if(elCalc&&elCalc.parentNode!=elPrice){showCalculated=!discShown;elCalc.innerHTML='';}
5538}
5539if(!dontChangeDisplay){
5540if(elPrice)elPrice.style.display=discShown?'none':getComputedStyle(elPrice,'display');
5541if(elOrig)elOrig.style.display=discShown?getComputedStyle(elOrig,'display'):'none';
5542if(elCalc)elCalc.style.display=discShown||showCalculated?getComputedStyle(elCalc,'display'):'none';
5543var el = gl('ProductDiscountDisplay-'+Id);
5544if(el) {
5545if(discShown) {
5546el.style.display='block';
5547if(pi == "")
5548$(el).parent('#ProductContainer1').show();
5549} else {
5550el.style.display='none';
5551if(pi == "")
5552$(el).parent('#ProductContainer1').hide();
5553}
5554}
5555}
5556if(!bsk.tax.showBoth){
5557var elTaxText=gl('Product'+apq+'IncTaxes-'+Id),tt=tid?(bsk.tax._tax.get(tid).incTax?tinc:texc):'';
5558if(elTaxText&&elTaxText.parentNode!=elPrice)elTaxText.innerHTML=(tt==''?'':'('+tt+')');
5559else {
5560if(!discShown)ret.push(_prcStr);
5561if(tt)ret.push(' <span class="Product'+apq+'IncTaxes" id="Product'+apq+'IncTaxes-'+Id+'">('+tt+')</span>');
5562}
5563}
5564if(!region){setTimeout('tf.utils.populatePrice();tf.utils.populateOpt();',1000);return ret;}
5565if(!tfc.isInSF())prodDiscMsg(Id);
5566return ret.join('');
5567}
5568function ppriceTemplateLayout(elPrice,args,apq) {
5569apq=apq||'';
5570var ret=[]; var Id=args[0],pi=args[1],pt=args[2],b1=args[3],b2=args[4],b3=args[5];
5571var _prc=getPrc(Id,null),_dp=getPrc(Id,null,1),_prcStr='',_dpStr='',_txtStr='',p=tf.wm.pProp(Id);
5572var bsk=tf.core.Basket,discShown=(_prc-_dp>0.001);
5573var $orig=$('#Product'+apq+'PriceOriginal-'+Id),
5574$calc=$('#Product'+apq+'PriceCalculated-'+Id),
5575$price=$(elPrice),
5576$disc=$('#ProductDiscountDisplay-'+Id), $txt=$('#Product'+apq+'IncTaxes-'+Id),
5577$priceOther=$('#Product'+apq+'PriceTaxPrice-'+Id),
5578$priceOtherTxt=$('#Product'+apq+'PriceTaxPriceText-'+Id)
5579$shippingCharge=$('#Product'+apq+'ShippingChargeForProduct-'+Id)
5580;
5581if(!elPrice)oPrice=$('#Product'+apq+'Price-'+Id);
5582if(pi)$('#Product'+apq+'PriceIntro-'+Id).html(pi);
5583if(tf.conf)tf.conf.populateTSI();
5584var arrTexts=taxDispTexts(pt,tsI,tsIx),tid=arrTexts[0],tinc=arrTexts[1],texc=arrTexts[2];
5585var _prcA=bsk.tax.dispValues(tid,_prc,null,tinc,texc,'Product'+apq+'CurrencySymbol'), _dpA={};
5586_prcStr=_prcA['p1a'];
5587_txtStr=_prcA['p1t'];
5588if (discShown) {
5589_dpA=bsk.tax.dispValues(tid,_dp,null,tinc,texc,'Product'+apq+'CurrencySymbol');
5590_dpStr=_dpA['p1a'];
5591}
5592if(p&&p['autoIntro'])_prcStr='<span class="ProductPriceOtherInformation" style="float:none;"><small class="ProductPriceIntroAuto">'+p['autoIntro']+'</small></span> '+_prcStr;
5593var dontChangeDisplay=false;
5594if (discShown) {
5595$orig.show().css('display','').html(_prcStr);
5596$calc.show().css('display','').html(_dpStr);
5597$price.hide();
5598$disc.show().css('display','');
5599if(pi == "")
5600$disc.parent('#ProductContainer1').show();
5601}
5602else {
5603$orig.hide();
5604$calc.hide();
5605$price.show().css('display','').html(_prcStr);
5606$disc.hide();
5607if(pi == "")
5608$disc.parent('#ProductContainer1').hide();
5609}
5610$txt.html(_txtStr);
5611if(bsk.tax.showBoth){
5612$priceOther.html(discShown ? _dpA['p2a'] : _prcA['p2a'])
5613$priceOtherTxt.html(_prcA['p2t'])
5614}
5615if(!region){setTimeout('tf.utils.populatePrice();tf.utils.populateOpt();',1000);return ret;}
5616if(!tfc.isInSF())prodDiscMsg(Id);
5617}
5618function getPPrices(prid,txids,itm,val,valDscApplied){
5619var bsk=tf.core.Basket,arr={};
5620var exT_dp_opt=inT_dp_opt=exT_prc_opt=inT_prc_opt=_prc_opt=_dp_opt=op=dp=0;
5621var dscAppliesToOptions=true,shdscAppliesToOptions=false;
5622if(itm){
5623var _prc=itm.calc('pur_inc'),_dp=itm.calc('pur_inc+dsc');
5624var exT_dp=itm.calc('pur_exc+dsc'),inT_dp=_dp;
5625var exT_prc=itm.calc('pur_exc'),inT_prc=_prc;
5626var exT_dp_opt=itm.calc('pur_exc+opt+dsc'),inT_dp_opt=itm.calc('pur_inc+opt+dsc');
5627var exT_prc_opt=itm.calc('pur_exc+opt'),inT_prc_opt=itm.calc('pur_inc+opt');
5628}
5629else {
5630if(val){
5631var _prc=val,_dp=val-(valDscApplied?0:getDscAmt(prid,val,true,!dscAppliesToOptions, !shdscAppliesToOptions));
5632}
5633else{
5634var _prc=tf.core.getPrc(prid),_dp=tf.core.getPrc(prid,null,1);
5635}
5636var exT_dp=bsk.tax.exTax(txids,_dp),inT_dp=exT_dp+bsk.tax.allAmt(txids,_dp);
5637var exT_prc=bsk.tax.exTax(txids,_prc),inT_prc=exT_prc+bsk.tax.allAmt(txids,_prc);
5638}
5639if(tf.conf)tf.conf.populateTSI();
5640var arrTexts=taxDispTexts(txids,tsI,tsIx);
5641var tid=arrTexts[0],tinc=arrTexts[1],texc=arrTexts[2];
5642if(_prc-_dp>0.001){
5643var exT=exT_dp,inT=inT_dp;
5644var discounted=true;
5645}
5646else {
5647var exT=exT_prc,inT=inT_prc;
5648var discounted=false;
5649}
5650if((typeof(bsk.tax._tax.get(tid)) != 'undefined') && bsk.tax._tax.get(tid).incTax){
5651var p1t=tinc, p1a=tf.core.dPrc(inT,1,true);
5652var p2t=texc, p2a=tf.core.dPrc(exT,1,true);
5653op=inT_prc;
5654dp=inT_dp;
5655_prc_opt=inT_prc_opt?tf.core.dPrc(inT_prc_opt,1,true):null;
5656_dp_opt=inT_dp_opt?tf.core.dPrc(inT_dp_opt,1,true):null;
5657}
5658else{
5659var p1t=texc, p1a=tf.core.dPrc(exT,1,true);
5660var p2t=tinc, p2a=tf.core.dPrc(inT,1,true);
5661op=exT_prc;
5662dp=exT_dp;
5663_prc_opt=exT_prc_opt?tf.core.dPrc(exT_prc_opt,1,true):null;
5664_dp_opt=exT_dp_opt?tf.core.dPrc(exT_dp_opt,1,true):null;
5665}
5666_prc=tf.core.dPrc(op,1,true);
5667_dp=tf.core.dPrc(dp,1,true);
5668arr['discounted']=discounted;
5669arr['op']=op;
5670arr['dp']=dp;
5671arr['orig']=_prc;
5672arr['calc']=_dp;
5673arr['orig+opt']=_prc_opt;
5674arr['calc+opt']=_dp_opt;
5675if (bsk.tax.showBoth) {
5676arr['prc1_text']=p1t;
5677arr['prc1_amt']=p1a;
5678arr['prc2_text']=p2t;
5679arr['prc2_amt']=p2a;
5680}
5681return arr;
5682}
5683function bprice(args) {
5684var b1=args[1],b2=args[2],b3=args[3],b4=parseFloat(args[4]);
5685if(b1&&isNaN(b1)||parseFloat(b1)<0.001) return '';
5686var p=tf.wm.pProp(args[0]),dscPrc=getPrc(args[0],null,1),hasDsc=p[5]==1||parseFloat(p[6])!=0||(dscPrc<b1),prc=b1;
5687if(b4&&!isNaN(b4) && (dscPrc>0.0001)){
5688dscPrc/=parseFloat(b4);
5689if(dscPrc<b1){
5690prc = dscPrc;
5691}
5692}
5693if(hasDsc){
5694if(getPrc(args[0])>0.001)prc=dscPrc/getPrc(args[0])*b1;
5695else prc=prc-getDscAmt(args[0],prc);
5696}
5697if($('input[name=ProductPriceLayout]').length>0){
5698return '<nobr>'+dPrc(prc*(tf.currentCurrency.multiplier/tf.shopCurrency.multiplier), tf.currentCurrency.decimal_places, '')+' / '+(parseInt(b2)==1?'':parseInt(b2)+' ')+b3+'</nobr>';
5699}
5700else{
5701return ld('LD_BASEPRICE','Basisprijs')+': <nobr>'+ld('LD_BASEPRICE_RESULT','%% %% = %%',[nfmt.toLoc(b2),b3,dPrc(prc,1)])+'</nobr>';
5702}
5703}
5704var crFFldOptPrc={
5705oCacheArr: null,
5706oOptIdx: {},
5707oPriceArr: null,
5708oOptions:null,
5709oFldSel:{},
5710busy:{},
5711setFocus:true,
5712updDisp:true,
5713cacheAndIndex:function(crFFldArr,opt){
5714var me=crFFldOptPrc;
5715for (var i=0,ii=crFFldArr.length;i<ii;i++){
5716var a=crFFldArr[i][5];
5717me.oCacheArr[a[0][0]]={'crFFldArr':{},'fldname':crFFldArr[i][1],'origprc':0,'origwgt':0};
5718for (var j=0,jj=a.length;j<jj;j++){
5719me.oCacheArr[a[0][0]]['crFFldArr'][a[j][2]]=a[j];
5720}
5721}
5722for (var i=0,ii=opt.length;i<ii;i++){
5723me.oOptIdx[opt[i][0]]=opt[i];
5724}
5725},
5726copyArr:function(lhs,rhs){
5727var me=crFFldOptPrc;
5728for(var n in rhs){
5729if(typeof(rhs[n])=='object'){
5730lhs[n]=(typeof(rhs[n].length)=='undefined'?{}:[]);
5731me.copyArr(lhs[n],rhs[n]);
5732}
5733else lhs[n]=rhs[n];
5734}
5735},
5736reset:function(){
5737var me=crFFldOptPrc;
5738if(me.oPriceArr){
5739me.copyArr(tf.wm._pArr,me.oPriceArr);
5740tf.nametag.add('_pArr', tf.sfJSON.stringify(tf.wm._pArr, null, true));
5741me.oPriceArr=null;
5742me.oPriceArrNewState=null;
5743}
5744},
5745resetTemporarily:function(prid){
5746var me=crFFldOptPrc;
5747if(!me.oPriceArr){me.oPriceArr={};me.copyArr(me.oPriceArr,tf.wm._pArr);}
5748me.oPriceArrNewState={};
5749me.copyArr(me.oPriceArrNewState,tf.wm._pArr[prid]);
5750me.copyArr(tf.wm._pArr[prid],me.oPriceArr[prid]);
5751},
5752unreset:function(prid){
5753var me=crFFldOptPrc;
5754if(me.oPriceArrNewState){
5755me.copyArr(tf.wm._pArr[prid],me.oPriceArrNewState);
5756me.oPriceArrNewState=null;
5757}
5758},
5759clearTextBox:function(id){
5760var el=tf.content.gl(id);
5761if(el){
5762el.focus();
5763el.value='';
5764el.blur();
5765}
5766return false;
5767},
5768updPrc:function(prid,id,crFFldArr,opt){
5769if(!tf.content.document.productForm)return;
5770var me=crFFldOptPrc;
5771if(me.busy[prid])return false;
5772me.busy[prid]=true;
5773if(!me.oPriceArr){me.oPriceArr={};me.copyArr(me.oPriceArr,tf.wm._pArr);}
5774if(!me.oCacheArr){me.oCacheArr={};me.cacheAndIndex(crFFldArr,opt);}
5775if(!me.oOptions)me.oOptions=new dynObj('options');
5776var optid=id.split('C')[0],p=tf.wm.pProp(prid),popt=getPrc(prid,optid),poptwgt=getWgt(prid,optid);
5777if(parseFloat(p[1])==0)me.updDisp=false;
5778var form=new iForm(tf.content.document.productForm),fld=form.getField(me.oCacheArr[optid]['fldname']);
5779if(fld.type=='checkbox'&&fld.rawValue==me.oFldSel[id]){me.busy[prid]=false;return;}
5780var o=me.oOptions.empty();
5781o.init(me.oOptIdx[optid],fld.value||'');
5782var i=0,updDisp=false,valCur=0,valOffset=o.price(),wgtCur=0,wgtOffset=o.weight();
5783var forceRePopOpt=false;
5784if(typeof(p['optPrice'])=='undefined')p['optPrice']=0;
5785if(typeof(p['optWeight'])=='undefined')p['optWeight']=0;
5786switch(fld.type){
5787case 'text':
5788case 'textarea':
5789if(fld.rawValue){
5790if(fld.rawValue==fld.origValue.split(str_sep1)[0]){
5791valOffset=0;
5792wgtOffset=0;
5793}
5794}
5795else{
5796if(fld.rawValue!=(me.oFldSel[id]||'')){
5797valOffset=-(me.oCacheArr[optid]['origprc']||valOffset);
5798wgtOffset=-(me.oCacheArr[optid]['origwgt']||wgtOffset);
5799}
5800else if(!(me.oFldSel[id]||'')){
5801valOffset=0;
5802wgtOffset=0;
5803}
5804}
5805break;
5806case 'radio':
5807if(me.oFldSel[id]==='0'){
5808if(o.type){
5809fld.ctrl.checked=true;
5810me.oFldSel[id]='1';
5811}
5812else{
5813valOffset=(me.oCacheArr[optid]['origprc']||valOffset);
5814wgtOffset=(me.oCacheArr[optid]['origwgt']||wgtOffset);
5815fld.value='';
5816forceRePopOpt=true;
5817}
5818}
5819updDisp=true;
5820break;
5821case 'checkbox':
5822if(fld.rawValue==0){
5823valOffset=-(me.oCacheArr[optid]['origprc']||valOffset);
5824wgtOffset=-(me.oCacheArr[optid]['origwgt']||wgtOffset);
5825}
5826updDisp=true;
5827break;
5828case 'select-one':
5829if(tfc.__sfChoiceImageLocation&&tfc.__sfChoiceImageLocation.indexOf('optionarea_')==0){
5830updDisp=true;
5831}
5832break;
5833}
5834if(fld==''){
5835valOffset=me.oCacheArr[optid]['origprc'];
5836valCur=parseFloat(p['optPrice']);
5837p['optPrice'] = valCur + valOffset;
5838me.oCacheArr[optid]['origprc']=0;
5839wgtOffset=me.oCacheArr[optid]['origwgt'];
5840wgtCur=parseFloat(p['optWeight']);
5841p['optWeight'] = wgtCur + wgtOffset;
5842me.oCacheArr[optid]['origwgt']=0;
5843}
5844for(var chid in me.oCacheArr[optid]['crFFldArr']){
5845if(chid==id){
5846valCur=parseFloat(p['optPrice']);
5847p['optPrice'] = valCur + valOffset;
5848wgtCur=parseFloat(p['optWeight']);
5849p['optWeight'] = wgtCur + wgtOffset;
5850}
5851valCur=parseFloat(popt[i*2+2])||0;
5852popt[i*2+2] = (valCur - valOffset).toString();
5853wgtCur=parseFloat(poptwgt[i+2])||0;
5854poptwgt[i+2] = (wgtCur - wgtOffset).toString();
5855switch(fld.type) {
5856case 'text':
5857case 'textarea':
5858if(valOffset)me.oCacheArr[optid]['origprc']=valOffset;
5859if(wgtOffset)me.oCacheArr[optid]['origwgt']=wgtOffset;
5860me.oFldSel[chid]=fld.rawValue;
5861break;
5862case 'checkbox':
5863me.oCacheArr[optid]['origprc']=valOffset;
5864me.oCacheArr[optid]['origwgt']=wgtOffset;
5865me.oFldSel[chid]=fld.rawValue;
5866break;
5867case 'radio':
5868if(chid==id&&!o.type)me.oCacheArr[optid]['origprc']-=valOffset;
5869if(chid==id&&!o.type)me.oCacheArr[optid]['origwgt']-=wgtOffset;
5870me.oFldSel[chid]=(chid==id?me.oFldSel[chid]:'0');
5871break;
5872case 'select-one':
5873if(chid==id)me.oCacheArr[optid]['origprc']-=valOffset;
5874if(chid==id)me.oCacheArr[optid]['origwgt']-=wgtOffset;
5875me.oFldSel[chid]=(chid==id?'1':'0');
5876break;
5877}
5878if(fld=='')me.oFldSel[chid]='0';
5879i++;
5880}
5881updDisp=(updDisp||valOffset||wgtOffset)&&me.updDisp;
5882if(updDisp){
5883if(tf.utils.heightHandler)tf.utils.heightHandler.reset();
5884tf.utils.populatePrice(null,prid);
5885tf.utils.populateOpt(null,prid,optid);
5886if(forceRePopOpt)setTimeout(function(){tf.utils.populateOpt(null,prid,optid);},100);
5887tf.utils.displayProductQuantityDiscounts(prid);
5888if(tf.core.setFocusID){
5889$('#'+tf.core.setFocusID).focus();
5890}
5891else if(me.setFocus){
5892form=new iForm(tf.content.document.productForm);
5893fld=form.getField(me.oCacheArr[optid]['fldname']);
5894if(fld&&fld.ctrl)fld.ctrl.focus();
5895}
5896}
5897else if(!me.updDisp)
5898{
5899if(tf.utils.heightHandler)tf.utils.heightHandler.reset();
5900tf.utils.populatePrice(null,prid);
5901tf.utils.populateOpt(null,prid);
5902if(forceRePopOpt)setTimeout(function(){tf.utils.populateOpt(null,prid,optid);},100);
5903tf.utils.displayProductQuantityDiscounts(prid);
5904}
5905tf.core.setFocusID=null;
5906me.updDisp=true;
5907me.busy[prid]=false;
5908return true;
5909}
5910};
5911if(tf.isIE&&tf.isIEBefore10)tf.addEvent('onbeforeunload',function(){crFFldOptPrc.reset();});
5912else {
5913tf.addEvent('onunload',function(){
5914crFFldOptPrc.reset();
5915});
5916tf.addEvent('pageshow',function(e){
5917if(e.persisted)document.location.reload();
5918});
5919tf.addEvent('pagehide',function(){
5920crFFldOptPrc.reset();
5921});}
5922var cthtb=null;
5923var oCachePPriceArr={indexed:false};
5924function crFFld(args){
5925var t=args[0],n=args[1],id=args[2],r=args[3],c=args[4],oA=args[5],dv=args[6],on=args[7],pid=args[8],maxlen=args[9],right=args[10],combine=args[11],choicesonly=false,required=args[12],chid='';
5926if(t==3||t==4||t==5){
5927var el=$('[name="'+args[1]+'"]').get(0);
5928if(el&&el.selectedIndex>0)dv='0';
5929}
5930var p=tf.wm.pProp(pid), updDisp=true;
5931if(required)on+='&nbsp;<span class="required">*</span>';
5932tfc=tf.content;
5933var choiceImageInProductImageArea=!tfc.__sfChoiceImageLocation||tfc.__sfChoiceImageLocation.indexOf('productimagearea')==0,noChoicesHaveImage=true,choiceImageMH=-1;
5934var first=true,pogB='<div class="ProductOptionInner" id="ProductOptionInner-'+id+'" data-option-type="'+(['','text','text-area','','select','radio','checkbox'][t])+'">',pogE='</div>',ponB='<div class="GC74 ProductOptionName">',ponE='</div>',pcnB='<div class="GC75 ProductChoiceName" id="ProductChoiceName-%%">',pcnE='</div>';
5935if(choicesonly)pcnB='<div id="ProductChoiceName-%%" class="ProductChoiceName">';
5936if(tfc.ppriceArr&&!oCachePPriceArr.indexed){
5937for (var i=0,ii=tfc.ppriceArr.length;i<ii;i++){
5938oCachePPriceArr[tfc.ppriceArr[i][0]]=tfc.ppriceArr[i];
5939}
5940oCachePPriceArr.indexed=true;
5941}
5942function optImgInit(a){
5943for (var i=0,ii=a.length;i<ii;i++) {
5944var chid=a[i][2];
5945if(tfc.gl('ChoiceImageHolder-'+chid))noChoicesHaveImage=false;
5946var el=tfc.gl('I'+chid);
5947if(el){
5948var w=parseInt(el.parentNode.getAttribute('tnw')),h=parseInt(el.parentNode.getAttribute('tnh')),mw=parseInt(el.parentNode.getAttribute('tnmw')),mh=parseInt(el.parentNode.getAttribute('tnmh'));
5949var wh=tf.core.crFFldImager.scale(mw,mh,w,h);
5950if(wh[1]>choiceImageMH)choiceImageMH=wh[1];
5951}
5952}
5953}
5954function optImg(id,locationpart){
5955if(noChoicesHaveImage)return '';
5956var s='';
5957if(tfc.__sfChoiceImageLocation&&tfc.__sfChoiceImageLocation.indexOf(locationpart)==0){
5958var elChImg=tfc.gl('ChoiceImageHolder-'+id);
5959if(elChImg){
5960var sChImg=tf.core.crFFldImager.outerHTML(elChImg).replace('ChoiceImageHolder-','ChoiceImage-').replace(/rel="sfMediaBox\[.*?\]"/,'');
5961s='<div class="ProductChoiceNameImageParent" '+(choiceImageMH>0?'style="height:'+choiceImageMH+'px"':'')+'>'+sChImg+'</div>';
5962}
5963else{
5964s='<div class="ProductChoiceNameImageParent NoImage" style="'+(choiceImageMH>0?'height:'+(choiceImageMH+0.5)+'px;':'')+'"><img src="'+(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../')+'media/no_image.png" /></div>';
5965}
5966}
5967return s;
5968}
5969function _v(v,a,o){
5970var s=' '+(v?'':'meta')+'value="'+[a[1].replace(/\"/g,'&quot;'),getOPrc(a[0],id,o),getOWgt(a[0],id,o),a[5].replace(/\"/g,'&quot;'),a[6],a[7],a[8],a[2]].join(str_sep1)+'"';
5971if(updDisp)tf.core.crFFldOptPrc.resetTemporarily(pid);
5972s+=' origvalue="'+[a[1].replace(/\"/g,'&quot;'),getOPrc(a[0],id,o,updDisp?true:false),getOWgt(a[0],id,o),a[5].replace(/\"/g,'&quot;'),a[6],a[7],a[8],a[2]].join(str_sep1)+'"';
5973if(updDisp)tf.core.crFFldOptPrc.unreset(pid);
5974return s;
5975}
5976function _opdp(v,a,o,minorPrice){
5977var pprice=oCachePPriceArr[pid]||[];
5978var op=getOPrc(v,a,o);
5979if(!minorPrice){
5980var doApplyTax=true;
5981if(pprice[2]){doApplyTax=!(tf.core.Basket.tax._tax.get(pprice[2]).incTax&&!tf.core.Basket.tax.forRegion(pprice[2],tf.core.region));}
5982if(doApplyTax)op=tf.core.BTax.taxAppliedRawAmt(pprice[2]||'',op);
5983}
5984var isNegative=(op<-0.001);
5985var aRet=tf.core.getPPrices(pid,pprice[2]||'',null,Math.abs(op)||'0.00');
5986if(isNegative){aRet['op']*=-1;aRet['dp']*=-1;}
5987return aRet;
5988}
5989function _p(v,a,o,showdsc){
5990var aRet=_opdp(v,a,o,tf.core.BTax.showBoth),op=aRet['op'],_dp=aRet['dp'];
5991if(op>0.001)var pf='LD_OPTION_PRICE_ADD';
5992else if(op<-0.001)var pf='LD_OPTION_PRICE_SUBTRACT';
5993{
5994if(updDisp)tf.core.crFFldOptPrc.resetTemporarily(pid);
5995aRet=_opdp(v,a,o,tf.core.BTax.showBoth);
5996var pf='',df=(aRet['op']<-0.001?'(-%%)':'(%%)');
5997if(updDisp)tf.core.crFFldOptPrc.unreset(pid);
5998if(aRet['op']==0)return'';
5999}
6000var div='<div style="white-space:nowrap;display:inline-block;*display:inline;">';
6001if (Math.abs(op-_dp)>0.001)return' '+(showdsc?'<del style="white-space:nowrap;">'+ld(pf,df, [aRet['orig']])+'</del> ':'')+(tf.core.BTax.showBoth?' '+div+ld(pf,df,[' '+aRet['prc1_text']+' '+aRet['prc1_amt']+', </div>'+div+aRet['prc2_text']+' '+aRet['prc2_amt']])+'</div>'
6002:' '+div+ld(pf,df,[aRet['calc']])+'</div>');
6003else
6004return (tf.core.BTax.showBoth?' '+div+ld(pf,df,[' '+aRet['prc1_text']+' '+aRet['prc1_amt']+', </div>'+div+aRet['prc2_text']+' '+aRet['prc2_amt']])+'</div>'
6005:' '+div+ld(pf,df,[aRet['calc']])+'</div>');
6006}
6007function _ip(n,t,cl,v,a,on,dv) {
6008optImgInit(a);
6009var s='',updStkDisp=true,len=a?a.length:0,idForImg=pid;
6010for (var i=0;i<len;i++) {
6011var chid=a[i][2];
6012if(updDisp){if(crFFldOptPrc.oFldSel[a[i][2]])dv=crFFldOptPrc.oFldSel[a[i][2]]}
6013var val=(t=='text')?' value="'+(dv||a[i][1]).replace(/"/g,'&quot;')+'"'+_v(v,a[i],i):_v(v,a[i],i);
6014var ch=(dv=='1')?' checked':'';ch=((dv?dv:'0')=='1'&&first)?' checked':'';
6015if (ch&&t=='radio') first=false;
6016var onfocus='if(tf.isInSF())return false;',onblur='',onblurcode='',onmousedown='',onmouseup='',onchange='',oncl
6016ick='if(tf.isInSF())return false;'+(combine?'core.stkDisp(\''+pid+','+a[i][5]+'\');':'');
6017var imgChanger=choiceImageInProductImageArea?'tf.core.crFFldImager.replace(\''+pid+'\','+(ch?'false':'true')+'?\''+a[i][2]+'\':null);':'';
6018var prcUpdater=(updDisp?'tf.core.setFocusID=\''+chid+'\';tf.core.crFFldOptPrc.updPrc(\''+pid+'\',\''+a[i][2]+'\',crFFldArr,opt);':'');
6019if(t=='radio'){onclick+='dBasePrice2(\''+pid+'\',this.value);';}
6020switch(t){
6021case 'text':
6022onmousedown+='tf.core.setFocusID=\''+chid+'\';';
6023onfocus+=imgChanger;
6024onblur+='tf.core.onblurcode=this.getAttribute(\'onblurcode\');tf.core.idTextOptionBlur=setTimeout(function(){'+prcUpdater+'if(tf.core.crFFldOptPrc.updDisp&&tf.utils.displaySelectedOpt)tf.utils.displaySelectedOpt();},500);';
6025onblurcode+=prcUpdater;
6026break;
6027case 'radio':
6028onmouseup+=codeToHandleTextBlur+imgChanger+'tf.content.document.productForm[\''+a[i][2]+'\'].checked=!tf.content.document.productForm[\''+a[i][2]+'\'].checked;'+(updDisp?'tf.core.crFFldOptPrc.oFldSel[\''+a[i][2]+'\']=tf.content.document.productForm[\''+a[i][2]+'\'].checked?\'1\':\'0\';':'')+prcUpdater;
6029onchange+=prcUpdater;
6030break;
6031case 'checkbox':
6032onclick+=codeToHandleTextBlur+imgChanger+prcUpdater;
6033onchange+=prcUpdater;
6034break;
6035default:
6036onclick+=codeToHandleTextBlur+imgChanger+prcUpdater;
6037}
6038var btn='<input onfocus="'+onfocus+'" onblur="'+onblur+'" onblurcode="'+onblurcode+'" onchange="'+onchange+'" onclick="cancelBuble(event);'+onclick+'" onmousedown="'+onmousedown+'" onmouseup="'+onmouseup+'" type='+t+val+' id="'+a[i][2]+'" name="'+n.replace(/"/g,'&quot;')+'" size="'+c+'" maxlength="'+maxlen+'" '+cl+ch+'>\n';
6039s+=pcnB.replace(/\%\%/,a[i][2]);
6040s+=optImg(chid,'optionarea_radiobutton_separate');
6041if(!right&&t!='text'){s+=btn;}
6042var dp=(t=='radio'||(t=='checkbox'))?_p(a[i][0],id,i,true):'';
6043if (t=='radio') s+='<span><label for="'+a[i][2]+'" onmouseup="'+onmouseup+'">'+a[i][1]+dp+'</label></span>';else if(t!='text')s+='<span><label for="'+a[i][2]+'">'+on+dp+'</label></span>';
6044if(right||t=='text'){s+=btn;}
6045s+=pcnE;
6046if(t=='text'||t=='checkbox')idForImg=chid;
6047var elImg=tf.content.gl('I'+pid);
6048if(ch&&core){
6049idForImg=chid;
6050if(updDisp){if(!tf.core.crFFldOptPrc.busy[pid])setTimeout("tf.core.crFFldOptPrc.setFocus=false;tf.core.crFFldOptPrc.updPrc('"+pid+"','"+a[i][2]+"',tfc.crFFldArr,tfc.opt);tf.core.crFFldOptPrc.setFocus=true;",500);}
6051if(combine){updStkDisp=false;setTimeout("tf.core.stkDisp('"+pid+","+a[i][5]+"')",400);}
6052setTimeout("tfc.dBasePrice2('"+pid+"','"+(['','','','',a[i][6],a[i][7],a[i][8]].join(str_sep1))+"',tfc)",500);
6053if(choiceImageInProductImageArea){
6054if(elImg){
6055var hasNoDimensions=(!elImg.getAttribute('width')&&!elImg.getAttribute('height'));
6056if(tf.isIE7)hasNoDimensions=!elImg.outerHTML.match(/(?:width|height)=/i);
6057if(hasNoDimensions)setTimeout('tf.core.crFFldImager.replace(\''+pid+'\',\''+a[i][2]+'\');',500);
6058}
6059}
6060}
6061if(elImg){
6062if(elImg.getAttribute('mediatype')=='HTML')setTimeout('tf.core.crFFldImager.replace(\''+pid+'\',\''+pid+'\');',500);
6063}
6064}
6065s=optImg(idForImg,'optionarea_radiobutton_one')+s;
6066if(combine&&updStkDisp)tf.core.stkDisp(pid);
6067return s;
6068}
6069function _sl(n,r,a,dv,on){
6070var s=[
6071'',
6072'<select name="'+n.replace(/"/g,'&quot;')+'"',
6073(updDisp?' onfocus="'+codeToHandleTextBlur+'"':''),
6074(updDisp?' onclick="cancelBuble(event);if(tf.isInSF())return false;"':' onclick="cancelBuble(event);if(tf.isInSF())return false;"'),
6075' onChange="',
6076choiceImageInProductImageArea?'tf.core.crFFldImager.replace(\''+pid+'\',this.value.split(core.str_sep1)[7]);':'',
6077'var c = this.value;',
6078(combine?'core.stkDisp(\''+pid+',\'\+this.value.split(core.str_sep1)[3]);':''),
6079(updDisp?'tf.core.crFFldOptPrc.updPrc(\''+pid+'\',this.value?this.value.split(core.str_sep1)[7]:\''+a[0][0]+'\',crFFldArr,opt);':''),
6080'dBasePrice2(\''+pid+'\',c);',
6081'return false;"',
6082' size='+r+'>\n'
6083];
6084if(args[6]=='0'){s.push('<option value="">'+on+'</option>');}
6085else{s.push('<option value="" disabled data-nosel="">'+on+'</option>');}
6086var iSel=-1,updStkDisp=true,idForImg=pid;
6087for (var i=0; i<a.length; i++) {
6088var checked='';iSel=-1;chid=a[i][2];
6089if(updDisp){
6090var sel='';
6091if(crFFldOptPrc.oFldSel[a[i][2]])sel=crFFldOptPrc.oFldSel[a[i][2]];
6092}
6093var bSel=false;
6094if (updDisp && (i==0&&dv!='0'&&!sel||sel=='1')) {
6095iSel=i;
6096bSel=true;
6097}
6098var elImg=tf.content.gl('I'+pid);
6099if (bSel || i==0&&dv!='0') {
6100idForImg=chid;
6101checked=' selected';
6102if(updDisp){if(!tf.core.crFFldOptPrc.busy[pid])setTimeout("tf.core.crFFldOptPrc.setFocus=false;tf.core.crFFldOptPrc.updPrc('"+pid+"','"+a[i][2]+"',tfc.crFFldArr,tfc.opt);tf.core.crFFldOptPrc.setFocus=true;",500);}
6103if(combine){updStkDisp=false;setTimeout("tf.core.stkDisp('"+pid+","+a[i][5]+"')",400);}
6104if(core)tfc.dBasePrice2(pid,(['','','','',a[i][6],a[i][7],a[i][8]].join(str_sep1)),tfc);
6105if(choiceImageInProductImageArea){
6106if(elImg) {
6107var hasNoDimensions=(!elImg.getAttribute('width')&&!elImg.getAttribute('height'));
6108if(tf.isIE7)hasNoDimensions=!elImg.outerHTML.match(/(?:width|height)=/i);
6109if(hasNoDimensions)setTimeout('tf.core.crFFldImager.replace(\''+pid+'\',\''+a[i][2]+'\');',500);
6110}
6111}
6112}
6113if(elImg) {
6114if(elImg.getAttribute('mediatype')=='HTML')setTimeout('tf.core.crFFldImager.replace(\''+pid+'\',\''+pid+'\');',500);
6115}
6116s.push('<option '+_v(1,a[i],i)+checked+'>'+a[i][1]+_p(a[i][0],id,i,false,checked?false:true)+'</option>\n');
6117}
6118s.push('</select>');
6119optImgInit(a);
6120s[0]=optImg(idForImg,'optionarea_');
6121if(combine&&updStkDisp)tf.core.stkDisp(pid);
6122return s.join('');
6123}
6124var codeToHandleTextBlur='if(tf.core.idTextOptionBlur){clearTimeout(tf.core.idTextOptionBlur);tf.core.idTextOptionBlur=null;}if(tf.core.onblurcode){eval(tf.core.onblurcode);tf.core.onblurcode=\'\';tf.core.setFocusID=\'\';}';tf.core.cthtb=codeToHandleTextBlur;
6125var showincluded=false,ponEE='';
6126var rc=(c=='')?'':' cols="'+c+'"';
6127rc+=(r=='')?'':' rows="'+r+'"';
6128if(updDisp){
6129if(t==1||t==2){
6130tf.core.crFFldOptPrc.resetTemporarily(pid);
6131showincluded=(getOPrc(oA[0][0],id,0)!=0);
6132tf.core.crFFldOptPrc.unreset(pid);
6133ponB='<div class="GC74 ProductOptionName">';
6134if(tf.utils&&tf.utils.imgEntryPageFix&&tf.isEntryPage)ponE=tf.utils.imgEntryPageFix(ponE);
6135}
6136else if(t==4){
6137pcnB=pcnB.replace(/\%1/,oA[0][2]);
6138}
6139}
6140var s='',ponBE=(choicesonly?'':ponB+on+(t==1?'<span style="font-weight:normal;">'+_p(oA[0][0],id,0,true,!showincluded)+'</span>':'')+ponE);
6141switch(t) {
6142case 1:s=pogB+ponBE+_ip(n,'text','TextInput',0,oA,on)+pogE;break;
6143case 5:s=pogB+ponBE+_ip(n,'radio','RadioButtonIcon',1,oA,on,dv)+pogE;break;
6144case 6:s='<div class="ProductOptionInner ProductOptionInnerCheckbox" data-option-type="checkbox">'+_ip(n,'checkbox','CheckBoxIcon',1,oA,on,dv)+pogE;break;
6145case 3:rc='';
6146case 4:
6147s=pogB+pcnB+_sl(n,r,oA,dv,on)+pcnE+pogE;
6148break;
6149case 2:
6150chid=oA[0][2];
6151if(updDisp){
6152if(crFFldOptPrc.oFldSel[oA[0][2]])dv=crFFldOptPrc.oFldSel[oA[0][2]];else dv='';
6153ponBE=(choicesonly?'':ponB+on+'<span style="font-weight:normal;">'+_p(oA[0][0],id,0,true,!showincluded)+'</span>'+ponE);
6154var prcUpdater='tf.core.crFFldOptPrc.updPrc(\''+pid+'\',\''+oA[0][2]+'\',crFFldArr,opt);';
6155}
6156else {
6157var prcUpdater='';
6158}
6159optImgInit(oA[0]);
6160var pcnBI=optImg(chid,'optionarea_');
6161s=pogB+ponBE+pcnB+'<textarea id="'+oA[0][2]+'"'+_v(0,oA[0],0)+' onclick="cancelBuble(event);if(tf.isInSF())return false;" onFocus="if(tf.isInSF())return false;core.crFFldImager.replace(\''+pid+'\',\''+oA[0][2]+'\');" onChange="'+prcUpdater+'this.value=this.value.substring(0,'+maxlen+');if(this.value.length>='+maxlen+'){alert(ld(\'LD_MAXLENGTH\',\'\',['+maxlen+']));}" onblur="tf.core.onblurcode=this.getAttribute(\'onblurcode\');tf.core.idTextOptionBlur=setTimeout(function(){'+prcUpdater+'if(tf.core.crFFldOptPrc.updDisp&&tf.utils.displaySelectedOpt)tf.utils.displaySelectedOpt();},500);" onblurcode="'+prcUpdater+'" onmousedown="tf.core.setFocusID=\''+oA[0][2]+'\';" onKeyUp="if(this.value.length>='+maxlen+'){this.blur();}" name="'+n.replace(/"/g,'&quot;')+'" '+rc+'>'+((updDisp?dv:'')||oA[0][1])+'</textarea>'+pcnE+pogE;break;
6162}
6163return s;
6164}
6165function load_add(d,type,id,title,weight,orderNo,useDec,esd,taxes,prd_cd,man_cd,dst_cd,prc_cd,opt,issf,s,minorder,temp) {
6166var ret=false;
6167if (!isNaN(prd_cd)) prd_cd+='%%P';
6168var qnty;
6169qnty=tf.content.document.getElementById(id+'_Quantity');
6170if (!minorder) minorder=(useDec>0)?'1.00':'1';
6171if (useDec<1) minorder=parseInt(minorder);
6172var qv='';
6173if(qnty){
6174qv=nfmt.fromLoc(qnty.value);
6175if(isNaN(qv))qnty.value=(useDec?nfmt.toLoc("1.00"):"1");
6176else{
6177if((useDec>0&&parseFloat(qv)<0.0001)||(useDec<1&&parseInt(qv)<1))qnty.value=nfmt.toLoc(minorder);
6178else qnty.value=nfmt.toLoc(qv);
6179}
6180}
6181qnty=qnty?parseFloat(nfmt.fromLoc(qnty.value)):0;
6182if (isNaN(qnty) || !qnty || (qnty<0)) qnty=1;
6183if (tf.coreLoaded&&issf!=true) {
6184var bt;bt=core.Basket;
6185if (type==1){bt=core.Favorite;bt.save();}
6186ret=bt.parse(id,d,qnty,title,weight,orderNo,useDec,esd,taxes,opt,prd_cd,man_cd,dst_cd,prc_cd,null,false,temp,type);
6187} else if (confirm(ld('LD_ENTER_SHOP','Om dit product te kopen moet u eerst de shop binnengaan. Wilt u nu naar de shop gaan?'))) {
6188location = s+'#'+id.toLowerCase();
6189}
6190return ret;
6191}
6192function prodTypeCode(type,prd) {
6193var code = '';
6194switch (type){
6195case 0: // Brand
6196code = prd[14];
6197break;
6198case 1: // ManufacturerCode
6199code = prd[11];
6200break;
6201case 2: // ProductCode
6202code = prd[9];
6203break;
6204case 3: // DistributorCode
6205code = prd[12];
6206break;
6207case 4: // PriceCode
6208code = prd[13];
6209break;
6210case 5: // DiscountCode
6211code = prd[23];
6212break;
6213}
6214return code;
6215}
6216var nfmt=new numeric(',','');
6217var css=new CSS();
6218var nfmt=new numeric(',',''),css=new CSS();
6219var Basket=new basket();
6220var bskRestoreHelper=new basket();
6221var theBsk=Basket;
6222var Favorite=new basket('Favorite');
6223tf.coreLoaded=true;
6224try{tf.content.core=this.window;}catch(e){}
6225tf.core=core=this.window;
6226if(currTime)currTime.getTime();
6227tf.nametag.add('showCookieWarning',getCookStr('showCookieWarning')=='false'?false:true);
6228function waitforconf(){
6229if(confLoaded&&tf.langLoaded&&typeof(load_page)!='undefined'){
6230if(!tf.isInSF()){
6231var restore=eval(tf.nametag.get('nmdt'));
6232if(!restore)restore=tf.core.getCookStr('nmdt');
6233if(restore){
6234if(tf.pgid=='D-6'||tf.pgid=='D-16'||tf.pgid=='D-8'){
6235tf.name=(restore===true?tf.core.getCookStr('nmdt'):restore);
6236}
6237tf.nametag.del('nmdt');
6238tf.core.delCookStr('nmdt');
6239}
6240}
6241if(!tf.isInSF())Basket.load();
6242if(!tf.isInSF()&&pm&&tf.content.$)pm.get();
6243rl_total();
6244setTimeout(Favorite.load.apply(Favorite),2000);
6245}
6246else setTimeout("waitforconf()",100);
6247}
6248var pageID=(window.external&&window.external['getPageID']?window.external['getPageID']():'');
6249if(pageID!='D-42'){
6250tf.load('grey.html','shipping');
6251tf.load('conf.html','conf',true);
6252waitforconf();
6253}
6254tf.core=this.window;
6255tf.utils=this.window;
6256if(tf.extra){this.dynamic=tf.extra.dynamic;this.dynLoad=tf.extra.dynLoad;}
6257if($)$(tf).trigger('coreLoaded');
6258ldjs('../../../shared_files/menu_scroller.js');
6259/*$Revision: 47065 $
6260$HeadURL: svn://localhost/ShopFactory/branches/V14_60/bin/Common%20Files/parseLang/sf.js $*/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.