PageSourceSearch

https://www.bicikel.com/library/js/core.js?revision=1790945497

js bicikel.com collected 2026-10-02 12:52:11 UTC 86,520 bytes, 2,959 lines download raw bytes

1var BASE_URL = $("#BASE_URL").val();
2
3jQuery('<div class="quantity-nav"><div class="quantity-button quantity-up"></div><div class="quantity-button quantity-down"></div></div>').insertAfter('.quantity input');
4jQuery('.quantity').each(function () {
5    var spinner = jQuery(this),
6            input = spinner.find('input[type="number"]'),
7            btnUp = spinner.find('.quantity-up'),
8            btnDown = spinner.find('.quantity-down'),
9            min = input.attr('min'),
10            max = input.attr('max');
11
12    btnUp.click(function () {
13        var oldValue = parseFloat(input.val());
14        if (oldValue >= max) {
15            var newVal = oldValue;
16        } else {
17            var newVal = oldValue + 1;
18        }
19        spinner.find("input").val(newVal);
20        spinner.find("input").trigger("change");
21    });
22
23    btnDown.click(function () {
24        var oldValue = parseFloat(input.val());
25        if (oldValue <= min) {
26            var newVal = oldValue;
27        } else {
28            var newVal = oldValue - 1;
29        }
30        spinner.find("input").val(newVal);
31        spinner.find("input").trigger("change");
32    });
33
34});
35
36
37$(document).on('ready', function () {
38
39    $(".tab1Slider").slick({
40        dots: true,
41        infinite: true,
42        slidesToShow: 4,
43        slidesToScroll: 4,
44        autoplay: true,
45        autoplaySpeed: 2000,
46        responsive: [
47            {
48                breakpoint: 1200,
49                settings: {
50                    slidesToShow: 4,
51                    slidesToScroll: 2,
52                    infinite: true,
53                    dots: true
54                }
55            },
56            {
57                breakpoint: 992,
58                settings: {
59                    slidesToShow: 2,
60                    slidesToScroll: 2
61                }
62            },
63            {
64                breakpoint: 768,
65                settings: {
66                    slidesToShow: 1,
67                    slidesToScroll: 1,
68                    dots: false
69                }
70            }
71        ]
72    });
73
74    $(document).on('click', 'a[href^="#"]', function (event) {
75        event.preventDefault();
76
77        $('html, body').animate({
78            scrollTop: $($.attr(this, 'href')).offset().top
79        }, 500);
80    });
81
82    $(window).scroll(function () {
83        $('#MagazineBox').slideUp();
84        $('.customDropdown').slideUp();
85    });
86
87
88    $(document).mouseup(function (e)
89    {
90        var container = $(".customDropdown");
91
92        // if the target of the click isn't the container nor a descendant of the container
93        if (!container.is(e.target) && container.has(e.target).length === 0)
94        {
95            container.slideUp();
96        }
97
98        var container = $("#MagazineBox");
99
100        // if the target of the click isn't the container nor a descendant of the container
101        if (!container.is(e.target) && container.has(e.target).length === 0)
102        {
103            container.slideUp();
104        }
105    });
106
107
108    setTimeout(function () {
109        // HIDE CLOUD AND ZERO IF NO COMMENTS
110        $(".article__comments__number").each(function () {
111            if ($(this).html() == "0") {
112                $(this).parent(".article__body__small").hide();
113                $(this).parent(".article__comments").hide();
114            }
115        });
116
117    }, 200);
118
119});
120
121function scrollToAnchor(aid) {
122    var tag = $("#" + aid + "");
123    if (aid == "lc") {
124        $('html,body').animate({scrollTop: tag.offset().top}, 'slow');
125    } else {
126        $('html,body').animate({scrollTop: tag.offset().top - 200}, 'slow');
127    }
128
129}
130
131function getParameterByName(name) {
132    var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
133    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
134}
135
136$(".TagsCheckboxes .pure-checkbox").click(function (event) {
137    var SelectedTag = $(event.currentTarget).find("input").val();
138    var CurrentUrl = window.location.href.split('?')[0];
139
140    /*var queryString = '&'+(document.location+'?').split('?')[1];
141     if(queryString.match(/&Tag=/)){
142     var TagQueryString = "Tag=" + SelectedTag;
143     } /*else if(queryString.match(/&Tag=/)){
144     var OrderQueryString = "OrderBy=" + SelectedTag;
145     }*/
146
147
148    SelectedTag = "?Tag=" + SelectedTag;
149    window.location.href = CurrentUrl + SelectedTag;
150
151    var TagQueryString = getParameterByName("Tag");
152    var OrderByQueryString = getParameterByName("OrderBy");
153
154
155});
156
157$(".forumPaginator .forumPaginator__element").click(function (event) {
158    var SelectedPage = $(event.currentTarget).data("page");
159    var CurrentUrl = window.location.href.split('?')[0];
160
161    SelectedPage = "?Page=" + SelectedPage;
162
163    var QueryString = CurrentUrl + SelectedPage;
164
165    var TagQueryString = getParameterByName("Tag");
166    if (TagQueryString)
167        QueryString = QueryString + "&Tag=" + TagQueryString;
168
169    var OrderByQueryString = getParameterByName("OrderBy");
170    if (OrderByQueryString)
171        QueryString = QueryString + "&OrderBy=" + OrderByQueryString;
172
173    window.location.href = QueryString;
174
175});
176
177function jumpToLastComment(LastPage) {
178    //var SelectedPage = $(event.currentTarget).data("page");
179    var CurrentUrl = window.location.href.split('?')[0];
180
181    var SelectedPage = "?Page=" + LastPage + "#lc";
182
183    var QueryString = CurrentUrl + SelectedPage;
184
185    var TagQueryString = getParameterByName("Tag");
186    if (TagQueryString)
187        QueryString = QueryString + "&Tag=" + TagQueryString;
188
189    var OrderByQueryString = getParameterByName("OrderBy");
190    if (OrderByQueryString)
191        QueryString = QueryString + "&OrderBy=" + OrderByQueryString;
192
193    window.location.href = QueryString;
194
195}
196
197
198$(".article__bookmark").hover(
199        function (event) {
200            var Selected = event.currentTarget;
201            $(Selected).find("img").attr("src", BASE_URL + "/library/images/heart.svg");
202        },
203        function (event) {
204            var Selected = event.currentTarget;
205            if (!$(Selected).hasClass("selected")) {
206                $(Selected).find("img").attr("src", BASE_URL + "/library/images/heart-outline.svg");
207            }
208        }
209);
210
211$(".article__bookmark").click(
212        function (event) {
213            event.preventDefault();
214            var Selected = event.currentTarget;
215            var NewsID = $(Selected).data("id");
216            var Type = "add";
217
218            if ($(Selected).hasClass("selected")) {
219                $(Selected).find("img").attr("src", BASE_URL + "/library/images/heart-outline.svg");
220                $(Selected).removeClass("selected");
221                Type = "delete";
222            } else {
223                $(Selected).find("img").attr("src", BASE_URL + "/library/images/heart.svg");
224                $(Selected).addClass("selected");
225            }
226
227            $.post(BASE_URL + "/application/ajax/portal/saveBookmark.php", {NewsID: NewsID, Type: Type}, function (data, status) {
228                var Data = JSON.parse(data);
229                if (Data.Status == "Success") {
230                    var ee = 1;
231                } else {
232                    $('#LoginModal').modal('show');
233                }
234            });
235        }
236);
237
238function resetlazyLoadListings() {
239    $('#LazyLoadSection').val(0);
240    $('.listings').html('');
241}
242
243function lazyLoadListings() {
244
245    console.log("lazyLoadListings");
246
247    var types = [];
248    $('[data-filter="type"]:checked').each(function () {
249        var element = $(this).val();
250        types.push("'" + element + "'");
251    });
252
253    var typesS = "";
254    if (types.length !== 0) {
255        typesS = types.join(",");
256    }
257
258    var sorts = [];
259    $('[data-filter="sort"]:checked').each(function () {
260        var element = $(this).val();
261        sorts.push("'" + element + "'");
262    });
263
264    var sortsS = "";
265    if (sorts.length !== 0) {
266        sortsS = sorts.join(",");
267    }
268
269    var categories = [];
270    $('[data-filter="category"]:checked').each(function () {
271        var element = $(this).val();
272        categories.push("'" + element + "'");
273    });
274
275    var categoriesS = "";
276    if (categories.length !== 0) {
277        categoriesS = categories.join(",");
278    }
279
280    var SearchInput = $("#SearchInput").val();
281
282    if (SearchInput !== "") {
283        $(".listings").empty();
284    }
285
286    var LazyLoadSection = $('#LazyLoadSection').val();
287    $.post(BASE_URL + "/application/ajax/portal/ll_listings.php", {LazyLoadSection: LazyLoadSection, Types: typesS, Sorts: sortsS, Categories: categoriesS, SearchInput: SearchInput}, function (data, status) {
288        var Data = JSON.parse(data);
289        if (Data.Status == "Success") {
290            //$("#PromoCodeValue").text(Data.Code);
291            $(".listings").append(Data.HTML);
292            $("#isTriggered").val(0);
293            $("#ProductsStatus").val(1);
294        } else {
295            $("#ProductsStatus").val(0);
296        }
297    });
298}
299
300function resetlazyLoadEvents() {
301    $('#LazyLoadSection').val(0);
302    $('.events').html('');
303}
304
305function lazyLoadEvents() {
306
307    console.log("lazyLoadEvents");
308
309    var types = [];
310    $('[data-filter="type"]:checked').each(function () {
311        var element = $(this).val();
312        types.push("'" + element + "'");
313    });
314
315    var typesS = "";
316    if (types.length !== 0) {
317        typesS = types.join(",");
318    }
319
320    var distances = [];
321    $('[data-filter="distance"]:checked').each(function () {
322        var element = $(this).val();
323        distances.push("'" + element + "'");
324    });
325
326    var distancesS = "";
327    if (distances.length !== 0) {
328        distancesS = distances.join(",");
329    }
330
331
332    /*
333     var sorts = [];
334     $('[data-filter="sort"]:checked').each(function() {
335     var element = $(this).val();
336     sorts.push("'" + element + "'");
337     }); 
338     
339     var sortsS = "";
340     if(sorts.length !== 0) {
341     sortsS = sorts.join(",");
342     }
343     
344     var categories = [];
345     $('[data-filter="category"]:checked').each(function() {
346     var element = $(this).val();
347     categories.push("'" + element + "'");
348     }); 
349     
350     var categoriesS = "";
351     if(categories.length !== 0) {
352     categoriesS = categories.join(",");
353     }
354     */
355
356
357    var SearchInput = $("#SearchInput").val();
358
359    if (SearchInput !== "") {
360        $(".events").empty();
361    }
362
363    console.log(typesS);
364    console.log(distancesS);
365
366    var LazyLoadSection = $('#LazyLoadSection').val();
367    $.post(BASE_URL + "/application/ajax/portal/ll_events.php", {LazyLoadSection: LazyLoadSection, Types: typesS, Distances: distancesS, SearchInput: SearchInput}, function (data, status) {
368
369        console.log(data);
370
371        var Data = JSON.parse(data);
372        if (Data.Status == "Success") {
373            //$("#PromoCodeValue").text(Data.Code);
374            $(".events").append(Data.HTML);
375            $("#isTriggered").val(0);
376            $("#ProductsStatus").val(1);
377        } else {
378            $("#ProductsStatus").val(0);
379        }
380    });
381}
382
383function lazyLoadLatest() {
384    var LazyLoadSection = $('#LazyLoadSection').val();
385    var Tag = $('#CurrentTag').val();
386    console.log("Tag = " + Tag);
387    $.post(BASE_URL + "/application/ajax/portal/ll_latest.php", {LazyLoadSection: LazyLoadSection, Tag: Tag}, function (data, status) {
388        var Data = JSON.parse(data);
389        if (Data.Status == "Success") {
390            //$("#PromoCodeValue").text(Data.Code);
391            $(".grid").append(Data.HTML);
392            $("#isTriggered").val(0);
393            $("#ProductsStatus").val(1);
394        } else {
395            $("#ProductsStatus").val(0);
396        }
397    });
398}
399
400function resetlazyLoadTests() {
401    $('#LazyLoadSection').val(0);
402    $('.grid').html('');
403}
404
405function lazyLoadTests() {
406    
407    var SearchQuery = $('#SearchQuery').val();
408    
409    console.log(SearchQuery);
410
411    var types = [];
412    $('[data-filter="type"]:checked').each(function () {
413        var element = $(this).val();
414        types.push("'" + element + "'");
415    });
416
417    var typesS = "";
418    if (types.length !== 0) {
419        typesS = types.join(",");
420    }
421
422    var materials = [];
423    $('[data-filter="material"]:checked').each(function () {
424        var element = $(this).val();
425        materials.push("'" + element + "'");
426    });
427
428    var materialsS = "";
429    if (materials.length !== 0) {
430        materialsS = materials.join(",");
431    }
432    
433    var electrical_bike= '';
434    if($('input#filter8').is(':checked')){
435        electrical_bike = $('#filter8').val();
436        console.log(electrical_bike);
437    }
438    else{
439        electrical_bike = '';
440    }
441    
442    console.log(typesS);
443    console.log(materialsS);
444
445    var MinPrice = $('#input-min').val();
446    var MaxPrice = $('#input-max').val();
447
448    console.log(MinPrice);
449    console.log(MaxPrice);
450
451    var LazyLoadSection = $('#LazyLoadSection').val();
452    console.log(LazyLoadSection);
453    $.post(BASE_URL + "/application/ajax/portal/ll_tests.php", {SearchQuery: SearchQuery, LazyLoadSection: LazyLoadSection, electrical_bike: electrical_bike, Types: typesS, Materials: materialsS, MinPrice: MinPrice, MaxPrice: MaxPrice}, function (data, status) {
454        var Data = JSON.parse(data);
455        if (Data.Status == "Success") {
456            //$("#PromoCodeValue").text(Data.Code);
457            console.log(Data);
458
459            $(".grid").append(Data.HTML);
460
461            //console.log(Data.HTML);
462            $("#isTriggered").val(0);
463            $("#ProductsStatus").val(1);
464        } else {
465            $("#ProductsStatus").val(0);
466        }
467    });
468}
469
470function adsLandingClick(AdID) {
471    $.post(BASE_URL + "/application/ajax/portal/adsLandingCount.php", {AdID: AdID}, function (data, status) {
472
473    });
474}
475
476function getQuote(ID) {
477    var Username = $("#Username" + ID).text();
478    var Comment = $("#Quote" + ID).html();
479
480    var Quote = "<blockquote><b>@" + Username + "</b><br>" + Comment + "</blockquote>";
481
482    /*$("#quoteTest").append(Quote);*/
483    $('#QuotePrepend').val(Quote);
484
485    $("#QuoteOutput").html(Quote);
486    $(".quoteAnswer").slideDown();
487
488    $('html, body').animate({
489        scrollTop: $("#AddCommentButton").offset().top - 300
490    }, 1000);
491
492}
493
494function getQuoteForum(ID, QuoteUserID) {
495    var Username = $("#Username" + ID).text();
496    var Comment = $("#Quote" + ID).html();
497
498    var Quote = "<blockquote><b>@" + Username + "</b><br>" + Comment + "</blockquote><br/><br/>";
499
500    /*$("#quoteTest").append(Quote);*/
501    $('#QuotePrepend').val(Quote);
502    $('#QuoteUserID').val(QuoteUserID);
503
504    $("#QuoteOutput").html(Quote);
505    $(".quoteAnswer").slideDown();
506
507    //$("#summernote").code($(Quote));
508    $("#summernote").summernote('code', Quote);
509
510    $('html, body').animate({
511        scrollTop: $("#AddCommentButton").offset().top - 300
512    }, 1000);
513
514}
515
516
517function editQuoteForum(ID, QuoteUserID) {
518
519    // TRANSFER CONTENT AND LOAD SUMMERNOTE
520    $("#summernoteedit" + ID).html($("#Quote" + ID).html());
521    loadSummernoteEdit(ID);
522
523
524    $("#Quote" + ID).hide();
525    $("#summernoteeditbox" + ID).show();
526
527//	var Username = $("#Username" + ID).text();
528//	var Comment = $("#Quote" + ID).html();
529//	
530//	var Quote = "<blockquote><b>@" + Username + "</b><br>" + Comment + "</blockquote>";
531//	
532//	/*$("#quoteTest").append(Quote);*/
533//	$('#QuotePrepend').val(Quote);
534//	$('#QuoteUserID').val(QuoteUserID);
535//	
536//	$("#QuoteOutput").html(Quote);
537//	$(".quoteAnswer").slideDown();
538//	
539//	$('html, body').animate({
540//        scrollTop: $("#AddCommentButton").offset().top - 300
541//    }, 1000);
542
543}
544
545function loadSummernoteEdit(ID) {
546    $('#summernoteedit' + ID).summernote({
547        dialogsInBody: true,
548        height: 300,
549        lang: 'sl-SI', /*,
550         toolbar: [
551         ['misc', ['emoji']]
552         ]*/
553
554        toolbar: [
555            // [groupName, [list of button]]
556            ['misc', ['emoji']],
557            ['style', ['bold', 'italic', 'underline', 'clear']],
558            /*['font', ['strikethrough', 'superscript', 'subscript']],*/
559            ['fontsize', ['fontsize']],
560            ['color', ['color']],
561            ['insert', ['picture', 'link', 'video', 'table', 'hr']],
562            ['para', ['ul', 'ol', 'paragraph']]
563        ]
564    });
565}
566
567function reportComment(ID, Type) {
568    $("#ReportCommentID").val(ID);
569    $("#ReportCommentReason").val("");
570    $("#ReportCommentType").val(Type);
571    $("#ReportSuccess").hide();
572    $("#ReportCommentModal").modal("show");
573}
574
575function submitCommentReport() {
576    var CommentID = $("#ReportCommentID").val();
577    var UserID = $("#ReportCommentUserID").val();
578    var Reason = $("#ReportCommentReason").val();
579    var Type = $("#ReportCommentType").val();
580
581    $.post(BASE_URL + "/application/ajax/portal/reportComment.php", {CommentID: CommentID, UserID: UserID, Reason: Reason, Type: Type}, function (data, status) {
582        if (data) {
583            $("#ReportSuccess").slideDown();
584            setTimeout(function () {
585                $("#ReportCommentModal").modal("hide");
586            }, 2000);
587        }
588    });
589}
590
591function voteComment(ID, Type, LoggedIn, CType) {
592    if (!LoggedIn) {
593        return 0;
594    }
595
596    var UserID = $("#ReportCommentUserID").val();
597
598    $.post(BASE_URL + "/application/ajax/portal/voteComment.php", {CommentID: ID, UserID: UserID, Type: Type, CType: CType}, function (data, status) {
599        var Data = JSON.parse(data);
600        if (Data.Status == "Success") {
601            $("#Pluses" + ID).text(Data.Pluses);
602            $("#Minuses" + ID).text(Data.Minuses);
603
604            if (Data.Voted == "true") {
605                if (Type == "positive") {
606                    $("#PlusSVG" + ID + " path").css("fill", "#f35719");
607                }
608                if (Type == "negative") {
609                    $("#MinusSVG" + ID + " path").css("fill", "#f35719");
610                }
611            }
612        }
613    });
614}
615
616function voteCommentForum(ID, Type, LoggedIn) {
617    if (!LoggedIn) {
618        return 0;
619    }
620
621    var UserID = $("#ReportCommentUserID").val();
622
623    $.post(BASE_URL + "/application/ajax/portal/voteForum.php", {CommentID: ID, UserID: UserID, Type: Type}, function (data, status) {
624        var Data = JSON.parse(data);
625        if (Data.Status == "Success") {
626            $("#Pluses" + ID).text(Data.Pluses);
627            $("#Minuses" + ID).text(Data.Minuses);
628
629            if (Data.Voted == "true") {
630                if (Type == "positive") {
631                    $("#PlusSVG" + ID + " path").css("fill", "#f35719");
632                }
633                if (Type == "negative") {
634                    $("#MinusSVG" + ID + " path").css("fill", "#f35719");
635                }
636            }
637        }
638    });
639}
640
641function switchInputMode(Element) {
642    var Selected = $(Element).val();
643    if (Selected == "manually") {
644        $("#GpxBox").hide();
645        $("#ManuallyBox").show();
646
647        $("#GPX").removeAttr("data-parsley-required");
648
649        $("#Date").attr("data-parsley-required");
650        $("#Time").attr("data-parsley-required");
651        $("#Distance").attr("data-parsley-required");
652        $("#Altitude").attr("data-parsley-required");
653
654    } else if (Selected == "gpx") {
655        $("#GpxBox").show();
656        $("#ManuallyBox").hide();
657
658        $("#Date").removeAttr("data-parsley-required");
659        $("#Time").removeAttr("data-parsley-required");
660        $("#Distance").removeAttr("data-parsley-required");
661        $("#Altitude").removeAttr("data-parsley-required");
662
663        $("#GPX").attr("data-parsley-required");
664
665
666    }
667}
668
669function setCookie(cname, cvalue, exdays) {
670    var d = new Date();
671    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
672    var expires = "expires=" + d.toUTCString();
673    document.cookie = cname + "=" + cvalue + "; " + expires + "path=/";
674}
675
676function getCookie(cname) {
677    var name = cname + "=";
678    var ca = document.cookie.split(';');
679    for (var i = 0; i < ca.length; i++) {
680        var c = ca[i];
681        while (c.charAt(0) == ' ')
682            c = c.substring(1);
683        if (c.indexOf(name) == 0)
684            return c.substring(name.length, c.length);
685    }
686    return "";
687}
688
689function saveNewsletter() {
690    var Email = $("#Email").val();
691    var Error = false;
692
693    if (Email == "" || !isEmail(Email)) {
694        $("#Email").css("border-color", "red");
695        Error = true;
696    } else {
697        Error = false;
698        $("#Email").css("border-color", "#efefef");
699    }
700
701
702    var Success = false;
703
704    if (!Error) {
705        $.ajax({
706            type: "POST",
707            async: false,
708            url: BASE_URL + "/application/ajax/portal/addToNewsLetter.php",
709            data: {Email: Email},
710            success: function (msg) {
711                Success = true;
712            },
713            error: function () {
714                Success = false;
715            }
716        });
717    } else {
718        Success = false;
719    }
720}
721
722
723function showTab(Element, Selector, TabsID) {
724    $("#" + TabsID + " .tabs__header__element__borderBottom").hide();
725    $("#" + TabsID + " #" + Element + " .tabs__header__element__borderBottom").show();
726
727    $("#" + TabsID + " .tabs__body").slideUp();
728    $("#" + Selector).slideDown();
729}
730
731function showTabTrio(Element, Selector, TabsID) {
732    $("#" + TabsID + " .tabsTrio__header__element__borderBottom").hide();
733    $("#" + TabsID + " #" + Element + " .tabsTrio__header__element__borderBottom").show();
734
735    $("#" + TabsID + " .tabsTrio__body").slideUp();
736    $("#" + Selector).slideDown();
737}
738
739function showTabAuto(Element, Selector, TabsID) {
740    $("#" + TabsID + " .tabsAuto__header__element__borderBottom").hide();
741    $("#" + TabsID + " #" + Element + " .tabsAuto__header__element__borderBottom").show();
742
743    $("#" + TabsID + " .tabsAuto__body").slideUp();
744    $("#" + Selector).slideDown();
745}
746
747function showBigImage(ImageSource) {
748    $("#BigImage").attr("href", ImageSource);
749    $("#BigImage img").attr("src", ImageSource);
750}
751
752function showBigImageBackground(ImageSource, ImageCaption) {
753
754    ImageSource = ImageSource.replace("large-", "");
755
756    $("#BigImage").css("background-image", "url('" + ImageSource + "')");
757    $(".BigImageInner").attr("href", ImageSource);
758    $(".BigImageInner").attr("data-title", ImageCaption);
759    $(".product__card__images__caption").text(ImageCaption);
760    $(".BigImageInner img").attr("src", ImageSource);
761
762    location.hash = '#TopOfImage';
763}
764
765
766function orderBy(OrderValue) {
767    if (OrderValue != 0) {
768
769        var URL = window.location.href + "?OrderBy=" + OrderValue;
770        URL = URL.replace(/\?.*/, '');
771        URL = URL + "?OrderBy=" + OrderValue;
772        window.location.href = URL;
773    }
774}
775
776function orderByForumIn(OrderValue) {
777    if (OrderValue != 0) {
778
779
780        var URL = window.location.href + "?OrderBy=" + OrderValue;
781        URL = URL.replace(/\?.*/, '');
782        URL = URL + "?OrderBy=" + OrderValue;
783
784        var PageQueryString = getParameterByName("Page");
785        if (PageQueryString)
786            URL = URL + "&Page=" + PageQueryString;
787
788        window.location.href = URL;
789    }
790}
791
792function orderByForum(OrderValue) {
793    if (OrderValue != 0) {
794
795        var URL = window.location.href + "?OrderBy=" + OrderValue;
796        URL = URL.replace(/\?.*/, '');
797        URL = URL + "?OrderBy=" + OrderValue;
798
799        var TagQueryString = getParameterByName("Tag");
800        var PageQueryString = getParameterByName("Page");
801        var OrderByQueryString = getParameterByName("OrderBy");
802
803        if (TagQueryString)
804            URL = URL + "&Tag=" + TagQueryString;
805        //if(PageQueryString) URL = URL + "&Page=" + PageQueryString;
806        window.location.href = URL;
807    }
808}
809
810function searchSuggestions(SearchValue) {
811    $("#SearchResultsBox").empty();
812
813    if (SearchValue.length != 0) {
814        $.post(BASE_URL + "/application/ajax/portal/getSearchResults.php", {SearchValue: SearchValue}, function (data, status) {
815            var Data = JSON.parse(data);
816            if (Data.Status == "Success") {
817                if ($("#SearchResultsBox").html() == "") {
818                    $("#SearchResultsBox").append(Data.HTML);
819                }
820                $(".top-search").slideDown();
821
822            } else {
823            }
824        });
825    } else {
826        $(".top-search").slideUp();
827    }
828}
829
830
831function checkCommentInput(e) {
832
833    $("#AddCommentButton").css("opacity", "0.4");
834    $("#AddCommentButton").css("pointer-events", "none");
835    $("#AddCommentLoader").show();
836
837    var Length = $('.commentInput').val().length;
838    if (Length <= 0) {
839        e.preventDefault();
840        $('.commentInput').css("border-color", "red");
841    }
842}
843
844function saveEditedCommentInput(e, CommentID) {
845
846    e.preventDefault();
847
848    var EditedComment = $("#summernoteedit" + CommentID).val();
849
850    console.log(CommentID);
851    console.log(EditedComment);
852
853    $.post(BASE_URL + "/application/ajax/portal/saveEditedComment.php", {CommentID: CommentID, EditedComment: EditedComment}, function (data, status) {
854        if (status == "success") {
855
856            console.log(data);
857
858            $("#summernoteeditbox" + CommentID).hide();
859            $("#Quote" + CommentID).html(data);
860            $("#Quote" + CommentID).show();
861        }
862    });
863
864
865//	$("#summernoteeditbox" + CommentID).hide();
866//	$("#Quote" + CommentID).html("TEST"); 
867//	$("#Quote" + CommentID).show(); 
868
869//	var Length = $('.commentInput').val().length;
870//	if(Length <= 0){
871//		e.preventDefault();
872//		$('.commentInput').css("border-color", "red");
873//	}
874}
875
876function checkCommentInput1(e, el) {
877    var Length = $('.' + el + ' .commentInput').val().length;
878    if (Length <= 0) {
879        e.preventDefault();
880        $('.' + el + ' .commentInput').css("border-color", "red");
881    }
882}
883
884/*function filterListings(Checkbox){
885 var AllListings = $(".listingCard");
886 var Checkboxes = $(".filtersBox input[type=checkbox]");
887 var FiltersSelected = false;
888 
889 var SelectingString = "";
890 $.each(Checkboxes, function(Index, Element){
891 if($(Element).is(":checked")){
892 var Filter = $(Element).data("filter");
893 console.log(Filter);
894 SelectingString += "[data-"+Filter+"='" + $(Element).val() + "']";
895 FiltersSelected = true;
896 }
897 });
898 
899 
900 //SelectingString = SelectingString.slice(0,-1);
901 console.log(SelectingString.split(/[[\]]/));
902 var FilteredListings = $(".listings").find(SelectingString);
903 
904 console.log(SelectingString);
905 console.log(FilteredListings);
906 
907 
908 if($(Checkbox).is(":checked")){
909 $.each(AllListings, function(Index, Element){
910 if(jQuery.inArray(Element, FilteredListings) !== -1){
911 $(Element).slideDown();
912 } else {
913 $(Element).slideUp();
914 }
915 });
916 } else {
917 $.each(AllListings, function(Index, Element){
918 if(jQuery.inArray(Element, FilteredListings) === -1){
919 $(Element).slideUp();
920 } else{
921 $(Element).slideDown();
922 }
923 });
924 }
925 
926 if(!FiltersSelected){
927 $.each(AllListings, function(Index, Element){
928 $(Element).slideDown();
929 });
930 }
931 }
932 */
933
934$("#SloveniaMap path").click(function (element) {
935    var SelectedRegion = element.currentTarget;
936    var RegionID = $(SelectedRegion).attr("id");
937    var RegionName = $(SelectedRegion).attr("title").toLowerCase();
938
939    $("#SloveniaMap path").attr("class", "land");
940    $("#" + RegionID).attr("class", "land active");
941
942    selectRegionFilter(RegionName);
943
944
945});
946
947$(".regionFilters input[type=checkbox]").click(function (element) {
948    var SelectedRegion = element.currentTarget;
949    var RegionName = $(SelectedRegion).val();
950    var AllCheckboxes = $(".regionFilters input[type=checkbox]");
951
952    $.each(AllCheckboxes, function (index, el) {
953        $(el).prop("checked", false);
954    });
955
956    $(element.currentTarget).prop("checked", true);
957
958    RegionName = RegionName.substr(0, 1).toUpperCase() + RegionName.substr(1);
959
960    $("#SloveniaMap path").attr("class", "land");
961    $("#SloveniaMap path[title='" + RegionName + "']").attr("class", "land active");
962});
963
964function selectRegionFilter(RegionName) {
965    var AllCheckboxes = $(".regionFilters input[type=checkbox]");
966    $.each(AllCheckboxes, function (index, el) {
967        $(el).prop("checked", false);
968    });
969
970    var Checkbox = $(".filtersBox input[type=checkbox][value='" + RegionName + "']");
971    $(Checkbox).prop("checked", true);
972    filterTrips(Checkbox);
973    console.log(Checkbox);
974}
975
976/*
977 function filterListings(Checkbox){
978 var AllListings = $(".listingCard");
979 var Checkboxes = $(".filtersBox input[type=checkbox]");
980 var FiltersSelectedType = false;
981 var FiltersSelectedSort = false;
982 var FiltersSelectedCategory = false;
983 
984 var SelectingString = "";
985 var SelectingStringType = "";
986 var SelectingStringSort = "";
987 var SelectingStringCategory = "";
988 
989 $.each(Checkboxes, function(Index, Element){
990 if($(Element).is(":checked")){
991 var Filter = "type";
992 if($(Element).data("filter") == Filter){
993 SelectingStringType += "[data-"+Filter+"='" + $(Element).val() + "'],";
994 FiltersSelectedType = true;
995 }
996 }
997 });
998 if(FiltersSelectedType)
999 SelectingStringType = SelectingStringType.slice(0,-1);
1000 
1001 $.each(Checkboxes, function(Index, Element){
1002 if($(Element).is(":checked")){
1003 var Filter = "sort";
1004 if($(Element).data("filter") == Filter){
1005 SelectingStringSort += "[data-"+Filter+"='" + $(Element).val() + "'],";
1006 FiltersSelectedSort = true;
1007 }
1008 }
1009 });
1010 
1011 if(FiltersSelectedSort)
1012 SelectingStringSort = SelectingStringSort.slice(0,-1);
1013 
1014 $.each(Checkboxes, function(Index, Element){
1015 if($(Element).is(":checked")){
1016 var Filter = "category";
1017 if($(Element).data("filter") == Filter){
1018 SelectingStringCategory += "[data-"+Filter+"='" + $(Element).val() + "'],";
1019 FiltersSelectedCategory = true;
1020 }
1021 }
1022 });
1023 
1024 if(FiltersSelectedCategory){
1025 SelectingStringCategory = SelectingStringCategory.slice(0,-1);
1026 var CategoryParameters = SelectingStringCategory.split(",");
1027 var CategoryParametersIf = [];
1028 $.each(CategoryParameters, function(Index, Element){
1029 var Parameter = Element.match(/'([^']+)'/)[1];
1030 CategoryParametersIf.push(Parameter);
1031 });
1032 }
1033 
1034 if(FiltersSelectedType){
1035 SelectingStringType = SelectingStringType.slice(0,-1);
1036 var TypeParameters = SelectingStringType.split(",");
1037 var TypeParametersIf = [];
1038 $.each(TypeParameters, function(Index, Element){
1039 var Parameter = Element.match(/'([^']+)'/)[1];
1040 TypeParametersIf.push(Parameter);
1041 });
1042 }
1043 
1044 if(FiltersSelectedSort){
1045 SelectingStringSort = SelectingStringSort.slice(0,-1);
1046 var SortParameters = SelectingStringSort.split(",");
1047 var SortParametersIf = [];
1048 $.each(SortParameters, function(Index, Element){
1049 var Parameter = Element.match(/'([^']+)'/)[1];
1050 SortParametersIf.push(Parameter);
1051 });
1052 }
1053 
1054 if(FiltersSelectedCategory){
1055 SelectingString += SelectingStringCategory;
1056 }
1057 
1058 var FilteredListings = $(".listingCard");
1059 var i = 0;
1060 $.each(FilteredListings, function(Index,Element){
1061 
1062 if(FiltersSelectedCategory){
1063 var Value = $(Element).data("category");
1064 if(jQuery.inArray(Value, CategoryParametersIf) === -1){
1065 delete FilteredListings[i];
1066 }
1067 }
1068 if(FiltersSelectedType){
1069 var Value = $(Element).data("type");
1070 if(jQuery.inArray(Value, TypeParametersIf) === -1){
1071 delete FilteredListings[i];
1072 }
1073 }
1074 
1075 if(FiltersSelectedSort){
1076 var Value = $(Element).data("sort");
1077 if(jQuery.inArray(Value, SortParametersIf) === -1){
1078 delete FilteredListings[i];
1079 }
1080 }
1081 
1082 i++;
1083 });
1084 
1085 if($(Checkbox).is(":checked")){
1086 $.each(AllListings, function(Index, Element){
1087 if(jQuery.inArray(Element, FilteredListings) !== -1){
1088 $(Element).slideDown();
1089 } else {
1090 $(Element).slideUp();
1091 }
1092 });
1093 } else {
1094 $.each(AllListings, function(Index, Element){
1095 if(jQuery.inArray(Element, FilteredListings) === -1){
1096 $(Element).slideUp();
1097 } else{
1098 $(Element).slideDown();
1099 }
1100 });
1101 }
1102 
1103 if(!FiltersSelectedType && !FiltersSelectedSort && !FiltersSelectedCategory){
1104 $.each(AllListings, function(Index, Element){
1105 $(Element).slideDown();
1106 });
1107 }
1108 }*/
1109
1110/*
1111 function filterTests(Checkbox){
1112 var AllTests = $(".testsCard");
1113 var Checkboxes = $(".filtersBox input[type=checkbox]");
1114 var FiltersSelectedType = false;
1115 var FiltersSelectedMaterial = false;
1116 //var FiltersSelectedCategory = false;
1117 
1118 var SelectingString = "";
1119 var SelectingStringType = "";
1120 var SelectingStringMaterial = "";
1121 //var SelectingStringCategory = "";
1122 
1123 $.each(Checkboxes, function(Index, Element){
1124 if($(Element).is(":checked")){
1125 var Filter = "type";
1126 if($(Element).data("filter") == Filter){
1127 SelectingStringType += "[data-"+Filter+"='" + $(Element).val() + "'],";
1128 FiltersSelectedType = true;
1129 }
1130 }
1131 });
1132 if(FiltersSelectedType)
1133 SelectingStringType = SelectingStringType.slice(0,-1);
1134 
1135 $.each(Checkboxes, function(Index, Element){
1136 if($(Element).is(":checked")){
1137 var Filter = "material";
1138 if($(Element).data("filter") == Filter){
1139 SelectingStringMaterial += "[data-"+Filter+"='" + $(Element).val() + "'],";
1140 FiltersSelectedMaterial = true;
1141 }
1142 }
1143 });
1144 
1145 if(FiltersSelectedMaterial)
1146 SelectingStringMaterial = SelectingStringMaterial.slice(0,-1);
1147 
1148 
1149 if(FiltersSelectedType){
1150 SelectingStringType = SelectingStringType.slice(0,-1);
1151 var TypeParameters = SelectingStringType.split(",");
1152 var TypeParametersIf = [];
1153 $.each(TypeParameters, function(Index, Element){
1154 var Parameter = Element.match(/'([^']+)'/)[1];
1155 TypeParametersIf.push(Parameter);
1156 });
1157 }
1158 
1159 if(FiltersSelectedMaterial){
1160 SelectingStringMaterial = SelectingStringMaterial.slice(0,-1);
1161 var MaterialParameters = SelectingStringMaterial.split(",");
1162 var MaterialParametersIf = [];
1163 $.each(MaterialParameters, function(Index, Element){
1164 var Parameter = Element.match(/'([^']+)'/)[1];
1165 MaterialParametersIf.push(Parameter);
1166 });
1167 }
1168 
1169 
1170 
1171 var FilteredTests = $(".testsCard");
1172 var i = 0;
1173 $.each(FilteredTests, function(Index,Element){
1174 
1175 
1176 if(FiltersSelectedType){
1177 var Value = $(Element).data("type");
1178 if(jQuery.inArray(Value, TypeParametersIf) === -1){
1179 delete FilteredTests[i];
1180 }
1181 }
1182 
1183 if(FiltersSelectedMaterial){
1184 var Value = $(Element).data("material");
1185 if(jQuery.inArray(Value, MaterialParametersIf) === -1){
1186 delete FilteredTests[i];
1187 }
1188 }
1189 
1190 i++;
1191 });
1192 
1193 if($(Checkbox).is(":checked")){
1194 $.each(AllTests, function(Index, Element){
1195 if(jQuery.inArray(Element, FilteredTests) !== -1){
1196 $(Element).slideDown();
1197 } else {
1198 $(Element).slideUp();
1199 }
1200 });
1201 } else {
1202 $.each(AllTests, function(Index, Element){
1203 if(jQuery.inArray(Element, FilteredTests) === -1){
1204 $(Element).slideUp();
1205 } else{
1206 $(Element).slideDown();
1207 }
1208 });
1209 }
1210 
1211 if(!FiltersSelectedType && !FiltersSelectedMaterial){
1212 $.each(AllTests, function(Index, Element){
1213 $(Element).slideDown();
1214 });
1215 }
1216 }*/
1217
1218
1219
1220function filterTrips(Checkbox) {
1221    var AllListings = $(".tripCard");
1222    var Checkboxes = $(".filtersBox input[type=checkbox]");
1223    var FiltersSelectedType = false;
1224    var FiltersSelectedSort = false;
1225    var FiltersSelectedCategory = false;
1226    var FiltersSelectedRegion = false;
1227
1228    var SelectingString = "";
1229    var SelectingStringType = "";
1230    var SelectingStringSort = "";
1231    var SelectingStringCategory = "";
1232    var SelectingStringRegion = "";
1233
1234    $.each(Checkboxes, function (Index, Element) {
1235        if ($(Element).is(":checked")) {
1236            var Filter = "type";
1237            if ($(Element).data("filter") == Filter) {
1238                SelectingStringType += "[data-" + Filter + "='" + $(Element).val() + "'],";
1239                FiltersSelectedType = true;
1240            }
1241        }
1242    });
1243    if (FiltersSelectedType)
1244        SelectingStringType = SelectingStringType.slice(0, -1);
1245
1246    $.each(Checkboxes, function (Index, Element) {
1247        if ($(Element).is(":checked")) {
1248            var Filter = "sort";
1249            if ($(Element).data("filter") == Filter) {
1250                SelectingStringSort += "[data-" + Filter + "='" + $(Element).val() + "'],";
1251                FiltersSelectedSort = true;
1252            }
1253        }
1254    });
1255
1256    if (FiltersSelectedSort)
1257        SelectingStringSort = SelectingStringSort.slice(0, -1);
1258
1259    $.each(Checkboxes, function (Index, Element) {
1260        if ($(Element).is(":checked")) {
1261            var Filter = "category";
1262            if ($(Element).data("filter") == Filter) {
1263                SelectingStringCategory += "[data-" + Filter + "='" + $(Element).val() + "'],";
1264                FiltersSelectedCategory = true;
1265            }
1266        }
1267    });
1268
1269    if (FiltersSelectedCategory)
1270        SelectingStringCategory = SelectingStringCategory.slice(0, -1);
1271
1272    $.each(Checkboxes, function (Index, Element) {
1273        if ($(Element).is(":checked")) {
1274            var Filter = "region";
1275            if ($(Element).data("filter") == Filter) {
1276                SelectingStringRegion += "[data-" + Filter + "='" + $(Element).val() + "'],";
1277                FiltersSelectedRegion = true;
1278            }
1279        }
1280    });
1281
1282
1283
1284
1285
1286
1287
1288    if (FiltersSelectedCategory) {
1289        SelectingStringCategory = SelectingStringCategory.slice(0, -1);
1290        var CategoryParameters = SelectingStringCategory.split(",");
1291        var CategoryParametersIf = [];
1292        $.each(CategoryParameters, function (Index, Element) {
1293            var Parameter = Element.match(/'([^']+)'/)[1];
1294            CategoryParametersIf.push(Parameter);
1295        });
1296    }
1297
1298    if (FiltersSelectedType) {
1299        SelectingStringType = SelectingStringType.slice(0, -1);
1300        var TypeParameters = SelectingStringType.split(",");
1301        var TypeParametersIf = [];
1302        $.each(TypeParameters, function (Index, Element) {
1303            var Parameter = Element.match(/'([^']+)'/)[1];
1304            TypeParametersIf.push(Parameter);
1305        });
1306    }
1307
1308    if (FiltersSelectedSort) {
1309        SelectingStringSort = SelectingStringSort.slice(0, -1);
1310        var SortParameters = SelectingStringSort.split(",");
1311        var SortParametersIf = [];
1312        $.each(SortParameters, function (Index, Element) {
1313            var Parameter = Element.match(/'([^']+)'/)[1];
1314            SortParametersIf.push(Parameter);
1315        });
1316    }
1317
1318    if (FiltersSelectedRegion) {
1319        SelectingStringRegion = SelectingStringRegion.slice(0, -1);
1320        var RegionParameters = SelectingStringRegion.split(",");
1321        var RegionParametersIf = [];
1322        $.each(RegionParameters, function (Index, Element) {
1323            var Parameter = Element.match(/'([^']+)'/)[1];
1324            RegionParametersIf.push(Parameter);
1325        });
1326    }
1327
1328    if (FiltersSelectedCategory) {
1329        SelectingString += SelectingStringCategory;
1330    }
1331
1332    var FilteredListings = $(".tripCard");
1333    var i = 0;
1334    $.each(FilteredListings, function (Index, Element) {
1335
1336        if (FiltersSelectedCategory) {
1337            var Value = $(Element).data("category");
1338            if (jQuery.inArray(Value, CategoryParametersIf) === -1) {
1339                delete FilteredListings[i];
1340            }
1341        }
1342        if (FiltersSelectedType) {
1343            var Value = $(Element).data("type");
1344            if (jQuery.inArray(Value, TypeParametersIf) === -1) {
1345                delete FilteredListings[i];
1346            }
1347        }
1348
1349        if (FiltersSelectedSort) {
1350            var Value = $(Element).data("sort");
1351            if (jQuery.inArray(Value, SortParametersIf) === -1) {
1352                delete FilteredListings[i];
1353            }
1354        }
1355
1356        if (FiltersSelectedRegion) {
1357            var Value = $(Element).data("region");
1358            if (jQuery.inArray(Value, RegionParametersIf) === -1) {
1359                delete FilteredListings[i];
1360            }
1361        }
1362
1363        i++;
1364    });
1365
1366    if ($(Checkbox).is(":checked")) {
1367        $.each(AllListings, function (Index, Element) {
1368            if (jQuery.inArray(Element, FilteredListings) !== -1) {
1369                $(Element).slideDown();
1370            } else {
1371                $(Element).slideUp();
1372            }
1373        });
1374    } else {
1375        $.each(AllListings, function (Index, Element) {
1376            if (jQuery.inArray(Element, FilteredListings) === -1) {
1377                $(Element).slideUp();
1378            } else {
1379                $(Element).slideDown();
1380            }
1381        });
1382    }
1383
1384    if (!FiltersSelectedType && !FiltersSelectedSort && !FiltersSelectedCategory && !FiltersSelectedRegion) {
1385        $.each(AllListings, function (Index, Element) {
1386            $(Element).slideDown();
1387        });
1388    }
1389}
1390
1391
1392
1393
1394function round2Fixed(value) {
1395    value = +value;
1396
1397    if (isNaN(value))
1398        return NaN;
1399
1400    // Shift
1401    value = value.toString().split('e');
1402    value = Math.round(+(value[0] + 'e' + (value[1] ? (+value[1] + 2) : 2)));
1403
1404    // Shift back
1405    value = value.toString().split('e');
1406    return (+(value[0] + 'e' + (value[1] ? (+value[1] - 2) : -2))).toFixed(2);
1407}
1408
1409function saveShippingPrice(Option) {
1410    //var ShipmentPrice = Option.attr("price");
1411    //console.log(Option.value);
1412    $("#ShippingBox").show();
1413    var Value = Option.value;
1414    Value = Value.split("-");
1415
1416    var Price = Value[1];
1417    var Type = Value[0];
1418
1419    $('#ShipmentValue').attr("price", Price);
1420    $('#ShipmentValue').attr("shipingtype", Type);
1421    $('#ShipmentValue').attr("shipingtype", Type);
1422
1423
1424    /*var ShippingPriceLabel = round2Fixed(Price);
1425     ShippingPriceLabel = ShippingPriceLabel.toString().replace(".", ",");
1426     $("#ShippingPriceLabel").text(ShippingPriceLabel);
1427     $('#ShippingPrice').val(Price);*/
1428
1429    var FreeShipping = $("#FreeShipping").val();
1430    if (FreeShipping == "1") {
1431        var FreeShipping = true;
1432    } else {
1433        var FreeShipping = false;
1434    }
1435
1436
1437    if (returnFreeShipping() <= 0 || FreeShipping) {
1438        removeShipping();
1439    } else {
1440        addShipping();
1441    }
1442
1443    calculateOrderFinalPrice();
1444
1445}
1446
1447function saveShippingPriceDefined(Option) {
1448    //var ShipmentPrice = Option.attr("price");
1449    //console.log(Option.value);
1450
1451    $("#ShippingBox").show();
1452
1453    var Value = Option.value;
1454    Value = Value.split("-");
1455
1456    var Price = Value[1];
1457    var Type = Value[0];
1458
1459    $('#ShipmentValue').attr("price", Price);
1460    $('#ShipmentValue').attr("shipingtype", Type);
1461    $('#ShipmentValue').attr("shipingtype", Type);
1462
1463
1464    /*var ShippingPriceLabel = round2Fixed(Price);
1465     ShippingPriceLabel = ShippingPriceLabel.toString().replace(".", ",");
1466     $("#ShippingPriceLabel").text(ShippingPriceLabel);
1467     $('#ShippingPrice').val(Price);*/
1468
1469    var FreeShipping = $("#FreeShipping").val();
1470    if (FreeShipping == "1") {
1471        var FreeShipping = true;
1472    } else {
1473        var FreeShipping = false;
1474    }
1475
1476
1477    if (returnFreeShipping() <= 0 || FreeShipping) {
1478        removeShipping();
1479    } else {
1480        addShipping();
1481    }
1482
1483    calculateOrderFinalPriceDefined();
1484
1485}
1486
1487
1488function calculateItemTotal(Selector, OrderProductID) {
1489    var Quantity = $("#Quantity" + Selector).val();
1490    var TotalPrice = 0;
1491
1492    var Price = $("#ItemPrice" + Selector).val();
1493    Price = parseFloat(Price.replace(",", "."));
1494
1495    TotalPrice = Price * Quantity;
1496
1497
1498    $("#TotalPrice" + Selector).val(TotalPrice);
1499
1500    //TotalPrice = TotalPrice.toFixed(2).replace(".", ",");
1501
1502    var num = new NumberFormat();
1503    num.setInputDecimal('.');
1504    num.setNumber(TotalPrice); // obj.value is '2340.20'
1505    num.setPlaces('2', false);
1506    num.setCurrencyValue('$');
1507    num.setCurrency(false);
1508    num.setCurrencyPosition(num.LEFT_OUTSIDE);
1509    num.setNegativeFormat(num.LEFT_DASH);
1510    num.setNegativeRed(false);
1511    num.setSeparators(true, '.', ',');
1512    TotalPrice = num.toFormatted();
1513
1514    $("#TotalPriceLabel" + Selector).text(TotalPrice);
1515
1516    $.post(BASE_URL + "/application/ajax/portal/changeOrderProductQuantity.php", {OrderProductID: OrderProductID, Quantity: Quantity}, function (data, status) {
1517        if (status == "success") {
1518
1519        }
1520    });
1521
1522
1523
1524
1525    calculateOrderPrice();
1526    calculateOrderFinalPrice();
1527    calculateFreeShipping();
1528
1529}
1530
1531
1532function calculateOrderPrice() {
1533    var NumberOfItems = $("#NumberOfItems").val();
1534    var PromoCodeDiscount = $("#PromoCodeValueHidden").val();
1535    var OrderPrice = 0;
1536    var ItemTotalPrice;
1537
1538    for (var i = 0; i <= NumberOfItems; i++) {
1539        ItemTotalPrice = parseFloat($("#TotalPrice" + i).val());
1540        if (isNaN(ItemTotalPrice)) {
1541            ItemTotalPrice = 0;
1542        }
1543        OrderPrice += ItemTotalPrice;
1544    }
1545
1546
1547    /*OrderPrice -= PromoCodeDiscount;
1548     
1549     if(OrderPrice < 0){
1550     OrderPrice = 0;
1551     }*/
1552
1553    $("#OrderTotalPrice").val(OrderPrice);
1554
1555    //OrderPrice = OrderPrice.toFixed(2).replace(".", ",");
1556    var num = new NumberFormat();
1557    num.setInputDecimal('.');
1558    num.setNumber(OrderPrice); // obj.value is '2340.20'
1559    num.setPlaces('2', false);
1560    num.setCurrencyValue('$');
1561    num.setCurrency(false);
1562    num.setCurrencyPosition(num.LEFT_OUTSIDE);
1563    num.setNegativeFormat(num.LEFT_DASH);
1564    num.setNegativeRed(false);
1565    num.setSeparators(true, '.', ',');
1566    OrderPrice = num.toFormatted();
1567
1568    $("#OrderTotalPriceLabel").text(OrderPrice);
1569
1570    calculateOrderFinalPrice();
1571
1572
1573    calculateShippingPrice(NumberOfItems);
1574
1575}
1576
1577function calculateOrderPriceDefined() {
1578    var OrderPrice = 0;
1579
1580
1581    $("#OrderTotalPrice").val(OrderPrice);
1582
1583    //OrderPrice = OrderPrice.toFixed(2).replace(".", ",");
1584    var num = new NumberFormat();
1585    num.setInputDecimal('.');
1586    num.setNumber(OrderPrice); // obj.value is '2340.20'
1587    num.setPlaces('2', false);
1588    num.setCurrencyValue('$');
1589    num.setCurrency(false);
1590    num.setCurrencyPosition(num.LEFT_OUTSIDE);
1591    num.setNegativeFormat(num.LEFT_DASH);
1592    num.setNegativeRed(false);
1593    num.setSeparators(true, '.', ',');
1594    OrderPrice = num.toFormatted();
1595
1596    $("#OrderTotalPriceLabel").text(OrderPrice);
1597
1598    calculateOrderFinalPriceDefined();
1599
1600}
1601
1602
1603function calculateOrderFinalPriceDefined() {
1604    var FinalPrice = 0.00;
1605    var OrderTotalPrice = 0.00;
1606    var ShippingPrice = 0.00;
1607    OrderTotalPrice = parseFloat($("#OrderTotalPrice").val());
1608    ShippingPrice = parseFloat($("#ShippingPrice").val());
1609
1610
1611    FinalPrice = OrderTotalPrice + ShippingPrice;
1612
1613    FinalPrice = round2Fixed(FinalPrice);
1614
1615    $("#OrderFinalPrice").val(FinalPrice);
1616
1617    //FinalPrice = FinalPrice.toFixed(2).replace(".", ",");
1618    //FinalPrice = parseFloat(FinalPrice).toFixed(2).replace(".", ",");;
1619    var num = new NumberFormat();
1620    num.setInputDecimal('.');
1621    num.setNumber(FinalPrice); // obj.value is '2340.20'
1622    num.setPlaces('2', false);
1623    num.setCurrencyValue('$');
1624    num.setCurrency(false);
1625    num.setCurrencyPosition(num.LEFT_OUTSIDE);
1626    num.setNegativeFormat(num.LEFT_DASH);
1627    num.setNegativeRed(false);
1628    num.setSeparators(true, '.', ',');
1629    FinalPrice = num.toFormatted();
1630
1631    $("#OrderFinalPriceLabel").text(FinalPrice);
1632
1633
1634}
1635
1636
1637function calculateShippingPrice(NumberOfItems) {
1638    var ProductData = [];
1639
1640    for (var i = 1; i <= NumberOfItems; i++) {
1641
1642        var ProductDataOne = [];
1643        ProductDataOne.push($("#ItemID" + i).val());
1644        ProductDataOne.push($("#Quantity" + i).val());
1645
1646
1647        ProductData.push(ProductDataOne);
1648    }
1649
1650    //console.log(ProductData);
1651
1652    var SelectedShipping = $('#ShipmentValue').attr("shipingtype");
1653    var Country = $('#Country').val();
1654
1655
1656    $.post("/application/ajax/portal/getShippingPrices.php", {ProductData: ProductData, SelectedShipping: SelectedShipping, Country: Country}, function (data, status) {
1657        var Data = JSON.parse(data);
1658        if (Data.Status == "Success") {
1659            console.log(Data.Country);
1660            $("#ShipmentValue").empty();
1661            console.log(Data.Options);
1662            $("#ShipmentValue").append(Data.Options);
1663            $("#ShipmentValue").attr("shipingtype", Data.SelectedValue);
1664            $("#ShipmentValue").attr("price", Data.SelectedPrice);
1665
1666            $(".selectShipment").val(Data.SelectedValue + '-' + Data.SelectedPrice).trigger("change");
1667
1668
1669            if (returnFreeShipping() > 0) {
1670                var ShippingPriceLabel = round2Fixed(Data.SelectedPrice);
1671                ShippingPriceLabel = ShippingPriceLabel.toString().replace(".", ",");
1672                $("#ShippingPriceLabel").text(ShippingPriceLabel);
1673                $('#ShippingPrice').val(Data.SelectedPrice);
1674            }
1675
1676            $('#OrderWeight').val(Data.Weight);
1677
1678            var Weight = round2Fixed(Data.Weight);
1679
1680            Weight = Weight.toString().replace(".", ",");
1681            $("#OrderWeightValue").text(Weight);
1682
1683            $("#ShipmentValue").val(Data.SelectedValue + '-' + Data.SelectedPrice).trigger("change");
1684        } else {
1685            console.log("in-else");
1686        }
1687    });
1688
1689}
1690
1691
1692function calculateOrderFinalPrice() {
1693    //console.log("inside");
1694    var FinalPrice = 0.00;
1695    var OrderTotalPrice = 0.00;
1696    var ShippingPrice = 0.00;
1697    OrderTotalPrice = parseFloat($("#OrderTotalPrice").val());
1698    ShippingPrice = parseFloat($("#ShippingPrice").val());
1699
1700    var PromoCodeDiscount = $("#PromoCodeValueHiddenRealValue").val();
1701
1702    FinalPrice = OrderTotalPrice + ShippingPrice;
1703
1704    FinalPrice = round2Fixed(FinalPrice);
1705
1706    //console.log("Type: " + $("#PromoCodeValueHiddenType").val());
1707
1708    if ($("#PromoCodeValueHiddenType").val() == "%") {
1709        var NewDiscount = $("#PromoCodeValueHiddenOriginalValue").val();
1710        NewDiscount = NewDiscount / 100;
1711
1712        PromoCodeDiscount = OrderTotalPrice * NewDiscount;
1713        //(OrderTotalPrice * (Data.Discount / 100))
1714
1715        var PromoCodeValue = PromoCodeDiscount;
1716
1717
1718        console.log(PromoCodeDiscount);
1719        $("#PromoCodeValueHiddenRealValue").val(PromoCodeValue);
1720
1721        var num = new NumberFormat();
1722        num.setInputDecimal('.');
1723        num.setNumber(PromoCodeValue); // obj.value is '2340.20'
1724        num.setPlaces('2', false);
1725        num.setCurrencyValue('$');
1726        num.setCurrency(false);
1727        num.setCurrencyPosition(num.LEFT_OUTSIDE);
1728        num.setNegativeFormat(num.LEFT_DASH);
1729        num.setNegativeRed(false);
1730        num.setSeparators(true, '.', ',');
1731        PromoCodeValue = num.toFormatted();
1732
1733
1734        $("#PromoCodeValueSummaryValue").text("-" + PromoCodeValue + " EUR");
1735    }
1736
1737    FinalPrice -= PromoCodeDiscount;
1738    if (FinalPrice < 0) {
1739        FinalPrice = 0;
1740    }
1741
1742    $("#OrderFinalPrice").val(FinalPrice);
1743
1744    //FinalPrice = FinalPrice.toFixed(2).replace(".", ",");
1745    //FinalPrice = parseFloat(FinalPrice).toFixed(2).replace(".", ",");;
1746    var num = new NumberFormat();
1747    num.setInputDecimal('.');
1748    num.setNumber(FinalPrice); // obj.value is '2340.20'
1749    num.setPlaces('2', false);
1750    num.setCurrencyValue('$');
1751    num.setCurrency(false);
1752    num.setCurrencyPosition(num.LEFT_OUTSIDE);
1753    num.setNegativeFormat(num.LEFT_DASH);
1754    num.setNegativeRed(false);
1755    num.setSeparators(true, '.', ',');
1756    FinalPrice = num.toFormatted();
1757
1758    $("#OrderFinalPriceLabel").text(FinalPrice);
1759
1760
1761}
1762
1763function returnFreeShipping() {
1764    var Amount = parseFloat($("#FreeShippingAmount").val());
1765    var OrderTotalPrice = parseFloat($("#OrderTotalPrice").val());
1766
1767    var Remaining = Amount - OrderTotalPrice;
1768
1769    return Remaining;
1770}
1771
1772
1773function calculateFreeShipping() {
1774    var Amount = parseFloat($("#FreeShippingAmount").val());
1775    var OrderTotalPrice = parseFloat($("#OrderTotalPrice").val());
1776
1777    var Remaining = Amount - OrderTotalPrice;
1778
1779    if (Remaining <= 0) {
1780        removeShipping();
1781        Remaining = 0;
1782    } else {
1783        addShipping();
1784    }
1785
1786    Remaining = round2Fixed(Remaining);
1787
1788    Remaining = Remaining.toString().replace(".", ",");
1789    $("#FreeShipping").text(Remaining);
1790
1791
1792}
1793
1794function removeShipping() {
1795    $("#ShippingPriceLabel").text("Brezplačno");
1796    $('#ShippingPrice').val(0);
1797    $('#ShippingPriceCurrency').hide();
1798    $('#FreeShippingText1').hide();
1799    $('#FreeShippingText2').show();
1800    calculateOrderFinalPrice();
1801}
1802
1803function addShipping() {
1804    var Value = $("#ShipmentValue").attr("price");
1805    $('#ShippingPrice').val(Value);
1806
1807    Value = round2Fixed(Value);
1808    Value = Value.toString().replace(".", ",");
1809    $("#ShippingPriceLabel").text(Value);
1810
1811    $('#ShippingPriceCurrency').show();
1812
1813    $('#FreeShippingText1').show();
1814    $('#FreeShippingText2').hide();
1815
1816    calculateOrderFinalPrice();
1817}
1818
1819function removeItem(Selector, OrderProductID, BaseURL) {
1820    $(".cartItem" + Selector).remove();
1821
1822    console.log(OrderProductID);
1823
1824    $.post(BaseURL + "/application/ajax/portal/removeOrderProduct.php", {OrderProductID: OrderProductID}, function (data, status) {
1825        if (data == "empty") {
1826            window.location.replace(BaseURL + "/portal/index/cart_empty");
1827        }
1828    });
1829
1830    calculateOrderPrice();
1831    calculateFreeShipping();
1832    if (returnFreeShipping() <= 0) {
1833        removeShipping();
1834    } else {
1835        addShipping();
1836    }
1837}
1838
1839function submitPromoCode() {
1840
1841    var OrderTotalPrice = parseFloat($("#OrderFinalPrice").val());
1842    var PromoCode = $('#PromoCode').val();
1843    var OrderID = $('#OrderID').val();
1844    var OrderTotalPrice = $("#OrderTotalPrice").val();
1845
1846    $.post(BASE_URL + "/application/ajax/portal/submitPromoCode.php", {PromoCode: PromoCode, OrderID: OrderID, OrderTotalPrice: OrderTotalPrice}, function (data, status) {
1847        var Data = JSON.parse(data);
1848        if (Data.Status == "Success") {
1849            $("#PromoCodeInput").hide();
1850            $("#PromoCodeValue").text(Data.Code + " Popust: -" + Data.Discount + " " + Data.Type);
1851            $("#PromoCodeUsed").show();
1852
1853            if (Data.Type == "EUR") {
1854                $("#PromoCodeValueHidden").val(Data.Discount);
1855
1856                $("#PromoCodeValueHiddenType").val("EUR");
1857                $("#PromoCodeValueHiddenOriginalValue").val(Data.Discount);
1858                $("#PromoCodeValueHiddenRealValue").val(Data.Discount);
1859
1860                var PromoCodeValue = Data.Discount.toString().replace(".", ",");
1861                $("#PromoCodeUsedSummary").show();
1862                $("#PromoCodeValueSummary").text("Promocijska koda: " + Data.Code);
1863                $("#PromoCodeValueSummaryValue").text("-" + PromoCodeValue + " " + Data.Type);
1864
1865            } else {
1866                console.log("Total: " + OrderTotalPrice);
1867                console.log("Discount: " + (Data.Discount / 100));
1868                console.log("DiscountTotal: " + (OrderTotalPrice * (Data.Discount / 100)));
1869                var NewDiscount = (OrderTotalPrice * (Data.Discount / 100));
1870                $("#PromoCodeValueHidden").val(NewDiscount);
1871                $("#PromoCodeValueHiddenRealValue").val(NewDiscount);
1872
1873                $("#PromoCodeValueHiddenOriginalValue").val(Data.Discount);
1874
1875                console.log("PromoCodeValueHiddenRealValue: " + NewDiscount);
1876
1877
1878                $("#PromoCodeValueHiddenType").val("%");
1879
1880                var PromoCodeValue = NewDiscount;
1881
1882                var num = new NumberFormat();
1883                num.setInputDecimal('.');
1884                num.setNumber(PromoCodeValue); // obj.value is '2340.20'
1885                num.setPlaces('2', false);
1886                num.setCurrencyValue('$');
1887                num.setCurrency(false);
1888                num.setCurrencyPosition(num.LEFT_OUTSIDE);
1889                num.setNegativeFormat(num.LEFT_DASH);
1890                num.setNegativeRed(false);
1891                num.setSeparators(true, '.', ',');
1892                PromoCodeValue = num.toFormatted();
1893
1894                $("#PromoCodeUsedSummary").show();
1895                $("#PromoCodeValueSummary").text("Promocijska koda: " + Data.Code);
1896                $("#PromoCodeValueSummaryValue").text("-" + PromoCodeValue + " EUR");
1897            }
1898
1899
1900
1901            calculateOrderPrice();
1902
1903        } else if (Data.Status == "SuccessPromocodeOnItem") {
1904
1905            //calculateOrderPrice();
1906
1907            location.reload();
1908
1909        } else {
1910            $("#PromoCode").css("border-color", "red");
1911        }
1912    });
1913}
1914
1915function selectPayment(SelectedID, braintree) {
1916    console.log("select payment entry " + SelectedID + " " + braintree);
1917
1918    var SelectedPayment = $('#' + SelectedID).val();
1919
1920    $("#PaymentType").val(SelectedID);
1921    var Checked = $('#' + SelectedID).is(":checked");
1922    var ID;
1923    if (Checked) {
1924
1925        $(".cartStep2PaymentMethod").hide();
1926        $("#" + SelectedID + "Box").show();
1927
1928        var $Inputs = $('#PaymentCheckboxes :input');
1929
1930        $Inputs.each(function (index) {
1931            ID = $(this).attr('id');
1932            $("#" + ID).prop('checked', false);
1933        });
1934
1935        $("#" + SelectedID).prop('checked', 'true');
1936
1937
1938        var Token = $("#Token").val();
1939        var Amount = $("#OrderFinalPrice").val();
1940        var PayPalInitialized = $("#PayPalInitialized").val();
1941        var CreditCardInitialized = $("#CreditCardInitialized").val();
1942
1943        console.log("PP: " + PayPalInitialized);
1944        console.log("CC: " + CreditCardInitialized);
1945
1946        if (SelectedID == "CreditCard" && CreditCardInitialized == 0) {
1947            initializeCardInput(braintree, Token);
1948        }
1949
1950        if (SelectedID == "PayPal" && PayPalInitialized == 0) {
1951            initializePayPalInput(braintree, Token, Amount);
1952        }
1953
1954        if (SelectedID == "PayPal") {
1955            $("#submitOrder").hide();
1956        } else {
1957            $("#submitOrder").show();
1958        }
1959
1960        if (SelectedID == "CreditCard") {
1961            $(".securePaymentBox").slideDown();
1962        } else {
1963            $(".securePaymentBox").slideUp();
1964        }
1965    }
1966}
1967
1968function showUserCreate(Checkbox) {
1969    $('#CreateUserBox').toggle('slideDown');
1970
1971    var Checked = $(Checkbox).is(":checked");
1972
1973    if (Checked) {
1974        $('#Password').attr("data-parsley-required", "");
1975        $('#PasswordRepeat').attr("data-parsley-required", "");
1976        $('#PasswordRepeat').attr("data-parsley-equalto", "#Password");
1977    } else {
1978        $('#Password').removeAttr("data-parsley-required");
1979        $('#PasswordRepeat').removeAttr("data-parsley-required");
1980        $('#PasswordRepeat').removeAttr("data-parsley-equalto");
1981    }
1982}
1983
1984
1985function showDifferentAddress(Checkbox) {
1986    $('#DifferentAddressBox').toggle('slideDown');
1987
1988    var Checked = $(Checkbox).is(":checked");
1989
1990    if (Checked) {
1991        $('#AddressDifferent').attr("data-parsley-required", "");
1992        $('#PostDifferent').attr("data-parsley-required", "");
1993        $('#FirstnameDifferent').attr("data-parsley-required", "");
1994        $('#LastnameDifferent').attr("data-parsley-required", "");
1995        $('#PostNumberDifferent').attr("data-parsley-required", "");
1996    } else {
1997        $('#AddressDifferent').removeAttr("data-parsley-required");
1998        $('#PostDifferent').removeAttr("data-parsley-required");
1999        $('#FirstnameDifferent').removeAttr("data-parsley-required");
2000        $('#LastnameDifferent').removeAttr("data-parsley-required");
2001        $('#PostNumberDifferent').removeAttr("data-parsley-required");
2002    }
2003}
2004
2005function showLegalPerson(Checkbox) {
2006
2007    $('#LegalPersonBox').toggle('slideDown');
2008
2009    var Checked = $(Checkbox).is(":checked");
2010
2011    if (Checked) {
2012        $('#Company').attr("data-parsley-required", "");
2013        $('#VATNumber').attr("data-parsley-required", "");
2014    } else {
2015        $('#Company').removeAttr("data-parsley-required");
2016        $('#VATNumber').removeAttr("data-parsley-required");
2017    }
2018}
2019
2020
2021function showHasCompany() {
2022
2023	var RadioBtn = $("#filter21");
2024
2025	if(RadioBtn.data('waschecked') == true) {
2026			
2027        RadioBtn.data('waschecked', false);
2028		
2029		RadioBtn.prop('checked', false);
2030		
2031		$('#HasCompany').hide();
2032		$('#Company').removeAttr("data-parsley-required");
2033		$('#VATNumber').removeAttr("data-parsley-required");
2034			
2035    } else {
2036        RadioBtn.data('waschecked', true);
2037			
2038		$('#HasCompany').show();
2039		$('#Company').attr("data-parsley-required", "");
2040		$('#VATNumber').attr("data-parsley-required", "");		
2041	}
2042
2043}
2044
2045function hideHasCompany() {
2046
2047    $('#HasCompany').hide();
2048    $('#Company').removeAttr("data-parsley-required");
2049    $('#VATNumber').removeAttr("data-parsley-required");
2050}
2051
2052function initializePayPalInput(braintree, Token, Amount) {
2053    console.log("init PP " + braintree);
2054    console.log("Amount: " + Amount);
2055    console.log("Token: " + Token);
2056
2057    braintree.setup(Token, "custom", {
2058        onReady: function (integration) {
2059            //checkout = integration;
2060            console.log("braintree paypal on ready");
2061        },
2062        paypal: {
2063            container: "paypal-container",
2064            singleUse: true, // Required
2065            amount: Amount, // Required
2066            currency: 'EUR', // Required
2067        },
2068        dataCollector: {
2069            paypal: true
2070        },
2071        onPaymentMethodReceived: function (obj) {
2072            console.log("braintree paypal + on payment method received");
2073
2074            var nonce = obj.nonce;
2075            $("#payment_method_nonce").val(nonce);
2076            $("#Paypal").submit();
2077
2078            $("#submitOrder").show();
2079
2080            console.log("Nonce: " + nonce);
2081
2082
2083        }
2084    });
2085
2086
2087    if (!(navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1)) {
2088        setTimeout(function () {
2089            $("#braintree-paypal-loggedout > span > button").click();
2090        }, 2000);
2091    }
2092
2093    $("#PayPalInitialized").val("1");
2094}
2095
2096function initializeCardInput(braintree, Token) {
2097    console.log("init CC " + braintree);
2098    console.log(Token);
2099
2100    braintree.setup(Token, "custom", {id: "cartStep2Submit"});
2101
2102
2103    var card = new Card({
2104        form: 'div[name="creditCardsInput"]',
2105        container: '.card-wrapper',
2106
2107        formSelectors: {
2108            numberInput: 'input#cardNumber',
2109            expiryInput: 'input#expiryDate',
2110            cvcInput: 'input#controlNumber',
2111            nameInput: 'input#cardHolder'
2112        },
2113
2114        width: 300,
2115        formatting: true,
2116
2117        messages: {
2118            validDate: 'Datum veljavnosti',
2119            monthYear: 'mm/yyyy',
2120        },
2121
2122        placeholders: {
2123            number: '•••• •••• •••• ••••',
2124            name: 'Ime in priimek',
2125            expiry: '••/••',
2126            cvc: '•••'
2127        },
2128
2129        masks: {
2130            //cardNumber: '•' // optional - mask card number
2131        },
2132
2133        debug: false
2134    });
2135
2136    $("#CreditCardInitialized").val("1");
2137}
2138
2139
2140
2141function showLoginBox() {
2142    $("#LoginBox").show();
2143    $("#LoginBoxRight").hide();
2144
2145    $("#RegisterBox").hide();
2146    $("#RegisterBoxRight").show();
2147}
2148
2149function showRegisterBox() {
2150    $("#LoginBox").hide();
2151    $("#LoginBoxRight").show();
2152
2153    $("#RegisterBox").show();
2154    $("#RegisterBoxRight").hide();
2155}
2156
2157function selectGender(Element, Type) {
2158    $(".modalGenderSelect").removeClass("modalGenderSelectActive");
2159    $(Element).addClass("modalGenderSelectActive");
2160    $("#GenderInput-Male").removeAttr('checked');
2161    $("#GenderInput-Female").removeAttr('checked');
2162    $("#GenderInput-" + Type).attr('checked', 'checked');
2163}
2164
2165function selectSearch(Element, Type) {
2166    $(".modalGenderSelect").removeClass("modalGenderSelectActive");
2167    $(Element).addClass("modalGenderSelectActive");
2168    $("#SearchInput-1").removeAttr('checked');
2169    $("#SearchInput-2").removeAttr('checked');
2170    $("#SearchInput-3").removeAttr('checked');
2171    $("#SearchInput-" + Type).attr('checked', 'checked');
2172}
2173
2174function selectGenderGift(Element, Type) {
2175    $(".modalGenderSelect .gift").removeClass("modalGenderSelectActive");
2176    $(Element).addClass("modalGenderSelectActive");
2177    $("#GenderInputGift-Male").removeAttr('checked');
2178    $("#GenderInputGift-Female").removeAttr('checked');
2179    $("#GenderInputGift-" + Type).attr('checked', 'checked');
2180}
2181
2182function recaptchaCallback() {
2183    var Data = JSON.parse(event.data);
2184    var Message = Data.message;
2185    console.log(Message);
2186
2187    $.post(BASE_URL + "/application/ajax/portal/setCaptchaToSession.php", {Message: Message}, function (data, status) {
2188        var Data = JSON.parse(data);
2189        $("#CaptchaMessage").val(Data.Message);
2190    });
2191
2192    $('#RegisterButton').removeAttr('disabled');
2193    $('#RegisterButton').removeClass('loginButtonDisabled');
2194}
2195;
2196
2197function submitRegister() {
2198    event.preventDefault();
2199    // needs for recaptacha ready
2200    grecaptcha.ready(function () {
2201        // do request for recaptcha token
2202        // response is promise with passed token
2203        grecaptcha.execute('6Lc1c3YUAAAAAOZ8Inj03BwXnZobnz464FOmUNoz', {action: 'register'}).then(function (token) {
2204            // add token to form
2205            $('#RegisterForm').append('<input type="hidden" name="token" value="' + token + '">');
2206            $('#RegisterForm').append('<input type="hidden" name="action" value="register">');
2207            // submit form now
2208            $('#RegisterForm').submit();
2209        });
2210        ;
2211    });
2212}
2213
2214function submitMagazine() {
2215    event.preventDefault();
2216    // needs for recaptacha ready
2217    grecaptcha.ready(function () {
2218        // do request for recaptcha token
2219        // response is promise with passed token
2220        grecaptcha.execute('6Lc1c3YUAAAAAOZ8Inj03BwXnZobnz464FOmUNoz', {action: 'magazine'}).then(function (token) {
2221            // add token to form
2222            $('#Magazine').append('<input type="hidden" name="token" value="' + token + '">');
2223            $('#Magazine').append('<input type="hidden" name="action" value="register">');
2224            // submit form now
2225            $('#Magazine').submit();
2226        });
2227        ;
2228    });
2229}
2230
2231function recaptchaCallback2() {
2232
2233    var Data = JSON.parse(event.data);
2234    var Message = Data.message;
2235    console.log(Message);
2236
2237    $.post(BASE_URL + "/application/ajax/portal/setCaptchaToSession.php", {Message: Message}, function (data, status) {
2238        var Data = JSON.parse(data);
2239        $("#CaptchaMessage1").val(Data.Message);
2240    });
2241
2242    $('#OrderButton').removeAttr('disabled');
2243    $('#OrderButton').removeClass('loginButtonDisabled');
2244
2245}
2246;
2247
2248function getPostalOffice(Type, PostCodeID, CityID) {
2249
2250    var PostCode = $(PostCodeID).val().trim();
2251    var City = $(CityID).val().trim();
2252
2253    $.post(BASE_URL + "/application/ajax/portal/getPostalOffice.php", {Type: Type, PostCode: PostCode, City: City}, function (data, status) {
2254
2255        if (Type == "PostCode") {
2256
2257            $(CityID).val(data);
2258
2259        } else if (Type == "City") {
2260
2261            $(PostCodeID).val(data);
2262
2263        }
2264
2265    });
2266
2267}
2268;
2269
2270function showGiftBox(Checkbox) {
2271    if ($(Checkbox).is(":checked")) {
2272        $("#GiftBox").slideDown();
2273
2274        $("#FirstnameGift").attr('data-parsley-required', 'true');
2275        $("#LastnameGift").attr('data-parsley-required', 'true');
2276        $("#AddressGift").attr('data-parsley-required', 'true');
2277        $("#PostCodeGift").attr('data-parsley-required', 'true');
2278        $("#CityGift").attr('data-parsley-required', 'true');
2279        $("#EmailGift").attr('data-parsley-required', 'true');
2280
2281    } else {
2282        $("#GiftBox").slideUp();
2283
2284        $("#FirstnameGift").removeAttr('data-parsley-required');
2285        $("#LastnameGift").removeAttr('data-parsley-required');
2286        $("#AddressGift").removeAttr('data-parsley-required');
2287        $("#PostCodeGift").removeAttr('data-parsley-required');
2288        $("#CityGift").removeAttr('data-parsley-required');
2289        $("#EmailGift").removeAttr('data-parsley-required');
2290    }
2291}
2292
2293
2294function filterProducts(Checkbox) {
2295    var Checkboxes = $(".filtersBox input[type=checkbox]:checked");
2296
2297    var FilterValue = $(Checkbox).val();
2298    console.log(FilterValue);
2299
2300    var Filtered = $(".productCard__product[data-type*=" + FilterValue + "]");
2301    var All = $(".productCard__product");
2302
2303    $.each(All, function (Index, Element) {
2304        if (jQuery.inArray(Element, Filtered) !== -1) {
2305            $(Element).slideDown();
2306        } else {
2307            $(Element).slideUp();
2308        }
2309    });
2310
2311    console.log(Checkboxes.length);
2312
2313    if (Checkboxes.length < 1) {
2314        $.each(All, function (Index, Element) {
2315            $(Element).slideDown();
2316        });
2317    }
2318}
2319
2320
2321function isScrolledToBottom(el) {
2322    var $el = $(el);
2323    return el.scrollHeight - $el.scrollTop() - $el.outerHeight() < 1;
2324}
2325
2326
2327function loadMessages(SenderID) {
2328    /*$(".messagesContainer").hide();*/
2329    $(".messagesContainer").html("");
2330
2331    var MessageTemplate = $(".messageTemplate").html();
2332    var NewCard = MessageTemplate;
2333
2334    $.post(BASE_URL + "/application/ajax/portal/getMessages.php", {SenderID: SenderID}, function (data, status) {
2335        var Data = JSON.parse(data);
2336        if (Data.Status == "Success") {
2337            var Messages = Data.Messages;
2338            $.each(Messages, function (index, MessageSingle) {
2339                var NewCard = MessageTemplate;
2340
2341                NewCard = NewCard.replace("#USERNAME#", MessageSingle.Username);
2342                NewCard = NewCard.replace("#DATE#", MessageSingle.Date);
2343                NewCard = NewCard.replace("#MESSAGE#", MessageSingle.Message);
2344                NewCard = NewCard.replace(/#TEXT_ALIGN#/gi, "text-align: " + MessageSingle.Align + ";");
2345                NewCard = NewCard.replace(/#ALIGN#/gi, "pull-" + MessageSingle.Align + "");
2346
2347                $(".messagesContainer").append(NewCard);
2348            });
2349
2350        }
2351
2352        $(".ReceiverID").val(SenderID);
2353    });
2354
2355
2356    $(".messagesContainer").show();
2357    $(".sendMessage").show();
2358
2359    /*setTimeout(function(){
2360     $(".mCont1").scrollTop(1E10);
2361     }, 200);
2362     */
2363    console.log("before");
2364    setTimeout(function () {
2365        $(".mCont1").animate({scrollTop: $('.mCont1').prop("scrollHeight")}, 1000);
2366        console.log("in");
2367    }, 200);
2368}
2369
2370function openConversation(SenderID) {
2371    if ($(window).width() < 960) {
2372        window.location.href = BASE_URL + "/portal/profile/messages-in/" + SenderID;
2373    }
2374}
2375
2376function loadMessagesPartial(SenderID) {
2377    /*$(".messagesContainer").hide();*/
2378    var MessageTemplate = $(".messageTemplate").html();
2379    var NewCard = MessageTemplate;
2380
2381    var InitialTime = $("#InitialTime").val();
2382
2383    $.post(BASE_URL + "/application/ajax/portal/getNewMessages.php", {SenderID: SenderID, InitialTime: InitialTime}, function (data, status) {
2384        var Data = JSON.parse(data);
2385        if (Data.Status == "Success") {
2386            var Messages = Data.Messages;
2387            $.each(Messages, function (index, MessageSingle) {
2388                var NewCard = MessageTemplate;
2389
2390                NewCard = NewCard.replace("#USERNAME#", MessageSingle.Username);
2391                NewCard = NewCard.replace("#DATE#", MessageSingle.Date);
2392                NewCard = NewCard.replace("#MESSAGE#", MessageSingle.Message);
2393                NewCard = NewCard.replace(/#TEXT_ALIGN#/gi, "text-align: " + MessageSingle.Align + ";");
2394                NewCard = NewCard.replace(/#ALIGN#/gi, "pull-" + MessageSingle.Align + "");
2395
2396                $(".messagesContainer").append(NewCard);
2397            });
2398
2399        }
2400
2401        $(".ReceiverID").val(SenderID);
2402        $("#InitialTime").val(Data.NewTime);
2403    });
2404
2405
2406    var ScrollTop = $(".mCont1").scrollTop();
2407    var ScrollHeight = $('.mCont1')[0].scrollHeight;
2408    var OuterHeight = $('.mCont1').outerHeight();
2409
2410    /*console.log(ScrollTop);
2411     console.log(ScrollHeight);
2412     console.log("ScrollHeight - ScrollTop: " + (ScrollHeight - ScrollTop));
2413     console.log("OuterHeight: " + OuterHeight);*/
2414
2415
2416
2417    //setTimeout(function(){$(".mCont1").scrollTop(1E10);},100);
2418
2419    if (((ScrollHeight - ScrollTop) == OuterHeight) || FirstLoad == 1) {
2420        $(".mCont1").animate({scrollTop: $('.mCont1').prop("scrollHeight")}, 1000);
2421        FirstLoad = 0;
2422    }
2423}
2424
2425function sendMessage() {
2426    var ReceiverID = $(".m1 .ReceiverID").val();
2427    var Message = $(".m1 .commentInput").val();
2428
2429    $.post(BASE_URL + "/application/ajax/portal/sendMessage.php", {ReceiverID: ReceiverID, Message: Message}, function (data, status) {});
2430
2431    loadMessagesPartial(ReceiverID);
2432    $(".m1 .commentInput").val("");
2433    $(".m1 .commentInput").text("");
2434
2435    $(".note-editable").html("");
2436
2437}
2438
2439// mredkj.com
2440function NumberFormat(num, inputDecimal)
2441{
2442    this.VERSION = 'Number Format v1.5.4';
2443    this.COMMA = ',';
2444    this.PERIOD = '.';
2445    this.DASH = '-';
2446    this.LEFT_PAREN = '(';
2447    this.RIGHT_PAREN = ')';
2448    this.LEFT_OUTSIDE = 0;
2449    this.LEFT_INSIDE = 1;
2450    this.RIGHT_INSIDE = 2;
2451    this.RIGHT_OUTSIDE = 3;
2452    this.LEFT_DASH = 0;
2453    this.RIGHT_DASH = 1;
2454    this.PARENTHESIS = 2;
2455    this.NO_ROUNDING = -1
2456    this.num;
2457    this.numOriginal;
2458    this.hasSeparators = false;
2459    this.separatorValue;
2460    this.inputDecimalValue;
2461    this.decimalValue;
2462    this.negativeFormat;
2463    this.negativeRed;
2464    this.hasCurrency;
2465    this.currencyPosition;
2466    this.currencyValue;
2467    this.places;
2468    this.roundToPlaces;
2469    this.truncate;
2470    this.setNumber = setNumberNF;
2471    this.toUnformatted = toUnformattedNF;
2472    this.setInputDecimal = setInputDecimalNF;
2473    this.setSeparators = setSeparatorsNF;
2474    this.setCommas = setCommasNF;
2475    this.setNegativeFormat = setNegativeFormatNF;
2476    this.setNegativeRed = setNegativeRedNF;
2477    this.setCurrency = setCurrencyNF;
2478    this.setCurrencyPrefix = setCurrencyPrefixNF;
2479    this.setCurrencyValue = setCurrencyValueNF;
2480    this.setCurrencyPosition = setCurrencyPositionNF;
2481    this.setPlaces = setPlacesNF;
2482    this.toFormatted = toFormattedNF;
2483    this.toPercentage = toPercentageNF;
2484    this.getOriginal = getOriginalNF;
2485    this.moveDecimalRight = moveDecimalRightNF;
2486    this.moveDecimalLeft = moveDecimalLeftNF;
2487    this.getRounded = getRoundedNF;
2488    this.preserveZeros = preserveZerosNF;
2489    this.justNumber = justNumberNF;
2490    this.expandExponential = expandExponentialNF;
2491    this.getZeros = getZerosNF;
2492    this.moveDecimalAsString = moveDecimalAsStringNF;
2493    this.moveDecimal = moveDecimalNF;
2494    this.addSeparators = addSeparatorsNF;
2495    if (inputDecimal == null) {
2496        this.setNumber(num, this.PERIOD);
2497    } else {
2498        this.setNumber(num, inputDecimal);
2499    }
2500    this.setCommas(true);
2501    this.setNegativeFormat(this.LEFT_DASH);
2502    this.setNegativeRed(false);
2503    this.setCurrency(false);
2504    this.setCurrencyPrefix('$');
2505    this.setPlaces(2);
2506}
2507function setInputDecimalNF(val)
2508{
2509    this.inputDecimalValue = val;
2510}
2511function setNumberNF(num, inputDecimal)
2512{
2513    if (inputDecimal != null) {
2514        this.setInputDecimal(inputDecimal);
2515    }
2516    this.numOriginal = num;
2517    this.num = this.justNumber(num);
2518}
2519function toUnformattedNF()
2520{
2521    return (this.num);
2522}
2523function getOriginalNF()
2524{
2525    return (this.numOriginal);
2526}
2527function setNegativeFormatNF(format)
2528{
2529    this.negativeFormat = format;
2530}
2531function setNegativeRedNF(isRed)
2532{
2533    this.negativeRed = isRed;
2534}
2535function setSeparatorsNF(isC, separator, decimal)
2536{
2537    this.hasSeparators = isC;
2538    if (separator == null)
2539        separator = this.COMMA;
2540    if (decimal == null)
2541        decimal = this.PERIOD;
2542    if (separator == decimal) {
2543        this.decimalValue = (decimal == this.PERIOD) ? this.COMMA : this.PERIOD;
2544    } else {
2545        this.decimalValue = decimal;
2546    }
2547    this.separatorValue = separator;
2548}
2549function setCommasNF(isC)
2550{
2551    this.setSeparators(isC, this.COMMA, this.PERIOD);
2552}
2553function setCurrencyNF(isC)
2554{
2555    this.hasCurrency = isC;
2556}
2557function setCurrencyValueNF(val)
2558{
2559    this.currencyValue = val;
2560}
2561function setCurrencyPrefixNF(cp)
2562{
2563    this.setCurrencyValue(cp);
2564    this.setCurrencyPosition(this.LEFT_OUTSIDE);
2565}
2566function setCurrencyPositionNF(cp)
2567{
2568    this.currencyPosition = cp
2569}
2570function setPlacesNF(p, tr)
2571{
2572    this.roundToPlaces = !(p == this.NO_ROUNDING);
2573    this.truncate = (tr != null && tr);
2574    this.places = (p < 0) ? 0 : p;
2575}
2576function addSeparatorsNF(nStr, inD, outD, sep)
2577{
2578    nStr += '';
2579    var dpos = nStr.indexOf(inD);
2580    var nStrEnd = '';
2581    if (dpos != -1) {
2582        nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
2583        nStr = nStr.substring(0, dpos);
2584    }
2585    var rgx = /(\d+)(\d{3})/;
2586    while (rgx.test(nStr)) {
2587        nStr = nStr.replace(rgx, '$1' + sep + '$2');
2588    }
2589    return nStr + nStrEnd;
2590}
2591function toFormattedNF()
2592{
2593    var pos;
2594    var nNum = this.num;
2595    var nStr;
2596    var splitString = new Array(2);
2597    if (this.roundToPlaces) {
2598        nNum = this.getRounded(nNum);
2599        nStr = this.preserveZeros(Math.abs(nNum));
2600    } else {
2601        nStr = this.expandExponential(Math.abs(nNum));
2602    }
2603    if (this.hasSeparators) {
2604        nStr = this.addSeparators(nStr, this.PERIOD, this.decimalValue, this.separatorValue);
2605    } else {
2606        nStr = nStr.replace(new RegExp('\\' + this.PERIOD), this.decimalValue);
2607    }
2608    var c0 = '';
2609    var n0 = '';
2610    var c1 = '';
2611    var n1 = '';
2612    var n2 = '';
2613    var c2 = '';
2614    var n3 = '';
2615    var c3 = '';
2616    var negSignL = (this.negativeFormat == this.PARENTHESIS) ? this.LEFT_PAREN : this.DASH;
2617    var negSignR = (this.negativeFormat == this.PARENTHESIS) ? this.RIGHT_PAREN : this.DASH;
2618    if (this.currencyPosition == this.LEFT_OUTSIDE) {
2619        if (nNum < 0) {
2620            if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS)
2621                n1 = negSignL;
2622            if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS)
2623                n2 = negSignR;
2624        }
2625        if (this.hasCurrency)
2626            c0 = this.currencyValue;
2627    } else if (this.currencyPosition == this.LEFT_INSIDE) {
2628        if (nNum < 0) {
2629            if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS)
2630                n0 = negSignL;
2631            if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS)
2632                n3 = negSignR;
2633        }
2634        if (this.hasCurrency)
2635            c1 = this.currencyValue;
2636    } else if (this.currencyPosition == this.RIGHT_INSIDE) {
2637        if (nNum < 0) {
2638            if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS)
2639                n0 = negSignL;
2640            if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS)
2641                n3 = negSignR;
2642        }
2643        if (this.hasCurrency)
2644            c2 = this.currencyValue;
2645    } else if (this.currencyPosition == this.RIGHT_OUTSIDE) {
2646        if (nNum < 0) {
2647            if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS)
2648                n1 = negSignL;
2649            if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS)
2650                n2 = negSignR;
2651        }
2652        if (this.hasCurrency)
2653            c3 = this.currencyValue;
2654    }
2655    nStr = c0 + n0 + c1 + n1 + nStr + n2 + c2 + n3 + c3;
2656    if (this.negativeRed && nNum < 0) {
2657        nStr = '<font color="red">' + nStr + '</font>';
2658    }
2659    return (nStr);
2660}
2661function toPercentageNF()
2662{
2663    nNum = this.num * 100;
2664    nNum = this.getRounded(nNum);
2665    return nNum + '%';
2666}
2667function getZerosNF(places)
2668{
2669    var extraZ = '';
2670    var i;
2671    for (i = 0; i < places; i++) {
2672        extraZ += '0';
2673    }
2674    return extraZ;
2675}
2676function expandExponentialNF(origVal)
2677{
2678    if (isNaN(origVal))
2679        return origVal;
2680    var newVal = parseFloat(origVal) + '';
2681    var eLoc = newVal.toLowerCase().indexOf('e');
2682    if (eLoc != -1) {
2683        var plusLoc = newVal.toLowerCase().indexOf('+');
2684        var negLoc = newVal.toLowerCase().indexOf('-', eLoc);
2685        var justNumber = newVal.substring(0, eLoc);
2686        if (negLoc != -1) {
2687            var places = newVal.substring(negLoc + 1, newVal.length);
2688            justNumber = this.moveDecimalAsString(justNumber, true, parseInt(places));
2689        } else {
2690            if (plusLoc == -1)
2691                plusLoc = eLoc;
2692            var places = newVal.substring(plusLoc + 1, newVal.length);
2693            justNumber = this.moveDecimalAsString(justNumber, false, parseInt(places));
2694        }
2695        newVal = justNumber;
2696    }
2697    return newVal;
2698}
2699function moveDecimalRightNF(val, places)
2700{
2701    var newVal = '';
2702    if (places == null) {
2703        newVal = this.moveDecimal(val, false);
2704    } else {
2705        newVal = this.moveDecimal(val, false, places);
2706    }
2707    return newVal;
2708}
2709function moveDecimalLeftNF(val, places)
2710{
2711    var newVal = '';
2712    if (places == null) {
2713        newVal = this.moveDecimal(val, true);
2714    } else {
2715        newVal = this.moveDecimal(val, true, places);
2716    }
2717    return newVal;
2718}
2719function moveDecimalAsStringNF(val, left, places)
2720{
2721    var spaces = (arguments.length < 3) ? this.places : places;
2722    if (spaces <= 0)
2723        return val;
2724    var newVal = val + '';
2725    var extraZ = this.getZeros(spaces);
2726    var re1 = new RegExp('([0-9.]+)');
2727    if (left) {
2728        newVal = newVal.replace(re1, extraZ + '$1');
2729        var re2 = new RegExp('(-?)([0-9]*)([0-9]{' + spaces + '})(\\.?)');
2730        newVal = newVal.replace(re2, '$1$2.$3');
2731    } else {
2732        var reArray = re1.exec(newVal);
2733        if (reArray != null) {
2734            newVal = newVal.substring(0, reArray.index) + reArray[1] + extraZ + newVal.substring(reArray.index + reArray[0].length);
2735        }
2736        var re2 = new RegExp('(-?)([0-9]*)(\\.?)([0-9]{' + spaces + '})');
2737        newVal = newVal.replace(re2, '$1$2$4.');
2738    }
2739    newVal = newVal.replace(/\.$/, '');
2740    return newVal;
2741}
2742function moveDecimalNF(val, left, places)
2743{
2744    var newVal = '';
2745    if (places == null) {
2746        newVal = this.moveDecimalAsString(val, left);
2747    } else {
2748        newVal = this.moveDecimalAsString(val, left, places);
2749    }
2750    return parseFloat(newVal);
2751}
2752function getRoundedNF(val)
2753{
2754    val = this.moveDecimalRight(val);
2755    if (this.truncate) {
2756        val = val >
2756= 0 ? Math.floor(val) : Math.ceil(val);
2757    } else {
2758        val = Math.round(val);
2759    }
2760    val = this.moveDecimalLeft(val);
2761    return val;
2762}
2763function preserveZerosNF(val)
2764{
2765    var i;
2766    val = this.expandExponential(val);
2767    if (this.places <= 0)
2768        return val;
2769    var decimalPos = val.indexOf('.');
2770    if (decimalPos == -1) {
2771        val += '.';
2772        for (i = 0; i < this.places; i++) {
2773            val += '0';
2774        }
2775    } else {
2776        var actualDecimals = (val.length - 1) - decimalPos;
2777        var difference = this.places - actualDecimals;
2778        for (i = 0; i < difference; i++) {
2779            val += '0';
2780        }
2781    }
2782    return val;
2783}
2784function justNumberNF(val)
2785{
2786    newVal = val + '';
2787    var isPercentage = false;
2788    if (newVal.indexOf('%') != -1) {
2789        newVal = newVal.replace(/\%/g, '');
2790        isPercentage = true;
2791    }
2792    var re = new RegExp('[^\\' + this.inputDecimalValue + '\\d\\-\\+\\(\\)eE]', 'g');
2793    newVal = newVal.replace(re, '');
2794    var tempRe = new RegExp('[' + this.inputDecimalValue + ']', 'g');
2795    var treArray = tempRe.exec(newVal);
2796    if (treArray != null) {
2797        var tempRight = newVal.substring(treArray.index + treArray[0].length);
2798        newVal = newVal.substring(0, treArray.index) + this.PERIOD + tempRight.replace(tempRe, '');
2799    }
2800    if (newVal.charAt(newVal.length - 1) == this.DASH) {
2801        newVal = newVal.substring(0, newVal.length - 1);
2802        newVal = '-' + newVal;
2803    } else if (newVal.charAt(0) == this.LEFT_PAREN
2804            && newVal.charAt(newVal.length - 1) == this.RIGHT_PAREN) {
2805        newVal = newVal.substring(1, newVal.length - 1);
2806        newVal = '-' + newVal;
2807    }
2808    newVal = parseFloat(newVal);
2809    if (!isFinite(newVal)) {
2810        newVal = 0;
2811    }
2812    if (isPercentage) {
2813        newVal = this.moveDecimalLeft(newVal, 2);
2814    }
2815    return newVal;
2816}
2817
2818
2819function calculateSpecialPrices() {
2820
2821    var OrderProductsCount = $("#OrderProductsCount").val();
2822
2823    // console.log(OrderProductsCount);
2824
2825    if ($('#Subscriber').is(':checked')) {
2826
2827        // console.log("subscriber checbox is checked");
2828
2829        for (var i = 1; i <= OrderProductsCount; i++) {
2830
2831            // write special price
2832            var SpecialPrice = $("#ItemSpecialPrice" + i).val();
2833
2834            if (SpecialPrice != 0) {
2835
2836                $("#ItemPrice" + i).val(SpecialPrice);
2837
2838                var num = new NumberFormat();
2839                num.setInputDecimal('.');
2840                num.setNumber(SpecialPrice); // obj.value is '2340.20'
2841                num.setPlaces('2', false);
2842                num.setCurrencyValue('$');
2843                num.setCurrency(false);
2844                num.setCurrencyPosition(num.LEFT_OUTSIDE);
2845                num.setNegativeFormat(num.LEFT_DASH);
2846                num.setNegativeRed(false);
2847                num.setSeparators(true, '.', ',');
2848                SpecialPrice = num.toFormatted();
2849
2850                console.log(SpecialPrice);
2851
2852                // write special price text
2853                $("#PriceLabel" + i).text(SpecialPrice);
2854
2855                // change quantity
2856                $("#Quantity" + i).change();
2857            }
2858        }
2859
2860    } else {
2861        // console.log("subscriber checbox is not checked");
2862
2863        for (var i = 1; i <= OrderProductsCount; i++) {
2864
2865            // write special price
2866            var ItemPrice = $("#ItemPriceRemember" + i).val();
2867            $("#ItemPrice" + i).val(ItemPrice);
2868
2869            var num = new NumberFormat();
2870            num.setInputDecimal('.');
2871            num.setNumber(ItemPrice); // obj.value is '2340.20'
2872            num.setPlaces('2', false);
2873            num.setCurrencyValue('$');
2874            num.setCurrency(false);
2875            num.setCurrencyPosition(num.LEFT_OUTSIDE);
2876            num.setNegativeFormat(num.LEFT_DASH);
2877            num.setNegativeRed(false);
2878            num.setSeparators(true, '.', ',');
2879            ItemPrice = num.toFormatted();
2880
2881            // write special price text
2882            $("#PriceLabel" + i).text(ItemPrice);
2883
2884            // change quantity
2885            $("#Quantity" + i).change();
2886        }
2887    }
2888}
2889
2890
2891//$('#SearchQuery').on('change', function () {
2892//    console.log($(this).val());
2893//    var Search = $(this).val();
2894//    return ReturnSearchMagazines(Search);
2895//});
2896
2897
2898
2899
2900function ReturnSearchMagazines(Chapter) {
2901    
2902    var Search = $("#SearchQuery").val();
2903    var LazyLoadSection = $('#LazyLoadSection').val();
2904
2905    console.log(LazyLoadSection);
2906
2907//   console.log(Search);
2908
2909    $.post(BASE_URL + "/application/ajax/portal/returnSearchMagazines.php",
2910            {
2911                Search: Search,
2912                Chapter: Chapter,
2913                LazyLoadSection: LazyLoadSection
2914            },
2915            function (data, status) {
2916                var Data = JSON.parse(data);
2917                if (Data.Status == "Success") {
2918
2919//                     console.log(Data.HTML);
2920                    $("#NoResults").slideUp();
2921                    $(".grid_items").html(Data.HTML);
2922
2923                } else {
2924                    $("#NoResults").slideDown();
2925                    $(".grid_items").html("");
2926                }
2927            });
2928
2929}
2930
2931function ReturnSearchNews() {
2932    
2933    var Search = $("#SearchQuery").val();
2934    var LazyLoadSection = $('#LazyLoadSection').val();
2935
2936    console.log(LazyLoadSection);
2937
2938//   console.log(Search);
2939
2940    $.post(BASE_URL + "/application/ajax/portal/returnSearchNews.php",
2941            {
2942                Search: Search,
2943                LazyLoadSection: LazyLoadSection
2944            },
2945            function (data, status) {
2946                var Data = JSON.parse(data);
2947                if (Data.Status == "Success") {
2948
2949//                     console.log(Data.HTML);
2950                    $("#NoResults").slideUp();
2951                    $(".grid").html(Data.HTML);
2952
2953                } else {
2954                    $("#NoResults").slideDown();
2955                    $(".grid").html("");
2956                }
2957            });
2958
2959}

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