// <script>
var tf=tf||this,LD=tf,tfc=tf.content||this,tfcd=tfc.document,$=tfc.$;
if(tf.isInSF()){
var wx=window.external,arrLoad=[];
function 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);}
}
var isIEBefore7=parseFloat(navigator.appVersion.split('MSIE')[1])<7;
if ($) { (function($) { $.support.placeholder = ('placeholder' in document.createElement('input')); })(jQuery); }
var prpgmap={
pgMap:{},
prMap:{},
requested:{},
loaded:{},
onloadPgMap:function(oResp,fn){
tf.merge(this.pgMap,tf.sfJSON.parse(oResp.req.responseText));
if(fn)fn.call(this);
},
onloadPrMap:function(oResp,fn){
tf.merge(this.prMap,tf.sfJSON.parse(oResp.req.responseText));
if(fn)fn.call(this);
},
getParentPage:function(prid,pgid,fn){
if(!pgid){pgid=tf.content.pgid;}
pgid=pgid.toLowerCase();
prid=prid.toLowerCase();
var pridNum=parseInt(prid.substr(1)),pgidNum=parseInt(pgid.substr(1)),pgidFound=0;
if(pgid.indexOf('/'+tf.enterFilename)!=-1||pgid=='/')pgidNum=-2;
var prmapURL='prpgmap/prmap_'+Math.floor(pridNum/2000)+'.js';
if(isNaN(pridNum)||this.prMap[pridNum]){
if(isNaN(pridNum))pgidFound=pgidNum;
else {
var a=this.prMap[pridNum];
if(typeof(a.length)=='number'&&typeof(a)!='string'){
pgidFound=a[0];
for(var n=1,num=a.length;n<num;n++){
if(a[n]==pgidNum||a[n].toString().indexOf(pgidNum+'_')==0){
pgidFound=a[n];
break;
}
}
}
else pgidFound=a;
}
var pgidSplit=(isNaN(pgidFound)?pgidFound.split('_'):[pgidFound]);
if(typeof(this.pgMap[pgidSplit[0]])!='undefined'){
var s=this.pgMap[pgidSplit[0]], internalURL=((s==''||s.indexOf('_')==0)||unescape(s).indexOf('://')==-1),specialPage=(parseInt(pgidSplit[0])<0&&parseInt(pgidSplit[0])>-10000);
if(parseInt(pgidSplit[0])==-2&&pgid.indexOf('/'+tf.enterFilename)!=-1)s=tf.enterFilename.replace(/\.[^.]*$/,'');
var f=(internalURL&&!specialPage?'d'+pgidSplit[0]:'')+s+(pgidSplit[1]?'_'+pgidSplit[1]:'')+(internalURL||(specialPage&&internalURL)?'.html':'');
if(parseInt(pgidSplit[0])==-2&&pgid=='/')f=pgid;
return fn(f,prid,'d'+pgidSplit[0]);
}
else{
var pgmapURL='prpgmap/pgmap_'+Math.floor(Math.abs(pgidSplit[0])/2000)+'.js';
if(!tf.utils.prpgmap.requested[pgmapURL]){
tf.utils.prpgmap.requested[pgmapURL]=true;
new net.ContentLoader(
tf.wm.url(pgmapURL,'-'),
function(){tf.utils.prpgmap.onloadPgMap.call(tf.utils.prpgmap,this,function(){this.loaded[pgmapURL]=true;this.getParentPage(prid,pgid,fn);});},
null, null, 'GET', '');
}
else if(tf.utils.prpgmap.loaded[pgmapURL])return fn('',prid,pgid);
else setTimeout(function(){tf.utils.prpgmap.getParentPage(prid,pgid,fn)},0);
}
}
else{
if(!tf.utils.prpgmap.requested[prmapURL]){
tf.utils.prpgmap.requested[prmapURL]=true;
new net.ContentLoader(
tf.wm.url(prmapURL,'-'),
function(){tf.utils.prpgmap.onloadPrMap.call(tf.utils.prpgmap,this,function(){this.loaded[prmapURL]=true;this.getParentPage(prid,pgid,fn);});},
null, null, 'GET', '');
}
else if(tf.utils.prpgmap.loaded[prmapURL])return fn('',prid,pgid);
else setTimeout(function(){tf.utils.prpgmap.getParentPage(prid,pgid,fn)},0);
}
}
};
if ($) {
var mobileMenusLoaded = false;
function loadMobileMenu() {
$('.idx-menu').each(function(){
var o = $(this);
$.get(tf.wm.url(o.data('deptid')+'.html','-',true),function(data){
o.html(data.replace(/<img[^>]*?>/g,''));
if(o.data('branchid')){
$('> ul:first',o).replaceWith($('[id^=idx][id$='+o.data('branchid')+']',o).next('ul'));
}
o.find('.idx1List,.idx1,.idx2List,.idx2').removeClass('idx1List idx1 idx2List idx2');
if(o.data('folding')!==false){
o.find('li a').each(function(){
$(this).parent().clone(true).prependTo($(this).next('ul')).find('ul,i').remove();
if ($(this).next('ul').length > 0) {
$(this)
.attr('name',$(this).attr('href'))
.click(function(event){
event.preventDefault();
event.stopPropagation();
return true;
})
;
}
});
}
if(tf.isEntryPage){
o.find('a[href]').not('a[href^=http]').each(function(){
if(this.id.match(/D-2$/)) this.href=tf.wm.url((tf.lang==tf.baseLang?'../../':'../../'+tf.lang+'/')+this.href.replace(/.*\//,''),'-');
else this.href=tf.wm.url(this.href.replace(/.*\//,''),'-',true);
});
}
o.find('a[href]').each(function(){
if(o.data('folding')!==false){
if($(this).next('ul').get(0)) $(this).append('<i class="icon-arrow-down3"></i>');
}
});
$('#Index1 #idx1D-2').parents('body').find('#idx2D-2', o).parent('li').remove();
$('#Index2 #idx2D-2').parents('body').find('#idx1D-2', o).parent('li').remove();
o.find('[class^=GC]').each(function(){this.className=this.className.replace(/GC\d+ ?/,'');});
o.find('li a:has(i)').click(function(event){
event.preventDefault();
event.stopPropagation();
if (!$(this).hasClass('active')){
if (!$(this).parents('ul').prev().hasClass('active')) {
$('li ul', o).slideUp('fast');
$('li a', o).removeClass('active')
;
}
$(this)
.addClass('GC32 active').next().slideToggle('fast')
.end()
;
}
else {
$(this)
.removeClass('GC32 active').next().slideToggle('fast')
.end()
;
}
});
o.find('li a').not(':has(i)')
.removeClass('idx1 idx1Sub idx2 idx2Sub')
.click(function(event){
$.sidr('close','Sidemap');
});
o.find('[id$='+tf.pgid+']').addClass('selected').parents('ul').prev().find('i').click();
mobileMenusLoaded = true;
o.trigger('load');
});
});
}
$(document).ready(function(){
$(document).on('keypress', 'input.prd_qty', function(e){
if(e.which==13){
e.preventDefault();
e.stopPropagation();
$(this).parents('.product').find('.calculate').click();
}
});
$('.ProductQuantity > input[id*=_Quantity]').on('keypress', function(e){
if(e.which==13){
e.preventDefault();
e.stopPropagation();
$(this).parents('.Product').find('.AddToBasketButton,.AddToBasketButton > *').click();
}
});
function applysidr() {
if(!$('#sidemap-button').sidr) {setTimeout(applysidr,100); return;}
$('#sidemap-button').sidr({ name:'Sidemap', displace:false,
onOpen:function() {
if (mobileMenusLoaded) $('.idx-menu').trigger('load'); else loadMobileMenu();
$('html').css('overflow-x','');
},
onOpenEnd:function() {
mobile_fallbackColours();
}
});
}
applysidr();
$('#sidemap-button').click(function(e){
e.preventDefault();
e.stopPropagation();
$('#Sidemap').css('visibility','visible').animate({'left':'0'});
$.sidr('open', 'Sidemap');
});
$('#sidemap-close').click(function(e){
e.preventDefault();
e.stopPropagation();
$.sidr('close','Sidemap');
return false;
});
function mobile_fallbackColours(){
$('.header.mobile,.footer.mobile,#Sidemap').each(function(){
var GC=this.className.replace(/.*(GC\d+).*/,'$1');
if($(this).css('background-color')=='transparent'||$(this).css('background-color')=='rgba(0, 0, 0, 0)'){
$(this).css('background-color',tf.autoText.lightText);
}
if($(this).css('color')==$(this).css('background-color')||typeof(tf.autoText.GCUsesAutoText[GC])=='undefined'){
$(this).add('*',this).css('color',tf.autoText.isColorDark(tf.content.document,this)?tf.autoText.lightText:tf.autoText.darkText);
}
});
}
mobile_fallbackColours();
$('#gototop-button').click(function(e){
e.preventDefault();
tf.content.document.body.scrollTop = 0;
tf.content.document.documentElement.scrollTop = 0;
return false;
});
showMobileUtils = function(){
$(window).scroll(function(){
if ($(window).scrollTop() >= 50) {
$('.utils.group').addClass('fixed-header');
$('.utils.group').addClass('visible-title');
}
else {
$('.utils.group').removeClass('fixed-header');
$('.utils.group').removeClass('visible-title');
}
});
};
retractMobileUtils = function() {
if ($('.header.mobile:visible').length == 0) return;
if ($('#mobile_search input:focus').length > 0) return;
if ($(tf.content).height() >= $(tf.content.document).height()) return;
if (($(tf.content).scrollTop() == 0) || ($(tf.content).scrollTop() + $(tf.content).height() >= $(tf.content.document).height() - $('.footer.mobile:visible').height())) {
$('html').css({'margin-top':0, 'margin-bottom':0});
}
$('.header.mobile:visible').css({top:-($('.header.mobile:visible').height())}, 'fast', 'swing', function(){$(tf.content).bind('scroll', showMobileUtils)});
$('.footer.mobile:visible').css({bottom:-($('.footer.mobile:visible').height())}, 'fast');
$(tf.content).data({'mobile-utils-scrolltop':$(tf.content).scrollTop()});
}
$(tf.content).data({'mobile-utils-scrolltop':$(tf.content).scrollTop()}).bind({'scroll resize':showMobileUtils});
$('#sidemap-close').click(showMobileUtils);
if(!tf.isInSF()&&!tf.SF_disableYT) {
$('iframe[sf_ytsrc]').each(function(){
var src=$(this).attr('sf_ytsrc');
$(this).removeAttr('sf_ytsrc').attr('src',src);
});
}
});
}
var tmplParser = {
parse:function(tmplName, vars) {
var el=(typeof(tmplName)=='string'?tf.extra.document.getElementById(tmplName):tmplName);
if(!el)return false;
var result=el.innerHTML.replace('<!--','').replace('-->','').replace('<![CDATA[','').replace(']]>','');
if(vars){
for(var param in vars){
var reg=eval('/__'+param+'__(?:="")?/gi'),val=new String(vars[param]);
result=result.replace(reg, val.replace(/\$/g,'&#36;'));
}
}
var reg = /__(LD_.+?)__/g;
result = result.replace(reg,
function($0, $1) {
var str = eval('tf.'+$1);
if (str) return str;
else return $1;
}
);
return result;
}
};
var sfMediaBox={
closeBox:function(redirectTo){
this.unrender('sfLightBox');
this.unrender('sfLightBoxOverlay');
this.showDropDowns(true);
tfc.document.body.style.overflow='';
tfc.document.documentElement.style.overflow='';
tfcd.body.className=tfcd.body.className.replace(' mobileBox','');
tf.delEvent('onkeydown',this.keyHandler,tfcd.body);
tf.delEvent('onresize',this.centerBox);
if(this.fnAfterClose)this.fnAfterClose();
if(typeof redirectTo === "string") {
tf.wm.rld(tf.content,redirectTo,'-',1);
}
},
centerBox:function(o,custW,custH){
var meme=tf.utils.sfMediaBox;
if(custW)meme.cacheW=custW;
if(custH)meme.cacheH=custH;
var w=tf.innerWidth,h=tf.innerHeight;
var elLB=gl('sfLightBox');
if(elLB){
if(tf.isMobile_SmallLandscape||tf.isMobile_SmallPortrait||tf.isMobile_Small||tf.isMobile_LargePortrait){
if(tfcd.body.className.indexOf('mobileBox')==-1)tfcd.body.className+=' mobileBox';
elLB.style.marginLeft=(-w/2)+'px';
elLB.style.marginTop=(-h/2)+'px';
w-=(parseInt(elLB.style.paddingLeft)+parseInt(elLB.style.paddingRight));
h-=(parseInt(elLB.style.paddingTop)+parseInt(elLB.style.paddingBottom));
if(meme.useOffsetTop)h-=24;
}
else{
tfcd.body.className=tfcd.body.className.replace(' mobileBox','');
var rc=elLB.getBoundingClientRect(),rc2=gl('sfLightBoxTopBar').getBoundingClientRect();
var padh=(parseInt(elLB.style.paddingTop)+parseInt(elLB.style.paddingBottom));
w=meme.getVirtualWidth(meme.cacheW);
h=meme.getVirtualHeight(meme.cacheH);
var sflbc=gl('sfLightBoxContents');
sflbc.style.overflowX='';
sflbc.style.overflowY='';
if(rc2.width>0&&rc2.height>0){
if(meme.cacheH<=(rc.height-rc2.height-((rc2.top-rc.top)*2))) {
if(meme.cacheH>=sflbc.scrollHeight)sflbc.style.overflowY='hidden';
}
else w+=22;
if(meme.cacheW<=rc2.width){}// sflbc.style.overflowX='hidden';
else h+=22;
}
elLB.style.marginLeft=(-w/2)+'px';
elLB.style.marginTop=((-(h+(rc2.bottom-rc2.top)+padh))/2)+'px';
}
var IDs={'sfLightBoxBody':[w+'px',null],'sfLightBoxContents':[w+'px',h+'px'],'sfLightBoxLoading':[w+'px',h+'px'],'sfPopupFrame':[w+'px',h+'px']};
for(var n in IDs){
var el=gl(n);
if(el){
if(IDs[n][0]!=null)el.style.width=IDs[n][0];
if(IDs[n][1]!=null)el.style.height=IDs[n][1];
}
}
IDs=['sfLightBoxNavLeft','sfLightBoxNavRight'];
for(var n=0;n<IDs.length;n++){
var el=gl(IDs[n]);
if(el){
el.style.height=h+'px';
}
}
}
},
hide:function(id){ if(gl(id))gl(id).style.display='none'; },
show:function(id){ if(gl(id))gl(id).style.display='block'; },
showDropDowns:function(show){
function looper(a,show){
for(var i=0,num=a.length;i<num;i++){
a[i].style.visibility=(show?'visible':'hidden');
}
}
if(tf.isIE6)looper(tfcd.getElementsByTagName('SELECT'),show);
looper(tfcd.getElementsByTagName('OBJECT'),show);
looper(tfcd.getElementsByTagName('EMBED'),show);
looper(tfcd.getElementsByTagName('IFRAME'),show);
},
content_onload:function(o){
var $el2=$(o).parents('#sfLightBoxContents'),oi1=o.getAttribute('index'),oi2=$el2.attr('index');
if(oi1!=oi2)return;
if(o.width==0||o.height==0)return;
$el2.parent().find('#sfLightBoxLoading').hide();
},
render:function(o,a,isMM){
var el=tfcd.createElement('div');
el.innerHTML=(typeof(a)=='function'?a(o):a);
for(var i=0,num=el.childNodes.length;i<num;i++){
if(tf.isIE&&!el.childNodes[0].style){el.removeChild(el.childNodes[0]);continue;}
if(tf.isIE&&isMM)el.childNodes[0].style.visibility='hidden';
var elNew=o.tfcdb().appendChild(el.childNodes[0]);
if(tf.isIE6&&elNew.currentStyle.position=='fixed')elNew.style.position='absolute';
if(tf.isIE&&isMM)setTimeout(function(){elNew.style.visibility='visible';},20);
}
},
unrender:function(id){ var el=gl(id); if(el)el.parentNode.removeChild(el); },
scale:function(mW, mH, cW, cH){
if(cW<mW&&cH<mH)return[cW,cH];
var r=cH/cW,cx=mW,cy=parseInt((mW*r)+0.5);
if(cy>mH){ r=cW/cH; cx=parseInt((mH*r)+0.5); cy=mH; }
return [cx,cy];
},
getVirtualWidth:function(w){ return Math.max(100,Math.min(w,tf.innerWidth * 0.9)); },
getVirtualHeight:function(h){ return Math.max(100,Math.min(h,tf.innerHeight * 0.85)) + 5; },
mw:-1,
mh:-1,
useOffsetTop:true,
useLargestSize:true,
gl:function(s){try{return tf.extra.document.getElementById(s);}catch(e){return null;}},
fnAfterClose:null,
tfcdb:function(){return (tf.isSafari?tfcd.documentElement:tfcd.body);},
relPrefix:(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../'),
close_onclick:'tf.utils.sfMediaBox.closeBox();return false;',
prevnext_onmouseover:function(el,dir){
el.style.backgroundImage='url('+(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../')+'media/mediabox_large_'+dir+'.png)';
},
prevnext_onmouseout:function(el){
el.style.backgroundImage='url('+(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../')+'media/trans.gif)';
},
aHTML:[
function(o){ return tmplParser.parse(o.gl('tmplSFLightBoxOverlay'), { height:'100%', close_onclick:o.close_onclick, className:'', contents:'' }); },
function(o){ return tmplParser.parse(o.gl('tmplSFLightBox'), o.data); }
],
aRef:[],
aPrefetch:[],
hasTitle:false,
hasDescription:false,
currIdx:-1,
onMobile:tf.isMobile,
cacheW:-1,
cacheH:-1,
useFlickity:true,
keyHandler:function(evt){
var me=tf.utils.sfMediaBox;
switch(evt.keyCode){
case 27: me.closeBox(); break;
case 37: me.showContents(me.currIdx==0?me.aRef.length-1:me.currIdx-1); break;
case 39: me.showContents(me.currIdx==me.aRef.length-1?0:me.currIdx+1); break;
}
},
init:function(names,jumptoid){
this.closeBox();
this.fnAfterClose=null;
this.aRef=[];
this.aPrefetch=[];
this.mw=this.mh=-1;
var a=tfcd.querySelectorAll('a[rel^=sfMediaBox]'),jumptoidx=0;
for(var m=0,mm=names.length;m<mm;m++){
for(var n in a){
if(a[n].rel=='sfMediaBox['+names[m]+']'&&(a[n].href||a[n].getAttribute('src'))!=unescape(tf.wm.host)){
this.aRef.push(a[n]);
if(a[n].title)this.hasTitle=true;
if(a[n].getAttribute('description'))this.hasDescription=true;
if(a[n].id==jumptoid)jumptoidx=this.aRef.length-1;
if(this.useLargestSize){
var mw=parseInt(a[n].getAttribute('mw')),mh=parseInt(a[n].getAttribute('mh'));
if(mw>this.mw)this.mw=mw;
if(mh>this.mh)this.mh=mh;
}
}
}
}
if(this.aRef.length>0 && this.aRef[0].mediaType!='MM'){
this.render(this, this.aHTML[0]);
var me=this;
this.aPrefetch[jumptoidx]=new Image();
this.aPrefetch[jumptoidx].onload=function(){
this.loaded=true;
if(me.aRef.length==1){
me.showContents(jumptoidx);
tf.addEvent('onkeydown',me.keyHandler,tfcd.body);
}
if(!me.useFlickity){
for(var n=0,nn=me.aRef.length;n<nn;n++){
if(!me.aPrefetch[n]){
var img=new Image();
img.loaded=false;
img.onload=function(){this.loaded=true;}
img.src=me.aRef[n].href||me.aRef[n].getAttribute('src');
me.aPrefetch[n]=img;
}
}
}
}
this.aPrefetch[jumptoidx].src=this.aRef[jumptoidx].href||this.aRef[jumptoidx].getAttribute('src');
if(me.aRef.length>1){
this.showContents(jumptoidx);
tf.addEvent('onkeydown',this.keyHandler,tfcd.body);
}
}
},
showContents:function(n){
this.currIdx=n;
var el=gl('sfLightBox');if(el)el.parentNode.removeChild(el);
var o=this.aPrefetch[n],oo=this.aRef[n];
if(!o){this.aPrefetch[0].onload();o=this.aPrefetch[n];}
var type=oo.getAttribute('mediaType'),isMM=(type=='MM'),isHTML=(type=='HTML'),w=o.width,h=o.height;
if(isMM){w=oo.getAttribute('mw');h=oo.getAttribute('mh');}
if(this.useLargestSize&&this.mw>-1&&this.mh>-1){w=this.mw;h=this.mh;}
var vw=this.getVirtualWidth(w), vh=this.getVirtualHeight(h);
this.cacheW=w;this.cacheH=h;
this.useOffsetTop=true;
this.data={
navdisplay:(this.aRef.length>1?'block':'none'), captiondisplay:oo.title||oo.getAttribute('description')?'block':'none', relprefix:this.relPrefix,
close_onclick:this.close_onclick,
prev_visible:(this.aRef.length==1?'hidden':'visible'), next_visible:(this.aRef.length==1?'hidden':'visible'),
count:this.aRef.length, index:n+1,
prev_onclick:'tf.utils.sfMediaBox.showContents('+(n==0?this.aRef.length-1:n-1)+');return false;',
next_onclick:'tf.utils.sfMediaBox.showContents('+(n==this.aRef.length-1?0:n+1)+');return false;',
prev_onmouseover:'tf.utils.sfMediaBox.prevnext_onmouseover(this,\'left\');',
prev_onmouseout:'tf.utils.sfMediaBox.prevnext_onmouseout(this);',
next_onmouseover:'tf.utils.sfMediaBox.prevnext_onmouseover(this,\'right\');',
next_onmouseout:'tf.utils.sfMediaBox.prevnext_onmouseout(this);',
width:vw+'px', height:vh+'px',
overflow:'auto',
title:(oo.title?oo.title:(this.hasTitle?'&nbsp;':'')), description:(oo.getAttribute('description')?oo.getAttribute('description'):(this.hasDescription?'&nbsp;':'')),
loadingdisplay:(o.loaded||isMM||isHTML?'none':'block'),loadingmessage:'',
position:'fixed',
marginleft:(-vw/2+this.tfcdb().scrollLeft)+'px', margintop:(-vh/2+this.tfcdb().scrollTop)+'px',
decorationborder:'5px',
className:'',
imagecontrols:'',
contents:''
};
if(this.useFlickity){
for(var i=0;i<this.aRef.length;i++){
var _o=this.aPrefetch[i],_oo=this.aRef[i];
var type=_oo.getAttribute('mediaType'),isMM=(type=='MM'),isHTML=(type=='HTML'),w=0,h=0;
if(!_o){
var img=null;
if(!isMM&&!isHTML){
img=new Image();
img.loaded=false;
img.onload=function(){this.loaded=true;}
img.src=this.aRef[i].href||this.aRef[i].getAttribute('src');
}
this.aPrefetch[i]=img;
if(this.aPrefetch[i])this.aPrefetch[i].onload();
_o=this.aPrefetch[i];
}
if(!isMM&&!isHTML){w=_o.width;h=_o.height;}
if(isMM){w=_oo.getAttribute('mw');h=_oo.getAttribute('mh');}
this.data['captiondisplay']=_oo.title||_oo.getAttribute('description')?'block':'none';
this.data['title']=(_oo.title?_oo.title:(this.hasTitle?'&nbsp;':''));
this.data['description']=(_oo.getAttribute('description')?_oo.getAttribute('description'):(this.hasDescription?'&nbsp;':''));
this.data['loadingdisplay']=(isMM||isHTML||_o.loaded?'none':'block');
this.data['contents']+=tmplParser.parse(this.gl('tmplSFLightBoxFlickityItem'),
{
code:(isMM?this.getMMHTML(_oo.id,_oo.href||_oo.getAttribute('src'),_oo.getAttribute('filetype'),w,h,_oo.title):
(isHTML
?this.getMMHTMLUsingExtraction(_oo.id,unescapeUTF8(_oo.getAttribute('href')),vw,vh)
:'<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);')+'" />'
)
),
title:this.data['title'],
description:this.data['description']
}
);
}
this.data['title']='';
this.data['description']='';
this.data['contents']=tmplParser.parse(this.gl('tmplSFLightBoxFlickity'), this.data);
}
else{
this.data['contents']=(isMM?
this.getMMHTML(oo.id,oo.href||oo.getAttribute('src'),oo.getAttribute('filetype'),w,h,oo.title):
(isHTML?
this.getMMHTMLUsingExtraction(oo.id,oo.href,vw,vh):
tmplParser.parse(this.gl('tmplSFLightBoxImage'),
{ wh:'height:'+vh+'px;', src:o.src, wide:(vw<w)?'width="100%"' : '', index:n+1, onload:(o.loaded?'':'tf.utils.sfMediaBox.content_onload(this);') }
)
)
);
this.data['imagecontrols']=tmplParser.parse(this.gl('tmplSFLightBoxImageControls'), this.data);
}
this.showDropDowns(false);
this.render(this, this.aHTML[1], isMM);
this.centerBox();
tf.$(tfc).on('resize',this.centerBox);
tfc.document.body.style.overflow='hidden';
if(this.useFlickity){
var $=tf.$;
var $lightBoxCarousel = $('.LightBoxCarousel .gallery-box').flickity({
wrapAround: true,
autoPlay: false,
draggable: true,
freeScroll: false,
setGallerySize: false,
prevNextButtons: true,
pageDots: true
});
$lightBoxCarousel
.flickity('resize')
.on('cellSelect', function() {
$lightBoxCarousel.flickity('bindDrag');
var flkty = $(this).data('flickity');
$('#sfLightBoxBottomBar .title').html($('.title', flkty.selectedElement).html());
$('#sfLightBoxBottomBar .description').html($('.introduction', flkty.selectedElement).html());
$('object,embed',flkty.selectedElement).each(function(){
var w=$(this).attr('width'),h=$(this).attr('height');
if(w&&h){
var ratio=h/w;
w=$(this).parents('.box').width();
h=w*ratio;
$(this).attr({'width':w,'height':h});
}
});
})
.flickity('select',n,true,true)
;
$('#sfLightBoxContents,#sfLightBoxContents > div:last-child').css('overflow','');
$(tfc).on('resize',function(){
var $coll=$lightBoxCarousel.add($('.box',$lightBoxCarousel)).add($('#sfLightBoxContents'));
if(tf.isMobile_SmallLandscape||tf.isMobile_SmallPortrait||tf.isMobile_Small||tf.isMobile_LargePortrait){
$('#sfLightBox').attr('style',$('#sfLightBox').attr('style')+'height:100%!important;');
$coll.height($('#sfLightBox').height()-$('#sfLightBoxTopBar').outerHeight(true)-$('#sfLightBoxBottomBar').outerHeight(true));
}
else{
$('#sfLightBox').height('');
$coll.height('');
}
}).trigger('resize');
tfc.Flickity.prototype._dragPointerDown=function(event,pointer){
this.pointerDownPoint=tfc.Unipointer.getPointerPoint(pointer);
var isTouchstart = event.type == 'touchstart';
var targetNodeName = event.target.nodeName;
if ( !isTouchstart && targetNodeName != 'SELECT' && targetNodeName != 'OBJECT' && targetNodeName != 'EMBED') {
event.preventDefault();
}
}
}
},
getMMHTML:function(id,s,t,w,h,title){
if((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');}}
var src=unescape(s);
return sfMM([id,'',t,src,w,h,w,h,title]);
},
getMMHTMLUsingExtraction:function(id,s,mw,mh){
var w=this.mw,h=this.mh,src='',html='';
if(s.match(/width=['"](.*?)['"]/i))w=RegExp.$1;
if(s.match(/height=['"](.*?)['"]/i))h=RegExp.$1;
var dim=this.scale(mw,mh,w,h);
w=dim[0];h=dim[1];
html=s.replace(/ width="(.*?)"/,' width="'+w+'"').replace(/ height="(.*?)"/,' height="'+h+'"');
return html;
}
}
function populatePrice(arr,idx){
var a=arr||tfc.ppriceArr;if(!a||!tf.core.region){setTimeout('tf.utils.populatePrice()',1000);return;}
$(tfc).trigger('_sfEvt_PopulatePrice_Begin');
for(var i=0,l=a.length;i<l;i++){
if(typeof(idx)!='undefined'&&a[i][0]!=idx)continue;
var p=tf.wm.pProp(a[i][0]);
if(!p)continue;
var el=gl('ProductPrice-'+a[i][0]);
if($('input[name=ProductPriceLayout]').length>0){tf.core.ppriceTemplateLayout(el,a[i]);$('.ShippingChargeForProduct',el).html($('.ShippingChargeForProduct',el).html());}
else if(el||a[i][1]!=''){var s=tf.core.pprice(el,a[i]);if(el&&s)el.innerHTML=s;}
if(p['optWeight']){
el=gl('ProductWeightFormatted-'+a[i][0]);
var wgt=(p['optWeight']+parseFloat(p[10])).toString();
if(el)el.innerHTML=core.nfmt.display(wgt,3,'');
}
el=gl('Product-'+a[i][0]);
}
if(tf.content.pgid.indexOf('P')==0)populateCrossPromotionPrice();
else {
if(tfc.equalHeight)tfc.equalHeight();
if($) {$(tf.content.document).trigger('domChanged');}
}
$(tfc).trigger('_sfEvt_PopulatePrice_End');
}
function populateCrossPromotionPrice(arr,idx){
var a=arr||tfc.ppriceCrossPromotionArr;if(!a||!tf.core.region){setTimeout('tf.utils.populateCrossPromotionPrice()',1000);return;}
var changed=false;
for(var i=0,l=a.length;i<l;i++){
if(typeof(idx)!='undefined'&&a[i][0]!=idx)continue;
if(!tf.wm.pProp(a[i][0]))continue;
var el=gl('ProductCrossPromotionPrice-'+a[i][0]);
if(el&&tf.wm.pProp(a[i][0])){
if($('input[name=ProductPriceLayout]').length>0) {
tf.core.ppriceTemplateLayout(el,a[i],'CrossPromotion');
$('.ShippingChargeForProduct',$(el).parent()).each(function(){
$(this).html($('.Product .ShippingChargeForProduct').filter(function(){return $(this).parents('.ProductCrossPromotion').length==0;}).html().replace('add_'+tf.pgid,'add_'+a[i][0]));
});
changed = true;
}
else{
var s=tf.core.pprice(el,a[i],'CrossPromotion');
if(s){if(s!=el.innerHTML)changed=true;el.innerHTML=s;}
}
el=gl('ProductCrossPromotion-'+a[i][0]);
}
}
a=tfc.bpriceCrossPromotionArr;
if(a&&a.length){
for(var i=0,l=a.length;i<l;i++){
if(typeof(idx)!='undefined'&&a[i][0]!=idx)continue;
var p=tf.wm.pProp(a[i][0]);
if(!p)continue;
var el=gl('ProductCrossPromotionBasePrice-'+a[i][0]);
if(el){
if(!a[i][3]){a[i][1]=p[18];a[i][2]=p[19];a[i][3]=p[20];}
if(a[i][3]){
var s=core.bprice(a[i]);
if(s!=el.innerHTML)changed=true;
el.innerHTML=s;
}
else el.style.display='none';
}
}
}
if(changed) {
if(tf.content.equalHeight)tf.content.equalHeight();
if($) {$(tf.content.document).trigger('domChanged');}
}
}
function populatedata(){
tfc.specialLoading=true;
if(wx&&typeof(wx.getPageID)=='function'&&(wx.getPageID()=='D-34'||wx.getPageID()=='D-33'))return;
$(tfc).trigger('_sfEvt_PopulateData_Begin');
core=tf.core;
if(!tfc.ppriceArr||!tf.bskLoaded||!tf.coreLoaded||!core.tsI||!tf.core.BTax){setTimeout('populatedata()',50);return;}
if(tfc.timedDiscountsExist&&(!window.SFOrderForm||!window.SFOrderForm.verifying)){tf.core.active_servers=[];tf.core.ping.go(false);tf.core.currTime.getTime();}
populatePrice();
a=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,'');}
a=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]);}
populateOpt();
if(tf.core.loadPricesForIDs&&tfc.ppriceCrossPromotionArr)tf.core.loadPricesForIDs(tfc.ppriceCrossPromotionArr);
tfc.specialLoading=false;
displayProductQuantityDiscounts();
$(tfc).trigger('_sfEvt_PopulateData_End');
}
function populateOpt(origA, idx, optid) {
$(tfc).trigger('_sfEvt_PopulateOpt_Begin');
var a = tfc.crFFldArr || [], origa = origA || tf.wm._pArr, optHTML = { length : 0 };
for (var i = 0, l = a.length; i < l; i++) {
var choicesOnly= typeof(optid) != 'undefined', id = a[i][8];
if(typeof(idx) != 'undefined' && id != idx)
continue;
if (typeof(optid) != 'undefined' && a[i][2] != optid)
continue;
if (!tf.wm.pProp(id))
continue;
if (!optHTML[id]) {
optHTML[id] = '';
optHTML.length++;
}
optHTML[id] += tf.core.crFFld(a[i], origa[id]);
}
for (var i in optHTML) {
var el = gl(choicesOnly ? ('ProductOptionInner-' + optid) : ('ProductOptions-' + i));
if (el) {
var lock=(!choicesOnly && !$(el).data('initialised'));
el.innerHTML = optHTML[i];
if (lock) {
$(el).find('.locker').remove().end().css('position','relative').append(_sfEvt_htmlLocker.replace(/title=""/g,'title="'+((LD&&LD.LD_LOADING)||'').replace(/"/g,'&quot;')+'"'));
var removeLocker = debounce2(function(){
$('.ProductOptions').data('initialised',true).find('.locker').remove();
$('.ProductIcons').find('.locker').remove();
}, 2000);
$(tfc).off('_sfEvt_PopulateOpt.locker').on('_sfEvt_PopulateOpt.locker', removeLocker);
}
}
}
$(tfc).off('_sfEvt_PopulateOpt.hash').on('_sfEvt_PopulateOpt.hash', function(){
if(location.hash)location.hash=location.hash;
});
function fnEqualWidth() {
tf.equalWidth('.ProductOptionInner[data-option-type=radio], .ProductOptionInner[data-option-type=checkbox]', '.ProductChoiceName', 185, 5, true);
if(tf.equalHeight)tf.equalHeight();
}
var fnPopulateOpt=tfc['fnPopulateOpt']||fnEqualWidth;
fnPopulateOpt();
$(tfc).off('resize.populateOpt imageLoaded.populateOpt');
$(tfc).on('resize.populateOpt imageLoaded.populateOpt', function() {
setTimeout(function(){fnPopulateOpt();},20);
});
$(tfc).trigger('_sfEvt_PopulateOpt');
$(tfc).trigger('_sfEvt_PopulateOpt_End');
setTimeout(displaySelectedOpt, 20);
}
var _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>';
if ($) {
$(function () {
$('.ProductIcons').each(function () {
productIconsLocker($(this).attr('id').replace('ProductIcons-', ''));
});
});
}
function displaySelectedOpt(){
var tfc=tf.content,core=tf.core;
if(typeof(tfc.pgid)=='undefined'||tfc.pgid.substr(0,1)!='P')return;
var el=gl('ProductSelectedOptions-'+tf.pgid);
if(!el||!tf.wm.pProp(tf.pgid))return;
var s='',itm=core.Basket.createTemp(tfc.pgid,tfc.document,tfc.opt,1,'','','','','',tfc.ppriceArr[0][2],'',false,true);
if (typeof(itm)!='object'||!itm){
el.innerHTML='';
return;
}
var opt=itm.options.start();
while (opt!=null) {
if (opt.choice()!=='') {
s+='<div class="ProductSelectedOptionsItem"><div class="ProductSelectedOptionsName">'+opt.title+':</div>'+opt.choice()+'</div>';
}
opt=itm.options.next();
}
if(s){
s='<div class="ProductSelectedOptions"><div class="ProductSelectedOptionsHead">'+tf.LD.LD_SELECTEDOPTIONS+'</div><div class="ProductSelectedOptionsBody">'+s+'</div></div>';
el.innerHTML=s;
}
}
function displayProductQuantityDiscounts(prid){
var tfc=tf.content, core=tf.core;
if(prid)displayProductQuantityDiscountsWorker(prid);
else if(typeof tfc._sfProductsInPage!='undefined'){
for(var n=0,nn=tfc._sfProductsInPage.length;n<nn;n++){
displayProductQuantityDiscountsWorker(tfc._sfProductsInPage[n]);
}
}
}
function displayProductQuantityDiscountsWorker(prid){
var elPQD = gl('ProductQuantityDiscounts-'+prid);
if(!elPQD)return;
var tfc=tf.content, core=tf.core;
if(!tf.core||!tf.wm.pProp(prid)||tfc.specialLoading){setTimeout(function(){tf.utils.displayProductQuantityDiscountsWorker(prid);},100);return;}
var bsk=core.Basket, outstr='', bskqnty=1, p=tf.wm.pProp(prid);
bsk.disc.eAdd(prid,[p[5], p[6], p[7]]);
var disc=bsk.disc.get(prid),ranges=disc.rg.cnt(),qtyUnit=p[22];
var itm=bsk.createTemp(prid,tfc.document,tfc.opt,1,'','','','','',tfc.ppriceArr[0][2],'',false);
if (typeof(itm) != 'object' || !itm){
elPQD.innerHTML = '';
return;
}
for (var n=0;n<ranges;n++){
var range=disc.getNextRange(bskqnty), nmin=parseFloat(range.min);
if(nmin==0) continue;
if(typeof(range)=='object'){
if (disc.getData(nmin)) {
outstr+='<div class="ProductQuantityDiscountsRange" id="ProductQuantityDiscountsRange-'+prid+'R'+range.idtag+'">';
itm.quantity=nmin;
var 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>';
switch (disc.type.toString()) {
case '4': case '5':
var adprice=itm.calc('pur',null,0)/nmin;
var a=[nmin,qtyUnit,'<strong>'+core.showPrc(adprice)+'</strong>',qtyUnit];
outstr+=atagB;
outstr+=(tf.content.ld('LD_BUY_FOR','',a)).replace(/\s+\.$/, '.');
outstr+=atagE;
break;
case '2':
var a=[nmin,qtyUnit,disc.getData(nmin),qtyUnit];
outstr+=atagB;
outstr+=(bskqnty>0)?tf.content.ld('LD_BUY_MORE_AND_GET_FREE','',a):tf.content.ld('LD_BUY_AND_GET_FREE','',a);
outstr+=atagE;
break;
case '3':
var a=[nmin,qtyUnit,bsk.fbsk.getTitles(disc.getData(nmin))];
outstr+=atagB;
outstr+=(bskqnty>0)?tf.content.ld('LD_BUY_MORE_AND_GET_FREE','',a):tf.content.ld('LD_BUY_AND_GET_FREE','',a);
outstr+=atagE;
break;
}
outstr+='</div>';
}
bskqnty=parseFloat(range.min);
}
}
elPQD.innerHTML=outstr;
}
function sfMM(a){
var 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];
if(src.toLowerCase().lastIndexOf(t)==src.length-t.length){
if(typeof(isInLL)=='undefined'||!isInLL){src=tf.wm.url(src,'-');src=src.replace(/\\/g,'/');if(!tf.wm.online)src=src.replace(/^(file:\/\/)?(.*)$/,'file://$2');}
src=unescape(src); w=(w>0?w:mw); h=(h>0?h:mh);
var dim=' width="'+w+'" height="'+h+'"',s='';
switch(t){
case 'mp4': case 'webm':case 'ogg':
s+='<video controls><source src="'+src+'" type="audio/'+t+'"></video>';
break;
case 'mp3': case 'wav':case 'ogg':
s+='<audio controls><source src="'+src+'" type="audio/'+t+'"></audio>';
break;
case 'mov': case 'avi': case 'mpg':
s+='<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>';
break;
case 'wmv':
s+='<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>';
break;
case 'swf':
s+='<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>';
break;
default:
s+='<embed src="'+src+'" quality="high" '+dim+' title="'+alt+'"></embed>';
}
}
return s;
}
function 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);}}}}}
function rmvwmode(){
var d=tfc.document,a=d.embeds;
for(var i=0,ii=a.length;i<ii;i++){ if (a[i].id.indexOf('DSObject_') == 0)a[i].setAttribute('wmode','window'); }
var els = d.getElementsByTagName('object'),obj = [];
for(var i = 0; i < els.length; i++){ if (els[i].getElementsByTagName('param').length==0)continue; obj.push(els[i]); }
for(var i = 0; i < obj.length; i++){
var html = obj[i].outerHTML;
var wrapper = d.createElement('div');
obj[i].parentNode.appendChild(wrapper);
obj[i].parentNode.removeChild(obj[i]);
wrapper.innerHTML = html.replace(/<param name="wmode" value="[^"]*?"[^>]*?>/gi,'<param name="wmode" value="window" />');
}
}
function 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'); } }
function imgs(){sfMMDraw();if(tf.isInSF()&&navigator.userAgent.indexOf('Trident/6.0')!=-1)rmvwmode();else embwmode();}
function imgEntryPageFix(ss){if(tf.isEntryPage)ss=ss.replace(/\.\.\/media\//g,(tf.lang!=tf.baseLang?'../':'')+'contents/media/');return ss;}
function applyms(){
if(typeof(ms)=='function'&&(!tf.extra||tf.extra.loadInProgress<1)){
var aMS=tf.content.aMS;
if(aMS){
var cnt=aMS.length,a;
for(var n=0;n<cnt;n++){a=aMS[n];ms(a[0],a[1],a[2],a[3]);}
}
}
else{setTimeout('applyms()',100);}
}
var ms_rv,ms_lv,ms_dv,ms_uv,ms_oldn,ms_n,ms_sp=3,ms_sp2=20;
function 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);}
function 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);}
function 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);}
function 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);}
var ms_right=ms_rt,ms_left=ms_lt,ms_down=ms_dn;
function ms_stop(dir){clearTimeout(eval('ms_'+dir.substr(0,1)+'v'));}
function ms_set(oldn,n,sp,sp2){ms_oldn=oldn;ms_n=n;if(typeof(sp)!='undefined')ms_sp=sp;if(typeof(sp2)!='undefined')ms_sp2=sp2;}
function applyFlickityToIndex(idxNum){
var $idxSlider = $('#Index'+idxNum+' > .idx'+idxNum+'List');
$('> li', $idxSlider)
.each(function(){ $(this).outerHeight($(this).outerHeight()); })
.last().clone().appendTo($idxSlider).children().remove()
;
function setIdxSlider() {
$idxSlider.parent().width('100%').css('float','none');
$idxSlider
.on('cellSelect', function(){
var flkty = $(this).data('flickity');
if (flkty) {
if (flkty.selectedIndex == $(this).data('selectedIndex')) return;
if ($(this).data('translateX') == $('.flickity-slider', this).css('transform')) {
if (flkty.selectedIndex > $(this).data('selectedIndex')) flkty.selectedIndex = $(this).data('selectedIndex');
else if (flkty.selectedIndex < $(this).data('selectedIndex')) flkty.selectedIndex--;
}
$(this).data({'selectedIndex':flkty.selectedIndex, 'translateX':$('.flickity-slider', this).css('transform')});
}
})
.on('settle', function(){
var $last = $('.flickity-slider > li', this).last(), shifted = $('.flickity-slider', this).css('transform').match(/matrix\((.+)\)/) || $('.flickity-slider', this).css('transform').match(/matrix3d\((.+)\)/), shiftedpx = 0;
if (shifted && shifted.length > 1) shiftedpx = parseFloat((shifted[1].split(', ')[12]) || (shifted[1].split(', ')[4]));
if (parseFloat($last.css('left')) + $last.outerWidth(true) <= $('.flickity-slider', this).width() + Math.abs(shiftedpx)) $('.next', this).attr('disabled', 'disabled');
else $('.next', this).removeAttr('disabled');
})
.flickity({
cellAlign: 'left',
contain: true,
wrapAround: false,
autoPlay: false,
draggable: true,
freeScroll: true,
setGallerySize: false,
prevNextButtons: true,
pageDots: false,
percentPosition: false
})
.flickity('resize')
.find('.flickity-viewport')
.find('.flickity-slider').addClass('idx'+idxNum+'List')
.end()
.parentsUntil('[id^=WebSite]').each(function(){
var zIndex = $(this).css('z-index');
if (zIndex == 'auto' || parseInt(zIndex) <= 0) $(this).css('z-index', idxNum == 2 ? 1000 : 1001);
})
;
}
function unsetIdxSlider() {
if ($idxSlider.hasClass('flickity-enabled')) {
$idxSlider
.flickity('destroy')
;
}
$idxSlider.parent().css({'float':''});
}
$(window).on('resize', function () {
unsetIdxSlider(); $idxSlider.parent().css({'width':'', 'float':'none'});
if ($('#WebSite').width() > 619) {
var w = 0, wContainer = ($idxSlider.parent().outerWidth(true)||$idxSlider.outerWidth(true))+1;
$('> li, .flickity-slider > li', $idxSlider).each(function(){ w += $(this).outerWidth(true); $(this).css('height',''); if($(this).outerHeight()>0)$(this).outerHeight($(this).outerHeight()); });
if (w-1 > wContainer) {
setIdxSlider();
$idxSlider.flickity('resize');
setTimeout(function(){$idxSlider.flickity('reposition');}, 200);
}
else if (w < wContainer) unsetIdxSlider();
}
});
$(window).trigger('resize');
}
function searchload(url,force){
var tfcd=tfc.document;
if(tf.isMobile && $('.mobile').is(':visible')) {
tf.searchPhrase=(tf.searchPhrase||tfcd.mobile_search.phrase.value);
}
else {
if(tfcd.search.phrase)tf.searchPhrase=tfcd.search.phrase.value;
else{
for(var n=0;n<tfcd.search.length&&!tf.searchPhrase;n++)tf.searchPhrase=tfcd.search[n].phrase.value;
}
}
tf.searchPhrase=tf.searchPhrase.toLowerCase();
if (tf.searchPhrase==''&&!force) return;
var searchStringLength = $.trim(tf.searchPhrase).length;
if (searchStringLength > 0 && searchStringLength < 2){
alert (LD.LD_SEARCH_ENTER2CHARACTERS);
return false;
}
tf.nametag.add('searchPhrase',tf.searchPhrase);
if(encodeURIComponent)url+='?searchphrase='+encodeURIComponent(tf.searchPhrase);
else url+='?searchphrase='+window.encodeURI(tf.searchPhrase);
url+='&limitResultsPerPage=125';
tfc.location=tf.wm.url(url,'-');
}
function search(){searchload(tf.lang+'/search.html')}
function search_all(advanced)
{
if ( (tf.loc.hostname=='localhost' && tf.loc.port!='') || tf.loc.hostname=='')
{
alert(tf.LD.LD_PHPSEARCH_ONLY_WHEN_PUBLISHED);
}
else
{
tf.searchAdvanced=advanced;
if(typeof(tf.searchAdvanced)!='undefined')tf.nametag.add('searchAdvanced',tf.searchAdvanced);
searchload(tf.lang+'/search.html',false);
}
}
var varShowShippingChargesAfterAddToBasket={};
function showShippingChargesAfterAddToBasket(){
var prid=varShowShippingChargesAfterAddToBasket['prid'];
tf.content.sfAddPop('shipping_charge',true);
tf.content.sfAddRef['core']={};
tf.utils.sfMediaBox.fnAfterClose=function(){
if(tf.content['add_'+prid]){
varShowShippingChargesAfterAddToBasket['disponly']=true;
tf.content.sfAddPop();
tf.content['add_'+prid]();
}
else if(tf.pgid=='D-10'&&tf.content.add){ // Favorites page
varShowShippingChargesAfterAddToBasket['disponly']=true;
var itm=tf.core.Favorite.items.get(prid);
if(itm){
var idx=tf.core.Favorite.items.idx(itm.idtag);
tf.content.add(idx);
}
}
};
varShowShippingChargesAfterAddToBasket={};
}
function showPopup(url, width, height, useOverlay, showdecorations, delay, className, HTML){
function gl(s){try{return tf.extra.document.getElementById(s);}catch(e){return null;}}
var tfcd=tfc.document,tfcdb=(tf.isSafari?tfcd.documentElement:tfcd.body);
var w=width||640, h=height||480;
sfMediaBox.cacheW=w;sfMediaBox.cacheH=h;
showdecorations=typeof(showdecorations)=='undefined'||showdecorations;
delay=typeof(delay)!='undefined'&&delay;
sfMediaBox.fnAfterClose=null;
sfMediaBox.useOffsetTop=false;
var contents='';
if(url){
if(url.match(/^[#.]/)&&$(url).length>0){
contents=tmplParser.parse(gl('tmplSFLightBoxHTMLCode'),{'HTML':$(url).html()});
}
else{
contents=tmplParser.parse(gl('tmplSFLightBoxFrame'),
{
src:url,
height:showdecorations==true?'height="'+h+'px"':'100%',
onload:showdecorations==true?'tf.utils.sfMediaBox.centerBox();tf.utils.sfMediaBox.hide(\'sfLightBoxLoading\');return false;':''
});
}
}
else if(!url&&HTML){
contents=tmplParser.parse(gl('tmplSFLightBoxHTMLCode'),{'HTML':HTML});
}
var a=[
(useOverlay?tmplParser.parse(gl('tmplSFLightBoxOverlay'), { height:tfcdb.scrollHeight+'px', close_onclick:'return false;', className:className, contents:'' }):''),
tmplParser.parse(
gl('tmplSFLightBox'),
{
relprefix:(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../'),
captiondisplay:'none', navdisplay:'none', counterdisplay:'none',
loadingdisplay:(delay||(!url&&HTML)?'none':'block'), loadingmessage:(delay?'':tf.LD.LD_LOADING),
overflow:(delay?'auto':'hidden'),
cssborder:'border:1px #999999 solid;',
contents:contents,
close_onclick:tf.utils.sfMediaBox.close_onclick,
width:w+'px', height:h+'px',
position:'fixed',
marginleft:(-w/2+tfcdb.scrollLeft)+'px', margintop:(-h/2+tfcdb.scrollTop)+'px',
cssborder:showdecorations==true?'border:1px #999999 solid;':'border:1px #000000 solid;',
decorationborder:showdecorations==true?'5px':'0',
displaybottompart:showdecorations==true?'display:block;':'display:none;',
className:' '+className,
title:'',
description:'',
imagecontrols:''
}
)
];
sfMediaBox.showDropDowns(false);
for(var n=0,nn=a.length;n<nn;n++){
sfMediaBox.render(sfMediaBox,a[n]);
}
sfMediaBox.centerBox();
tf.addEvent('onresize',sfMediaBox.centerBox);
if(delay){
sfMediaBox.hide('sfLightBox');
sfMediaBox.hide('sfLightBoxOverlay');
}
tfc.document.body.style.overflow='hidden';
}
var dlgModal={
win:null,
w:-1,h:-1,
fnClose:function(){},
init:function(url,name,options,width,height,fnCreate,fnClose,fnComplete){
options=options||('scrollbars,resizable,width='+width+',height='+height);
this.win=(tf.external&&tf.external.IsInSF?null:window.open(url,name,options));
if(this.win){
this.w=width;
this.h=height;
sfMediaBox.render(sfMediaBox,
tmplParser.parse(tf.extra.document.getElementById('tmplSFLightBoxOverlay'),{
height:tfc.document.body.scrollHeight+'px',
close_onclick:'',
className:'',
contents:tmplParser.parse(tf.extra.document.getElementById('tmplSFPurchaseOverlayContents'),{})
})
);
var me=this;
$('#sfLightBoxOverlay')
.focus()
.on('click focus',function(){
setTimeout(function(){me.win.focus();}, 200);
me.win.focus();
}
);
tf.$(window)
.on('focus',function(){
$('#sfLightBoxOverlay').focus().click();
}
);
if(fnClose)this.fnClose=fnClose;
function close(){
clearInterval(interval);
if(fnClose)fnClose();
}
this.win.focus();
tf.$(window).on('beforeunload',function(){me.win.close();});
if(fnCreate)fnCreate();
var leftDomain=false;
var interval=window.setInterval(function(){
try {
if(me.win==null||me.win.closed){ close(); }
else if(me.win.document.domain===document.domain){
if(leftDomain){
if(fnComplete)fnComplete();
close();
}
}
else leftDomain=true;
}
catch(e){
if(me.win.closed){ close(); return; }
leftDomain=true;
}
},500);
}
return this.win;
},
center:function(){
if(!this.win||this.win.closed)return;
var l=Math.max((this.win.opener.outerWidth-this.w)/2,0)+this.win.opener.screenLeft,
t=Math.max((this.win.opener.outerHeight-this.h)/2,0);
this.win.moveTo(l,t);
}
};
var equalDivPoll=[];
var equaldiv = function (c) {
if(!c)c='EqualHeight';
clearTimeout(equalDivPoll[c]);
equalDivPoll[c] = setTimeout(function(){
equaldivCall(c);
equalDivPoll[c] = null;
}, 500);
};
function equaldivCall(c) {
var tfcd=tfc.document,coll=[],t=tfcd.querySelectorAll('.'+c);
for (var x = 0, cnt=t.length; x<cnt; x++) {
if (t[x].scrollHeight > 0) {
t[x].style.height='auto';
coll.push(t[x]);
}
}
if(coll.length>0){
equaldivWorker(coll);
}
}
function equaldivWorker(coll) {
var maxh=0;
if(typeof(tf.content.fnEqualDivGetHeight)=='function'){
for (x=0,cnt=coll.length; x<cnt; x++) {
maxh = Math.max(maxh, tf.content.fnEqualDivGetHeight(coll[x]));
}
}
else {
for (x=0,cnt=coll.length; x<cnt; x++) {
maxh = Math.max(maxh, $(coll[x]).outerHeight());
}
}
for (x=0,cnt=coll.length; x<cnt; x++) {
$(coll[x]).outerHeight(maxh);
}
}
var cookieWarning = {
_loadOptInOut:function(){
var $=tfc.$;
function handleData($o, data){
var js='',HTML=data.replace(/(<scr\ipt[^>]*>)((?:[\n\r]|.)*?)(<\/scr\ipt>)/gim,
function($0, $1, $2, $3){js+=$2;return $1+''+$3;}
);
$o.empty().html(HTML);
eval(js);
$(window).trigger('cookieOptInApprovedLoaded.cookiewarning');
}
if($('#optinout_dept').length>0&&tf.pgid){
$.get(tf.wm.url(pgid.toLowerCase()+'_optinout.html',lmd['optinout'],true), function(data){
handleData($('#optinout_dept'),data);
});
}
},
_optInApproved:function(){
var $=tfc.$;
tf.nametag.add('cookieOptInApproved',true);
tf.savCookStr('cookieOptInApproved',true,-1);
$(function () {
tf.cookieWarning['_loadOptInOut']();
});
},
_optOut:function(){
var $=tfc.$;
tf.nametag.del('cookieOptInApproved');
tf.delCookStr('cookieOptInApproved');
$('[name=optinout]').empty();
$('#optinout_dept').empty();
},
_render:function(a,show){
var el=tfcd.createElement('div'),html=(typeof(a)=='function'?a(o):a);
if(show){if(tf.isEntryPage)html=html.replace(/\.\.\/media\//g,(tf.lang!=tf.baseLang?'../':'')+'contents/media/');}
el.innerHTML=html;
for(var i=0,num=el.childNodes.length;i<num;i++){
var elNew=el.childNodes[i];
if(elNew){
if (elNew.nodeType!=3&&tfc.gl(elNew.id)){
tfcd.body.removeChild(tfc.gl(elNew.id));
}
if(show&&elNew.nodeType!=3)elNew=tfcd.body.appendChild(elNew);
}
}
},
show:function(){
if (!tf.extra || !tf.extra.document.getElementById('tmplSFCookieWarningBar')){setTimeout(cookieWarning['show'],100);return;}
if (tf.getCookStr('showCookieWarning')=='false') {
if (tf.getCookStr('cookieOptInApproved')=='true') tf.cookieWarning['_optInApproved']();
return;
}
var langvalues={'fr':['Ce site utilise des cookies pour garantir une expérience sur mesure aux visiteurs.','privacy.html#cookiePrivacy','En savoir plus','Accepter','Désactiver']};
var a=[tmplParser.parse(tf.extra.document.getElementById('tmplSFCookieWarningBar'),
{
warningtext:langvalues[tf.lang][0], privacyhref:(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../')+tf.lang+'/'+langvalues[tf.lang][1], privacypagetitle:langvalues[tf.lang][2], 'LD_ACCEPT':langvalues[tf.lang][3], 'LD_OPTOUT':langvalues[tf.lang][4]
})];
for(var n=0,nn=a.length;n<nn;n++){ cookieWarning._render(a[n],true); }
var $=tfc.$;
$('#sfCookieWarningBar .Close, #sfCookieWarningBar .OptOut').off('click.cookiewarning').on('click.cookiewarning', function(e){
e.stopPropagation();
e.preventDefault();
tf.cookieWarning['_optOut']();
tf.cookieWarning.close();
})
;
$('#sfCookieWarningBar .OK').off('click.cookiewarning').on('click.cookiewarning', function(e){
e.stopPropagation();
e.preventDefault();
tf.cookieWarning['_optInApproved']();
tf.cookieWarning.close();
})
;
$(window).off('resize.cookiewarning').on('resize.cookiewarning', function(e){
if($('.footer.mobile:visible').get(0))$('#sfCookieWarningBar').css('bottom',$('.footer.mobile').height()+'px');
});
},
close:function(){
tf.nametag.add('showCookieWarning',false);
tf.savCookStr('showCookieWarning',false, -1);
var a=[tmplParser.parse(tf.extra.document.getElementById('tmplSFCookieWarningBar'), {})];
for(var n=0,nn=a.length;n<nn;n++){ cookieWarning._render(a[n],false); }
}
}
if(!tf.isInSF()){
$(function () { tf.cookieWarning['show'](); });
}
var sfIFramer = {
iframeHandler: null,
fnReceive:null,
msgHandlers:{},
pingQualifier:'',
iframeInit: function(name,fnReceive,initNotifyData){
sfIFramer.iframeHandler = gl(name);
if (sfIFramer.iframeHandler) {
if(fnReceive)sfIFramer.fnReceive=fnReceive;
tf.addEvent("onmessage", sfIFramer.embedReceiveMessage);
tf.addEvent("onresize", sfIFramer.embedNotifyResize);
sfIFramer.embedPing();
if(initNotifyData)sfIFramer.sendInitNotifyData(initNotifyData);
}
},
embedReceiveMessage: function (e) {
e = e || window.event();
if (e.data.indexOf && e.data.indexOf('santuiframe') == 0) {
var dt = e.data.split('|');
if (!dt[1] || dt[1].indexOf('h') == -1) return;
var dth = dt[1].split('='),height=dth[1];
if(sfIFramer.iframeHandler&&(sfIFramer.iframeHandler.height!=height||sfIFramer.iframeHandler.getAttribute('origheightattribute')!=height)){
if(sfIFramer.iframeHandler.style.height)sfIFramer.iframeHandler.style.height='';
sfIFramer.iframeHandler.height = height;
if(sfIFramer.iframeHandler.getAttribute('height')!=sfIFramer.iframeHandler.getAttribute('origheightattribute'))sfIFramer.iframeHandler.setAttribute('origheightattribute',height);
tf.content.equalHeight();
if($) {$(tf.content.document).trigger('domChanged');}
gl('WebSiteContent').style.height='auto';
gl('WebSite').style.height='auto';
var tfc=tf.content.document;
tfc.body.style.height='auto';
tfc.documentElement.style.height='auto';
tfc.body.style.overflowY='auto';
tfc.documentElement.style.overflowY='auto';
if (tf.isMobile) setTimeout(function(){sfIFramer.iframeHandler.height = height;},1000);
if(sfIFramer.fnReceive)sfIFramer.fnReceive();
}
sfIFramer.pingQualifier='?lmd='+Math.random();
}
if (e.data.split) {
var edata = e.data.split('|'), emsg = edata[0], emsgdata = edata[1] || '';
if (sfIFramer.msgHandlers[emsg]) sfIFramer.msgHandlers[emsg](emsgdata);
}
},
embedNotifyResize: function () {
if (sfIFramer.iframeHandler)sfIFramer.iframeHandler.contentWindow.postMessage('resize', sfIFramer.iframeHandler.domain||sfIFramer.iframeHandler.src);
},
embedPing: function () {
setInterval(function () {
if (sfIFramer.iframeHandler && sfIFramer.iframeHandler.src.indexOf('http')==0)
sfIFramer.iframeHandler.contentWindow.postMessage('ping|' + document.location.href+sfIFramer.pingQualifier, sfIFramer.iframeHandler.domain||sfIFramer.iframeHandler.src);
}, 200);
},
sendInitNotifyData: function (data) {
setInterval(function () {
if (sfIFramer.iframeHandler && sfIFramer.iframeHandler.src.indexOf('http')==0)
sfIFramer.iframeHandler.contentWindow.postMessage(data, sfIFramer.iframeHandler.domain||sfIFramer.iframeHandler.src);
}, 800);
},
addMsgHandler: function(msg, fn) {
this.msgHandlers[msg] = fn;
}
};
tf.addEvent('onload',
function(){
try {
var aIfr = tf.content.document.getElementsByTagName('IFRAME');
for (var n = 0; n < aIfr.length; n++) {
if (aIfr[n].src && aIfr[n].src.indexOf('santu.com') != -1) tf.utils.sfIFramer.iframeInit(aIfr[n].id);
}
}
catch(e){}
}, tf.content
);
if (!tf.isInSF() && tf !== window.top) { // Iframe!
var iframeholderdomain= false;
var iframeresize = function () {
if (iframeholderdomain) {
tf.parent.postMessage("santuiframe|h=" + $('html').height() + "|w=" + $('html').width(), iframeholderdomain);
}
};
var receiveMessage = function (event) {
if (event.data && event.data=='resize') {
iframeresize();
}
if (event.data && event.data.indexOf) {
if(event.data.indexOf('ping|')==0) {
var iframeholderdomain2 = event.data.substr(5,512);
if(iframeholderdomain!= iframeholderdomain2){
iframeholderdomain = iframeholderdomain2;
setTimeout(iframeresize,1000);
}
}
if (event.data.indexOf('getheight=') == 0) {
$('html').css('height','auto');
var domain = event.data.substr(10, 512);
tf.parent.postMessage("santuheight=" + $('html').height(), domain);
}
}
};
tf.addEventListener ? tf.addEventListener("message", receiveMessage, false) : tf.attachEvent("onmessage", receiveMessage);
}
if(!tf.isInSF() && $){
$(document).ready(function(){
if(tf.content.pgid && tf.content.pgid.indexOf('P')==0&&!tf.isTablet&&!tf.isMobile){
$('.ProductImage a img:not(.pici)')
.wrap('<span style="display:inline-block"></span>')
.css('display', 'block')
.parent()
.on('imageLoaded', function(e){
$(this).zoom({
duration:250,
callback:function(){$(this).attr('title',$(this).parent().find('img:first').attr('title'));},
onZoomIn:function(){$(this).prev('img').stop().animate({'opacity':'0'},'fast');},
onZoomOut:function(){$(this).siblings('img').stop().animate({'opacity':'1'},'fast');$(this).siblings('img.zoomImg').remove();}
});
})
;
$('a.ThumbnailSliderItem[onclick]')
.click(function(){
function waitForRealImage(el){
if($(el).attr('src')&&$(el).attr('src').indexOf('media/progress')==-1&&$(el).attr('src')!=$(el).next('.zoomImg').attr('src')){
$(el).trigger('zoom.destroy').parent().zoom();
}
else{
setTimeout(function(){waitForRealImage(el);},250);
}
}
waitForRealImage($(this).parents('.ProductImageContainer').find('.ProductImage a img').get(0));
})
;
}
});
}
if ($) {
$(document).ready(function(){
if(!tf.isInSF()) {
$('#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>');
} else {
while($('div.sf-scrollbar-table > table').length > 0) {
$('div.sf-scrollbar-table > table').unwrap();
}
}
});
}
var layoutModer = {
_modeNone:0,
_modeDesktop:1,
_modeMobile:2,
switchTo: function(mode) {
var oSS = $('#global-responsive-css');
if (oSS) {
var $mainContentArea=tfc.$('#SideBar_L').next('[class*=content], #Content');
switch (mode) {
case this._modeNone:
case this._modeDesktop:
oSS.attr('disabled', true);
if (parseFloat($mainContentArea.css('min-width')) != 0) $mainContentArea.width($mainContentArea.css('min-width'));
tf.nametag.add('layoutMode', this._modeDesktop);
if(tf.content.makeResponsive)tf.content.makeResponsive();
break;
case this._modeMobile:
oSS.attr('disabled', false);
$mainContentArea.width('');
tf.nametag.add('layoutMode', this._modeMobile);
break;
}
if (tf.content.equalHeight) setTimeout(tf.content.equalHeight);
}
},
init: function() {
$('#mobile_switchview a.mobile-xor, #util_switchview a.mobile-xor').click(function(){
tf.utils.layoutModer.switchTo(tf.utils.layoutModer._modeDesktop);
return false;
});
$('#mobile_switchview a.desktop-xor, #util_switchview a.desktop-xor').click(function(){
tf.utils.layoutModer.switchTo(tf.utils.layoutModer._modeMobile);
return false;
});
var mode = parseInt(tf.nametag.get('layoutMode'))||parseInt('2');
tf.nametag.add('layoutMode', mode);
this.switchTo(mode);
}
}
if ($) {
$(document).ready(function () {
if (!$.support.placeholder) {
$('[placeholder]')
.focus(function () { if ($(this).val() == $(this).attr('placeholder')) $(this).val(''); })
.blur(function () { if ($(this).val() == '') $(this).val($(this).attr('placeholder')); })
.blur();
$('[placeholder]').parents('form').submit(function () {
$(this).find('[placeholder]').each(function() {
if ($(this).val() == $(this).attr("placeholder")) {
$(this).val('');
}
});
});
}
var makeResponsivPoll=0;
tf.content.makeResponsiveCall = function(){
$('img:not([src=""])').each(function(){
var img = $(this);
if(this.getAttribute('data-echo')) return;
img.toggleClass('responsive',false);
if(img.parents('.sf-scrollbar-table, .no-responsive, .ThumbnailSlider, .ProductIcons').length > 0 || img.hasClass('zoomImg')) return;
if(img.parents('#Content').length == 0 || $(this.offsetParent).parents('#Content').length == 0) return;
var w = img.width(), h = img.height();
if (typeof(img.data('origwidth')) == 'undefined') {
img.data('origwidth', w);
img.data('origheight', h);
}
var w=img.data('origwidth')||w;
if(w!=0){
var $offsetParent=$(this.offsetParent);
if($offsetParent.hasClass('ProductImage')){
if($offsetParent.css('display').indexOf('inline')!=-1){
$offsetParent.css('display','block');
img.css({'margin-left':'auto','margin-right':'auto'});
}
if(w >= $offsetParent.width()) img.toggleClass('responsive',true);
}
else{
if(w > $offsetParent.width()) img.toggleClass('responsive',true);
}
}
});
if (tf.content.equalHeight) tf.content.equalHeight();
if($) {$(tf.content.document).trigger('domChanged');}
}
tf.content.makeResponsive = function(){
clearTimeout(makeResponsivPoll);
makeResponsivPoll = setTimeout(function(){
tf.content.makeResponsiveCall();
makeResponsivPoll = null;
}, 500);
}
$(tf.content.window).resize(tf.content.makeResponsive);
tf.content.makeResponsive();
layoutModer.init();
$('.SwitchCurrencyLink').attr('href', tf.wm.url('changecurrency.html',null,true));
$('.SwitchLangLink').on('click', function(e){
e.preventDefault();
tf.utils.change_lang($(this).data('langparm'));
});
if($('#Search #phrase ~ [class*=cross-icon]').length==0)$('#Search #phrase').after('<span class="cross-icon-1234" title="LD_CANCEL"><i class="icon-cross"></i></span>');
$('.SearchButton').each(function(){
if ($(this).attr('href') == '#') {
if ($(this).hasClass('SearchButtonAdvanced')) $(this).on('click', function(){tf.utils.search_all(1); });
else $(this).on('click', function(e){
e.stopPropagation();
e.preventDefault();
tf.utils.search_all();
});
}
});
$('.SearchTextField').parents('form').on('submit', function(e){
e.preventDefault();
tf.utils.search_all();
});
$(document).on('click', '[class^=cross-icon-123]', function (e) {
e.stopPropagation();
$(this).parent().children('input').val('').focus();
});
});
}
/* net.js begin */
var net={};
net.READY_STATE_UNINITIALIZED=0;
net.READY_STATE_LOADING=1;
net.READY_STATE_LOADED=2;
net.READY_STATE_INTERACTIVE=3;
net.READY_STATE_COMPLETE=4;
net.ContentLoader=function(url,onload,onerror,onupdate,method,params,contentType){
this.req=null;
this.onload=onload;
this.onerror=(onerror?onerror:this.defaultError);
this.onupdate=onupdate;
this.loadXMLDoc(url,method,params,contentType);
}
net.ContentLoader.prototype.loadXMLDoc=function(url,method,params,contentType){
if(!method){method="GET";}
if(!contentType&&method=="POST"){contentType='application/x-www-form-urlencoded; charset=utf-8;';}
if(!tf.isInSF()&&window.XMLHttpRequest&&(!isIE||url.indexOf('file:')==-1)){this.req=new XMLHttpRequest();}
else if(window.ActiveXObject){
try{this.req=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){this.req=null;}
}
if(this.req){
try{
var loader=this;
this.req.onreadystatechange=function(){net.ContentLoader.onReadyState.call(loader);}
this.req.open(method,url,true);
if(contentType){this.req.setRequestHeader('Content-Type', contentType);}
this.req.send(params);
}
catch(err){this.onerror.call(this);}
}
}
net.ContentLoader.onReadyState=function(){
var req=this.req,ready=req.readyState;
if(ready==net.READY_STATE_COMPLETE){
var httpStatus=req.status;
if(httpStatus==200||httpStatus==0){this.onload.call(this);}
else{this.onerror.call(this);}
}
}
net.ContentLoader.prototype.defaultError=function(){
alert("error fetching data!"+"\n\nreadyState:"+this.req.readyState
+"\nstatus: "+this.req.status+"\nheaders: "+this.req.getAllResponseHeaders());
}
net.cmdQueues=[];
net.CommandQueue=function(id,url,data,freq,immediate,onLoad,onError,onUpdate){
this.id=id;
this.url=url;
this.data=data;
this.onLoad=(onLoad?onLoad:net.CommandQueue.onload);
this.onError=(onError?onError:net.CommandQueue.onerror);
this.onUpdate=(onUpdate?onUpdate:net.CommandQueue.onupdate);
this.lastUpdateTime=0;
if(immediate)this.fireRequest();
if(freq)this.repeat(freq);
net.cmdQueues[id]=this;
}
net.CommandQueue.prototype.fireRequest=function(){
if(!this.onUpdate){return;}
this.loader=new net.ContentLoader(this.url,this.onLoad,this.onError,this.onUpdate,"POST",this.data);
}
net.CommandQueue.onload=function(loader){
var jsonText=this.req.responseText;
var o=tf.sfJSON.parse(jsonText);
if(o){this.onupdate.call(this,o);}
}
net.CommandQueue.prototype.repeat=function(freq){
this.unrepeat();
if (freq>0){
this.freq=freq;
var cmd="net.cmdQueues['"+this.id+"'].fireRequest()";
this.repeater=setInterval(cmd,freq*1000);
}
}
net.CommandQueue.prototype.unrepeat=function(){
if (this.repeater){clearInterval(this.repeater);}
this.repeater=null;
}
/* net.js end */
var navRO=tf.navRO,navOvr=tf.navOvr,navOut=tf.navOut,navClk=tf.navClk;
if(typeof(SymRealWinOpen)!='undefined')window.open=SymRealWinOpen;
if(window.NS_ActualOpen){window.open=NS_ActualOpen;}
var str_sep1='~|`';
var shopName='www.cerfvolantservice.com',shopRegion='FR';
var confLoaded=false;
var region='',regionChanged=false,method='',pmKey='--';
function getCoreProperties(){
return {'active_servers':active_servers,'region':region,'regionChanged':regionChanged,'method':method,'ResellerID':ResellerID,'gmtTime':gmtTime,'reseller':reseller,'pmKey':pmKey};
}
function setCoreProperties(arr){
for(var s in arr){
if(s=='reseller'){tf.merge(reseller,arr[s]);}
else this[s]=arr[s];
}
}
function 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('%%','');}
var d=document;function dw(s){d.write(s);}function gl(s){return d.getElementById(s);}
function isInSFClassic(){try{if(window.external&&typeof(window.external.isInSF)=='number')return window.external.isInSF();else return false;}catch(e){return false;}}
function isInSFull(){try{if(window.external&&typeof(window.external.isFullViewEdit)=='number')return window.external.isFullViewEdit();else return false;}catch(e){return false;}}
function isInSF(){return isInSFClassic()||isInSFull();}
function isInDesigner(){try{return typeof(tf.parent.applyColorScheme)!='undefined';}catch(e){return false;}}
function dw(s){document.write(s);}
var active_servers=[],gmtTime=0;
var ping={
timer1:null,
timer2:null,
timer3:[],
poll:function(){
if(typeof(country_code)=='undefined'){ping.timer1=setTimeout("ping.poll()",100);return;}
if(active_servers.length>0){for(var tt in ping.timer3){clearTimeout(ping.timer3[tt]);}ping.timer3=[];}
clearTimeout(ping.timer2);ping.timer2=null;clearTimeout(ping.timer1);ping.timer1=null;
if(country_code!=''&&country_code!='A1'&&country_code!='A2'&&shopRegion.indexOf(country_code)!=0){region=country_code;regionChanged=true;}
else region=shopRegion;
tf.nametag.add('coreProperties',tf.sfJSON.stringify(getCoreProperties()));
if(tf.utils&&tf.core&&tf.bskLoaded){
if(tf.utils.populatePrice)tf.utils.populatePrice();
if(tf.utils.populateOpt)tf.utils.populateOpt();
}
},
failed:function(){
if(ping.timer2){
clearTimeout(ping.timer1);
if(ping.timer3.length==0)ping.go(true);
if(!region){
region=shopRegion;
if(tf.utils&&tf.core&&tf.bskLoaded){
if(tf.utils.populatePrice)tf.utils.populatePrice();
if(tf.utils.populateOpt)tf.utils.populateOpt();
}
}
}
},
go:function(all){
if(active_servers.length>0)return;
function id(n){return'ping'+servers[n].replace(/[^a-zA-Z0-9]/g,'');}
function 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']:'');}
var i=0,servers='//timecheck.shopfactory.com/ping/v7ping.js'.split(','),fake_country=(tf.parm&&tf.parm['fake_country'])?'?c='+tf.parm['fake_country']+'&':'?';
scr.load(id(i),url(i));
if(all){
for(i=1;i<servers.length;i++){
ping.timer3.push(setTimeout("scr.load('"+id(i)+"','"+url(i)+"')",1000*i));
}
}
else ping.timer2=setTimeout('ping.failed()',5000);
ping.poll();
}
};
if(!isInSF() && tf.nametag){
setCoreProperties(tf.sfJSON.parse(tf.nametag.get('coreProperties')));ping.go(false);
}
else{country_code=region=shopRegion;} // We don't ping if in SF, so we need to initialise country_code
if(tf.wm){
tf.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;}
tf.wm.pProp=function(id,prop){if(this._pArr==null)this._pArr=[];if(prop!=null)this._pArr[id]=prop;return this._pArr[id];}
tf.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]}
tf.wm.pPropMin=function(id,val){return this.pPropStk(id,2,val);}
tf.wm.pPropMax=function(id,val){return this.pPropStk(id,3,val);}
tf.wm.pPropQty=function(id,val){return this.pPropStk(id,4,val);}
}
var lang=tf.lang?tf.lang:'fr';
function regionalSettingsObj(rulesList) {
this.defDecimal='.';
this.defThousand=',';
this.defPosition=0;
this.regions=[];
this.region=function(dec,thous,pos) {
this.decimal=dec;
this.thousand=thous;
this.position=pos;
}
for (var i in rulesList) {
switch (rulesList[i].length) {
case 1: this.regions[rulesList[i][0]]=new this.region(this.defDecimal,this.defThousand,this.defPosition);break;
case 3: this.regions[rulesList[i][0]]=new this.region(rulesList[i][1],rulesList[i][2],this.defPosition);break;
case 4: this.regions[rulesList[i][0]]=new this.region(rulesList[i][1],rulesList[i][2],rulesList[i][3]);break;
}
}
this.getCurrentSettings=function() {
return this.getSettings(navigator.language?navigator.language.toLowerCase():navigator.userLanguage.toLowerCase());
}
this.getSettings=function(lang)  {
if(lang&&this.regions[lang])return this.regions[lang];
else if (lang&&lang.length>2&&this.regions[lang.substr(0,2)])return this.regions[lang.substr(0,2)];
else return this.defRegion;
}
this.getMerchantSettings=function() {
return this.getSettings('fr');
}
this.defRegion=new this.region(this.defDecimal,this.defThousand,this.defPosition);
}
var regionalSettings=new regionalSettingsObj([["af",".",",",2],["ar",".",",",2],
["az",",","",3],["be",",","",3],["bg",",","",3],["ca",",",".",3],["cs",",","",3],
["da",",",".",2],["de",",",".",3],["de-at",",",".",2],["de-ch",".","'",2],
["de-li",".","'",2],["de-lu",",",".",3],["div",".",",",3],["el",",",".",3],
["en"],["es",",",".",3],["es-ar",",",".",2],["es-bo",",",".",2],["es-cl",",",".",2],
["es-co",",",".",2],["es-cr",",",".",0],["es-do"],["es-ec",",",".",2],
["es-es",",",".",3],["es-gt"],["es-hn",".",",",2],["es-mx"],["es-ni",".",",",2],
["es-pa",".",",",2],["es-pe",".",",",2],["es-pr",".",",",2],["es-py",",",".",2],
["es-sv"],["es-uy",",",".",2],["es-ve",",",".",2],["et",".","",3],["eu",",",".",3],
["fa","/",",",2],["fi",",","",3],["fo",",",".",2],["fr",",","",3],["fr-be",",",".",3],
["fr-ca",",","",3],["fr-ch",".","'",2],["fr-lu",",","",3],["fr-mc",",","",3],
["gl",",",".",2],["gu",".",",",2],["he",".",",",2],["hi",".",",",2],
["hr",",",".",3],["hu",",","",3],["hy",".",",",3],["id",",",".",0],
["is",",",".",3],["it",",",".",2],["it-ch",".","'",2],["ja"],["ka",",","",3],
["kk","-","",0],["kn",".",",",2],["ko"],["kok",".",",",2],["ky","-","",3],
["lt",",",".",3],["lv",",","",2],["mk",",",".",3],["mn",",","",1],
["mr",".",",",2],["ms",",",".",0],["ms-bn",",",".",0],["nb",",","",2],
["nl",",",".",2],["nl-be",",",".",3],["nn-no",",","",2],["pa",".",",",2],
["pl",",","",3],["pt",",",".",0],["pt-pt",",",".",3],["ro",",",".",3],
["ru",",","",1],["sa",".",",",2],["sk",",","",3],["sl",",",".",3],
["sq",",",".",1],["sr",",",".",3],["sv",",",".",3],["sv-fi",",","",3],
["sw"],["syr",".",",",2],["ta",".",",",2],["te",".",",",2],["th"],
["tr",",",".",3],["tt",",","",3],["uk",",","",3],["ur"],["uz",",","",3],
["vi",",",".",3],["zh"]]);
function def(str) {return (str==null)?'':str;}
function ckCodeStr(obj, order, sep, str)
{
if (str==null) str = '';
function delim(i, s) {return (i==0)?'':s}
var cstr = [];
var arr  = str.split(sep);
var len  = arr.length;
for (var i=0,ii=order.length; i<ii; i++){
var val='';
if(typeof(arr[i])=='string'){
if(len>1){
val=unescape(arr[i]);
val=val.replace(/\\"/g,'"').replace(/&#44;/g,',').replace(/&#45;/g,'-');
}
else val=arr[i].replace(/"/g,'\\"').replace(/,/g,'&#44;').replace(/-/g,'&#45;');
}
else{arr[i];}
if(val=='false'||val=='true')val=eval(val);
else {
if (typeof(val)=='string')val=val.replace(/[\n\r]/g,' ').replace(/"/g,'\\"');
val = (isNaN(val)||val=='')?'"'+val+'"':parseFloat(val);
}
val	= (len>1)?'='+val:'';
val = eval('obj.'+order[i]+val);
val = (val == 'undefined'||typeof(val)=='undefined'?'':val);
cstr.push(delim(i,sep) + def(len>1?val:escape(val)));
}
if (typeof(obj.xcode)=='function') cstr.push(sep + obj.xcode((str!='')?arr[i]:''));
return cstr.join('');
}
var sym = new Array();
sym['yen']   = '%A5';
sym['pound'] = '%A3';
function entities(s)
{
var i=s.indexOf('&');
if (i==-1) return s;
var j=s.indexOf(';', i);
var s1=s.substring(0,i);
var s2=unescape(sym[s.substring(i+1,j)]);
var s3=entities(s.substring(j+1,s.length));
return s1+s2+s3;
}
function dCurr(val, raw, c1, c2)
{
if (isNaN(val)) return val;
var scurr='';
if (c1==null) return nfmt.display(val);
if (c2!=null) {
var val2 = val*(c2.multiplier/tf.shopCurrency.multiplier);
if (!raw) scurr = nfmt.display(val2, c2.decimal_places,entities(c2.abbrev));
scurr='<span class="SecondaryCurrencyAmount">(~'+scurr+')</span> ';
}
if (!raw) val = nfmt.display(val*(c1.multiplier/tf.shopCurrency.multiplier), c1.decimal_places,c1.abbrev);
return (scurr?scurr+'<span>'+val+'</span>':val);
}
function dispCurr(val, c1, c2) {return dCurr(val, 0, c1, c2);}
function showPrc(val, type) {
if (type||!tf.secondCurrency) return dCurr(val, 0, tf.currentCurrency);
return dCurr(val, 0, tf.currentCurrency, tf.secondCurrency);
}
function showItemCountInBasketIndicator(){
if (!LD||!tf.content||!tf.utils||!tf.core||!tf.core.Basket) {setTimeout(showItemCountInBasketIndicator, 100);return;}
var tfc=tf.content;
if (tf.core.Basket.items.cnt()>0&&tfc.ppriceArr&&tfc.ppriceArr.length>0) {
if(tf.conf&&tf.conf.greySettings)tf.conf.greySettings();else return;
if(confLoaded){
var oCachePPriceArr={},oBskItm={};
for (var i=0,ii=tfc.ppriceArr.length;i<ii;i++){
oCachePPriceArr[tfc.ppriceArr[i][0]]=tfc.ppriceArr[i];
}
for (var i=0,ii=tfc.ppriceCrossPromotionArr.length;i<ii;i++){
oCachePPriceArr[tfc.ppriceCrossPromotionArr[i][0]]=tfc.ppriceCrossPromotionArr[i];
}
var bsk=tf.core.Basket,itm=bsk.items.start(),idLast='';
while (itm!=null) {
if (oCachePPriceArr[itm.id]) {
if (oBskItm[itm.id]) oBskItm[itm.id] += itm.quantity;
else oBskItm[itm.id] = itm.quantity;
idLast = itm.id;
}
itm=bsk.items.next();
}
var vars={
txtItems:LD.LD_ITEMS,
txtCheckout:LD.LD_MYBASKET
};
for (var prid in oBskItm) {
vars['prid'] = prid;
vars['itemcount'] = oBskItm[prid];
vars['relprefix'] = (tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/'+tf.lang+'/':'');
var html = tf.utils.tmplParser.parse('tmplSFItemCountInBasket', vars);
var el = tfc.gl('sfItemCountInBasket-'+prid);
if (el) el = el.parentNode;
else {
el = tfc.gl('ProductIcons-'+prid);
if (el) {
var elNew = tfc.document.createElement(el.nodeName);
elNew.className = 'ProductIcons ItemCountInBasket';
el = el.parentNode.insertBefore(elNew, el);
}
}
if (el) {
if (prid == idLast && typeof(tfc.jQuery) != 'undefined') {
var elThis = el;
(function(){
tfc.$(elThis).slideUp(250, function(){tfc.$(elThis).slideDown(250, function(){if(tf.equalHeight)tf.equalHeight();});});
})();
}
el.innerHTML = html;
}
var elATB = tfc.gl('AddToBasketButton-'+prid);
if (elATB) {
var spans = elATB.getElementsByTagName('span');
if (spans && spans.length > 0) {
for (var n = 0; n < spans.length; n++) {
if (spans[n].className == 'ImgLink') {
var sIcon = '', oNodes = spans[n].childNodes;
if (oNodes && oNodes.length > 0) {
for (var i = 0; i < oNodes.length; i++) {
if (oNodes[i].className&&oNodes[i].className.indexOf('icon-') != -1) {
sIcon = oNodes[i].outerHTML;
break;
}
}
}
spans[n].innerHTML = sIcon + '<span>' + LD.LD_ADD_MORE + '</span>';
break;
}
}
}
}
}
if(tf.equalHeight)tf.equalHeight();
if(tf.isInDesigner()){tf.parent.applyColorScheme(tf);}
}
}
}
var rl_total=debounce(function() {
var tfcd=tf.content.document;
if(tf.shipping&&tf.utils&&tfcd){
if(tfcd.getElementById('MiniCartTotal'))Basket.refreshTotal();
showItemCountInBasketIndicator();
}
else setTimeout(rl_total,100);
}, 1000);
rl_total();
function createMap(arr) {
var ret=[];
for (var i in arr) ret[arr[i]]=1;
return ret;
}
var reseller = {'frship':false,'frship_am':0,'ismember':false};
function updateReseller(prdc,values,type){
if (Basket&&Basket.gdisc) {
for (var i=0; i<prdc.length; i++) {
Basket.gdisc.eAdd(prdc[i], new Array(type,values[i],''))
}}}
var ResellerID='';
var ResellerPasswd='';
function smart_unescape(s) {
try {
return unescape(s);
} catch (e) { return s;}
}
function smart_escape(s) {
if(window.encodeURI) return encodeURI(s);
else return escape(s)
}
var startS=0;
var startR=0;
function getStyleClass(className,d){
var ss;
try{
if(d.all){
for(var s=startS; s<d.styleSheets.length; s++){
startS=s+1;
if(!d.styleSheets[s].cssRules||d.styleSheets[s].cssRules.length==0)continue;
ss=d.styleSheets[s].imports[0];
if(!ss)continue;
for(var r=startR; r<ss.rules.length; r++){
startR=r+1;
if(ss.rules[r].selectorText==className||ss.rules[r].selectorText.indexOf(className+',')==0){startS=s;return ss.rules[r];}
}}}
else if(d.getElementById){
for (var s=startS; s<d.styleSheets.length; s++){
startS=s+1;
try{if(!d.styleSheets[s].cssRules||d.styleSheets[s].cssRules.length==0)continue;}catch(e){continue;}
if(d.styleSheets[s].cssRules[0].type!=3)continue;
ss=d.styleSheets[s].cssRules[0].styleSheet;
for (var r=startR; r<ss.cssRules.length; r++){
startR=r+1;
if(ss.cssRules[r].selectorText==className||ss.cssRules[r].selectorText.indexOf(className+',')==0){return ss.cssRules[r];}
}}}
}catch(e){return null;}
return null;
}
function getCssText(className,d) {
if(!d)d=tf.content.document;
if(!d.styleSheets)return'';
startS=0;
startR=0;
var prevClass=getStyleClass(className,d);
var curClass=prevClass;
var css=prevClass?prevClass.style.cssText:'';
while(curClass) {
curClass=getStyleClass(className,d);
if (curClass) {prevClass=curClass;css+=prevClass.style.cssText;}
}
if (!prevClass) return '';
css=css.replace(/rgb\((\d+), (\d+), (\d+)\)/g, function($0, $1, $2, $3) {
var r=parseInt($1).toString(16),g=parseInt($2).toString(16),b=parseInt($3).toString(16);
if(r.length==1)r='0'+r;
if(g.length==1)g='0'+g;
if(b.length==1)b='0'+b;
return '#'+r+g+b;
});
return css;
}
var pm={
busy:false,
persist:{ dataraw:[], currConverted:true, lang:'', xml:'' },
data:[],
dataidx:{},
onGet:function(xml){
function getSurcharge(surcharge) {
var surchargecurr='';
if(surcharge.indexOf('%')==-1){
surchargecurr=surcharge.replace(/[0-9\-\+\. ]/g,'');
surcharge=parseFloat(surcharge);
if(surchargecurr&&tf.shopCurrency.iso!=surchargecurr&&(!tf.currencies||!tf.currencies[surchargecurr]))pm.persist.currConverted=false;
}
return [surcharge,surchargecurr];
}
pm.persist.dataraw=[];pm.data=[];pm.dataidx={};pm.persist.xml=xml;
var $=tf.content.$;
var data = $($.parseXML(xml)).find('data');
pm.persist.showServiceLogo=eval($(data).find('provider_name').attr('enabled'));
pm.persist.showSurchargeTax=eval($(data).find('surchargetax').attr('enabled'));
$(data).find('method').each(function(){
var arrSurcharge=getSurcharge($(this).find('fees').text()),surcharge=arrSurcharge[0],surchargecurr=arrSurcharge[1];
pm.persist.dataraw.push({
'idx':pm.persist.dataraw.length,
'service':$(this).find('service').text(),
'serviceLogo':$(this).find('service_logo').text().replace(/^https?:/,''),
'key':$(this).find('key').text(),
'name':$(this).find('name').text(),
'currencies':$(this).find('currencies').text(),
'country':$(this).find('country').text(),
'priority':parseInt($(this).find('priority').text()),
'surcharge':surcharge,
'surchargecurr':surchargecurr,
'logo':$(this).find('logo').text().replace(/^https?:/,''),
'commentName':$(this).find('comment_name').text(),
'comment':$(this).find('comment').text().replace(/\&\#38\;/g,'&').replace(/\&\#60\;/g,'<').replace(/\&\#62\;/g,'>'),
'isSpecial':false
});
});
var customMethods=tf.conf.payMethod();
for(var nm in customMethods){
pm.persist.dataraw.push({
'idx':pm.persist.dataraw.length,
'service':'Custom',
'serviceLogo':'',
'key':nm,
'name':nm,
'currencies':'',
'country':'',
'priority':1,
'surcharge':'',
'surchargecurr':'',
'logo':'',
'commentName':'',
'comment':'',
'isSpecial':false
});
}
if(!pm.persist.currConverted){
pm.currConv();
}
else{
pm.indexate();
pm.busy=false;
}
},
currConv:function(){
tf.nametag.del('cratesCalled');
tf.load('cload.html','cdata',false,true);
function waitForCurr(){
if(!tf.currencies||!tf.currencies[tf.shopCurrency.iso]){setTimeout(waitForCurr,200);return;}
pm.indexate();
pm.busy=false;
}
waitForCurr();
},
indexate:function(){
if(this.persist.dataraw){
this.data=[];this.dataidx={};
var oData=null,lookupCurrency=tf.shopCurrency.iso,lookupCountry=tf.core.region||tf.core.shopRegion;
for(var i=0;i<this.persist.dataraw.length;i++){
oData=this.persist.dataraw[i];
if(!oData.currencies||oData.currencies.indexOf(tf.currentCurrency.iso)!=-1){
lookupCurrency=tf.currentCurrency.iso;
break;
}
}
var key='',priorities={},priority=-1;
for(var i=0;i<this.persist.dataraw.length;i++){
oData=this.persist.dataraw[i];
key=oData.key;
var surchargecurr=oData.surchargecurr;
if(surchargecurr){
if(tf.shopCurrency.iso!=surchargecurr&&tf.currencies&&tf.currencies[surchargecurr]){
var surcharge=parseFloat(oData.surcharge)*(tf.currencies[tf.shopCurrency.iso]/tf.currencies[surchargecurr]);
surcharge=tf.core.nfmt.round(surcharge);
if(surcharge>0)surcharge='+'+surcharge;
oData.surcharge=surcharge;
oData.surchargecurr='';
this.persist.currConverted=true;
}
}
priority=oData.priority;
if(!priorities[key]){
if((!oData.currencies||oData.currencies.indexOf(lookupCurrency)!=-1)
&& (!oData.country||oData.country.indexOf(lookupCountry)!=-1)){
priorities[key]=priority;
this.data.push(oData);
this.data[this.data.length-1].idx=this.data.length-1;
this.dataidx[oData.key]=this.data[this.data.length-1];
}
}
}
tf.nametag.add('pmdata',tf.sfJSON.stringify(this.persist));
if(this.data.length==1)pmKey=this.data[0]['key'];
}
},
get:function(){
var pmstr=tf.nametag.get('pmdata'),doGet=true;
if(pmstr){
this.persist=tf.sfJSON.parse(pmstr);
doGet=(this.persist.lang!=tf.lang);
if(!doGet){
if(tf.conf&&tf.conf.pmdataraw&&tf.conf.pmdatasig!=this.persist.sig){
this.onGet(tf.conf.pmdataraw);
}
else{
if(!this.persist.currConverted)this.currConv();
else this.indexate();
}
}
}
if(doGet){
if(!tf.shipping||!tf.conf){setTimeout('pm.get();',500);return;}
if(!this.busy){
this.busy=true;
this.persist.lang=tf.lang;
if(tf.conf.pmdataraw){
this.persist.sig=tf.conf.pmdatasig;
this.onGet(tf.conf.pmdataraw);
}
else{
var pmxd=new tf.extra.xdmsg('//santu.com/webshop/getpaymentmethods.cgi?lang='+tf.lang+'&from=sf&ver=ShopFactory Gold 14.6.0 Build 24151&mid=tb-6681-ne','pmdata',this.onGet,'_sfpmping','_sfpmdata');
pmxd.init();
}
}
}
}
};
function savCookStr(name,val,days) { tf.sfPersist.set(name,val,days); }
function delCookStr(name) { tf.sfPersist.set(name,'',0); }
function getCookStr(name) { return tf.sfPersist.get(name); }
function timeMgr(offset)
{
this.handlers={getTime:[]};
this.setTime = tmSetTime;
this.getTime = tmGetTime;
this.isActive = tmIsActive;
this.offset = tmOffset;
this.myTZ = (new Date()).getTimezoneOffset() / 60 * -1;
this.timestamp = new Date();
this.offset(offset);
return this;
}
var currTime = new timeMgr('');
currTime.getTime();
function tmGetTime(){
if(tf.isInSF())return;
if (gmtTime==0) setTimeout("currTime.getTime()", 500);
else{(this.setTime(gmtTime));var hl=this.handlers['getTime'];for(var n=0,num=hl.length;n<num;n++)hl[n]();}
}
function tmSetTime(ti)
{
if (ti==null) return this._cTime;
this._cTime = ti;
return this._cTime;
}
function tmOffset(os)
{
if (os!=null&&os!='') this._offset=os;
return this._offset;
}
function tmIsActive(fr, to, rep, freq)
{
if (fr==null || fr=='') return 1;
if (to==null) {
var a=fr.split(',');
if (a.length==1) return 1;
return this.isActive(a[0],a[1],a[2],a[3]);
}
fr=parseInt(fr);to=parseInt(to);rep=parseInt(rep);freq=parseInt(freq);
var now  = this.setTime();
if(!now)return 1;
for (var i=0; i<=rep; i++) {
var period = i*freq*86400;
if (fr+period <= now && now <= to+period) return 1;
}
return 0;
}
function numeric(fmt, dp)
{
this.cvt = numCvt;
this.fmt = numFmt;
this.display = numDisplay;
this.parse = numParse;
this.delim = numDelim;
this.round = numRnd;
this.toLoc = numToLoc;
this.fromLoc = numFromLoc;
this.getDecPlaces=numDecimalPlaces;
this.roundTotalTable=[];
this.roundTotal=numRndTotal;
this.roundTotalSetup=numRndTotalSetup;
this.roundTotalSetup();
this.fmt(fmt, dp);
return this;
}
function numDelim() {return this.del2};
function numFmt(fmt, dp)
{
if(!regionalSettings.getCurrentSettings())
this.settings=regionalSettings.getMerchantSettings();
else
this.settings=regionalSettings.getCurrentSettings();
this.del2=this.settings.decimal;
this.del1=this.settings.thousand;
this.pos=this.settings.position;
this.dec_sep='.';
this.dec_num=tf.currentCurrency.decimal_places;
this.dec = (!dp||isNaN(dp))?1/Math.pow(10,this.dec_num):parseFloat(dp);
}
function numCvt(val, del)
{
var len = val.length;
if (len <= 3) return val;
if (val < 0 && len <= 4) return val;
var rem = this.cvt(val.substring(0, len - 3), del);
var dig = val.substring(len - 3, len);
if (rem == '') del = '';
return rem+del+dig;
}
function numToLoc(val)
{
val=''+val;val=val.replace(/^0*/,'');
var a=val.split(this.dec_sep);
if(a.length==1)return ''+parseFloat(val.replace(this.del2,''));
if(a.length>1){
if(!a[0])a[0]='0';if(!a[1])a[1]='0';
return ''+parseInt(a[0])+this.del2+a[1];
}
else return val;
}
function numFromLoc(val)
{
val=''+val;val=val.replace(/^0*/,'');
var a=val.split(this.del2);
if(a.length==1)return ''+parseFloat(val.replace(this.del1,''));
if(a.length>1){
if(!a[0])a[0]='0';if(!a[1])a[1]='0';
return ''+parseInt(a[0])+this.dec_sep+a[1];
}
else return val;
}
function numRnd(val,dp,roff)
{
var ret=val;
if (dp==null){ dp = this.dec; var dn=parseFloat(this.dec_num); }
else var dn=(1/dp).toString().length-1;
if (roff) return Math.round(val/roff)*roff;
if(!dp)return val;
var pow=Math.pow(10, dn+1);
return Math.round((val/dp)+(dn>0?1/pow:0))/(1/dp);
}
function numDecimalPlaces(v)
{
var s=v.toString();
s=s.substr(s.indexOf('.')+1);
return 1/Math.pow(10,s.length);
}
function numDisplay(val, dp, curSym)
{
if (dp==null) dp = this.dec;
val = this.round(val,1/Math.pow(10,dp)).toString();
var idx = val.indexOf(this.dec_sep);
var itr = (idx == -1)?val:val.substring(0, idx);
var dec = (idx == -1)?'':val.substring(idx+1, idx+dp+1);
itr = this.cvt(itr, this.del1);
for (var i=dec.length;i<dp; i++) dec += '0';
var ret=(dp<1)?itr:itr + this.del2 + dec;
switch(this.pos) {
case 1: ret=ret+curSym;break;
case 2: ret=curSym+' '+ret;break;
case 3: ret=ret+' '+curSym;break;
default: ret=curSym+ret;break;
}
return ret;
}
function numParse(str,dec)
{
str=str.toString();
if (str=='') return 0;
function _chg(s,del) {
var idx = s.indexOf(del);
if (idx == -1) return s;
var ts = s.substring(0, idx) + _chg(s.substring(idx+1, s.length));
return ts;
}
var pwr = Math.pow(10, (dec==null)?1:dec);
return (Math.round(parseFloat(_chg(str,this.del1))*pwr)/pwr);
}
function numRndTotalSetup()
{
var a='CHF,0.05;'.split(';');
for(var n=0,l=a.length;n<l;++n)
{
if(a[n])
{
var nv=a[n].split(',');
if(nv[0]&&nv[1])this.roundTotalTable[nv[0]]=parseFloat(nv[1]);
}
}
}
function numRndTotal(val,iso)
{
var rnd=this.roundTotalTable[iso];
if(rnd){
val=Math.round(val/rnd)*rnd;
}
return val;
}
var hexdelim	= "O";
var chrsz	= 8;
var hexcase = 0;
var b64pad  = "";
function add(s) {return binb2hex(core_sha1(str2binb(s),s.length * chrsz))}
function core_sha1(x, len)
{
x[len >> 5] |= 0x80 << (24 - len % 32)
x[((len + 64 >> 9) << 4) + 15] = len
var w = Array(80)
var a =  1732584193
var b = -271733879
var c = -1732584194
var d =  271733878
var e = -1009589776
for(var i = 0,ii=x.length; i < ii; i += 16)
{
var olda = a,oldb = b,oldc = c,oldd = d,olde = e;
for(var j = 0; j < 80; j++)
{
if(j < 16) w[j] = x[i + j];
else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1)
var t = safe_add(safe_add(rol(a, 5), ft(j, b, c, d)),
safe_add(safe_add(e, w[j]), kt(j)))
e = d
d = c
c = rol(b, 30)
b = a
a = t
}
a = safe_add(a, olda)
b = safe_add(b, oldb)
c = safe_add(c, oldc)
d = safe_add(d, oldd)
e = safe_add(e, olde)
}
return Array(a, b, c, d, e)
function ft(t, b, c, d)
{
if(t < 20) return (b & c) | ((~b) & d);
if(t < 40) return b ^ c ^ d;
if(t < 60) return (b & c) | (b & d) | (c & d);
return b ^ c ^ d;
}
function kt(t)
{
return (t < 20) ?  1518500249 : (t < 40) ?  1859775393 :
(t < 60) ? -1894007588 : -899497514;
}
}
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF)
var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
return (msw << 16) | (lsw & 0xFFFF)
}
function rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt))
}
function str2binb(str)
{
var bin = Array()
var mask = (1 << chrsz) - 1
for(var i = 0,ii=str.length * chrsz; i < ii; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32)
return bin
}
function binb2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef", a = [];
for(var i = 0, num = binarray.length * 4; i < num; i++)
{
a.push(hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8  )) & 0xF));
}
return a.join('');
}
function place(s) {
var a=[];
for (var x = 0, num = s.length; x < num; x++) {
a.push(s.charCodeAt(x).toString(16));
}
return a.join('');
}
function show(v) {
var a=[];
if((v.length%2)==0){
for (var x = 0, num = v.length; x < num; x+=2) {
a.push(String.fromCharCode(parseInt(v.charAt(x)+v.charAt(x+1),16)));
}
}
return a.join('');
}
function stock()
{
this.init = stkInit;
this.check = stkCheck;
this.update = stkUpd;
this.code = stkCode;
return this;
}
function stkInit(min,max,avail,prdc,manc,dstc,prcc)
{
this.min = isNaN(min)?-1:parseFloat(min);
this.max = isNaN(max)?-1:parseFloat(max);
this.avail = isNaN(avail)?-1:parseFloat(avail);
this.prd_cd = prdc;
this.man_cd = manc;
this.dst_cd = dstc;
this.prc_cd = prcc;
this.used  = 0;
}
function stkCheck(itm)
{
function getMsg(title,msg,min,max,avail,used){
if(min>0 && used<min && qnty<min){
rc=1;
msg.push(title+'\n\n'+LD.LD_MIN_ORD_QTY+' '+min);
}
if(max>0 && used>max){
rc=1;
msg.push(title+'\n\n'+LD.LD_MAX_ORD_QTY+' '+max);
}
if(avail>=0 && used>avail){
rc=1;
msg.push(title+'\n\n'+LD.LD_STOCK_ORD_QTY+' '+avail);
}
return rc;
}
var rc=0,msg=[];
var qnty = parseFloat(itm.quantity),itemNo=itm.getItemNo();
if (!qnty||qnty<=0) return 0;
var used = qnty + this.used;
var min = this.min, max = this.max, avail = this.avail;
rc = getMsg(itm.title+' ['+itemNo+']',msg,min,max,avail,used);
var optcnt=itm.options.cnt();
for(var n=0;n<optcnt;n++){
var opt=itm.options.get(n);
if(opt.choice()==''||opt.combine||!opt.optId())continue;
var itemNo=opt.prop[3],stkopt=Basket.stk.getS(itemNo);
if(stkopt){
min=stkopt.min;max=stkopt.max;avail=stkopt.avail;
used = qnty + stkopt.used;
rc = getMsg(itm.title+'/'+opt.prop[0]+' ['+itemNo+']',msg,min,max,avail,used);
}
}
return [rc,msg.join('\n')];
}
function stkUpd(itm, neg)
{
if(itm.temporary)return;
if (neg == null) this.used += itm.quantity;
else this.used = Math.max(0, this.used - itm.quantity);
var optcnt=itm.options.cnt();
for(var n=0;n<optcnt;n++){
var opt=itm.options.get(n);
if(opt.choice()==''||opt.combine||!opt.optId())continue;
var stkopt=Basket.stk.getS(opt.prop[3]);
if(neg==null)stkopt.used += itm.quantity;
else stkopt.used = Math.max(0, stkopt.used - itm.quantity);
}
}
var _stkArr = new Array('min','max','avail');
function stkCode(str)
{
return ckCodeStr(this, _stkArr, '|', str);
}
var stkQryQueue=null;
var stkQryState={arrQS:{},arrQSLen:0,arrQSCnt:0};
function stkFetchBulk(fnSuccess,fnFail){
function upd(data){
var state=tf.core.stkQryState;
tf.core.stkFetchUpd(data);
state['arrQSCnt']++;
if(state['arrQSCnt']>=state['arrQSLen']){
var bsk=tf.core.Basket,it=new SF_Iterator(bsk.items),i=it.start(),msg=[],rc=0;
while (i!=null) {
var stk=bsk.stk.getS(i.getItemNo());
if(stk){
stk.update(i,'neg');
var chk=stk.check(i);
rc+=chk[0];
if(chk[1].length>0)msg=msg.concat(chk[1]);
}
i=it.next();
}
if(rc==0)fnSuccess();
else fnFail(msg);
}
}
tf.core.stkQryState['arrQSCnt']=tf.core.stkQryState['arrQSLen']=0;
var a=tf.core.stkQryState['arrQS'];
for(var qs in a)tf.core.stkQryState['arrQSLen']++;
for(var qs in a){
$.ajax({method:'POST',url:tf.wm.url('stkcontrol/stkControl.php','-'),data:a[qs],dataType:'json',async:true,processData:false})
.done(function(data,textStatus,jqXHR){
var ignoreCodes = {'-2':true,'-5':true,'-7':true,'-8':true};
if(!ignoreCodes[data.statuscode]&&data.statuscode<0&&data.errmsg)fnFail([data.errmsg]);
else upd(data);
})
.fail(function(data,textStatus,jqXHR){
fnFail(jqXHR.responseText);
})
;
}
}
function stkFetchUpd(o){
for(var itemNo in o.data){
var o2=o.data[itemNo];
if(typeof(o2)=='object'){
for(var n=0,nn=o2.length;n<nn;n++){
var prid=o2[n]['InternalID'];
tf.wm.pPropQty(prid,o2[n]['Quantity']);
tf.wm.pPropQty(itemNo,o2[n]['Quantity']);
tf.wm.pPropMin(prid,o2[n]['MinOrderQuantity']);
tf.wm.pPropMin(itemNo,o2[n]['MinOrderQuantity']);
tf.wm.pPropMax(prid,o2[n]['MaxOrderQuantity']);
tf.wm.pPropMax(itemNo,o2[n]['MaxOrderQuantity']);
var stk=tf.core.Basket.stk.getS(itemNo),pstk=tf.wm.pProp(itemNo);
if(stk){
if(!pstk)pstk=tf.wm.pProp(prid);
stk.avail=parseFloat(pstk[4]);
stk.min=parseFloat(pstk[2]);
stk.max=parseFloat(pstk[3]);
}
}
}
}
if(tf.equalHeight)tf.equalHeight();
tf.core.Basket.save();
if(tf.wm._pArr){
tf.wm._pArr['wssig']=tf.wssig;
tf.nametag.add('_pArr',tf.sfJSON.stringify(tf.wm._pArr,null,true));
}
}
function dynObj(gid)
{
this.gid = gid;
this._arr = [];
this._idtags = [];
this._idxArr = {};
this._cnt = 0;
this.cnt = dOCnt;
this.idx = dOIdx;
this.add = dOAdd;
this.del = dODel;
this.get = dOGet;
this.getS = dOGetS;
this.getById = dOGetById;
this.empty = dOEmpty;
this.start = dOStart;
this.next  = dONext;
this.replace = dOReplace;
this.eAdd  = dOEAdd;
this.eAddS = dOEAddS;
this.reidx = dOReidx;
}
function dOReidx()
{
this._idtags = [];
this._idxArr = {};
for(var i=0;i<this._cnt;i++){
this._idtags.push(this._arr[i].idtag);
this._idxArr[this._arr[i].idtag]=i;
}
}
function dOCnt()
{
return this._cnt;
}
function dOIdx(idtag)
{
var i=this._idxArr[idtag];
if(typeof(i)=='undefined')return -1;
return i;
}
function dOAdd(obj)
{
var idx = this.idx(obj.idtag);
if (idx!=-1) return 0;
if (!isNaN(obj.idtag)) obj.idtag = (obj.id&&isNaN(obj.id))?'_'+obj.id:this._cnt;
this._arr[this._cnt++] = obj;
this.reidx();
return 1;
}
function dODel(idx)
{
if (isNaN(idx)) {
idx = this.idx('_'+idx);
if (idx==-1) return '';
}
if (idx<0 || idx>=this._cnt) return '';
for (var i=idx; i<this._cnt-1; i++) this.replace(i, this._arr[i+1]);
this._cnt--;
delete this._arr[this._cnt];
this.reidx();
}
function dOReplace(idx, obj)
{
if (isNaN(idx)) return this.replace(this.idx('_'+idx));
if (idx<0 || idx>this._cnt) return this.add(obj);
this._arr[idx] = obj;
this.reidx();
}
function dOGet(idx)
{
if (isNaN(idx)){
var i=this._idxArr['_'+idx];
if(typeof(i)=='undefined')return '';
return this._arr[i];
}
if (idx<0||idx>=this._cnt) return '';
return this._arr[idx];
}
function dOGetS(idx)
{
var i=this._idxArr['_'+idx];
if(typeof(i)=='undefined')return '';
return this._arr[i];
}
function dOStart()
{
this._idx = 0;
return this._arr[0];
}
function dONext()
{
return this._arr[++this._idx];
}
function dOEmpty(idtag)
{
if (idtag==null) idtag = this._cnt;
else idtag = '_'+idtag;
var tmp;
switch(this.gid){
case 'range':tmp=new range();break;
case 'tax_regn':tmp=new tax_regn();break;
case 'item':tmp=new item();break;
case 'stock':tmp=new stock();break;
case 'discount':tmp=new discount();break;
case 'keyval':tmp=new keyval();break;
case 'options':tmp=new options();break;
default:tmp=null;break;
}
if(tmp){
tmp.gid = this.gid;
tmp.idtag = idtag;
}
return tmp;
}
function dOEAdd(idtag, a)
{
var obj = this.get(idtag);
if (obj!='') return obj;
var s='obj.init(';for (var i=0;i<a.length-1;i++) s+='a['+i+'],';s+='a['+i+'])';
obj=this.empty(idtag); eval(s);
this.add(obj);
return obj;
}
function dOEAddS(idtag, a)
{
var obj = this.getS(idtag);
if (obj!='') return obj;
var s='obj.init(';for (var i=0;i<a.length-1;i++) s+='a['+i+'],';s+='a['+i+'])';
obj=this.empty(idtag); eval(s);
this.add(obj);
return obj;
}
function dOGetById(idtag) {
var gd=null;
if (isNaN(idtag)) idtag='_'+idtag;
var i=this.start();
while(i!=null) {
if (i.idtag==idtag) {gd=i;break;}
i=this.next();
}
return gd;
}
function SF_Iterator(obj) {
this.obj=obj;
this.objarr=obj._arr
this.idx=0;
this.start=itStart;
this.next=itNext;
}
function itStart() {
this._idx = 0;
return this.objarr[0];
}
function itNext()
{return this.objarr[++this._idx];}
function iField(field)
{
var type = field.type;
var idx	= 0;
var value = '', origvalue = '';
switch (type) {
case 'hidden':
value = field.value;
break;
case 'text':
case 'textarea':
idx = 1;
var a = field.getAttribute('metavalue');
if (a) { a = a.split(str_sep1); a[0] = field.value; value = a.join(str_sep1);}
else { value = field.value; }
this.rawValue = field.value;
break;
case 'radio':
idx = $(field).parent().parent().children('.ProductChoiceName').index($(field).parent())+1;
if (field.checked) value = field.value;
break;
case 'checkbox':
idx = 1;
value = field.value;
this.rawValue = field.checked ? '1' : '0';
break;
case 'select-one':
idx = field.selectedIndex;
idx=(idx>0)?idx:0;
if(field[idx].getAttribute('data-nosel')===''){
idx++;
value = field[idx].getAttribute('origvalue');
}
else value = field[idx].value;
origvalue = field[idx].getAttribute('origvalue');
break;
}
this.ctrl   = field;
this.value	= value;
this.origValue = origvalue || field.getAttribute('origvalue');
this.idx	= idx;
this.type	= type;
this.name	= field.name;
this.display	= field.display;
if (!def(this.display)) this.display = '';
return this;
}
function iForm(form)
{
this.getField = iformGFld;
this.getValue = iformGVal;
this.getOriginalValue = iformGOrigVal;
this.getIdx = iformGIdx;
this.count = 0;
this.fields = new Array();
for (var i=0; i<form.length; i++) {
var fld = new iField(form[i]);
if (fld.value == '' && fld.type != 'radio') continue;
var exist = this.getField(fld.name);
if (exist != '') {
if (fld.type == 'radio') {
if (fld.value != '' && exist.value == '') {
exist.value = fld.ctrl.value;
exist.origValue = fld.origValue;
exist.idx = fld.idx;
}
}
else exist.value += '&&' + fld.value;
}
else this.fields[this.count++] = fld;
}
return this;
}
function iformGFld(name)
{
var str = '';
for (var i=0; i<this.count; i++)
if (this.fields[i].name == name) return this.fields[i];
return '';
}
function iformGVal(name)
{
var val = this.getField(name).value;
return def(val);
}
function iformGOrigVal(name)
{
var val = this.getField(name).origValue;
return def(val);
}
function iformGIdx(name)
{
var val = this.getField(name).idx;
return def(val);
}
function options()
{
this.prop	= new Array();
this.order	= _oArr;
this.separator	= ',';
this.init	= optInit;
this.check	= optCheck;
this.choiceId = optChoiceId;
this.choice	= optChoice;
this.price	= optPrice;
this.calcedPrice = optCalcedPrice;
this.weight	= optWeight;
this.optId	= optOptId;
this.internalOptId	= optInternalOptId;
this.code	= optCode;
this.idxPrc = 0;
return this;
}
function optInit(arr, value)
{
this.name  = arr[1];
this.title = arr[2];
this.type  = arr[3]==1;
this.opttype = arr[4];
this.combine = arr[5];
this.value = value;
this.prop  = value.split(str_sep1);
}
function optCheck()
{
if (this.prop[0] == '' && this.type) {
return this.title;
}
return '';
}
function optChoice()
{
return this.prop[0];
}
function optChoiceId()
{
return this.prop[7];
}
function optPrice(newPrc)
{
if (newPrc != null) {
this.prop[1] = newPrc;
}
else {
var prc = this.prop[1];
return (!def(prc))?0:parseFloat(prc);
}
}
function optCalcedPrice()
{
var prc = 0;
switch(this.opttype){
case 1:
case 2:
if (this.prop[0] != '') prc = this.prop[1];
break;
default:
prc = this.prop[1];
break;
}
return (!def(prc))?0:parseFloat(prc);
}
function optWeight()
{
var wght = this.prop[2];
return (!def(wght))?0:parseFloat(wght);
}
function optOptId()
{
var id = this.prop[3];
if (id == ' ') id = '';
return (!def(id))?'':id;
}
function optInternalOptId()
{
var id = this.prop[7];
if (id.indexOf('C')>-1) id=id.substr(0,id.indexOf('C'));
return (!def(id))?'':id;
}
var _oArr=['prop[0]','prop[1]','prop[2]','prop[3]','title','combine','prop[4]','prop[5]','prop[6]','prop[7]','idxPrc'];
function optCode(str)
{
if (this.choice() === '') return '';
return ckCodeStr(this, _oArr, ',', str);
}
function range()
{
this.init = rgInit;
this.getData = rgGetData;
return this;
}
function rgInit(min,max,data)
{
if (max == null) {
var arr = min.split(',');
return this.init(arr[0], arr[1], arr[2]);
}
this.min = min;
this.max = max;
this.data = data;
}
function rgGetData(value, type)
{
if (type==null) type=0;
if (this.min==this.max) type=1;
if (type==1) if (this.min <= value) return this.data;
if (this.min <= value && value < this.max) return this.data;
return '';
}
function keyval()
{
this.init = srInit;
this.val =  srVal;
}
function srInit(i,v,s)
{
this._id = i;
this.val(v);
this.str = (s==null)?'':s;
}
function srVal(v)
{
if (v!=null) this._val = v;
return this._val;
}
function discount()
{
this.rg = new dynObj('range');
this.init = discInit;
this.getData = discData;
this.amount = discAmount;
this.purchasePrice = discPurchasePrice;
this.purchasePriceByPrice = discPurchasePriceByPrice;
this.getNextRange = discGetNextRange;
this.free = discFree;
this.code = discCode;
this.useLimitToCode = discUseLimitToCode;
this.canApplyToProduct = discCanApplyToProduct;
return this;
}
function discInit(type, val, tlim, del1, del2, limitToCodeType, limitToCodes)
{
this.type = type;
this.value = val;
this.tlim = tlim;
this.del1 = (del1==null)?';':del1;
this.del2 = (del2==null)?',':del2;
this.limitToCodeType = limitToCodeType;
this.limitToCodes = str_sep1 + limitToCodes + str_sep1;
var a1 = this.value.split(this.del1);
for (var i=0; i<a1.length; i++) {
var a2 = a1[i].split(this.del2);
if (a2.length == 1) continue;
var tmp = this.rg.empty();
tmp.init(a2[0],a2[1],a2[2]);
this.rg.add(tmp);
}
}
function discUseLimitToCode(){
return this.limitToCodeType >= 0 && this.limitToCodes;
}
function discCanApplyToProduct(prd){
if (!this.useLimitToCode()) return true;
var code = prodTypeCode(this.limitToCodeType,prd);
var pos = this.limitToCodes.indexOf(str_sep1 + code + str_sep1);
return (pos != -1);
}
function discData(key,type,getO)
{
var cnt = this.rg.cnt();
if (!cnt) return '';
if (!currTime.isActive(this.tlim)||key<this.rg.get(0).min) return '';
for (var i=0; i<cnt; i++) {
var rg = this.rg.get(i);
if (rg == '') return '';
var data = rg.getData(key,type);
if (data!='') return (data=='-')?'':(getO)?rg:data;
}
var rg = this.rg.get(cnt-1);
return (getO)?rg:rg.data;
}
function discGetNextRange(key)
{
var cnt = this.rg.cnt();
if (!cnt) return '';
if (key<this.rg.get(0).min) return this.rg.get(0);
var flag=false;
for (var i=0; i<cnt; i++) {
var rg = this.rg.get(i);
if (rg == '') return '';
if (flag) return rg;
var data = rg.getData(key);
if (data!='') flag=true;
}
return '';
}
function discAmount(prc,qnty,oprc,prd)
{
var type=this.type.toString();
if (false)
return 0;
if (prd && !this.canApplyToProduct(prd)) return 0;
var p=0,perc = 0;
if (!currTime.isActive(this.tlim)) return p;
var prc2=prc+(type=='5'?0:oprc);
switch(type) {
case '0': p=prc-parseFloat(this.value==''||isNaN(this.value)?0:this.value); break;
case '1': case '10': case '11': p=prc2*(parseFloat(this.value)/100);break;
case '5': perc=this.getData(qnty);p=(isNaN(perc))?0:(prc2-perc);break;
case '4': perc=this.getData(qnty);
p=(isNaN(perc))?0:prc2*(perc/100);break;
}
if (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;}
return p;
}
function discPurchasePrice(prc) {
var type=this.type.toString();
if (type==4)return 0;
if (false) return 0;
var perc=this.getData(prc);
var p=(isNaN(perc))?0:(prc)*(perc/100);
if (p>=prc) return 0;
return p;
}
function discPurchasePriceByPrice(prc,discPrice) {
var type=this.type.toString();
if (type==4)return 0;
if (false) return 0;
var perc=this.getData(discPrice);
var p=(isNaN(perc))?0:(prc)*(perc/100);
if (p>=prc) return 0;
return p;
}
function discFree(qnty)
{
var type=this.type.toString();
if (false)
return 0;
switch(this.type) {
case '2': return parseInt(qnty/this.rg.get(0).max)*this.getData(qnty);break;
case '3': var rg=this.getData(qnty,null,1);return (rg)?new Array((qnty>rg.max)?parseInt(qnty/rg.max):1,rg.data):'';
case '103': return new Array(1,this.getData(qnty));
}
return '';
}
var _dArr = new Array('type','value','tlim');
function discCode(str)
{
return ckCodeStr(this, _dArr, '|', str);
}
var rules = new Array();
var taxExemptObj=new taxExempt();
function taxExempt()
{
this.len=new Function('x','return this.s.length==x');
this.chr=new Function('x','y','x=this.s.charAt(x);return y?(x==y):("A"<=x&&x<="z")');
this.num=new Function('x','y','x=this.s.substring(x,y);return parseInt(x.replace(/^0+/,\'\'))==x');
this.chk=function(s,c){
this.s=s.toUpperCase();
var rule=rules[c],len=c.length;
if(!rule&&len>4){rule=rules[c.substr(0,4)];}
if(!rule&&len>2){rule=rules[c.substr(0,2)];}
return rule?eval(rule):1;
}
this.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']);
}
rules['AT']="L(9)&&C(0,'U')&&N(1,8)";
rules['BE']="L(10)&&N(0,10)";
rules['BG']="(L(9)&&N(0,9))||(L(10)&&N(0,10))";
rules['CY']="L(9)&&(N(0,8)&&C(8))";
rules['CZ']="(L(8)&&N(0,8))||(L(9)&&N(0,9))||(L(10)&&N(0,10))";
rules['DE']="L(9)&&N(0,9)";
rules['DK']="L(8)&&N(0,8)";
rules['EE']="L(9)&&N(0,9)";
rules['ES']="L(9)&&((C(0)&&N(1,8))||(N(0,8)&&C(8))||(C(0)&&C(8)&&N(1,7)))";
rules['FI']="L(8)&&N(0,8)";
rules['FR']="L(11)&&N(2,11)";
rules['GR']="L(9)&&N(0,9)";
rules['HU']="L(8)&&N(0,8)";
rules['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))";
rules['IT']="L(11)&&N(0,11)";
rules['LT']="(L(9)&&N(0,9))||(L(12)&&N(0,12))";
rules['LU']="L(8)&&N(0,8)";
rules['LV']="L(11)&&N(0,11)";
rules['MT']="L(8)&&N(0,8)";
rules['NL']="L(12)&&N(0,8)&&C(9,'B')&&N(10,12)";
rules['PL']="L(10)&&N(0,10)";
rules['PT']="L(9)&&N(0,9)";
rules['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))";
rules['SE']="L(12)&&N(0,10)&&C(10,'0')&&C(11,'1')";
rules['SI']="L(8)&&N(0,8)";
rules['SK']="L(10)&&N(0,10)";
rules['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)))";
var taxExemptCtryPre={'GR':'EL'};
function rplTxEx(s,f,t){
var i=s.indexOf(f);
if (i==-1) return s;
return rplTxEx(s.substring(0,i)+t+s.substring(i+f.length,s.length), f, t);
}
for (i in rules) {
rules[i] = rplTxEx(rules[i],'L(','this.len(');
rules[i] = rplTxEx(rules[i],'C(','this.chr(');
rules[i] = rplTxEx(rules[i],'N(','this.num(');
}
function tax_regn()
{
this.init = taxRInit;
this.calcShipAmt = taxCalcShipAmt;
return this;
}
function taxRInit(i,c,p,t,e,it,additive)
{
this.id	  = i;
this.code = c;
this.perc = parseFloat(p);
this.taxName	= t;
this.exempt	= e;
this.exNo	= '';
this.incTax	= it;
this.prodAmt = 0;
this.additive = additive;
this.cache	= 0;
}
function taxCalcShipAmt(sumRates,avgAmt) {
if (this.exempt && this.exNo) return 0;
return avgAmt*this.perc/(100*sumRates);
}
function tax()
{
this._tax = new dynObj('tax_regn');
this._rgn = new Array();
this.exNo = '';
this.init	= taxInit;
this.getDefaultReg=taxGetDefaultReg;
this.currRegn	= taxCurrRegn;
this.addArea	= taxAddArea;
this.regnName	= taxRegnName;
this.cntInc	= taxCntInc;
this.regnRate	= taxRegnRate;
this.forRegion	= taxForRegion;
this.rate	= taxRate;
this.amt	= taxAmt;
this.allAmt	= taxAllAmt;
this.singleAmt	= taxSingleAmt;
this.inTax	= taxInTax;
this.exTax	= taxExTax;
this.calcTax	= taxCalcTax;
this.disp	= taxDisp;
this.dispValues	= taxDispValues;
this.dispTexts = taxDispTexts;
this.taxAppliedRawAmt = taxTaxAppliedRawAmt;
this.list	= taxList;
this.allCodes	= taxAllCodes;
this.allIDs	= taxAllIDs;
this.ship	= taxShip;
this.isEmpty	= taxIsEmpty;
this.anyTaxInclCountry=taxAnyTaxInclCountry;
this.anyTaxForRegion=taxAnyTaxForRegion;
this.findMajorityTaxID=taxFindMajorityTaxID;
this.mapRegn	= {};
this.mapTax	= {};
this.resetCache = taxResetCache;
return this;
}
function taxInit(d,s)
{
this._default	= d;
this.showBoth	= s;
}
function taxGetDefaultReg(){
if (this._default) return this._default;
var rc=window.shopRegion;
var _t = this._tax.start();
while (_t!=null) {
if (rc.indexOf(_t.code)==0&&_t.code.length>this._default.length) this._default=_t.code;
_t  = this._tax.next();
}
if (!this._default) this._default=rc;
return this._default;
}
function taxCurrRegn(rc)
{
if (!rc) this._current = rc;
else rc=this._current;
if (!rc) rc=window.region;
if (!rc) rc=this.getDefaultReg();
this._current=rc;
return rc;
}
function taxAddArea(id,c,p,t,r,inc,additive)
{
var tr = this._tax.get(id);
if (tr == '') tr = this._tax.eAdd(id, new Array(id,c,p,t,r,inc,additive||false));
else tr.code += ','+c;
if(this.mapRegn[c]) {
if(!this.mapTax[id]) this.mapRegn[c]+=','+id;
} else {
this.mapRegn[c]=id;
}
this.mapTax[id]=tr.code;
return 0;
}
function taxForRegion(tax,reg,exact) {
if(!tax||!reg||!this.mapTax[tax])return false;
var tmp=this.mapTax[tax].split(',');
for(var i=0,num=tmp.length;i<num;i++){
if(exact){if(reg==tmp[i]) return true;}
else if(reg.indexOf(tmp[i])==0) return true;
}
return false;
}
function taxRegnName(rc,rn)
{
if (rn != null) this._rgn[rc] = rn;
return (this._rgn[rc]==null)?'':this._rgn[rc];
}
function taxRegnRate(tid,c,ign)
{
if (tid == '') return 0;
var a = tid.split(','), aAdditive = [];
var ret=0;
for (var j=0; j<a.length; j++) {
if(!a[j])continue;
var tr = this._tax.get(a[j]);
if (tr=='') continue;
if (tr.exempt && tr.exNo && !ign) continue;
if (c==null || c=='') c=this.currRegn();
if (c==-1) c=(this.anyTaxInclCountry(this.currRegn()))?this.currRegn():'FR';
if (tr.additive) { aAdditive.push(tr); continue; }
var cd=tr.code.split(',');
var tmpreg='',tmpval=0;
for (var i=0; i<cd.length; i++) {
if (cd[i]=='') continue;
if (c.indexOf(cd[i])==0) {
if (tmpreg.length<cd[i].length) {
tmpreg=cd[i];
tmpval=tr.perc;
}
}
}
ret+=tmpval/100;
}
for (var j=0; j<aAdditive.length; j++) {
var tr = aAdditive[j];
var cd=tr.code.split(',');
var tmpreg='',tmpval=0;
for (var i=0; i<cd.length; i++) {
if (cd[i]=='') continue;
if (c.indexOf(cd[i])==0) {
if (tmpreg.length<cd[i].length) {
tmpreg=cd[i];
tmpval=tr.perc/100;
}
}
}
ret=(ret*(1+tmpval))+tmpval;
}
return ret;
}
function taxAnyTaxInclCountry(regn) {
var it = new SF_Iterator(this._tax);
var _t=it.start();
while (_t!=null) {
if(_t.incTax&&this.forRegion(_t.id,regn)) return true;
_t = it.next();
}
return false;
}
function taxAnyTaxForRegion(regn) {
var it = new SF_Iterator(this._tax);
var _t=it.start();
while (_t!=null) {
if(this.forRegion(_t.id,regn)) return true;
_t = it.next();
}
return false;
}
function taxFindMajorityTaxID(regn) {
function findMajorityTaxIDAtSameLevel(o,rgn) {
var it = new SF_Iterator(o._tax),_t=it.start(),high=0,highRate=0,highID='';
while (_t!=null) {
if (o.forRegion(_t['id'],rgn,true) && typeof(_t['prodAmt'])!='undefined'){
var rate=_t['perc'];
if (_t['prodAmt']>high || (_t['prodAmt']==high && rate>highRate)) { high=_t['prodAmt']; highRate=rate; highID=_t['id']; }
}
_t = it.next();
}
return highID+(highID?',':'');
}
var highID='',rgn=regn;
highID+=findMajorityTaxIDAtSameLevel(this,rgn.substr(0,2));
if(rgn.length>2)highID+=findMajorityTaxIDAtSameLevel(this,rgn.substr(0,4));
if(rgn.length>4)highID+=findMajorityTaxIDAtSameLevel(this,rgn);
return highID;
}
function taxRate(i,c)
{
var a = i.split(',');
var r = 0;
for (var j=0; j<a.length; j++) r += this.regnRate(a[j], c);
return r;
}
function taxAmt(inc,i,p,c)
{
var r = this.rate(i,c);
var amt = p * r * 10 / 10;
var val = (inc)?amt/(1+r):amt;
return val;
}
function taxAllAmt(i,p,c)
{
if (!c) c=this.currRegn();
var tot=0;
p=this.exTax(i,p);
var a = i.split(',');
for (var j=0,jj=a.length; j<jj; j++){
if(!a[j])continue;
var t=this._tax.get(a[j]);
if (t && !t.additive) tot += this.amt(0,a[j],p);
}
for (var j=0,jj=a.length; j<jj; j++){
if(!a[j])continue;
var t=this._tax.get(a[j]);
if (t && t.additive) tot += this.amt(0,a[j],p+tot);
}
return tot;
}
function taxSingleAmt(i,p,c)
{
var r = this.regnRate(i, c)
var val = p * r * 10 / 10;
return val;
}
function taxInTax(i,p,c)
{
p = this.exTax(i,p);
var amt = this.amt(0,i,p,c);
var val = p+amt;
return val;
}
function taxExTax(i,p,uadd)
{
var prc = parseFloat(p);
var a = i.split(',');
var r=0;
uadd=uadd||false;
for (var j=0,jj=a.length; j<jj; j++){
if(!a[j])continue;
var t=this._tax.get(a[j]);
if (t&&t.additive==uadd) r += t.incTax?this.regnRate(a[j],-1,1):0;
}
prc-=prc*r/(1+r);
return prc;
}
function taxCalcTax(i,p,c,uadd)
{
if (!c) c=this.currRegn();
if (this.exempt && this.exNo) return this.exTax(i,p);
var a = i.split(',');
var d=0;
var exPrc=this.exTax(i,p);
uadd=uadd||false;
for (var j=0,jj=a.length; j<jj; j++){
if(!a[j])continue;
var t=this._tax.get(a[j]);
if (t&&t.additive==uadd) d+=t.incTax?this.singleAmt(a[j],exPrc,c):0;
}
var val = exPrc+d;
return val;
}
function taxDisp(i,p,co,ccr,onpage,tinc,texc,symbolClass)
{
var exT = this.exTax(i,p);
var inT = exT+this.allAmt(i,p);
if (ccr != null && ccr!=0) {
inT /= ccr;
exT /= ccr;
}
var s='';
if (this.isEmpty(i)||exT>=inT) { s=(onpage?dPrc(inT,1,false,true,symbolClass):'\n '+showPrc(inT));}
else {
if (this.showBoth && inT>exT) {
if(onpage) {
if(this._tax.get(i).incTax){
var p1t=tinc, p1a=dPrc(inT,1,false,true,symbolClass);
var p2t=texc, p2a=dPrc(exT,1,false,true);
}
else{
var p1t=texc, p1a=dPrc(exT,1,false,true,symbolClass);
var p2t=tinc, p2a=dPrc(inT,1,false,true);
}
s='<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>';
}
else s='\n - '+LD.LD_INC_TOTAL_TAX+' '+showPrc(inT)+' '+LD.LD_EX_TOTAL_TAX+' '+showPrc(exT);
} else {
s=dPrc(p,1,false,true,symbolClass);
}
}
return s;
}
function taxDispValues(i,p,ccr,tinc,texc,symbolClass)
{
var exT = this.exTax(i,p);
var inT = exT+this.allAmt(i,p);
if (ccr != null && ccr!=0) {
inT /= ccr;
exT /= ccr;
}
var p1t='', p1a=null, p2t='', p2a=null;
if (this.isEmpty(i)||exT>=inT) { p1a=dPrc(inT,1,false,true,symbolClass);}
else {
if (this.showBoth && inT>exT) {
if(this._tax.get(i).incTax){
p1t=tinc;
p1a=dPrc(inT,1,false,true,symbolClass);
p2t=texc;
p2a=dPrc(exT,1,false,true);
}
else{
p1t=texc;
p1a=dPrc(exT,1,false,true,symbolClass);
p2t=tinc;
p2a=dPrc(inT,1,false,true);
}
} else {
p1a=dPrc(p,1,false,true,symbolClass);
p1t=(this._tax.get(i).incTax ? tinc : texc);
}
}
return {p1t:p1t, p1a:p1a, p2t:p2t, p2a:p2a};
}
function taxDispTexts(txids,tsI,tsIx)
{
var a=txids.split(','),tinc='',texc='',tid=txids;
var otinc={},otexc={};
for (var i=0,ii=a.length; i<ii; i++){
if(tsI[a[i]])otinc[tsI[a[i]]]=true;
if(tsIx[a[i]])otexc[tsIx[a[i]]]=true;
if(typeof(tsI[a[i]])!='undefined')tid=a[i];
}
for(var s in otinc){tinc+=', '+s;}
for(var s in otexc){texc+=', '+s;}
tinc=tinc.substr(2);
texc=texc.substr(2);
return [tid,tinc,texc];
}
function taxTaxAppliedRawAmt(i,p,ccr)
{
var exT = this.exTax(i,p);
var inT = exT+this.allAmt(i,p);
if (ccr != null && ccr!=0) {
inT /= ccr;
exT /= ccr;
}
var ret = 0;
if (this.isEmpty(i)||Math.abs(exT)>=Math.abs(inT)) { ret = inT; }
else {
if (this.showBoth && Math.abs(inT)>Math.abs(exT)) {
ret = this._tax.get(i).incTax ? inT : exT;
}
else {
ret = p;
}
}
return ret;
}
function taxList(taxes)
{
var a=taxes.split(',');
var ret = new Array();
for (i=0; i<a.length; i++) {
if (!this.regnRate(a[i])) continue;
var t=this._tax.get(a[i]);
if (t=='') continue;
ret[ret.length] = t;
}
return ret;
}
function taxAllCodes(uadd)
{
var s = '';
var _t = this._tax.start();
uadd=uadd||false;
while (_t!=null) {
if(_t.additive==uadd) s += _t.code + ',';
_t  = this._tax.next();
}
return s;
}
function taxAllIDs(uadd)
{
var s = new Array();
var _t = this._tax.start();
uadd=uadd||false;
while (_t!=null) {
if(_t.additive==uadd)s.push(_t.id);
_t = this._tax.next();
}
return s.join(',');
}
function taxShip(amt)
{
if (amt!=null) this._stax=amt;
return this._stax?this._stax:0;
}
function taxCntInc(items) {
var itm=items.start();
var a;
while (itm!=null) {
a=itm.taxes.split(',');
for (var j=0; j<a.length; j++)
if (a[j]&&this._tax.get(a[j])&&this._tax.get(a[j]).incTax&&this._tax.get(a[j]).perc>0) return true;
itm=items.next();
}
return false;
}
function taxIsEmpty(i,rcode) {
var a=i.split(',');
for (var j=0; j<a.length; j++) {
if(!a[j])continue;
var tax=this._tax.get(a[j]);
if (rcode) {
if (tax&&tax.perc>0){
var ad=false, t = tax.code.split(',');
for(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}}
if(ad) return false;
}
} else {
if (tax&&tax.perc>0) return false;
}
}
return true;
}
function taxResetCache() {
for (var i = 0, tl = this._tax; i < tl.cnt(); i++) {
tl.get(i).cache = 0;
}
}
var frPrArr={};
frPrArr['fr']=[];
function freeBasket(bsk)
{
this._add	= fb_Add;
this.bsk	= bsk;
this.fqnty	= fbQnty;
this.fprod	= fbProd;
this.add	= fbAdd;
this.clear	= fbClear;
this.overall	= fbOverall;
this.checkBasket=fbCheckBasket;
this.delByPr	=fbDelByPr;
this.getTitles	=fbGetTitles;
this.clear();
}
function fbClear()
{
this.items = new dynObj('item');
}
function fb_Add(id, qnty, title, weight,price, prdc,imgid)
{
var tmp = this.items.get(id);
prdc=prdc.replace('%%P','');
if (tmp==''){
var prc=price;
this.items.eAdd(id, new Array(this.bsk,id,tf.content.document,parseFloat(qnty),prc,title,parseFloat(weight),prdc,'','','','',imgid));
}
else tmp.quantity = qnty;
}
function fbGetTitles(ids,del) {
var ret=''; if (!del) del=',';
for (var i=0,a=frPrArr[tf.lang],l=a.length; i<l; i++) {
if (ids.indexOf(a[i][0])==-1) continue;
ret+=del+a[i][1];
}
return ret.substr(1);
}
function fbQnty(val, itm, disp)
{
if (disp) return ld('LD_FREE_QUANTITY', '')+ ':  ' + val + ' x ' + itm.title;
this._add(itm.id+"|"+itm.id, parseFloat(val), itm.title, itm.weight(), itm.price, itm.itemNo, itm.pimg);
}
function fbProd(val,itm,disp)
{
if (!val) return '';
var str = ld('LD_FREE_PRODUCT', '');
var freeqnty=val[0]; val=val[1];
var z=0;
for (var i=0,a=frPrArr[tf.lang],l=a.length; i<l; i++) {
if (val.indexOf(a[i][0])==-1) continue;
z=1;
if (disp) str += '<br>  '+freeqnty+' x ' + a[i][1];
else {
pid=(itm.id)?itm.id:'shop';
this._add(pid+"|"+a[i][0], freeqnty, a[i][1], a[i][2],a[i][3],a[i][4],a[i][5]);
}
}
return (z)?str:'';
}
function fbAdd(itm, disc, stk, disp)
{
var qnty=(typeof(itm)=='object')?itm.quantity:0;
if (typeof(itm)=='number') qnty=itm;
var free = (disc)?disc.free(qnty):null;
if (!free) return '';
if (disp==null) disp=0;
switch(disc.type) {
case '2': return this.fqnty(free, itm, disp);
case '3': case '103': return this.fprod(free, itm, disp);
}
return '';
}
function fbOverall(type)
{
var ret = 0, useDec = 0;
for (var i=0; i<this.items.cnt(); i++) {
var itm = this.items.get(i);
switch (type) {
case 'weight':	 ret += itm.weight() * itm.quantity; break;
case 'quantity': ret += itm.quantity; break;
case 'quantityround': ret += itm.quantity; if(itm.useDec>0) useDec=1; break;
default: break;
}
}
if(type == 'quantityround')
ret = (useDec)?Math.round(ret*100)/100:Math.round(ret);
return ret;
}
function fbCheckBasket(id) {
var i=this.items.start();
while (i!=null) {
if (i.id.split('|')[0]==id) return 1
i=this.items.next();
}
return 0;
}
function fbDelByPr(id) {
var delArr=new Array();
var it=new SF_Iterator(this.items); var i=it.start();
while (i!=null) {
if (i.id.split('|')[0]==id) delArr[delArr.length]=i.id;
i=it.next();
}
for (var i=0; i<delArr.length; i++) {
this.items.del(delArr[i]);
}
}
function basket(name)
{
this.name  = (name!=null)?name:'';
this.items = new dynObj('item');
this.stk   = new dynObj('stock');
this.disc  = new dynObj('discount');
this.gdisc = new dynObj('discount');
this.ship  = new dynObj('keyval');
this.fbsk  = new freeBasket(this);
this.tax   = new tax();
this.cache = {};
this.chk_total=0;
this.chk_total_tax=0;
this.chk_total_nopmsurcharge=0;
this.chk_pmsurcharge=0;
this.chk_pmsurchargetax=0;
this.chk_pmsurchargeIsIncTax=0;
this.chk_tax_noshiptax=0;
this.chk_tax_ship=0;
this.chk_disc_novoucher=0;
this.decodeState = 'initialised';
this.parse	= bskParse;
this.createTemp = bskCreateTemp;
this.add	= bskAdd;
this.del	= bskDel;
this.save	= bskSave;
this.load	= bskLoad;
this.encode	= bskEncode;
this.decode	= bskDecode;
this.shpP	= 0;
this.shDisc	= bskShDisc;
this.updQnty	= bskUpdQnty;
this.total	= bskTotal;
this.ckOut	= bskCkOut;
this.hasDisc	= bskHasDisc;
this.overall	= bskOverall;
this.shipPrice	= bskShpPrice;
this.noShip	= bskNoShp;
this.shipMeths	= bskShpMeths;
this.pShip	= bskPShip;
this.searchTaxes= bskSearchTaxes;
this.hasTaxAtCountyLevel = bskHasTaxAtCountyLevel;
this.invalidate = bskInvalidate;
this.getTaxIDs	= bskGetTaxIDs;
this.refreshTotal=bskRefreshTotal;
this.plusTaxTexts = bskPlusTaxTexts;
this.plusShipTaxTexts = bskPlusShipTaxTexts;
this.calcTotal = bskCalcTotal;
this.clearBsk	= bskClearBsk;
this.updDecodeState = bskUpdDecodeState;
this.itemsTemporary = new dynObj('item');
this.merge=bskMerge;
this.hasOnlyRequests = bskHasOnlyRequests;
this.groupByCode = bskGroupByCode;
}
function bskParse(id,doc,qnty,title,weight,itemNo,useDec,esd,taxes,opts,prdc,manc,dstc,prcc,ship,restoring,temp,type)
{
var price=0;
function cf(i,d,sd,s,t,st){
currentItem	= i;
var dcf		= doc.cf_popup;
tf.load('conf.html','conf',true);
tf.load('grey.html','shipping');
var wnd=tf.content;
wnd.sfAddRef={core:window,item:i,stock:st,options:opts,pdoc:doc}
return false;
}
var stkEn=0,p=tf.wm.pProp(id);
if(!p)return alert('Error: 0x00CEFF');
var price=parseFloat(p[1]);
if(!weight)weight=parseFloat(p[10]);
var itm=this.items.empty();
itm.init(this,id,doc,qnty,price,title,weight,itemNo,useDec,esd,taxes,prdc);
itm.makeRequest(type);
var chk=itm.addOpt(opts,doc);
if(chk!=''){
tf.content.sfAddUnpop();
if(chk!=' ')return alert(LD.LD_OPTION_ERROR_FIELDS+'\n'+chk);
if(!confirm(LD.LD_CHOOSE_OPTIONS))return -1;
}
else{
itm.optPrice = p['optPrice']||0;
}
var stkItm=this.items.empty();
stkItm.init(this,id,doc,qnty,price,title,weight,itemNo,useDec,esd,taxes,prdc);
stkItm.addOpt(opts,doc);
var stkItmNo=stkItm.getItemNo(),pstk=tf.wm.pProp(stkItmNo);
if(typeof(pstk)=='undefined')pstk=p;
var smin=pstk[2],smax=pstk[3],savail=pstk[4],st='';
if (stkItmNo){
var stk=Basket.stk.eAddS(stkItmNo,[smin,smax,savail,prdc,manc,dstc,prcc]);
stk.avail=useDec>0?parseFloat(savail):parseInt(savail);
var stkopts=stkItm.options;
for (var i=0;i<stkopts.cnt();i++){
var opt=stkopts.get(i);
if(opt.choice()==''||opt.combine||!opt.optId())continue;
var pstkopt=tf.wm.pProp(opt.optId());
if(pstkopt){
var stkopt=Basket.stk.eAddS(opt.optId(),[pstkopt[2],pstkopt[3],pstkopt[4],manc,dstc,prcc]);
stkopt.avail=useDec>0?parseFloat(pstkopt[4]):parseInt(pstkopt[4]);
}
}
}
var disc = Basket.disc.eAdd(itm.id,[p[5], p[6], p[7]]);
if (!opts && doc && disc) {
disc.type = p[5];
disc.value = p[6];
disc.tlim = p[7];
}
var ship = Basket.ship.eAdd(itm.id,[itm.id, p[8]]);
if(this.name != ''){
if(title!=''){this.add(itm);}
else this.add(itm);
return null;
}
if (title!='' && !cf(itm, disc, this.shDisc(), stk, this.tax, st)) return 0;
if (!this.add(itm)) return 0;
return 1;
}
function bskCreateTemp(id,doc,opts,qnty,title,weight,itemNo,useDec,esd,taxes,prdc,showAlert,forcecreate){
var p=tf.wm.pProp(id);
if(!p)return alert('Error: 0x00CEFF');
var price=parseFloat(p[1]);
if(!weight)weight=parseFloat(p[10]);
var itm=this.itemsTemporary.empty();
itm.init(this,id,doc,qnty,price,title,weight,itemNo,useDec,esd,taxes,prdc,null,true);
var chk=itm.addOpt(opts,doc);
if(chk!=''){
tf.content.sfAddUnpop();
if(showAlert){
if(chk!=' ')return alert(LD.LD_OPTION_ERROR_FIELDS+'\n'+chk);
if(!confirm(LD.LD_CHOOSE_OPTIONS))return -1;
}
else if(!forcecreate){
return null;
}
}
else itm.optPrice = p['optPrice']||0;
return itm;
}
function bskAdd(itm)
{
var stk=this.stk.getS(itm.getItemNo());
var items=this.items,l=items.cnt();
for (var i=0; i<l; i++) {
var tmp = items.get(i);
if (!itm.isSame(tmp)) continue;
tmp.transfer(itm);
items.del(i)
break;
}
items.add(itm);
if(this.name==''&&stk){
stk.update(itm);
tf.core.stkQryState['arrQS'][tf.pgidx]=tf.qsStkQry;
tf.nametag.add('stkQryState',tf.sfJSON.stringify(tf.core.stkQryState));
}
itm.cache=[];
this.cache['itmGrp']={};
if(this.decodeState=='complete'){
if(this.name==''){
this.calcTotal(tf.ship_obj);
rl_total();
}
this.save();
}
$(this).trigger('Add', [itm.getItemNo(), itm]);
return 1;
}
function bskDel(idx)
{
var itm = this.items.get(idx);
if (itm == '') return '';
this.items.del(idx);
this.tax.resetCache();
this.cache['itmGrp']={};
if (this.fbsk&&this.name=='') {
this.fbsk.delByPr(itm.id);
this.fbsk.delByPr('shop');
this.fbsk.add(this.total(), this.shDisc(), null, 0);
}
if(this.name==''){
this.calcTotal(tf.ship_obj);
rl_total();
}
this.save();
}
function bskUpdQnty(idx, qnty)
{
var itm = this.items.get(idx);
var tmp = itm.quantity,qty=(itm.useDec>0?parseFloat(qnty):parseInt(qnty));
if (isNaN(qty)||qty<0) qty=tmp;
if (qty==0) {this.del(idx); return;}
var stk=this.stk.getS(itm.getItemNo());
// Subtract old quantity from stock
itm.quantity=qty;
if(stk){
stk.update(itm);
}		// Update new quantity to stock
itm.cache=new Array();
this.cache['itmGrp']={};
if(this.name==''){
this.calcTotal(tf.ship_obj);
rl_total();
}
this.save();
this.ckOut();
}
function bskTotal(type, nocache, incAll)
{
var apply_dsc=true;
if (type=='orig') {apply_dsc=false; type=''}
if (type==null) type='';
this.groupByCode(this.shDisc.limitToCodeType);
var idxs = null, includeAll = (typeof(incAll) == 'undefined'  || incAll);
var tot=0,prprice=0,purtot=0,n=0;
var items=this.items,i=items.start();
while (i!=null) {
var include = includeAll;
var tot1 = i.calc(type, null, nocache);
if (!i.requestQuote&&!i.requestSample) tot += tot1;
purtot+=i.cache['pur'+i.quantity];
if (type=='tax') prprice+=(i.getGDsc()||i.parent.shDisc()?i.calc('dsc', null, nocache):i.calc('ndc', null, nocache));
i = items.next();
n++;
}
var shDisc=this.shDisc();
if((type==''||type=='pur'||type=='inc')&&apply_dsc&&this._shDisc){tot-=shDisc.purchasePrice(tot);}
if((type=='exc'||type=='exc_noround')&&apply_dsc&&this._shDisc)tot-=shDisc.purchasePriceByPrice(tot,purtot);
if(type=='tax'&&apply_dsc&&this._shDisc) {
tot-=shDisc.purchasePriceByPrice(tot,prprice);
}
return tot;
}
function bskHasDisc()
{
return this.total('damt');
}
function bskShDisc(type, val, tLim, del1, del2, limitToCodeType, limitToCodes)
{
if (type==null||type=='') return this._shDisc;
if (this._shDisc==null) this._shDisc=this.disc.eAdd('shop', [type,val,tLim,null,null,limitToCodeType,limitToCodes]);
return this._shDisc;
}
function bskOverall(type, ckOut, incAll)
{
var ret = 0, useDec = 0, includeAll = (typeof(incAll) == 'undefined' || incAll);
if(type=='pmsurcharge'){
ret=this.chk_pmsurcharge
return ret;
}
else if(type=='pmsurchargetax'){
if(this.chk_pmsurchargeIsIncTax)ret=this.chk_pmsurchargetax;
else ret=0;
return ret;
}
var idxs = null;
for (var i=0; i<this.items.cnt(); i++) {
var itm = this.items.get(i), p = tf.wm.pProp(itm.id);
var include = includeAll || ((!itm.requestQuote && !itm.requestSample) || (itm.requestSample && p && parseInt(p[21/*requestSample_IncludeShippingCost*/])));
switch (type) {
case 'weight'  :
if (include) ret += itm.weight() * itm.quantity;
break;
case 'quantity':
if (include) ret += itm.quantity;
break;
case 'quantityround':
if (include) ret += itm.quantity; if(itm.useDec>0) useDec=1;
break;
default: break;
}
}
if (ckOut != null) return ret;
this.ckOut();
ret += this.fbsk.overall(type);
if(type == 'quantityround')
ret = (useDec)?Math.round(ret*100)/100:Math.round(ret);
return ret;
}
function bskCkOut()
{
this.fbsk.clear();
for (var i=0; i<this.items.cnt(); i++) {
var itm = this.items.get(i);
var dsc = this.disc.get(itm.id);
var stk = this.stk.getS(itm.getItemNo());
this.fbsk.add(itm, dsc, stk);
}
this.fbsk.add(this.total(), this._shDisc);
}
function bskShpPrice(shp_obj, ckOut, inc)
{
if (shp_obj && typeof(shp_obj)=='object')this.shp_obj=shp_obj;
if (shp_obj!=null) {
if (shp_obj.cost==null) return 0;
var e = 0;
var t = this.total('tax', true);
var p = this.total('exc', true);
var pur = this.total(null, true);
var w = this.overall('weight', ckOut);
var q = this.overall('quantity', ckOut);
var s = 0;
if (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));
this.shpP = (s==null||s<0)?0:s+this.pShip(shp_obj.cLink.mid,inc);
this.tax.ship(shp_obj.tax(this.shpP, p));
}
return parseFloat(this.shpP);
}
function bskNoShp()
{
var itm = this.items.start();
var ps  = new Array();
while (itm) {
var tmp = itm.shipMth();
for (var i in tmp) if (i) ps[i]=(typeof(ps[i])=='undefined'?(!parseInt(tmp[i])):(ps[i]&&!parseInt(tmp[i])));
itm = this.items.next();
}
return ps;
}
function bskShpMeths()
{
if (!tf.shipping || !tf.shipping.ship) return;
var ps = [], fap = tf.shipping.ship.forAllProds;
for (var i in fap) {
ps[i] = 0;
}
var itm = this.items.start(), high = 0;
while (itm) {
var itmMth = itm.shipMth(), yes = 0;
for (var i in fap) {
if (typeof(itmMth[i]) == 'undefined') yes = fap[i];
else if (parseInt(itmMth[i]) == 1) yes = 1;
else yes = 0;
ps[i] += yes;
if (ps[i] > high) high = ps[i];
}
itm = this.items.next();
}
for (var i in ps) {
if (ps[i] < high) delete ps[i];
}
return ps;
}
function bskPShip(mid,inc)
{
if(!mid)return 0;
var loc=-1;
if (tf.core&&tf.core.region){
var cnt=this.shp_obj.links.length,code=core.region;
if(code.length>4)code=code.substring(0,4);
var rgnLen=Math.min(core.shopRegion.length,code.length);
for(var i=0;i<cnt;i++){
var lk=this.shp_obj.links[i];
if(lk.mid==mid&&lk.zip[code]!=null){
loc=(core.shopRegion.indexOf(code.substr(0,rgnLen))==0?2:3);
break;
}
}
}
if(loc==-1)return 0;
var e	= 0;
var itm = this.items.start();
while (itm) {
var n=itm.shipMth(mid, loc);
if(typeof(inc)=='undefined'){
var rgnCde=core.region;len=rgnCde.length-(rgnCde.length%2);
for(var l=len;l>0;){
if(typeof(core.STax.mapRegn[rgnCde])!='undefined'){e+=n;break;}
l-=2;
rgnCde=rgnCde.substring(0,l);
}
if(l==0)e+=core.STax.exTax(itm.taxes,n);
}
else{e+=(inc?n:core.STax.exTax(itm.taxes,n));}
itm = this.items.next();
}
return e;
}
function bskSearchTaxes(rcode)
{
var it = new SF_Iterator(this.items),i=it.start();
while (i!=null) {
if (i.taxes!='') {
if (!this.tax.isEmpty(i.taxes,rcode)) return true;
}
i = it.next();
}
return false;
}
function bskHasTaxAtCountyLevel(statecode)
{
var it = new SF_Iterator(this.items),i=it.start(),has=false;
while (i!=null&&i.taxes!='') {
var a=i.taxes.split(',');
for (var j=0,jmax=a.length; j<jmax; j++) {
if(!a[j])continue;
var tax=this.tax._tax.get(a[j]);
if (tax&&tax.perc>0){
var t=tax.code.split(',');
for(var k=0,kmax=t.length;k<kmax;k++){if(t[k].indexOf(statecode)==0 && t[k].length>statecode.length){has=true;break;}}
}
}
i = it.next();
}
return has;
}
function bskGetTaxIDs()
{
var it	= new SF_Iterator(this.items),i=it.start(),ret=new Array();
while (i!=null) {
var a=i.taxes.split(',');
for (var j=0;j<a.length;j++) {
if(ret.join(',').indexOf(a[j])==-1) ret[ret.length]=a[j];
}
i=it.next();
}
return ret.join(',');
}
function bskInvalidate() {
this.cache={};
var it=new SF_Iterator(this.items),i=it.start();
while (i!=null) {
i.cache=[];
i=it.next();
}
}
function bskCalcTotal(shipObj){
var ppur,ppur_ex,shp,ttax,shp_asis,shtaxex,taxonshp,tax,t,bsk=this;
if(shipObj){
ppur=bsk.total();
ppur_ex=bsk.total('exc');
shp=bsk.shipPrice(shipObj);
ttax=(ppur>0.001)?bsk.total('tax'):0;
shp_asis=bsk.shipPrice(shipObj,null,1);
var tid=tf.core.STax.allIDs();
if(shipObj._ttype==1)tid=tf.core.BTax.findMajorityTaxID(core.BTax.currRegn())||tid;
shtaxex=tf.core.STax.exTax(tid,shp_asis);
taxonshp=(ppur>0.001)?shipObj.tax(shp_asis,ppur_ex,null,shtaxex):0;
tax=ttax+taxonshp;
if(ppur_ex!=ppur){
t=ppur+shp+(shp_asis==shtaxex?taxonshp:0);
if((ppur-ppur_ex)>0.01){
var tmp=tax-(ppur-bsk.total('exc_noround'))-(shp_asis==shtaxex?taxonshp:shp_asis-shtaxex);
if(Math.abs(tmp)>=0.01)t+=Math.round(tmp);
}
}
else
t=ppur_ex+tax+shtaxex;
}else{
ppur_ex=bsk.total('exc');
ttax=bsk.total('tax');
t=ppur_ex+ttax;
}
bsk.chk_total_novoucher=core.nfmt.roundTotal(t,tf.shopCurrency.iso);;
t=core.nfmt.roundTotal(t,tf.shopCurrency.iso);
bsk.chk_total=t;
bsk.chk_total_tax=tax;
bsk.chk_total_nopmsurcharge=bsk.chk_total;
bsk.chk_pmsurcharge=0;
bsk.chk_pmsurchargetax=0;
bsk.chk_pmsurchargeIsIncTax=true;
if(core.pmKey&&core.pmKey!='--'&&pm.dataidx[core.pmKey]){
var surcharge=pm.dataidx[core.pmKey]['surcharge'];
if(surcharge){
if(isNaN(surcharge)&&surcharge.indexOf('%')>0)surcharge=t*parseFloat(surcharge)/100;
else surcharge=parseFloat(surcharge);
surcharge=core.nfmt.round(surcharge);
bsk.chk_pmsurcharge=surcharge;
bsk.chk_total+=bsk.chk_pmsurcharge;
if (pm.persist.showSurchargeTax) {
var oTax=core.Basket.tax,taxids=oTax.allIDs();
var excSurchargeTax=(oTax.calcTax(taxids,surcharge)==oTax.exTax(taxids,surcharge));
var surchargetax=oTax.allAmt(taxids,surcharge);
bsk.chk_pmsurchargetax=surchargetax;
bsk.chk_pmsurchargeIsIncTax=!excSurchargeTax;
bsk.chk_total+=(excSurchargeTax?surchargetax:0);
}
}
}
bsk.chk_tax_noshiptax=ttax;
bsk.chk_tax_ship=taxonshp;
return [ppur,shp,shtaxex,bsk.chk_total,bsk.chk_pmsurcharge,bsk.chk_pmsurchargetax];
}
function bskRefreshTotal(dd){
if(LD&&tf.content&&tf.utils) {
if(tf.conf&&tf.conf.greySettings)tf.conf.greySettings();else return;
if(this.items.cnt()==0&&!tf.isSFXTheme){
tf.sfMakeSpace.go(true,'','MiniCart');
}
else {
if(confLoaded){
function MiniCartTotalAmount(o){
if(!tf.shipping)return '';
if(showPlusDoneTax==-1)showPlusDoneTax=getShowPlusDoneTax(o);
var a=o.calcTotal(tf.shipping.ship), s='';
if(showPlusDoneTax==true){
s='&nbsp;'+showPrc(o.chk_total,0);
}
else {
s='&nbsp;'+showPrc(a[0],0);
}
return s;
}
var showPlusShipping=-1,showPlusTax=-1,showPlusDoneShipping=-1,showPlusDoneTax=-1,taxTexts=[];
function getShowPlusShipping(o){
return true;
}
function getShowPlusTax(o){
if(showPlusDoneTax==-1)showPlusDoneTax=getShowPlusDoneTax(o);
var t={};
o.plusTaxTexts(t,taxTexts,showPlusDoneTax)
return t.length > 0;
}
function getShowPlusDoneShipping(o){
return (tf.core.regionChanged&&(tf.core.method!='--'&&tf.core.method!=''));
}
function getShowPlusDoneTax(o){
return tf.core.regionChanged;
}
if(!tf.core.regionChanged){
var regionChanged=true;
var itm=this.items.start(),regn=tf.core.region||this.tax.getDefaultReg();
while (itm!=null) {
var a=itm.taxes.split(',');
for (var j=0,jj=a.length; j<jj; j++){
var _t=this.tax._tax.get(a[j]);
if(_t&&this.tax.regnRate(_t.id,regn)&&!_t.incTax){regionChanged=false;}
}
itm=this.items.next();
}
if(regionChanged){
if(tf.shipping&&tf.shipping.ship&&tf.shipping.ship.method.cnt()==1){
tf.core.method=tf.shipping.ship.method.get(0)._id;
}
}
}
var dd=dd||tf.content.document;
var arr={
MiniCartTotalAmount:function(o){return MiniCartTotalAmount(o);},
MiniCartTotalSummary:function(o){return o.overall('quantity')+' '+LD.LD_ITEMS+' = '+MiniCartTotalAmount(o);},
MiniCartTotalItemsQuantity:function(o){return o.overall('quantityround');},
MiniCartTotalItemsQuantity_Mobile:function(o){return o.overall('quantity');},
MiniCartTotalTotalText:function(o){
if(tf.miniCartHandler&&tf.miniCartHandler.shippingChargeHandler)return;
if(showPlusDoneShipping==-1)showPlusDoneShipping=getShowPlusDoneShipping(o);
if(showPlusDoneTax==-1)showPlusDoneTax=getShowPlusDoneTax(o);
return (showPlusDoneShipping==true&&showPlusDoneTax==true ? LD.LD_TOTAL : LD.LD_SUBTOTAL);
},
MiniCartTotalPlusExpenses:function(o){
if(tf.miniCartHandler&&tf.miniCartHandler.shippingChargeHandler)return;
return '<a href="#" class="ImgLink" onclick="cancelBuble(event);sfAddPop(\'shipping_charge\',true);sfAddRef[\'core\']={};return false;">' + fnMiniCartTotalPlusExpensesText(o) + '</a>';
},
MiniCartTotalPlusExpensesText:function(o){
if(showPlusDoneShipping==-1)showPlusDoneShipping=getShowPlusDoneShipping(o);
if(showPlusDoneTax==-1)showPlusDoneTax=getShowPlusDoneTax(o);
if(showPlusShipping==-1)showPlusShipping=getShowPlusShipping(o);
if(showPlusTax==-1)showPlusTax=getShowPlusTax(o);
if(showPlusShipping!=true&&showPlusTax!=true&&showPlusDoneShipping!=true&&showPlusDoneTax!=true)return '';
var HTML=[],HTML2=[];
if((showPlusDoneTax==true||showPlusTax==true)&&taxTexts.length>0)HTML.push(taxTexts.join(', '));
if(showPlusShipping==true)HTML.push((showPlusDoneShipping==true?LD.LD_INC+' ':'+')+LD.LD_SHIPPING_CHARGES);
if(HTML.length>0){
HTML2.push('<span id="PlusExpensesText">');
HTML2.push(HTML.join(', '));
HTML2.push('</span>');
}
return HTML2.join('');
},
MiniCartTotalList:function(o){
var HTML=[],itms=o.items,itFree=new core.SF_Iterator(o.fbsk.items);
for (var i=0,num=itms.cnt(); i<num; i++) {
var itm = itms.get(i);
var vars={
'ProductQuantity':itm.quantity,
'ProductTitle':itm.title,
'ProductPrice':showPrc(itm.calc(),0),
'ProductImage':'src="'+(itm.pimg!=''?itm.pimg:tf.wm.url('../media/trans.gif','-'))+'"',
'ProductURL':'href="'+(unescape(itm.purl).replace('#'+itm.id.toLowerCase(),''))+'#'+itm.id.toLowerCase()+'"'
};
HTML.push(tf.utils.tmplParser.parse(tfcd.getElementById('tmplMiniCartTotalList'), vars));
var idtag=(isNaN(itm.id)?'_':'')+itm.id,iFree=itFree.start();
while(iFree!=null) {
if(iFree.idtag.split("|")[0]==idtag) {
vars={
'ProductQuantity':iFree.quantity,
'ProductTitle':iFree.title,
'ProductPrice':LD.LD_FREE,
'ProductImage':'src="'+(tf.isEntryPage?'contents/media/':'')+(iFree.pimg!=''?iFree.pimg:'../media/trans.gif')+'"'
};
HTML.push(tf.utils.tmplParser.parse(tfcd.getElementById('tmplMiniCartTotalFreeList'), vars));
}
iFree=itFree.next();
}
}
var iFree=itFree.start();
while(iFree!=null) {
if(iFree.idtag.split("|")[0]=='_shop') {
vars={
'ProductQuantity':iFree.quantity,
'ProductTitle':iFree.title,
'ProductPrice':LD.LD_FREE,
'ProductImage':'src="'+(tf.isEntryPage?'contents/media/':'')+(iFree.pimg!=''?iFree.pimg:'../media/trans.gif')+'"'
};
HTML.push(tf.utils.tmplParser.parse(tfcd.getElementById('tmplMiniCartTotalFreeList'), vars));
}
iFree=itFree.next();
}
return HTML.join('');
}
};
var fnMiniCartTotalPlusExpensesText=arr['MiniCartTotalPlusExpensesText'];
for(var n in arr){
tf.content.$('.'+n).html(arr[n](this));
var el=dd.getElementById(n);
if(el){el.innerHTML=arr[n](this);}
}
tf.content.$('.MiniCartLink, #MiniCartLink').attr('href', tf.wm.url('basket.html','-',true));
}
tf.sfMakeSpace.go(true,'','MiniCart');
}
if(tf.miniCartHandler&&tf.miniCartHandler.refreshEnd)tf.miniCartHandler.refreshEnd();
if(tf.autoText)tf.autoText.apply('ancestorGC');
if(tf.equalHeight)tf.equalHeight();
if(tf.isInDesigner()){tf.parent.applyColorScheme(tf);}
}
}
function bskPlusTaxTexts(t,aTaxTexts,showPlusDoneTax,onlyInc,incTT) {
var itm=this.items.start(),regn=(showPlusDoneTax==true?null:tf.core.region||this.tax.getDefaultReg());
t.length=0;
var oaTaxTexts={},oincTT={};
while (itm!=null) {
var a=itm.taxes.split(',');
for (var j=0,jj=a.length; j<jj; j++){
var _t=this.tax._tax.get(a[j]);
if(_t&&typeof(t[_t.id])=='undefined'){
if(onlyInc&&!_t.incTax)continue;
if(this.tax.regnRate(_t.id,regn)){
t[_t.id]=1;
t.length++;
if(!showPlusDoneTax){
if(tf.core.tsIx[_t.id])oaTaxTexts[tf.core.tsIx[_t.id]]=true;
}
else {
if(_t.incTax&&tf.core.tsI[_t.id])oaTaxTexts[tf.core.tsI[_t.id]]=true;
if(!_t.incTax&&tf.core.tsIx[_t.id])oaTaxTexts[tf.core.tsIx[_t.id]]=true;
}
if(incTT&&tf.core.tsI[_t.id])oincTT[tf.core.tsI[_t.id]]=true;
}
}
}
itm=this.items.next();
}
for(var s in oaTaxTexts){aTaxTexts.push(s);}
for(var s in oincTT){incTT.push(s);}
}
function bskPlusShipTaxTexts(t,aTaxTexts,showPlusDoneTax,onlyInc,incTT) {
var _stax=tf.core.STax;
var regn=(showPlusDoneTax==true?null:tf.core.region||_stax.getDefaultReg());
t.length=0;
var oaTaxTexts={},oincTT={};
for (var tid in tf.core.tsshI) {
if(tid=='length')continue;
var _t=_stax._tax.get(tid);
if(_t&&typeof(t[_t.id])=='undefined'){
if(onlyInc&&!_t.incTax)continue;
if(_stax.regnRate(_t.id,regn)){
t[_t.id]=1;
t.length++;
if(!showPlusDoneTax){
if(tf.core.tsshIx[_t.id])oaTaxTexts[tf.core.tsshIx[_t.id]]=true;
}
else {
if(_t.incTax&&tf.core.tsshI[_t.id])oaTaxTexts[tf.core.tsshI[_t.id]]=true;
if(!_t.incTax&&tf.core.tsshIx[_t.id])oaTaxTexts[tf.core.tsshIx[_t.id]]=true;
}
if(incTT&&tf.core.tsshI[_t.id])oincTT[tf.core.tsshI[_t.id]]=true;
}
}
}
for(var s in oaTaxTexts){aTaxTexts.push(s);}
for(var s in oincTT){incTT.push(s);}
}
function bskClearBsk() {
this.stk   = new dynObj('stock');
this.items = new dynObj('item');
this.fbsk  = new freeBasket(this);
}
function load_price(args)
{
var all = args[1],inTempBsk=(args[2]!=false);
for (var i=0, num=all.length; i<num; i++) {
var itm = all[i];
args[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));
if (itm['optPrice'] && typeof (args[0].items.getS(itm.id)) == 'object')
args[0].items.getS(itm.id).optPrice = itm['optPrice'];
}
var complete=args[0].updDecodeState();
if(complete){
for(var o in tf.wm._pArr)if(tf.wm._pArr[o].optPrice)delete tf.wm._pArr[o].optPrice;
tf.core.stkFetchBulk(function(){}, function(){});
if(tf.isFavoritesPage)tf.fillBasketTable();
if(args[0].name==''){
args[0].calcTotal(tf.ship_obj);
rl_total();
}
args[0].save();
$(document).trigger('_sfEvt_bskLoad_Complete');
}
}
function loadPricesForIDs(is)
{
if(!tf.utils||!tf.utils.prpgmap||!tf.core){setTimeout(function(){loadPricesForIDs(is);},100);return;}
function _L(f,prid,pgid){
idcnti++;
var myf=f.split('_');
if(myf.length==3&&myf[1]=='Page')myf=f.replace(/\.html/,'_');else myf=f.replace(/(_\d\d)?\.html/,'_$1');
var p=tf.lang+'/'+myf.replace(/&#44;/g,',').replace(/&#45;/g,'-');
if (!pg[p])pg[p] = [];
pg[p]=pg[p].concat(f);
if(idcnti==expectedidcnt){
if(tf.isInSFClassic()){
for(var i in pg){tf.core.scr.load(f, i);tf.utils.populateCrossPromotionPrice();}
}
else{
for(var i in pg){tf.core.load_page(i, 'tf.utils.populateCrossPromotionPrice', null);}
}
}
}
var pg = [], idtmp = {}, expectedidcnt = 0, idcnti = 0;
for (var i=0,ii=is.length;i<ii;i++) {
var id=is[i][0];
if (!tf.wm.pProp||!tf.wm.pProp(id)) {
if(!idtmp[id]){expectedidcnt++;idtmp[id]=true;}
}
}
if(expectedidcnt==0)tf.utils.populateCrossPromotionPrice();
for (var id in idtmp){
tf.utils.prpgmap.getParentPage(id,'',_L);
}
}
function bskSave()
{
if(tf.isInSF())return;
tf.saveBskToName();
if (getCookStr('storebasket')!='1'&&this.name!='Favorite') return;
var ck = '';
var ckName = this.name; if (!ckName) ckName='ADDRESS';
if (this.items.cnt()>0) {
ck = this.encode();
var pck=place(ck);
ck = pck + "TEST" + add(pck);
}
if (this.name!='')savCookStr(ckName, ck, -1);
else savCookStr(ckName, ck, '1');
this.shpP = 0;
tf.nametag.add('askRestoreBsk','false');
}
function bskLoad()
{
if(tf.isInSF()){tf.bskLoaded=true;return;}
$(document).trigger('_sfEvt_bskLoad_Begin');
tf.loadBskFromName();
if(getCookStr('storebasket')!='1'&&this.name!='Favorite'){this.decodeState='complete';return;}
var ckName = this.name; if (!ckName) ckName='ADDRESS';
var arr = getCookStr(ckName).split("TEST"),askAgain=true;
if ((tf.nametag.get('askRestoreBsk') != 'false' || this.name) && arr.length == 2 && add(arr[0]) == arr[1]) {
askAgain=false;
if (this.name!='' || confirm(shopName+':\n\n'+LD.LD_LOAD_BASKET+'  '+this.name)){
var sa=show(arr[0]);
this.decode(sa);
}
else{
savCookStr(ckName, "", '1');
this.decodeState='complete';
}
}
else {
rl_total();
this.decodeState='complete';
$(document).trigger('_sfEvt_bskLoad_Complete');
}
if(!askAgain)tf.nametag.add('askRestoreBsk','false');
}
function bskEncode()
{
var is=[];
for (var i=0,ii=this.items.cnt(); i<ii; i++) {
var itm = this.items.get(i);
if(itm.temporary)continue;
is.push(itm.code());
}
return '['+is.join('~')+']';
}
function bskDecode(str,decodeOnly)
{
var s = str.substring(1,str.length-1), sa = s.split(']['), is = sa[0].split('~');
function _L(f,prid,pgid){
pgcnti++;
var myf=f.split('_');
if(myf.length==3&&myf[1]=='Page')myf=f.replace(/\.html/,'_');else myf=f.replace(/(_\d\d)?\.html/,'_$1');
var p=tf.lang+'/'+myf.replace(/&#44;/g,',').replace(/&#45;/g,'-');
if (!pg[p]){thisBsk.expectedpgcnt++;pg[p] = [];}
pg[p]=pg[p].concat(pgtmp[prid]?pgtmp[prid]:pgtmp[f]);
if(pgcnti==expectedpgcnt){for(var i in pg)load_page(i, 'core.load_price', [thisBsk, pg[i], false]);}
}
if(is.length>0)this.decodeState='loading';
var pg = [], pgtmp = {}, expectedpgcnt = 0, pgcnti = 0, thisBsk = this;
for (var i=0,ii=is.length; i<ii; i++) {
var itm = this.items.empty();
itm.code(this,is[i]);
if(decodeOnly){
this.disc.eAdd(itm.id,['','','']);
this.add(itm);
continue;
}
if (tf.wm.pProp(itm.id)) {		// Price already exists
this.parse(itm.id, itm, itm.quantity,'','');
if(itm['optPrice']&&typeof(this.items.getS(itm.id))=='object')this.items.getS(itm.id).optPrice=itm['optPrice'];
}
else {
var jfile=tf.wm.jfile(itm.purl).split('?')[0],id=jfile.replace(/[._].*/,'');
if(window.decodeURIComponent(jfile).substr(0,1)=='#')id=itm.id.toLowerCase();
if(id.substr(0,1)!='p')id=jfile;
if(id=='index.html'||id==='')id='front.html';
if(!pgtmp[id]){expectedpgcnt++;pgtmp[id]=[];}
pgtmp[id].push(itm);
}
}
if(decodeOnly)return;
this.pgcnti=0;
this.expectedpgcnt=0;
for (var jfile in pgtmp){
var id=jfile.replace(/[._].*/,'');
if(id.substr(0,1)=='p'){tf.utils.prpgmap.getParentPage(id,'',_L);}
else _L(jfile,'',id);
}
if(expectedpgcnt==0){
this.decodeState='complete';
for(var o in tf.wm._pArr)if(tf.wm._pArr[o].optPrice)delete tf.wm._pArr[o].optPrice;
tf.saveBskToName();
$(document).trigger('_sfEvt_bskLoad_Complete');
}
}
function bskUpdDecodeState(){
this.pgcnti++;
if(this.pgcnti>=this.expectedpgcnt){
this.decodeState='complete';
delete this.pgcnti;
delete this.expectedpgcnt;
return true;
}
return false;
}
function bskMerge(o,lvl,o2,oTop){
if(isNaN(lvl)){lvl=0;oTop=this;}else if(lvl>10)return;
lvl++;
var oThis=(o2?o2:this);
for (var i in o){
if(i=='parent'||i=='bsk'){oThis[i]=oTop;continue;}
if(typeof(o[i])=='object'&&o[i])
if(o[i]&&!isNaN(o[i].length)){oThis[i]=[];bskMerge(o[i],lvl,oThis[i],oTop);}
else if(oThis[i]&&(oThis[i].gid||o[i].gid)){
for(var oi in o[i]._arr){
if(!o[i]._arr[oi])continue;
if(!oThis[i].getById(o[i]._arr[oi].id)){
var oNew=oThis[i].empty();
bskMerge(o[i]._arr[oi],lvl,oNew,oTop);
oThis[i].add(oNew);
}
else if(i=='items'&&oThis[i]._arr&&!oThis[i]._arr[oi]){
var oNew=oThis[i].empty(),newidtag=oNew.idtag;
bskMerge(o[i]._arr[oi],lvl,oNew,oTop);
oNew.idtag=newidtag;
oThis[i].add(oNew);
}
if(oThis[i]._arr[oi].gid=='item')oThis[i]._arr[oi].parent=oTop;
}
}
else if(i=='fbsk'||i=='tax'){
for(var oo in o[i]){
bskMerge(o[i],lvl,oThis[i],oTop);
}
}
else{oThis[i]=new bskMerge(o[i],lvl,null,oTop);}
else
oThis[i]=o[i];
}
}
function bskHasOnlyRequests(){
var hasOnlyRequests=true;
for (var i=0,ii=this.items.cnt(); i<ii; i++) {
var itm = this.items.get(i);
if(!itm.requestQuote&&!itm.requestSample){
hasOnlyRequests=false;
break;
}
}
return hasOnlyRequests;
}
function bskGroupByCode(type,nocache) {
if(type<0)return {};
if(!nocache&&this.cache['itmGrp']&&this.cache['itmGrp'][type])return this.cache['itmGrp'][type];
var itmGrp={},n=0;
for (var i=0,ii=this.items.cnt(); i<ii; i++) {
var itm=this.items.get(i);
var p=tf.wm.pProp(itm.id);
if(p){
var code=prodTypeCode(type,p);
if (code&&!itm.requestQuote&&!itm.requestSample) {
if(!itmGrp[code])itmGrp[code]=[0,[]];
itmGrp[code][0]+=itm.quantity;
itmGrp[code][1].push(n);
}
}
n++;
}
if(!this.cache['itmGrp'])this.cache['itmGrp']={};
this.cache['itmGrp'][type]=itmGrp;
return itmGrp;
}
function item()
{
this.options	= new dynObj('options');
this.init	= itemInit;
this.isSame	= itemIsSame;
this.transfer	= itemTx;
this.sig	= itemSig;
this.code	= itemCode;
this.getItemNo = itemGetItemNo;
this.xcode	= itemXCode;
this.updQnty	= itemUQnty;
this.addOpt	= itemAddOpt;
this.weight	= itemWeight;
this.shipMth	= itemShipMth;
this.calc	= itemCalc;
this.getGDsc = itemGetGDsc;
this.makeRequest = itemMakeRequest;
this.getXData = itemGetXData;
return this;
}
function itemInit(prt,id,doc,qnty,price,title,weight,itemNo,useDec,esd,taxes,prdc,imgsrc,temp)
{
var loc='',img='',info='';
if(doc){
if (doc.gid=='item'){
var o=doc;
title=o.title;if(!weight)weight=o.weight;itemNo=o.itemNo;
useDec=o.useDec;esd=o.esd;taxes=o.taxes;loc=o.purl;img=o.pimg;
}else{
var pcpu='data-productcrosspromotionurl-'+id.replace(/^.*\|(p\d+)(d\d+)?/i,'$1').toLowerCase();
if($('['+pcpu+']').length>0){
var pcpurl=$('['+pcpu+']').attr(pcpu);
loc=escape(pcpurl.indexOf('#')==0?tf.wm.hostbaseurl+pcpurl:tf.wm.url(tf.wm.host+pcpurl,'-',true));
}
else loc=tf.wm.url(escape(doc.location.toString().replace(doc.location.search,'')));
if(!imgsrc){
var i=doc.getElementById('I'+id);
if(i){
var tnreal=i.parentNode.getAttribute('tnreal');
if(tnreal&&tnreal!='undefined'&&tnreal.toLowerCase().indexOf('.swf')!=tnreal.length-4){
img=(i.getAttribute('mediatype')=='HTML'?'':tnreal);
}
else if(i.getAttribute('origsrc'))img=tf.wm.url(i.getAttribute('origsrc'));
else img=tf.wm.url(i.src);
}
}
else img=imgsrc;
}
}
this.parent	= prt;
this.id		= id;
this.useDec	= useDec;
this.title	= title;
this.information = info;
this.itemNo	= itemNo;
this.esd	= esd;
this.purl	= loc;
this.pimg	= img;
this.prdc	= prdc;
this.quantity=0;
this._wght=0;
var p = tf.wm.pProp(this.id);
if (p) {
this.department = p[15];
this.category = p[16];
this.producttype = p[17];
this.xdata = p[24];
this.brand = p[14];
this.ean = p[25];
}
this.cache	= [];
this.price	= parseFloat(price);
this.optPrice = 0;
this.taxes	= taxes;
this.updQnty(qnty);
this.weight(weight);
this.handlingcosts=[];
this.requestQuote = false;
this.requestSample = false;
}
function itemGetItemNo(){
var s=this.itemNo;
for (var i=0, o=this.options;i<o.cnt();i++){
var opt=o.get(i);
if(opt.combine&&opt.optId()){
s=opt.optId();
break;
}
}
return s;
}
function itemTx(obj,dcp)
{
if (!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;}
obj.code(this.code());
}
function itemIsSame(obj)
{
if (obj.id != this.id) return 0;
if (obj.requestQuote != this.requestQuote) return 0;
if (obj.requestSample != this.requestSample) return 0;
var myOpt = this.options;
var yrOpt = obj.options;
if (myOpt.cnt() != yrOpt.cnt()) return 0;
for (var i=0; i<myOpt.cnt(); i++) {
var opt = yrOpt.get(i);
if (opt == '' || myOpt.get(i).choice() != opt.choice()) return 0;
}
return 1;
}
var _iArr=['id','quantity','title','price','_wght','itemNo','taxes','esd','useDec','purl','pimg','optPrice','information','requestQuote','requestSample'];
function itemCode(prt,str)
{
if (prt) this.parent=prt;
return ckCodeStr(this, _iArr, '|', str);
}
function itemSig(compress)
{
var p=tf.wm.pProp(this.id);
if (!p) return '';
p[9]=p[9].replace('%%P','');
var op = new Array();
for (var i in p['opt']){
var s=p['opt'][i].join('~');
if(compress&&tf.isIE8)s=s.replace(/~~~~~/g,'~');
op[op.length]=s;
}
var ret=p.join('~') + ((op.length)?'/'+op.join('/'):'') + '/' + p['sig'];
if (!isNaN(p[9])) p[9]+='%%P';
return ret;
}
function itemXCode(str)
{
var s = '';
if (str==null||str=='') {
for (var i=0; i<this.options.cnt(); i++) {
s += (i==0)?'':';';
s += this.options.get(i).code();
}
} else {
var arr = str.split(';');
for (var i=0; i<arr.length; i++) {
var opt = this.options.empty();
opt.code(arr[i]);
this.options.add(opt);
}
}
return s;
}
function itemUQnty(qnty)
{
this.quantity = (this.useDec>0)?parseFloat(qnty):parseInt(qnty);
}
function itemAddOpt(allOpts, doc)
{
var opts = this.options;
var _f=doc.productForm;
if (!_f) {
_f=doc.options;
this.optPrice = 0;
for (var i=0; i<_f.cnt(); i++) {
var o = opts.empty();
o.code(_f.get(i).code());
o.price(getOPrc(doc.id, o.internalOptId(), o.idxPrc-1));
this.optPrice += o.price();
opts.add(o);
}
tf.wm.pProp(doc.id).optPrice=this.optPrice;
return '';
}
var len=(allOpts)?allOpts.length:0;
var form=new iForm(_f);
for (var i=0; i<len; i++) {
var arr = allOpts[i];
if (arr[0].substr(0,this.id.length)!=this.id||arr[0].substr(this.id.length,1)!='O') continue;
var o = opts.empty();
o.init(arr, form.getOriginalValue(arr[1]));
o.idxPrc = form.getIdx(arr[1]);
if(!o.prop[7])o.prop[7]=arr[0]+'C1';
var fld = form.getField(arr[1]);
if (fld){
if(fld.type=='text'||fld.type=='textarea'){
var oTmp = opts.empty();
oTmp.init(arr, fld.ctrl.getAttribute('metavalue'));
o.prop[0] = fld.rawValue==oTmp.choice() ? '' : fld.rawValue;
}
else if(fld.type=='radio'){
if(fld.value==''){o.prop[0]='';o.prop[1]='0';}
}
else if(fld.type=='checkbox'){
if(fld.rawValue=='0'){o.prop[0]='';o.prop[1]='0';}
}
}
opts.add(o);
}
var str  = '';
var warn = 0;
for (var i=0; i<opts.cnt();i++) {
var s = opts.get(i).check();
if (!s) continue;
if (s==' ') warn=1; else str+=s+'\n';
}
if (str != '') return str;
if (warn) return ' ';
return '';
}
function itemWeight(w)
{
if (w!=null) this._wght = parseFloat(w);
else w=this._wght;
if (isNaN(w)) w=0;
for (var i=0,o=this.options; i<o.cnt(); i++) {
if (o.get(i).choice()) w += o.get(i).weight();
}
return w;
}
function itemGetGDsc()
{
var prt= this.parent,gdsc=(ResellerID!='')?prt.gdisc.get(this.prdc):null;
if (!gdsc&&ResellerID!='') gdsc=prt.gdisc.get('ALL_OTHERS');
return gdsc;
}
function itemCalc(type,shMeth,nocache)
{
if (type=='cgi') {
if (this.requestQuote || this.requestSample) return 0;
type='';
}
if (!type) type='pur';
var qtyCache=type+this.quantity;
if (!nocache&&this.cache[qtyCache]) return this.cache[qtyCache];
var qty=this.quantity,prt= this.parent,sd = prt.shDisc();
var dsc = prt.disc.get(this.id),gdsc = this.getGDsc();
var tax = prt.tax, prc = 0, prd = tf.wm.pProp(this.id);
switch (type) {
case 'pdamt':
prc=0;
if(true)prc=dsc.amount(this.price,qty,this.calc('opt',shMeth,nocache),prd);
if(gdsc)prc=prc+gdsc.amount(this.price-prc,qty,this.calc('opt',shMeth,nocache),prd);
break;
case 'damt':
var all = this.parent.items;
for (var i=0,ii=all.cnt(); i<ii; i++) {
var itm = all.get(i);
if (itm==this) continue;
prc += (itm.calc('snd',shMeth,nocache)-itm.calc('pdamt',shMeth,nocache))*itm.quantity;
}
var iprc = this.calc('snd',shMeth,nocache) - this.calc('opt',shMeth,nocache) - this.calc('pur_pdamt',shMeth,nocache),itmGrp=this.parent.groupByCode(sd.limitToCodeType);
prc += qty?iprc*qty:iprc;
prc  = sd.amount(iprc,(itmGrp[tf.core.prodTypeCode(sd.limitToCodeType,prd)]||[0,0])[0],0,prd) + this.calc('pdamt',shMeth,nocache);
break;
case 'opt': prc+=this.optPrice;break;
case 'snd': prc=this.price+this.calc('opt',shMeth,nocache);break;
case 'sdc': prc=this.calc('snd',shMeth,nocache)-this.calc('damt',shMeth,nocache);break;
case 'ndc': prc=(this.price+this.calc('opt',shMeth,nocache))*qty;break;
case 'dsc': prc=this.calc('sdc',shMeth,nocache)*qty;break;
case 'tax': prc=tax.allAmt(this.taxes,this.calc('dsc'));break;
case 'pur': prc=tax.calcTax(this.taxes,this.calc('dsc',shMeth,nocache));break;
case 'exc': prc=tax.exTax(this.taxes,this.calc('dsc',shMeth,nocache)); break;
case 'exc_noround': prc=tax.exTax(this.taxes,this.calc('dsc',shMeth,nocache)); break;
case 'inc': prc=tax.calcTax(this.taxes,this.calc('dsc',shMeth,nocache)); break;
case 'sdp': prc=this.price-this.calc('damt',shMeth,nocache);break;
case 'pur_pdamt':
prc=0;
if(true)prc=dsc.amount(this.price,qty,0,prd);
if(gdsc)prc=prc+gdsc.amount(this.price-prc,qty,0,prd);
break;
case 'pur_damt':
var all = this.parent.items;
for (var i=0,ii=all.cnt(); i<ii; i++) {
var itm = all.get(i);
if (itm==this) continue;
prc += (this.price-itm.calc('pur_pdamt',shMeth,nocache))*itm.quantity;
}
var iprc = this.price - this.calc('pur_pdamt',shMeth,nocache),itmGrp=this.parent.groupByCode(sd.limitToCodeType);
prc += qty?iprc*qty:iprc;
prc  = sd.amount(iprc,(itmGrp[prodTypeCode(sd.limitToCodeType,prd)]||[0,0])[0],0,prd) + this.calc('pur_pdamt',shMeth,nocache);
break;
case 'pur_exc': prc=tax.exTax(this.taxes,this.price); break;
case 'pur_inc': prc=tax.calcTax(this.taxes,this.price);break;
case 'pur_exc+dsc': prc=this.calc('pur_exc',shMeth,nocache)-this.calc('pur_damt',shMeth,nocache); break;
case 'pur_inc+dsc': prc=this.calc('pur_inc',shMeth,nocache)-this.calc('pur_damt',shMeth,nocache);break;
case 'pur_exc+opt': prc=tax.exTax(this.taxes,this.calc('snd',shMeth,nocache)); break;
case 'pur_inc+opt': prc=tax.calcTax(this.taxes,this.calc('snd',shMeth,nocache));break;
case 'pur_exc+opt+dsc': prc=tax.exTax(this.taxes,this.calc('sdc',shMeth,nocache)); break;
case 'pur_inc+opt+dsc': prc=tax.calcTax(this.taxes,this.calc('sdc',shMeth,nocache));break;
}
prc=parseFloat(prc);
if(((type=='pur'||type=='exc')&&!tax.exempt&&qty==1)||(type=='dsc'&&qty==1)||type=='sdc')prc=nfmt.round(prc);
if (!nocache) this.cache[qtyCache]=prc;
return prc;
}
function itemShipMth(mid, cde)
{
var ps  = new Array();
var sh  = this.parent.ship.get(this.id);
var val = sh?sh.val():'';
if (!val) return mid?0:ps;
val = val.split(';');
for (v in val) {
var e = val[v].split(',');
if (!mid) ps[e[0]] = e[1];
else if (mid==e[0]) return e[cde]?parseFloat(e[cde])*this.quantity:0;
}
return mid?0:ps;
}
function itemMakeRequest(type)
{
this.requestQuote=(type==2);
this.requestSample=(type==3);
}
function itemGetXData(jsonPath) {
if(!this.xdata)return null;
var o=tf.sfJSON.parse(this.xdata),val=null;
if(o)eval('val=o.'+jsonPath);
return val;
}
function regPrc(arr)
{
function h2a(decode,s) {
var ret = '', aRet = [];
if(decode) {
var len = s.length-32;
for (var i=0; i<len; i+=2) {
if (s.charAt(i)+s.charAt(i+1) == '4x') {
aRet.push(String.fromCharCode(parseInt(s.charAt(i+2)+s.charAt(i+3)+s.charAt(i+4)+s.charAt(i+5),16)));
i += 4;
}
else aRet.push(unescape('%'+s.charAt(i)+s.charAt(i+1)));
}
aRet.push(s.substring(len,len+32));
ret = aRet.join('');
} else {
ret = s;
}
var arr = [];
if(ret){
arr = ret.split('/');
for (var i=0; i<arr.length; i++){arr[i]=arr[i].replace(/&#47;/g,'/');}
}
return arr;
}
var oOptIdx={},oOptWgtIdx={};
for(var i=0,ii=opt.length;i<ii;i++){
oOptIdx[opt[i][0]]=opt[i];
if(!crFFldArr[i]||!crFFldArr[i][5])continue;
var oOptWgt=[opt[i][0],''];
for(var j=0,jj=crFFldArr[i][5].length;j<jj;j++){
oOptWgt.push(parseFloat(crFFldArr[i][5][j][4]));
}
if(!(oOptWgtIdx[crFFldArr[i][8]]))oOptWgtIdx[crFFldArr[i][8]]=[];
oOptWgtIdx[crFFldArr[i][8]].push(oOptWgt);
}
var ret = 1;
for (var i=0; i<arr.length; i++) {
var sr = h2a(!isNaN(parseInt(arr[i])), arr[i]);
if(!sr[0])continue;
var prop=sr[0].split('~');
var discType=parseInt(prop[5]);
if (tf.wm.pProp(prop[0])) {
ret = 0;
continue;
}
var op=new Array();
for (var j=1; j<sr.length-1; j++) {
var tmp = sr[j].split('~');
op[op.length] = tmp;
}
prop['sig'] = sr[sr.length-1];
prop['opt'] = op;
prop['optWgt'] = oOptWgtIdx[prop[0]];
if (!isNaN(prop[9])) prop[9]+='%%P';
var optprcmin=getOPrcMin(prop,oOptIdx);
if(optprcmin!==false)prop['optprcmin']=optprcmin;
tf.wm.pProp(prop[0], prop);
}
$(tf).trigger('pPropUpdated');
return ret;
}
var sh_dobj;
if (this.discount) {
sh_dobj = new discount();
gd_obj = new discount();
sh_dobj.init('103','','','','',-1,'');
if(!isInSF()){
if(window.timedDiscountsExist){
function shopDiscMsg(){
$(function () {
var el=tf.content.document.getElementById('ShopDiscountMessage-'+tf.content.pgid);
if(el)el.style.display=currTime.isActive(sh_dobj.tlim)?'block':'none';
});
}
currTime.handlers['getTime'].push(shopDiscMsg);
}
if(window.timedDiscountsExist)currTime.handlers['getTime'].push(function(){if(tf.bskLoaded&&tf.utils){tf.utils.populatePrice();tf.utils.populateOpt();}});
}
}
function getDscAmt(id, prc, usePrc, dontApplyPrdDsc, dontApplyShopDsc)
{
var p=tf.wm.pProp(id);
var amt=0;
var dsc_obj = new discount();
if (!p || !dsc_obj) return '';
if (true) {
if(!dontApplyPrdDsc){
dsc_obj.init(p[5], p[6], p[7]);
amt += dsc_obj.amount(prc, 1, 0);
}
if(!dontApplyShopDsc){
var itmGrp=core.Basket.groupByCode(sh_dobj.limitToCodeType);
if(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);
}
}
if (ResellerID!='') {
var Basket=core.Basket;
var gdsc=Basket.gdisc.get(p[9]);
if (!gdsc) gdsc=Basket.gdisc.get('ALL_OTHERS');
if (gdsc) amt+=gdsc.amount(parseFloat(prc)-amt, 1, 0);
}
return amt;
}
function getPrc(id, sid, dsc)
{
var p=tf.wm.pProp(id);
if (p==null) return '';
var prcDsc=(p[5]=='0'&&parseFloat(p[6])!=0),dscAppliesToOptions=true,shdscAppliesToOptions=false;
var prc = parseFloat(p[1]), optprc = (p['optPrice']||0);
if (sid) { for (var i in p['opt']) { if (p['opt'][i][0] == sid) { prc = p['opt'][i]; break; } } return prc; }
var val = prc + optprc;
p['autoIntro'] = '';
if(val == 0.0&&p['optprcmin']) {
val = p['optprcmin'];
prc = p['optprcmin'];
p['autoIntro'] = (LD.LD_PRICEINTRO_FROM||'');
}
if (dsc) val -= (getDscAmt(id, prc, true) + getDscAmt(id, optprc, true, prcDsc ? true : !dscAppliesToOptions, !shdscAppliesToOptions));
if(!isNaN(val)){
if(nfmt.dec!=tf.currentCurrency.decimal_places)val=nfmt.round(val,nfmt.dec);
val=nfmt.round(val,1/Math.pow(10,tf.currentCurrency.decimal_places));
}
return val;
}
function getWgt(id, sid)
{
var p=tf.wm.pProp(id);
if (p==null) return '';
var optWgt=null;
if (sid) {
for (var i in p['optWgt']) { if (p['optWgt'][i][0] == sid) { optWgt = p['optWgt'][i]; break; } } return optWgt;
}
}
function getOPrc(id, sid, od, dsc, dscx)
{
if (id.indexOf('O')>-1) id=id.substr(0,id.indexOf('O'));
var op=getPrc(id,sid),p=tf.wm.pProp(id),ret=0,optprc=op[od*2+2]||0;
var prcDsc=(p[5]=='0'&&parseFloat(p[6])!=0),dscAppliesToOptions=true,shdscAppliesToOptions=false;
if(dscx)ret=(op==null)?0:(dsc?optprc-getDscAmt(id,Math.abs(optprc),true,prcDsc ? true : !dscAppliesToOptions, !shdscAppliesToOptions)*(optprc>0?1:-1):optprc);
else ret=(op==null)?0:(dsc?optprc-getDscAmt(id,optprc,true,prcDsc ? true : !dscAppliesToOptions, !shdscAppliesToOptions):optprc);
return ret;
}
function getOPrcMin(p,oIdx)
{
var oOptIdx=oIdx;
if(!oOptIdx){
for(var i=0,ii=opt.length;i<ii;i++)oOptIdx[opt[i][0]]=opt[i];
}
var mintot=0;
for(var i in p['opt']){
if(oOptIdx[p['opt'][i][0]]&&oOptIdx[p['opt'][i][0]][3]==0)continue;
var oPMin=null;
for(var j=2;j<p['opt'][i].length;j+=2){
var oP=parseFloat(p['opt'][i][j]);
if(oP<oPMin||oPMin==null)oPMin=(oP||0);
}
mintot+=oPMin;
}
return mintot;
}
function getOWgt(id, sid, od)
{
if (id.indexOf('O')>-1) id=id.substr(0,id.indexOf('O'));
var op=getWgt(id,sid),p=tf.wm.pProp(id),ret=op[od+2]||0;
return ret;
}
function dPrc(prc, ifscurr,dispZero,fmtCurr,symbolClass)
{
var scurr='';
if (!ifscurr&&tf.secondCurrency) scurr='<span class="SecondaryCurrencyAmount">('+getSCurr(prc,fmtCurr,symbolClass)+')</span> ';
var abbrev = tf.currentCurrency.abbrev;
if (fmtCurr) abbrev = '<span'+(symbolClass?' class="'+symbolClass+'"':'')+'>'+abbrev+'</span>';
return (prc==''&&!dispZero)?'':scurr+'<span>'+nfmt.display(prc*(tf.currentCurrency.multiplier/tf.shopCurrency.multiplier), tf.currentCurrency.decimal_places,abbrev)+'</span>';
}
function getSCurr(prc,fmtCurr,symbolClass){
var scCurr=tf.secondCurrency, abbrev = scCurr ? scCurr.abbrev : '';
if (fmtCurr) abbrev = '<span'+(symbolClass?' class="'+symbolClass+'"':'')+'>'+abbrev+'</span>';
return (scCurr)?nfmt.display(prc*(scCurr.multiplier/tf.shopCurrency.multiplier),scCurr.decimal_places,abbrev):'';
}
function CSS(doc)
{
this.get  = cssGet;
this.init = cssInit;
this.init(doc);
}
function cssInit(doc)
{
function docSS(arr,doc) {
var ds=doc.styleSheets;
if (ds&&ds.length>0&&ds[0].imports&&ds[0].imports.length>0){
ds=ds[0].imports[0];
for(var j=0,rl=ds.rules;rl&&j<rl.length;j++){
if(!rl[j].selectorText)continue;
var tag=rl[j].selectorText.toLowerCase();
arr[tag]=rl[j].style.cssText;
}
}
else ds=null;
return ds;
}
function defSS(arr,doc) {}
if (!doc) doc=document;
this._css = new Array();
if (!docSS(this._css, doc)) defSS(this._css,doc);
}
function cssGet(name,type)
{
switch(type){
case 1: name='.'+name;break;
}
return this._css[name];
}
var crFFldImager={
img:new Image(),
prgImg:null,
gl:function(id){return tf.content.document.getElementById(id);},
elParS:null,
outerHTML:function(el){
var elPar=el.parentNode;
var elNew=tf.content.document.createElement(elPar.nodeName);
elNew.appendChild(el);
var html=elNew.innerHTML;
elPar.appendChild(el);
return html;
},
scale:function(mW, mH, cW, cH){
if(cW<mW&&cH<mH)return[cW,cH];
var r=cH/cW,cx=mW,cy=parseInt((mW*r)+0.5);
if(cy>mH){ r=cW/cH; cx=parseInt((mH*r)+0.5); cy=mH; }
return [cx,cy];
},
replace:function(prid,id){
if(this.busy){setTimeout(function(){tf.core.crFFldImager.replace(prid,id);},50);return;}
this.busy=true;
var elImg=this.gl('I'+prid),elPImg=this.gl('ProductImage-'+[prid]);
if(elImg&&elPImg){
this.elParS=elPImg.style;
var 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');
var elPar=elImg.parentNode,origw=elPImg.parentNode.offsetWidth||elImg.offsetWidth,origh=elPImg.parentNode.offsetHeight||elImg.offsetHeight;
if(!elImg.getAttribute('origsrc')){
var elPImgParS=elPImg.parentNode.style,origsrc=elImg.src||this.outerHTML(elImg);
elPImgParS.height=elPImg.parentNode.offsetHeight+'px';
elPImgParS.width=elPImg.parentNode.offsetWidth+'px';
if(elPImg.parentNode.className.indexOf('ImgLink')!=-1)elPImg.parentNode.style.overflow='hidden';
}
function createNew(nodeName,prid,el,elPar){
if(el.nodeName!=nodeName){
el.parentNode.removeChild(el);
el=tf.content.document.createElement(nodeName);
el.id='I'+prid;
el.setAttribute('origmm',true);
if(!el.parentNode){
el=elPar.insertBefore(el,elPar.childNodes[0]||null);
}
}
return el;
}
if(isHTML){
elImg=createNew('SPAN',prid,elImg,elPar);
}
else{
elImg=createNew('IMG',prid,elImg,elPar);
}
if(!elImg.getAttribute('origsrc')){
elImg.setAttribute('origsrc',origsrc);
}
elImg.setAttribute('origw',origw);
elImg.setAttribute('origh',origh);
jQuery(elImg).siblings('.zoomImg').remove();
if(elChImg){
this.elParS.margin='0 auto';
var elImgCap=this.gl('ProductImageCaption-'+prid);
if(elImgCap&&!elImgCap.getAttribute('origtext')){
elImgCap.setAttribute('origtext',elImgCap.innerHTML);
}
if(id||elChImg.className.indexOf('NoImage')==-1){
this.img=new Image();
this.img.onload=function(){
elImg.src='';
var cfi=tf.core.crFFldImager,newSize=cfi.scale(elImg.getAttribute('origw'),elImg.getAttribute('origh'),this.width,this.height);
elImg.src=this.src;
elImg.width=newSize[0];
elImg.height=newSize[1];
elImg.setAttribute('border','0');
elImg.style.marginTop='0';
elImg.style.top='0';
$(elPar).toggleClass('no-responsive', true);
cfi.prgImg.style.visibility='hidden';
cfi.elParS.width=newSize[0]+'px';
cfi.elParS.height=newSize[1]+'px';
var pici=cfi.gl('pici-'+prid);
if(pici){
pici.style.display='block';
pici.style.position='absolute';
pici.style.right='5px';
pici.style.bottom='5px';
}
if(elImgCap){
elImgCap.innerHTML=elChImg.getAttribute('title')||elChImg.getAttribute('description')||'&nbsp;';
if(!tf.isIE7){
elImgCap.style.position='relative';
elImgCap.style.clear='both';
}
}
jQuery(elImg).siblings('.zoomImg').remove();
cfi.busy=false;
}
this.img.onerror=function(){
var cfi=tf.core.crFFldImager;
cfi.busy=false;
elImg.style.visibility='hidden';
}
elPImg.setAttribute('jumptoid',elChImg.id);
if(!this.prgImg){
this.prgImg=tf.content.document.createElement('i');
this.prgImg.className='icon-spinner2 icon-fa-spin';
this.prgImg.style.position='absolute';
this.prgImg.style.marginTop='-0.5em';
this.prgImg.style.top='50%';
this.prgImg.style.marginLeft='-2em';
this.prgImg.style.left='50%';
this.prgImg.style.fontSize='2em';
this.prgImg=elPImg.parentNode.insertBefore(this.prgImg,elPImg.parentNode.childNodes[0]||null);
}
var mysrc=elChImg.getAttribute('tn')||elChImg.getAttribute('src')||elChImg.getAttribute('href');
if(mysrc!==''){
if(isHTML){
elImg.parentNode.style.background = '';
elImg.style.visibility='visible';
var newSize=this.scale(elImg.getAttribute('origw'),elImg.getAttribute('origh'),elChImg.getAttribute('mw'),elChImg.getAttribute('mh'));
newSize[1]=elImg.getAttribute('origh')-18;
elImg.innerHTML=tf.utils.sfMediaBox.getMMHTMLUsingExtraction('',window.decodeURIComponent(mysrc),newSize[0],newSize[1]);
elImg.style.display='inline-block';
elImg.style.width='auto';
elImg.style.height='auto';
elPImg.parentNode.style.height='auto';
var pici=this.gl('pici-'+prid);
if(pici){
pici.style.position='static';
pici.style.styleFloat='right';
pici.style.cssFloat='right';
elPar.appendChild(pici);
}
this.busy=false;
}
else{
elImg.parentNode.style.background = '';
elImg.style.visibility='visible';
this.prgImg.style.visibility='visible';
elImg.style.position='relative';
elImg.style.display='block';
if(this.gl('pici-'+prid))this.gl('pici-'+prid).style.display='none';
this.img.src=tf.wm.url(mysrc).replace('contents/contents/media/','contents/media/');
}
if(tf.content['ProductImageGroupSizer_'+prid])setTimeout(tf.content['ProductImageGroupSizer_'+prid],100);
jQuery(elImg).siblings('.zoomImg').remove();
} else {
this.busy = false;
}
}
else{
elImg.parentNode.style.background='url('+(tf.isEntryPage?(tf.lang!=tf.baseLang?'../':'')+'contents/':'../')+'media/no_image.png) center no-repeat';
elImg.style.visibility='hidden';
this.busy=false;
}
}
else{
this.busy=false;
}
}
}
};
var tsI=[],tsIx=[];
function prodDiscMsg(id){
var p=tf.wm.pProp(id);
if (p&&p[7]) {
var	el=tf.content.document.getElementById('ProductDiscountMessage-'+id);
if (el) {
el.style.display=currTime.isActive(p[7])?'block':'none';
}
else {
setTimeout(function(){prodDiscMsg(id);},100);
}
}
}
function pprice(elPrice,args,apq) {
function applyGC(s,el){
var GC='';
if(el){
GC=el.className.split(' ')[0];
if(GC.indexOf('GC')!=0)GC='';
}
return GC?s.replace(/class="([^G][^C])/g,'class="'+GC+' $1'):s;
}
function applyGCForClassName(ss,className,GC){
return GC?ss.replace(new RegExp('class="(?:GC[0-9]+ )?'+className,'g'),'class="'+GC+' '+className):ss;
}
function getComputedStyle(el,prop){
if(el.currentStyle)var val=el.currentStyle[prop];
else var val=tf.content.document.defaultView.getComputedStyle(el,'')[prop];
return val;
}
apq=apq||'';
var ret=[]; var Id=args[0],pi=args[1],pt=args[2],b1=args[3],b2=args[4],b3=args[5];
var _prc=getPrc(Id,null),_dp=getPrc(Id,null,1),_prcStr='',_dpStr='';
var bsk=tf.core.Basket,discShown=(_prc-_dp>0.001);
function gl(id){return tf.content.document.getElementById(id);}
if(!elPrice)elPrice=gl('Product'+apq+'Price-'+Id);
var elIntro=gl('Product'+apq+'PriceIntro-'+Id);
if(pi){
if(elIntro)elIntro.innerHTML=pi;
else ret.push('<span class="Product'+apq+'PriceIntro" id="Product'+apq+'PriceIntro-'+Id+'">'+pi+'</span> ');
}
if(tf.conf)tf.conf.populateTSI();
var arrTexts=taxDispTexts(pt,tsI,tsIx);
var tid=arrTexts[0],tinc=arrTexts[1],texc=arrTexts[2];
_prcStr=bsk.tax.disp(tid,_prc,tf.shopCurrency,null,true,tinc,texc,discShown?'':'Product'+apq+'CurrencySymbol');
_dpStr=bsk.tax.disp(tid,_dp,tf.shopCurrency,null,true,tinc,texc,discShown?'Product'+apq+'CurrencySymbol':'');
var elOrig=gl('Product'+apq+'PriceOriginal-'+Id),elCalc=gl('Product'+apq+'PriceCalculated-'+Id);
var dontChangeDisplay=false;
if (discShown) {
if(elOrig&&elOrig.parentNode!=elPrice)elOrig.innerHTML=applyGCForClassName(applyGC(_prcStr,elOrig),'Product'+apq+'CurrencySymbol','GC77');
else {dontChangeDisplay=true;ret.push('<span class="Product'+apq+'PriceOriginal" id="Product'+apq+'PriceOriginal-'+Id+'">'+_prcStr+'</span> ');}
if(elCalc&&elCalc.parentNode!=elPrice)elCalc.innerHTML=applyGCForClassName(applyGC(_dpStr,elCalc),'Product'+apq+'CurrencySymbol',tf.content.pgid.indexOf('P')==0?'GC80':'GC82');
else {dontChangeDisplay=true;ret.push('<span class="GC56 Product'+apq+'PriceCalculated" id="Product'+apq+'PriceCalculated-'+Id+'">'+_dpStr+'</span>');}
}
else {
if(elPrice)elPrice.innerHTML=applyGCForClassName(applyGC(_prcStr,elPrice),'Product'+apq+'CurrencySymbol',tf.content.pgid.indexOf('P')==0?'GC77':'GC81');
if(elCalc&&elCalc.parentNode!=elPrice){showCalculated=!discShown;elCalc.innerHTML='';}
}
if(!dontChangeDisplay){
if(elPrice)elPrice.style.display=discShown?'none':getComputedStyle(elPrice,'display');
if(elOrig)elOrig.style.display=discShown?getComputedStyle(elOrig,'display'):'none';
if(elCalc)elCalc.style.display=discShown||showCalculated?getComputedStyle(elCalc,'display'):'none';
var el = gl('ProductDiscountDisplay-'+Id);
if(el) {
if(discShown) {
el.style.display='block';
if(pi == "")
$(el).parent('#ProductContainer1').show();
} else {
el.style.display='none';
if(pi == "")
$(el).parent('#ProductContainer1').hide();
}
}
}
if(!bsk.tax.showBoth){
var elTaxText=gl('Product'+apq+'IncTaxes-'+Id),tt=tid?(bsk.tax._tax.get(tid).incTax?tinc:texc):'';
if(elTaxText&&elTaxText.parentNode!=elPrice)elTaxText.innerHTML=(tt==''?'':'('+tt+')');
else {
if(!discShown)ret.push(_prcStr);
if(tt)ret.push(' <span class="Product'+apq+'IncTaxes" id="Product'+apq+'IncTaxes-'+Id+'">('+tt+')</span>');
}
}
if(!region){setTimeout('tf.utils.populatePrice();tf.utils.populateOpt();',1000);return ret;}
if(!tfc.isInSF())prodDiscMsg(Id);
return ret.join('');
}
function ppriceTemplateLayout(elPrice,args,apq) {
apq=apq||'';
var ret=[]; var Id=args[0],pi=args[1],pt=args[2],b1=args[3],b2=args[4],b3=args[5];
var _prc=getPrc(Id,null),_dp=getPrc(Id,null,1),_prcStr='',_dpStr='',_txtStr='',p=tf.wm.pProp(Id);
var bsk=tf.core.Basket,discShown=(_prc-_dp>0.001);
var $orig=$('#Product'+apq+'PriceOriginal-'+Id),
$calc=$('#Product'+apq+'PriceCalculated-'+Id),
$price=$(elPrice),
$disc=$('#ProductDiscountDisplay-'+Id), $txt=$('#Product'+apq+'IncTaxes-'+Id),
$priceOther=$('#Product'+apq+'PriceTaxPrice-'+Id),
$priceOtherTxt=$('#Product'+apq+'PriceTaxPriceText-'+Id)
$shippingCharge=$('#Product'+apq+'ShippingChargeForProduct-'+Id)
;
if(!elPrice)oPrice=$('#Product'+apq+'Price-'+Id);
if(pi)$('#Product'+apq+'PriceIntro-'+Id).html(pi);
$shippingCharge.remove();
if(tf.conf)tf.conf.populateTSI();
var arrTexts=taxDispTexts(pt,tsI,tsIx),tid=arrTexts[0],tinc=arrTexts[1],texc=arrTexts[2];
var _prcA=bsk.tax.dispValues(tid,_prc,null,tinc,texc,'Product'+apq+'CurrencySymbol'), _dpA={};
_prcStr=_prcA['p1a'];
_txtStr=_prcA['p1t'];
if (discShown) {
_dpA=bsk.tax.dispValues(tid,_dp,null,tinc,texc,'Product'+apq+'CurrencySymbol');
_dpStr=_dpA['p1a'];
}
if(p&&p['autoIntro'])_prcStr='<span class="ProductPriceOtherInformation" style="float:none;"><small class="ProductPriceIntroAuto">'+p['autoIntro']+'</small></span> '+_prcStr;
var dontChangeDisplay=false;
if (discShown) {
$orig.show().css('display','').html(_prcStr);
$calc.show().css('display','').html(_dpStr);
$price.hide();
$disc.show().css('display','');
if(pi == "")
$disc.parent('#ProductContainer1').show();
}
else {
$orig.hide();
$calc.hide();
$price.show().css('display','').html(_prcStr);
$disc.hide();
if(pi == "")
$disc.parent('#ProductContainer1').hide();
}
$txt.html(_txtStr);
if(bsk.tax.showBoth){
$priceOther.html(discShown ? _dpA['p2a'] : _prcA['p2a'])
$priceOtherTxt.html(_prcA['p2t'])
}
if(!region){setTimeout('tf.utils.populatePrice();tf.utils.populateOpt();',1000);return ret;}
if(!tfc.isInSF())prodDiscMsg(Id);
}
function getPPrices(prid,txids,itm,val,valDscApplied){
var bsk=tf.core.Basket,arr={};
var exT_dp_opt=inT_dp_opt=exT_prc_opt=inT_prc_opt=_prc_opt=_dp_opt=op=dp=0;
var dscAppliesToOptions=true,shdscAppliesToOptions=false;
if(itm){
var _prc=itm.calc('pur_inc'),_dp=itm.calc('pur_inc+dsc');
var exT_dp=itm.calc('pur_exc+dsc'),inT_dp=_dp;
var exT_prc=itm.calc('pur_exc'),inT_prc=_prc;
var exT_dp_opt=itm.calc('pur_exc+opt+dsc'),inT_dp_opt=itm.calc('pur_inc+opt+dsc');
var exT_prc_opt=itm.calc('pur_exc+opt'),inT_prc_opt=itm.calc('pur_inc+opt');
}
else {
if(val){
var _prc=val,_dp=val-(valDscApplied?0:getDscAmt(prid,val,true,!dscAppliesToOptions, !shdscAppliesToOptions));
}
else{
var _prc=tf.core.getPrc(prid),_dp=tf.core.getPrc(prid,null,1);
}
var exT_dp=bsk.tax.exTax(txids,_dp),inT_dp=exT_dp+bsk.tax.allAmt(txids,_dp);
var exT_prc=bsk.tax.exTax(txids,_prc),inT_prc=exT_prc+bsk.tax.allAmt(txids,_prc);
}
if(tf.conf)tf.conf.populateTSI();
var arrTexts=taxDispTexts(txids,tsI,tsIx);
var tid=arrTexts[0],tinc=arrTexts[1],texc=arrTexts[2];
if(_prc-_dp>0.001){
var exT=exT_dp,inT=inT_dp;
var discounted=true;
}
else {
var exT=exT_prc,inT=inT_prc;
var discounted=false;
}
if((typeof(bsk.tax._tax.get(tid)) != 'undefined') && bsk.tax._tax.get(tid).incTax){
var p1t=tinc, p1a=tf.core.dPrc(inT,1,true);
var p2t=texc, p2a=tf.core.dPrc(exT,1,true);
op=inT_prc;
dp=inT_dp;
_prc_opt=inT_prc_opt?tf.core.dPrc(inT_prc_opt,1,true):null;
_dp_opt=inT_dp_opt?tf.core.dPrc(inT_dp_opt,1,true):null;
}
else{
var p1t=texc, p1a=tf.core.dPrc(exT,1,true);
var p2t=tinc, p2a=tf.core.dPrc(inT,1,true);
op=exT_prc;
dp=exT_dp;
_prc_opt=exT_prc_opt?tf.core.dPrc(exT_prc_opt,1,true):null;
_dp_opt=exT_dp_opt?tf.core.dPrc(exT_dp_opt,1,true):null;
}
_prc=tf.core.dPrc(op,1,true);
_dp=tf.core.dPrc(dp,1,true);
arr['discounted']=discounted;
arr['op']=op;
arr['dp']=dp;
arr['orig']=_prc;
arr['calc']=_dp;
arr['orig+opt']=_prc_opt;
arr['calc+opt']=_dp_opt;
if (bsk.tax.showBoth) {
arr['prc1_text']=p1t;
arr['prc1_amt']=p1a;
arr['prc2_text']=p2t;
arr['prc2_amt']=p2a;
}
return arr;
}
function bprice(args) {
var b1=args[1],b2=args[2],b3=args[3],b4=parseFloat(args[4]);
if(b1&&isNaN(b1)||parseFloat(b1)<0.001) return '';
var p=tf.wm.pProp(args[0]),dscPrc=getPrc(args[0],null,1),hasDsc=p[5]==1||parseFloat(p[6])!=0||(dscPrc<b1),prc=b1;
if(b4&&!isNaN(b4) && (dscPrc>0.0001)){
dscPrc/=parseFloat(b4);
if(dscPrc<b1){
prc = dscPrc;
}
}
if(hasDsc){
if(getPrc(args[0])>0.001)prc=dscPrc/getPrc(args[0])*b1;
else prc=prc-getDscAmt(args[0],prc);
}
if($('input[name=ProductPriceLayout]').length>0){
return '<nobr>'+dPrc(prc*(tf.currentCurrency.multiplier/tf.shopCurrency.multiplier), tf.currentCurrency.decimal_places, '')+' / '+(parseInt(b2)==1?'':parseInt(b2)+' ')+b3+'</nobr>';
}
else{
return ld('LD_BASEPRICE','Prix de base')+': <nobr>'+ld('LD_BASEPRICE_RESULT','%% %% = %%',[nfmt.toLoc(b2),b3,dPrc(prc,1)])+'</nobr>';
}
}
var crFFldOptPrc={
oCacheArr: null,
oOptIdx: {},
oPriceArr: null,
oOptions:null,
oFldSel:{},
busy:{},
setFocus:true,
updDisp:true,
cacheAndIndex:function(crFFldArr,opt){
var me=crFFldOptPrc;
for (var i=0,ii=crFFldArr.length;i<ii;i++){
var a=crFFldArr[i][5];
me.oCacheArr[a[0][0]]={'crFFldArr':{},'fldname':crFFldArr[i][1],'origprc':0,'origwgt':0};
for (var j=0,jj=a.length;j<jj;j++){
me.oCacheArr[a[0][0]]['crFFldArr'][a[j][2]]=a[j];
}
}
for (var i=0,ii=opt.length;i<ii;i++){
me.oOptIdx[opt[i][0]]=opt[i];
}
},
copyArr:function(lhs,rhs){
var me=crFFldOptPrc;
for(var n in rhs){
if(typeof(rhs[n])=='object'){
lhs[n]=(typeof(rhs[n].length)=='undefined'?{}:[]);
me.copyArr(lhs[n],rhs[n]);
}
else lhs[n]=rhs[n];
}
},
reset:function(){
var me=crFFldOptPrc;
if(me.oPriceArr){
me.copyArr(tf.wm._pArr,me.oPriceArr);
tf.nametag.add('_pArr', tf.sfJSON.stringify(tf.wm._pArr, null, true));
me.oPriceArr=null;
me.oPriceArrNewState=null;
}
},
resetTemporarily:function(prid){
var me=crFFldOptPrc;
if(!me.oPriceArr){me.oPriceArr={};me.copyArr(me.oPriceArr,tf.wm._pArr);}
me.oPriceArrNewState={};
me.copyArr(me.oPriceArrNewState,tf.wm._pArr[prid]);
me.copyArr(tf.wm._pArr[prid],me.oPriceArr[prid]);
},
unreset:function(prid){
var me=crFFldOptPrc;
if(me.oPriceArrNewState){
me.copyArr(tf.wm._pArr[prid],me.oPriceArrNewState);
me.oPriceArrNewState=null;
}
},
clearTextBox:function(id){
var el=tf.content.gl(id);
if(el){
el.focus();
el.value='';
el.blur();
}
return false;
},
updPrc:function(prid,id,crFFldArr,opt){
if(!tf.content.document.productForm)return;
var me=crFFldOptPrc;
if(me.busy[prid])return false;
me.busy[prid]=true;
if(!me.oPriceArr){me.oPriceArr={};me.copyArr(me.oPriceArr,tf.wm._pArr);}
if(!me.oCacheArr){me.oCacheArr={};me.cacheAndIndex(crFFldArr,opt);}
if(!me.oOptions)me.oOptions=new dynObj('options');
var optid=id.split('C')[0],p=tf.wm.pProp(prid),popt=getPrc(prid,optid),poptwgt=getWgt(prid,optid);
if(parseFloat(p[1])==0)me.updDisp=false;
var form=new iForm(tf.content.document.productForm),fld=form.getField(me.oCacheArr[optid]['fldname']);
if(fld.type=='checkbox'&&fld.rawValue==me.oFldSel[id]){me.busy[prid]=false;return;}
var o=me.oOptions.empty();
o.init(me.oOptIdx[optid],fld.value||'');
var i=0,updDisp=false,valCur=0,valOffset=o.price(),wgtCur=0,wgtOffset=o.weight();
var forceRePopOpt=false;
if(typeof(p['optPrice'])=='undefined')p['optPrice']=0;
if(typeof(p['optWeight'])=='undefined')p['optWeight']=0;
switch(fld.type){
case 'text':
case 'textarea':
if(fld.rawValue){
if(fld.rawValue==fld.origValue.split(str_sep1)[0]){
valOffset=0;
wgtOffset=0;
}
}
else{
if(fld.rawValue!=(me.oFldSel[id]||'')){
valOffset=-(me.oCacheArr[optid]['origprc']||valOffset);
wgtOffset=-(me.oCacheArr[optid]['origwgt']||wgtOffset);
}
else if(!(me.oFldSel[id]||'')){
valOffset=0;
wgtOffset=0;
}
}
break;
case 'radio':
if(me.oFldSel[id]==='0'){
if(o.type){
fld.ctrl.checked=true;
me.oFldSel[id]='1';
}
else{
valOffset=(me.oCacheArr[optid]['origprc']||valOffset);
wgtOffset=(me.oCacheArr[optid]['origwgt']||wgtOffset);
fld.value='';
forceRePopOpt=true;
}
}
updDisp=true;
break;
case 'checkbox':
if(fld.rawValue==0){
valOffset=-(me.oCacheArr[optid]['origprc']||valOffset);
wgtOffset=-(me.oCacheArr[optid]['origwgt']||wgtOffset);
}
updDisp=true;
break;
case 'select-one':
if(tfc.__sfChoiceImageLocation&&tfc.__sfChoiceImageLocation.indexOf('optionarea_')==0){
updDisp=true;
}
break;
}
if(fld==''){
valOffset=me.oCacheArr[optid]['origprc'];
valCur=parseFloat(p['optPrice']);
p['optPrice'] = valCur + valOffset;
me.oCacheArr[optid]['origprc']=0;
wgtOffset=me.oCacheArr[optid]['origwgt'];
wgtCur=parseFloat(p['optWeight']);
p['optWeight'] = wgtCur + wgtOffset;
me.oCacheArr[optid]['origwgt']=0;
}
for(var chid in me.oCacheArr[optid]['crFFldArr']){
if(chid==id){
valCur=parseFloat(p['optPrice']);
p['optPrice'] = valCur + valOffset;
wgtCur=parseFloat(p['optWeight']);
p['optWeight'] = wgtCur + wgtOffset;
}
valCur=parseFloat(popt[i*2+2])||0;
popt[i*2+2] = (valCur - valOffset).toString();
wgtCur=parseFloat(poptwgt[i+2])||0;
poptwgt[i+2] = (wgtCur - wgtOffset).toString();
switch(fld.type) {
case 'text':
case 'textarea':
if(valOffset)me.oCacheArr[optid]['origprc']=valOffset;
if(wgtOffset)me.oCacheArr[optid]['origwgt']=wgtOffset;
me.oFldSel[chid]=fld.rawValue;
break;
case 'checkbox':
me.oCacheArr[optid]['origprc']=valOffset;
me.oCacheArr[optid]['origwgt']=wgtOffset;
me.oFldSel[chid]=fld.rawValue;
break;
case 'radio':
if(chid==id&&!o.type)me.oCacheArr[optid]['origprc']-=valOffset;
if(chid==id&&!o.type)me.oCacheArr[optid]['origwgt']-=wgtOffset;
me.oFldSel[chid]=(chid==id?me.oFldSel[chid]:'0');
break;
case 'select-one':
if(chid==id)me.oCacheArr[optid]['origprc']-=valOffset;
if(chid==id)me.oCacheArr[optid]['origwgt']-=wgtOffset;
me.oFldSel[chid]=(chid==id?'1':'0');
break;
}
if(fld=='')me.oFldSel[chid]='0';
i++;
}
updDisp=(updDisp||valOffset||wgtOffset)&&me.updDisp;
if(updDisp){
if(tf.utils.heightHandler)tf.utils.heightHandler.reset();
tf.utils.populatePrice(null,prid);
tf.utils.populateOpt(null,prid,optid);
if(forceRePopOpt)setTimeout(function(){tf.utils.populateOpt(null,prid,optid);},100);
tf.utils.displayProductQuantityDiscounts(prid);
if(tf.core.setFocusID){
$('#'+tf.core.setFocusID).focus();
}
else if(me.setFocus){
form=new iForm(tf.content.document.productForm);
fld=form.getField(me.oCacheArr[optid]['fldname']);
if(fld&&fld.ctrl)fld.ctrl.focus();
}
}
else if(!me.updDisp)
{
if(tf.utils.heightHandler)tf.utils.heightHandler.reset();
tf.utils.populatePrice(null,prid);
tf.utils.populateOpt(null,prid);
if(forceRePopOpt)setTimeout(function(){tf.utils.populateOpt(null,prid,optid);},100);
tf.utils.displayProductQuantityDiscounts(prid);
}
tf.core.setFocusID=null;
me.updDisp=true;
me.busy[prid]=false;
return true;
}
};
if(tf.isIE&&tf.isIEBefore10)tf.addEvent('onbeforeunload',function(){crFFldOptPrc.reset();});
else {
tf.addEvent('onunload',function(){
crFFldOptPrc.reset();
});
tf.addEvent('pageshow',function(e){
if(e.persisted)document.location.reload();
});
tf.addEvent('pagehide',function(){
crFFldOptPrc.reset();
});}
var cthtb=null;
var oCachePPriceArr={indexed:false};
function crFFld(args){
var 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='';
if(t==3||t==4||t==5){
var el=$('[name="'+args[1]+'"]').get(0);
if(el&&el.selectedIndex>0)dv='0';
}
var p=tf.wm.pProp(pid), updDisp=true;
if(required)on+='&nbsp;<span class="required">*</span>';
tfc=tf.content;
var choiceImageInProductImageArea=!tfc.__sfChoiceImageLocation||tfc.__sfChoiceImageLocation.indexOf('productimagearea')==0,noChoicesHaveImage=true,choiceImageMH=-1;
var 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>';
if(choicesonly)pcnB='<div id="ProductChoiceName-%%" class="ProductChoiceName">';
if(tfc.ppriceArr&&!oCachePPriceArr.indexed){
for (var i=0,ii=tfc.ppriceArr.length;i<ii;i++){
oCachePPriceArr[tfc.ppriceArr[i][0]]=tfc.ppriceArr[i];
}
oCachePPriceArr.indexed=true;
}
function optImgInit(a){
for (var i=0,ii=a.length;i<ii;i++) {
var chid=a[i][2];
if(tfc.gl('ChoiceImageHolder-'+chid))noChoicesHaveImage=false;
var el=tfc.gl('I'+chid);
if(el){
var w=parseInt(el.parentNode.getAttribute('tnw')),h=parseInt(el.parentNode.getAttribute('tnh')),mw=parseInt(el.parentNode.getAttribute('tnmw')),mh=parseInt(el.parentNode.getAttribute('tnmh'));
var wh=tf.core.crFFldImager.scale(mw,mh,w,h);
if(wh[1]>choiceImageMH)choiceImageMH=wh[1];
}
}
}
function optImg(id,locationpart){
if(noChoicesHaveImage)return '';
var s='';
if(tfc.__sfChoiceImageLocation&&tfc.__sfChoiceImageLocation.indexOf(locationpart)==0){
var elChImg=tfc.gl('ChoiceImageHolder-'+id);
if(elChImg){
var sChImg=tf.core.crFFldImager.outerHTML(elChImg).replace('ChoiceImageHolder-','ChoiceImage-').replace(/rel="sfMediaBox\[.*?\]"/,'');
s='<div class="ProductChoiceNameImageParent" '+(choiceImageMH>0?'style="height:'+choiceImageMH+'px"':'')+'>'+sChImg+'</div>';
}
else{
s='<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>';
}
}
return s;
}
function _v(v,a,o){
var 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)+'"';
if(updDisp)tf.core.crFFldOptPrc.resetTemporarily(pid);
s+=' 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)+'"';
if(updDisp)tf.core.crFFldOptPrc.unreset(pid);
return s;
}
function _opdp(v,a,o,minorPrice){
var pprice=oCachePPriceArr[pid]||[];
var op=getOPrc(v,a,o);
if(!minorPrice){
var doApplyTax=true;
if(pprice[2]){doApplyTax=!(tf.core.Basket.tax._tax.get(pprice[2]).incTax&&!tf.core.Basket.tax.forRegion(pprice[2],tf.core.region));}
if(doApplyTax)op=tf.core.BTax.taxAppliedRawAmt(pprice[2]||'',op);
}
var isNegative=(op<-0.001);
var aRet=tf.core.getPPrices(pid,pprice[2]||'',null,Math.abs(op)||'0.00');
if(isNegative){aRet['op']*=-1;aRet['dp']*=-1;}
return aRet;
}
function _p(v,a,o,showdsc){
var aRet=_opdp(v,a,o,tf.core.BTax.showBoth),op=aRet['op'],_dp=aRet['dp'];
if(op>0.001)var pf='LD_OPTION_PRICE_ADD';
else if(op<-0.001)var pf='LD_OPTION_PRICE_SUBTRACT';
{
if(updDisp)tf.core.crFFldOptPrc.resetTemporarily(pid);
aRet=_opdp(v,a,o,tf.core.BTax.showBoth);
var pf='',df=(aRet['op']<-0.001?'(-%%)':'(%%)');
if(updDisp)tf.core.crFFldOptPrc.unreset(pid);
if(aRet['op']==0)return'';
}
var div='<div style="white-space:nowrap;display:inline-block;*display:inline;">';
if (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>'
:' '+div+ld(pf,df,[aRet['calc']])+'</div>');
else
return (tf.core.BTax.showBoth?' '+div+ld(pf,df,[' '+aRet['prc1_text']+' '+aRet['prc1_amt']+', </div>'+div+aRet['prc2_text']+' '+aRet['prc2_amt']])+'</div>'
:' '+div+ld(pf,df,[aRet['calc']])+'</div>');
}
function _ip(n,t,cl,v,a,on,dv) {
optImgInit(a);
var s='',updStkDisp=true,len=a?a.length:0,idForImg=pid;
for (var i=0;i<len;i++) {
var chid=a[i][2];
if(updDisp){if(crFFldOptPrc.oFldSel[a[i][2]])dv=crFFldOptPrc.oFldSel[a[i][2]]}
var val=(t=='text')?' value="'+(dv||a[i][1]).replace(/"/g,'&quot;')+'"'+_v(v,a[i],i):_v(v,a[i],i);
var ch=(dv=='1')?' checked':'';ch=((dv?dv:'0')=='1'&&first)?' checked':'';
if (ch&&t=='radio') first=false;
var onfocus='if(tf.isInSF())return false;',onblur='',onblurcode='',onmousedown='',onmouseup='',onchange='',onclick='if(tf.isInSF())return false;';
var imgChanger=choiceImageInProductImageArea?'tf.core.crFFldImager.replace(\''+pid+'\','+(ch?'false':'true')+'?\''+a[i][2]+'\':null);':'';
var prcUpdater=(updDisp?'tf.core.setFocusID=\''+chid+'\';tf.core.crFFldOptPrc.updPrc(\''+pid+'\',\''+a[i][2]+'\',crFFldArr,opt);':'');
if(t=='radio'){onclick+='dBasePrice2(\''+pid+'\',this.value);';}
switch(t){
case 'text':
onmousedown+='tf.core.setFocusID=\''+chid+'\';';
onfocus+=imgChanger;
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;
break;
case 'radio':
onmouseup+=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;
onchange+=prcUpdater;
break;
case 'checkbox':
onclick+=codeToHandleTextBlur+imgChanger+prcUpdater;
onchange+=prcUpdater;
break;
default:
onclick+=codeToHandleTextBlur+imgChanger+prcUpdater;
}
var 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';
s+=pcnB.replace(/\%\%/,a[i][2]);
s+=optImg(chid,'optionarea_radiobutton_separate');
if(!right&&t!='text'){s+=btn;}
var dp=(t=='radio'||(t=='checkbox'))?_p(a[i][0],id,i,true):'';
if (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>';
if(right||t=='text'){s+=btn;}
s+=pcnE;
if(t=='text'||t=='checkbox')idForImg=chid;
var elImg=tf.content.gl('I'+pid);
if(ch&&core){
idForImg=chid;
if(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);}
setTimeout("tfc.dBasePrice2('"+pid+"','"+(['','','','',a[i][6],a[i][7],a[i][8]].join(str_sep1))+"',tfc)",500);
if(choiceImageInProductImageArea){
if(elImg){
var hasNoDimensions=(!elImg.getAttribute('width')&&!elImg.getAttribute('height'));
if(tf.isIE7)hasNoDimensions=!elImg.outerHTML.match(/(?:width|height)=/i);
if(hasNoDimensions)setTimeout('tf.core.crFFldImager.replace(\''+pid+'\',\''+a[i][2]+'\');',500);
}
}
}
if(elImg){
if(elImg.getAttribute('mediatype')=='HTML')setTimeout('tf.core.crFFldImager.replace(\''+pid+'\',\''+pid+'\');',500);
}
}
s=optImg(idForImg,'optionarea_radiobutton_one')+s;
return s;
}
function _sl(n,r,a,dv,on){
var s=[
'',
'<select name="'+n.replace(/"/g,'&quot;')+'"',
(updDisp?' onfocus="'+codeToHandleTextBlur+'"':''),
(updDisp?' onclick="cancelBuble(event);if(tf.isInSF())return false;"':' onclick="cancelBuble(event);if(tf.isInSF())return false;"'),
' onChange="',
choiceImageInProductImageArea?'tf.core.crFFldImager.replace(\''+pid+'\',this.value.split(core.str_sep1)[7]);':'',
'var c = this.value;',
(updDisp?'tf.core.crFFldOptPrc.updPrc(\''+pid+'\',this.value?this.value.split(core.str_sep1)[7]:\''+a[0][0]+'\',crFFldArr,opt);':''),
'dBasePrice2(\''+pid+'\',c);',
'return false;"',
' size='+r+'>\n'
];
if(args[6]=='0'){s.push('<option value="">'+on+'</option>');}
else{s.push('<option value="" disabled data-nosel="">'+on+'</option>');}
var iSel=-1,updStkDisp=true,idForImg=pid;
for (var i=0; i<a.length; i++) {
var checked='';iSel=-1;chid=a[i][2];
if(updDisp){
var sel='';
if(crFFldOptPrc.oFldSel[a[i][2]])sel=crFFldOptPrc.oFldSel[a[i][2]];
}
var bSel=false;
if (updDisp && (i==0&&dv!='0'&&!sel||sel=='1')) {
iSel=i;
bSel=true;
}
var elImg=tf.content.gl('I'+pid);
if (bSel || i==0&&dv!='0') {
idForImg=chid;
checked=' selected';
if(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);}
if(core)tfc.dBasePrice2(pid,(['','','','',a[i][6],a[i][7],a[i][8]].join(str_sep1)),tfc);
if(choiceImageInProductImageArea){
if(elImg) {
var hasNoDimensions=(!elImg.getAttribute('width')&&!elImg.getAttribute('height'));
if(tf.isIE7)hasNoDimensions=!elImg.outerHTML.match(/(?:width|height)=/i);
if(hasNoDimensions)setTimeout('tf.core.crFFldImager.replace(\''+pid+'\',\''+a[i][2]+'\');',500);
}
}
}
if(elImg) {
if(elImg.getAttribute('mediatype')=='HTML')setTimeout('tf.core.crFFldImager.replace(\''+pid+'\',\''+pid+'\');',500);
}
s.push('<option '+_v(1,a[i],i)+checked+'>'+a[i][1]+_p(a[i][0],id,i,false,checked?false:true)+'</option>\n');
}
s.push('</select>');
optImgInit(a);
s[0]=optImg(idForImg,'optionarea_');
return s.join('');
}
var 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;
var showincluded=false,ponEE='';
var rc=(c=='')?'':' cols="'+c+'"';
rc+=(r=='')?'':' rows="'+r+'"';
if(updDisp){
if(t==1||t==2){
tf.core.crFFldOptPrc.resetTemporarily(pid);
showincluded=(getOPrc(oA[0][0],id,0)!=0);
tf.core.crFFldOptPrc.unreset(pid);
ponB='<div class="GC74 ProductOptionName">';
if(tf.utils&&tf.utils.imgEntryPageFix&&tf.isEntryPage)ponE=tf.utils.imgEntryPageFix(ponE);
}
else if(t==4){
pcnB=pcnB.replace(/\%1/,oA[0][2]);
}
}
var s='',ponBE=(choicesonly?'':ponB+on+(t==1?'<span style="font-weight:normal;">'+_p(oA[0][0],id,0,true,!showincluded)+'</span>':'')+ponE);
switch(t) {
case 1:s=pogB+ponBE+_ip(n,'text','TextInput',0,oA,on)+pogE;break;
case 5:s=pogB+ponBE+_ip(n,'radio','RadioButtonIcon',1,oA,on,dv)+pogE;break;
case 6:s='<div class="ProductOptionInner ProductOptionInnerCheckbox" data-option-type="checkbox">'+_ip(n,'checkbox','CheckBoxIcon',1,oA,on,dv)+pogE;break;
case 3:rc='';
case 4:
s=pogB+pcnB+_sl(n,r,oA,dv,on)+pcnE+pogE;
break;
case 2:
chid=oA[0][2];
if(updDisp){
if(crFFldOptPrc.oFldSel[oA[0][2]])dv=crFFldOptPrc.oFldSel[oA[0][2]];else dv='';
ponBE=(choicesonly?'':ponB+on+'<span style="font-weight:normal;">'+_p(oA[0][0],id,0,true,!showincluded)+'</span>'+ponE);
var prcUpdater='tf.core.crFFldOptPrc.updPrc(\''+pid+'\',\''+oA[0][2]+'\',crFFldArr,opt);';
}
else {
var prcUpdater='';
}
optImgInit(oA[0]);
var pcnBI=optImg(chid,'optionarea_');
s=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;
}
return s;
}
function load_add(d,type,id,title,weight,orderNo,useDec,esd,taxes,prd_cd,man_cd,dst_cd,prc_cd,opt,issf,s,minorder,temp) {
var ret=false;
if (!isNaN(prd_cd)) prd_cd+='%%P';
var qnty;
qnty=tf.content.document.getElementById(id+'_Quantity');
if (!minorder) minorder=(useDec>0)?'1.00':'1';
if (useDec<1) minorder=parseInt(minorder);
var qv='';
if(qnty){
qv=nfmt.fromLoc(qnty.value);
if(isNaN(qv))qnty.value=(useDec?nfmt.toLoc("1.00"):"1");
else{
if((useDec>0&&parseFloat(qv)<0.0001)||(useDec<1&&parseInt(qv)<1))qnty.value=nfmt.toLoc(minorder);
else qnty.value=nfmt.toLoc(qv);
}
}
qnty=qnty?parseFloat(nfmt.fromLoc(qnty.value)):0;
if (isNaN(qnty) || !qnty || (qnty<0)) qnty=1;
if (tf.coreLoaded&&issf!=true) {
var bt;bt=core.Basket;
if (type==1){bt=core.Favorite;bt.save();}
ret=bt.parse(id,d,qnty,title,weight,orderNo,useDec,esd,taxes,opt,prd_cd,man_cd,dst_cd,prc_cd,null,false,temp,type);
} else if (confirm(ld('LD_ENTER_SHOP','Pour acheter ce produit vous devez entrer dans la boutique. Souhaitez-vous accéder à la boutique maintenant ?'))) {
location = s+'#'+id.toLowerCase();
}
return ret;
}
function prodTypeCode(type,prd) {
var code = '';
switch (type){
case 0: // Brand
code = prd[14];
break;
case 1: // ManufacturerCode
code = prd[11];
break;
case 2: // ProductCode
code = prd[9];
break;
case 3: // DistributorCode
code = prd[12];
break;
case 4: // PriceCode
code = prd[13];
break;
case 5: // DiscountCode
code = prd[23];
break;
}
return code;
}
var nfmt=new numeric(',','');
var css=new CSS();
var nfmt=new numeric(',',''),css=new CSS();
var Basket=new basket();
var bskRestoreHelper=new basket();
var theBsk=Basket;
var Favorite=new basket('Favorite');
tf.coreLoaded=true;
try{tf.content.core=this.window;}catch(e){}
tf.core=core=this.window;
if(currTime)currTime.getTime();
tf.nametag.add('showCookieWarning',getCookStr('showCookieWarning')=='false'?false:true);
function waitforconf(){
if(confLoaded&&tf.langLoaded&&typeof(load_page)!='undefined'){
if(!tf.isInSF()){
var restore=eval(tf.nametag.get('nmdt'));
if(!restore)restore=tf.core.getCookStr('nmdt');
if(restore){
if(tf.pgid=='D-6'||tf.pgid=='D-16'||tf.pgid=='D-8'){
tf.name=(restore===true?tf.core.getCookStr('nmdt'):restore);
}
tf.nametag.del('nmdt');
tf.core.delCookStr('nmdt');
}
}
if(!tf.isInSF())Basket.load();
if(!tf.isInSF()&&pm&&tf.content.$)pm.get();
rl_total();
setTimeout(Favorite.load.apply(Favorite),2000);
}
else setTimeout("waitforconf()",100);
}
var pageID=(window.external&&window.external['getPageID']?window.external['getPageID']():'');
if(pageID!='D-42'){
tf.load('grey.html','shipping');
tf.load('conf.html','conf',true);
waitforconf();
}
tf.core=this.window;
tf.utils=this.window;
if(tf.extra){this.dynamic=tf.extra.dynamic;this.dynLoad=tf.extra.dynLoad;}
if($)$(tf).trigger('coreLoaded');
ldjs('../../../shared_files/menu_scroller.js');
/*$Revision: 47065 $
$HeadURL: svn://localhost/ShopFactory/branches/V14_60/bin/Common%20Files/parseLang/sf.js $*/