if (!gwpstyle) { var gwpstyle = document.createElement('style'); gwpstyle.textContent = ' .gwp-div { clear: both; position:relative; } .sm-gwp-img-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0px; width: 100%; } .gwp-opt { box-sizing: border-box; text-align: center; border:3px solid transparent; border-bottom: 0px; padding:1px 1px 5px 1px; margin:0px; border-radius:7px; overflow-x:hidden; position: relative; } .gwp-opt:hover { border:0px solid #EEEEEE; padding:1px; } .gwp-opt-sel { border:2px solid #777777 !important; padding:1px; } .gwp-opt-sel:hover { padding:1px; } .gwp-opt-name { text-align: center; width: 100%; } .gwp-opt-title { min-height: 1em; padding: 11px 0px; } .gwp-opt-prev { position:relative; } .gwp-opt-prev div { position:absolute; left:-205px; width:200px; display:none; z-index:1000; border:1px solid #bcbcbc; background-color:#FFFFFF; box-shadow:3px 3px 6px #AAAAAA; } .gwp-opt img { cursor:pointer; border-radius:7px; } .gwp-opt-more { position:relative; cursor:pointer; border-radius:7px; border:1px solid #888888; color:#888888; padding-top:100%; } .gwp-opt-more div { font-size:14px; text-align:center; line-height:12px; position:absolute; top:50%; left:0px; width:100%; margin-top:-0.5em; }'; document.head.appendChild(gwpstyle); } gwpNo = {2418: "0", 2326: "0", 2327: "0", 2328: "0", 2329: "0", 2357: "0", 2365: "0", 2366: "0", 2367: "0", 2368: "0", 2385: "0", 2448: "0", 2449: "0", 2466: "0", 2470: "0", 2480: "0", 2550: "0", 2551: "0", 2562: "0", 2563: "0", 2564: "0", 2576: "0", 2625: "0", 2641: "0", 2642: "0", 2643: "0", 2644: "0", 2645: "0", 2674: "0", 2675: "0", 2709: "0", 2754: "0", 3047: "0", 3186: "0", 3187: "0", 3188: "0", 3189: "0", 2351: "0", 2352: "0", 2353: "0", 2354: "0", 2356: "0", 2358: "0", 2359: "0", 2360: "0", 2361: "0", 2380: "0", 2381: "0", 2382: "0", 2383: "0", 2384: "0", 2446: "0", 2447: "0", 2476: "0", 2495: "0", 2518: "0", 2652: "0", 2653: "0", 2654: "0", 2655: "0", 2656: "0", 2657: "0", 2659: "0", 2660: "0", 2661: "0", 2662: "0", 2713: "0", 2722: "0", 2759: "0", 2760: "0", 3182: "0", 3183: "0", 3184: "0", 3185: "0", 2640: "0", 2668: "0", 2669: "0", 2670: "0", 2671: "0", 2672: "0", 2673: "0", 2697: "0", 2698: "0", 2700: "0", 2909: "0", 2910: "0", 2912: "0", 2913: "0", 2914: "0", 2915: "0", 2334: "0", 2335: "0", 2336: "0", 2337: "0", 2355: "0", 2374: "0", 2375: "0", 2911: "0", 2917: "0", 2376: "0", 2377: "0", 2386: "0", 2450: "0", 2451: "0", 2472: "0", 2505: "0", 2559: "0", 2621: "0", 2623: "0", 2634: "0", 2635: "0", 2636: "0", 2648: "0", 2649: "0", 2650: "0", 2651: "0", 2663: "0", 2664: "0", 2665: "0", 2666: "0", 2680: "0", 2681: "0", 2740: "0", 3046: "0", 3071: "0", 3178: "0", 3179: "0", 3180: "0", 3181: "0", 3211: "0", 2417: "0", 2420: "0", 2421: "1", 2436: "0", 2918: "0", 2919: "0", 2920: "0", 2921: "0", 2922: "0", 2923: "0", 2924: "0", 2925: "0", 2926: "0", 3003: "0", 3004: "0", 3005: "0", 3006: "0", 3007: "0", 3057: "0", 3147: "0", 3148: "0", 3149: "0", 3154: "0", 3227: "1", 3230: "0", 3232: "0", 3228: "0", 3231: "0", 3233: "0", 3155: "0", 3156: "0", 3157: "0", 3198: "0", 3199: "0", 3200: "0", 3216: "0", 3215: "0", 3193: "0", 3195: "0", 3194: "0", 3196: "0", 3197: "0", 3238: "0", 3236: "0", 3239: "0", 3237: "0", 3247: "1", 3248: "0", 3256: "0", 3257: "0", 3258: "0", 3260: "0", 3259: "0", 3262: "0", 3261: "0", 3263: "0", 3264: "0", 3265: "0", 3266: "0", 3267: "0", 3268: "0", 3269: "0", 3270: "0", 3274: "2", 3275: "2", 3283: "2", 3284: "2", 3285: "2", 3281: "2", 3282: "3", 3289: "2", 3290: "2", 3291: "3", 3279: "2", 3280: "2", 3286: "2", 3287: "2", 3288: "2", 3292: "2", 3293: "2", 3294: "2", 3297: "1", 3298: "1", 3299: "2", 3300: "1", 3301: "1", 3302: "1", 3303: "1", 3304: "1", 3326: "2", 3327: "1", 3328: "1", 3329: "1", 3330: "1", 3340: "1", 3341: "1", 3342: "1", 3343: "1", 3359: "1", 3360: "1", 3361: "1", 3362: "1", 3370: "1", 3371: "1", 3372: "1", 3373: "1", 3364: "1", 3365: "1", 3366: "1", 3367: "1", 3424: "1", 3425: "1", 3426: "1", 3427: "1", 3428: "1", 3429: "1", 3420: "1", 3430: "1", 3431: "1", 3432: "1", 3433: "1", 3434: "1", 3436: "1", 3437: "1", 3438: "1", 3439: "1", 3440: "1", 3441: "1", 3442: "1", 3447: "1", 3448: "1", 3449: "1", 3450: "1", 3451: "1", 3416: "1", 3457: "1", 3458: "1", 3473: "1", 3474: "1", 3475: "1", 3476: "1", 3435: "", 3477: "1", 3479: "1", 3480: "1", };var opt_list = [158,153,155,162,160,166,168,174,173,188]; var more_txt = [], less_txt = [], optTmp = [], optTmpVal = [], isStock = 0; var changeStock = 0; var sid = '19'; var url = 'https://gwp.brweb.pl/i/19/'; var imgLimit = '10'; var moreLabel = '+'; var lessLabel = '-'; var showMLcnt = 1; var prevMopen = ''; var selectLangVal = ['','wybierz','choose','wählen','Vybrat','vali','izvēlēties','pasirinkti','választ','vyberte si','вибрати']; function showPrev(e) { if (window.innerWidth < 700) return null; var id = e.id; var aId = id.split('__'); var aSO = aId[0].split('_'); var soptid = aSO[1]; var pid = soptid; var prev_div = document.getElementById('gwp_div_preview_'+pid); prev_div.style.display = 'block'; prev_div.innerHTML = ''; setTimeout(movePrev,10,pid); } function hidePrev(e) { if (window.innerWidth < 700) return null; var id = e.id; var aId = id.split('__'); var aSO = aId[0].split('_'); var soptid = aSO[1]; var pid = soptid; var prev_div = document.getElementById('gwp_div_preview_'+pid); prev_div.style.display = 'none'; prev_div.innerHTML = ''; prev_div.style.top = '0px'; } function movePrev(pid) { var prev_div = document.getElementById('gwp_div_preview_'+pid); var imgH = prev_div.getElementsByTagName('IMG')[0]; if (!imgH) { setTimeout(movePrev,10,pid); return false; } const recti = imgH.getBoundingClientRect(); if (recti.height == 0) { setTimeout(movePrev,10,pid); return false; } var hcorr = (recti.top + recti.height - window.innerHeight + 20) * -1; hcorr = (hcorr < 0 ? hcorr : 0); if (recti.top < 20) { hcorr = (recti.top + hcorr - 20) * -1; } if (recti.top > 20 && recti.height + 40 > window.innerHeight) { hcorr = (recti.top - 20) * -1; } prev_div.style.top = hcorr + 'px'; } function oClick(e,type) { if (type == 'S') { selectClick(e); } else { radioClick(e); } setTimeout(showGWP,500); } function selectClick(e) { var id = e.id; var aId = id.split('__'); if (document.getElementById(aId[0]).value != aId[1] || document.getElementById(aId[0]).length == 1) { document.getElementById(aId[0]).value = aId[1]; if (document.getElementById('gwp_div_title_'+aId[0].replace('option_',''))) document.getElementById('gwp_div_title_'+aId[0].replace('option_','')).innerHTML = e.title; } else { document.getElementById(aId[0]).selectedIndex = '0'; if (document.getElementById('gwp_div_title_'+aId[0].replace('option_',''))) document.getElementById('gwp_div_title_'+aId[0].replace('option_','')).innerHTML = ''; id = aId[0] + '__' + document.getElementById(aId[0]).value; } document.getElementById(aId[0]).dispatchEvent(new Event('change')); var c = document.getElementsByClassName('c_' + aId[0]); for( var i = 0; i < c.length; i++){ c[i].parentElement.className = c[i].parentElement.className.replace(' gwp-opt-sel',''); if ( c[i].id == id ) { c[i].parentElement.className = c[i].parentElement.className + ' gwp-opt-sel'; } } optTmpVal[aId[0].replace('option_','')] = document.getElementById(aId[0]).value; } function radioClick(e) { var id = e.id; var aId = id.split('__'); document.getElementById(aId[0]+'_'+aId[1]).click(); if (document.getElementById('gwp_div_title_'+aId[0].replace('option_',''))) document.getElementById('gwp_div_title_'+aId[0].replace('option_','')).innerHTML = e.title; var c = document.getElementsByClassName('c_' + aId[0]); for( var i = 0; i < c.length; i++){ c[i].parentElement.className = c[i].parentElement.className.replace(' gwp-opt-sel',''); if ( c[i].id == id ) c[i].parentElement.className = c[i].parentElement.className + ' gwp-opt-sel'; } } function gwpMore(oid) { var h = document.getElementsByClassName('gwpHidden'+oid); var type = more_txt[oid] == document.getElementById('gwp_more'+oid).innerHTML ? 'block' : 'none'; for( var i = 0; i < h.length; i++){ h[i].style.display = (h[i].className == 'gwp-opt gwpHidden'+oid+' gwp-opt-sel') ? 'block' : type; } document.getElementById('gwp_more'+oid).innerHTML = type == 'block' ? less_txt[oid] : more_txt[oid] ; } function showGWP() { var isLoading = 0; var isDiff = 0; opt_list.forEach(function(opt_id) { var sr = document.getElementsByName('option_'+opt_id); if (sr.length == 0) { return; } var optValue = ''; if (sr[0].id == sr[0].name ) { var optType = 'S'; var s = sr[0]; var c = s.getElementsByTagName('option'); var optValue = s.value; } else { var optType = 'R'; var s = sr[0].parentElement.parentElement; var c = sr; for( var j = 0; j < c.length; j++){ if (c[j].checked == true) { optValue = c[j].innerHTML; } } } isDiff = (!optTmp[opt_id] || optTmp[opt_id] != s.innerHTML || optTmpVal[opt_id] != s.value) ? 1 : 0; var eStock = (optType == 'S') ? s.parentElement.className : sr[0].parentElement.className; if (eStock.indexOf('option_truestock ') != -1 && eStock.indexOf('loading') != -1) { isLoading++; } if (isDiff == 1 || changeStock == 1) { console.log('gwp'); if (optType == 'R') { s.style.visibility = 'hidden'; s.style.width = '0px'; s.style.height = '0px'; s.style.position = 'absolute'; s.style.bottom = '0px'; } else { s.style.display = 'none'; } var sOptions = '', sPreview = '', sTitle = ''; var imgNo = 0; var optCnt = (optType == 'S') ? c.length - 1 : c.length; if (optType == 'R') { for( var j = 0; j < c.length; j++){ if (c[j].parentElement.className == 'radio-wrap none') { optCnt--; } } var rlabels = s.getElementsByTagName('label'); var rDict = new Array(); for( var rli = 0; rli < rlabels.length; rli++){ if (rlabels[1].innerHTML != '' || !rlabels[rli]) rDict[rlabels[rli].getAttribute('for')] = rlabels[rli].innerHTML; } } more_txt[opt_id] = moreLabel + (showMLcnt == 1 ? (optCnt - imgLimit + 1) : ''); less_txt[opt_id] = lessLabel + (showMLcnt == 1 ? (optCnt - imgLimit + 1) : ''); var smTitle = ''; for( var j = 0; j< c.length; j++){ if (!selectLangVal.includes(c[j].value) && c[j].parentElement.className != 'radio-wrap none') { imgNo++; var smIsSelect = ((optType == 'S' && (s.options[s.selectedIndex].value == c[j].value || s.value == c[j].value)) || (optType == 'R' && c[j].checked == true)) ? 1 : 0; smItenSelect = smIsSelect == 1 ? ' gwp-opt-sel' : ''; smItenDisplay = (imgNo < imgLimit || (imgNo == imgLimit && imgNo == optCnt)) ? 'block' : 'none'; var lastOpt = (imgNo == imgLimit - 1) ? '!important' : ''; var lastOptClass = (imgNo == imgLimit - 1) ? ' toHidden ' : ''; var lastOptId = (imgNo == imgLimit - 1) ? ' id="gwp_loi_'+oId+'" ' : ''; if (smIsSelect == 1) { smItenDisplay = 'block'; if (imgNo > imgLimit || (imgNo == imgLimit && imgNo < optCnt)) { sOptions = sOptions.replace('block!important','none'); sOptions = sOptions.replace('toHidden','gwpHidden'+opt_id); } } smItenHidden = (imgNo > imgLimit || (imgNo == imgLimit && imgNo != optCnt)) ? ' gwpHidden'+opt_id+' ' : ''; oName = (optType == 'S') ? c[j].innerHTML : rDict[c[j].id]; oId = (optType == 'S') ? s.id : c[j].name; if (smItenSelect == ' gwp-opt-sel') { smTitle = oName; } sOptions += '
'; } } if (optCnt > imgLimit) { sOptions += '
' + more_txt[opt_id] + '
'; } sPreview = '
'; if (document.getElementById('gwp_div_list_'+opt_id)) { document.getElementById('gwp_div_title_'+opt_id).innerHTML = sTitle; document.getElementById('gwp_div_list_'+opt_id).innerHTML = sOptions; } else { const div_title = document.createElement('div'); div_title.id = 'gwp_div_title_'+opt_id; div_title.className = 'gwp-opt-title'; div_title.innerHTML = sTitle; const div_prev = document.createElement('div'); div_prev.id = 'gwp_div_prev_'+opt_id; div_prev.className = 'gwp-opt-prev'; div_prev.innerHTML = sPreview; const div_list = document.createElement('div'); div_list.id = 'gwp_div_list_'+opt_id; div_list.className = 'sm-gwp-img-list'; div_list.innerHTML = sOptions; if (optType == 'S') { var div4title = s.parentElement.parentElement; } else { var div4title = s.parentElement; } div4title.prepend(div_title); if (optType == 'S') { s.parentElement.parentElement.parentElement.appendChild(div_prev); s.parentElement.parentElement.parentElement.appendChild(div_list); } else { s.parentElement.parentElement.appendChild(div_prev); s.parentElement.parentElement.appendChild(div_list); } } optTmp[opt_id] = s.innerHTML; optTmpVal[opt_id] = s.value; } }); changeStock = 0; if (isLoading > 0 || isDiff == 1) { setTimeout(showGWP,100); } } window.onload = function(){ showGWP(); }; showGWP(); setTimeout(showGWP,1000);