PageSourceSearch

https://alexandra.hu/Scripts/rb-4.3.6.js

js alexandra.hu collected 2026-10-02 06:25:26 UTC 188,408 bytes, 5,261 lines download raw bytes

1/*!
2* RB JavaScript Library
3*
4* Copyright 2016
5*/
6
7// Define a global function - Start
8function AddToFavs() {
9    title = document.title;
10    url = location.href;
11    if (window.sidebar) {
12        window.sidebar.addPanel(title, url, '');
13    }
14    else if (window.external) {
15        window.external.AddFavorite(url, title);
16    }
17    return false;
18}
19
20function SetHomePage() {
21    if (document.all) {
22        document.body.style.behavior = 'url(#default#homepage)';
23        document.body.setHomePage(location.href);
24    }
25    return false;
26}
27
28function RBLoadPage(clickurl, clickurltarget, parameters) {
29    if (clickurl) {
30        if (clickurltarget) {
31            window.open(clickurl, clickurltarget, parameters);
32        }
33        else {
34            location.href = clickurl;
35        }
36    }
37}
38
39function RBLoadPageEvent(event, clickurl, clickurltarget) {
40    RBLoadPage(clickurl, clickurltarget);
41    RBStopEvent(event);
42}
43
44function RBLoadPageWithParam(url, field) {
45    var value = $("#" + field).val();
46    value = encodeURIComponent(value);
47    RBLoadPage(url + value, "");
48}
49
50function RBStopEvent(e) {
51    if (!e)
52        e = window.event;
53    e.cancelBubble = true;
54    if (e.stopPropagation) e.stopPropagation();
55    return false;
56}
57
58function RBChangeUrl(title, url) {
59    if (typeof (history.pushState) != "undefined") {
60        var obj = { Page: title, Url: url };
61        history.pushState(obj, obj.Page, obj.Url);
62    } else {
63        // window.location.href = "homePage";
64        // alert("Browser does not support HTML5.");
65    }
66}
67
68function ReplaceAll(str, find, replace) {
69    return str.replace(new RegExp(find, 'g'), replace);
70}
71
72function RBLoadUrlAfterSelect(url, selector, selectmacro, ajaxdiv) {
73    var selectValue = RBGetValue('#' + selector);
74    url = url.replace(selectmacro, selectValue);
75    if (ajaxdiv)
76        RBAjax_AjaxLoadingStart(ajaxdiv, false);
77    RBLoadPage(url);
78}
79
80function TextReSize(id, unit, defaultmin) {
81    var item = document.getElementById(id);
82    if (item) {
83        if (item.style.fontSize == '') {
84            item.style.fontSize = defaultmin + 'px';
85        }
86        if (item.style.fontSize != '') {
87            var i = parseInt(item.style.fontSize.replace('px', ''));
88            i += unit;
89            if (i < 8) {
90                i = 8;
91            }
92            item.style.fontSize = i + 'px';
93        }
94    }
95    return false;
96}
97
98function SendMail() {
99    u = location.href;
100    t = document.title;
101    window.open('http://api.addthis.com/oexchange/0.8/forward/email/offer?url=' + encodeURIComponent(u) +
102        '&username=magyari&lng=hu-hu', 'mailshare', 'toolbar=0,status=0,location=1, width=650,height=600,scrollbars=1');
103    return false;
104}
105
106function RBInsertNodeAfter(referenceNode, newNode) {
107    if (referenceNode.nextSibling) {
108        referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
109    }
110    else {
111        referenceNode.parentNode.appendChild(newNode);
112    }
113}
114
115function toggleAction(actions) {
116    if ($(actions).css('visibility') == 'visible') {
117        $(actions).css('visibility', 'hidden');
118    }
119    else {
120        $(actions).css('visibility', 'visible');
121    }
122}
123
124function AddToToggleAction(action, child) {
125    $(action).mouseover(function () {
126        toggleAction($(this).children(child));
127    });
128    $(action).mouseout(function () {
129        toggleAction($(this).children(child));
130    });
131}
132
133function SetVisibleDisable(item) {
134    if ($(item).css('display') == 'block')
135        SetDisable(item);
136    else
137        SetVisible(item);
138}
139
140function SetVisible(item) {
141    $(item).css('display', 'block');
142}
143
144function SetVisibleValue(item, value) {
145    $(item).css('display', value);
146}
147
148function SetDisable(item) {
149    $(item).css('display', 'none');
150}
151
152function SetFocus(item) {
153    $(item).focus();
154}
155
156function RBAddClass(item, className) {
157    $(document).find(item).addClass(className);
158}
159
160function RBRemoveClass(item, className) {
161    $(document).find(item).removeClass(className);
162}
163
164function RBAddRemoveClass(item, className) {
165    if ($(document).find(item).hasClass(className)) {
166        $(document).find(item).removeClass(className);
167    }
168    else {
169        $(document).find(item).addClass(className);
170    }
171}
172
173function RBSetValue(item, value) {
174    var field = $(document).find(item);
175    if (field) {
176        if (field.val() != value)
177            field.val(value);
178    }
179}
180
181function RBSetLabelValue(item, value) {
182    var field = $(document).find(item);
183    if (field) {
184        field.html(value);
185    }
186}
187
188function RBSetValueChange(item, value) {
189    var field = $(document).find(item);
190    RBSetFieldValueChange(field, value);
191}
192
193function RBSetFieldValueChange(field, value) {
194    if (field) {
195        if (field.val() != value)
196            field.val(value).change();
197    }
198}
199
200function RBFieldChange(item) {
201    var field = $(document).find(item);
202    if (field)
203        field.change();
204}
205
206function RBSetCheckBoxValue(item, value) {
207    if ($(item).prop('checked') != value)
208        $(item).prop('checked', value).change();
209}
210
211function RBGetCheckBoxValue(item) {
212    return $(item).prop('checked');
213}
214
215function RBInitRBCheckBox(item, enablenull) {
216    $(item).click(function () {
217        var newvalue = "";
218        if ($(this).hasClass("rbcheckbox-1")) {
219            $(this).removeClass("rbcheckbox-1");
220            $(this).addClass("rbcheckbox-0");
221            newvalue = "0";
222        }
223        else {
224            if ($(this).hasClass("rbcheckbox-null") || !enablenull) {
225                $(this).removeClass("rbcheckbox-null");
226                $(this).removeClass("rbcheckbox-0");
227                $(this).addClass("rbcheckbox-1");
228                newvalue = "1";
229            }
230            else {
231
232                $(this).removeClass("rbcheckbox-0");
233                $(this).addClass("rbcheckbox-null");
234            }
235        }
236        $(this).val(newvalue).change();
237    });
238}
239
240function RBSetFocus(item) {
241    $(item).focus();
242}
243
244function RBSetFocusWait(item) {
245    setTimeout(function () { $(item).focus() }, 1000);
246}
247
248function RBFieldClearerOnChange(field, datafield) {
249    var value = RBGetValue('#' + datafield);
250    if (value) {
251        $('#' + field).addClass("rb-clearer-data").removeClass("rb-clearer-empty");
252    }
253    else {
254        $('#' + field).addClass("rb-clearer-empty").removeClass("rb-clearer-data");
255    }
256}
257
258function RBFieldClearerInit(field, datafield) {
259    $('#' + datafield).change(function () {
260        RBFieldClearerOnChange(field, datafield);
261    });
262    $('#' + datafield).keyup(function () {
263        RBFieldClearerOnChange(field, datafield);
264    });
265    $('#' + field).click(function () {
266        RBSetValueChange('#' + datafield, '');
267        RBSetFocus('#' + datafield);
268        RBFieldClearerOnChange(field, datafield);
269    });
270    RBFieldClearerOnChange(field, datafield);
271}
272
273function RBGetValue(item) {
274    if (!item)
275        return "";
276    if (item == "")
277        return "";
278    var field = $(document).find(item);
279    if (!field)
280        return "";
281    if (!field[0])
282        return "";
283    var result = field[0].value;
284    if (field[0].placeholder)
285        if (field[0].placeholder == result)
286            result = "";
287    return result;
288}
289
290function RBRadioGetValue(fieldradio) {
291    var myRadio = $('input[name=' + fieldradio + ']:checked');
292    if (myRadio) {
293        return myRadio.val();
294    }
295    else {
296        return;
297    }
298}
299
300function RBDocOnClick(doc, item) {
301    var field = $(doc).find(item);
302    if (field)
303        field.click();
304}
305
306function RBOnClick(item) {
307    RBDocOnClick(document, item);
308}
309
310function RBReLoad() {
311    document.location.reload(true);
312}
313
314function RBRedirect(url) {
315    document.location.href = url;
316}
317
318function RBHistoryBack() {
319    if (history.length > 0) {
320        history.back();
321    }
322    else {
323        RBRedirect("/");
324    }
325}
326
327function RBPreviewSearchOff() {
328    RBRemoveClass(".previewsearch-main", "previewsearch-active");
329    RBAddClass(".previewsearch-main", "previewsearch-disabled");
330}
331
332function RBEditIdSearchOff() {
333    RBRemoveClass(".editidsearch-main", "editidsearch-active");
334    RBAddClass(".editidsearch-main", "editidsearch-disabled");
335}
336
337function RBSidebarOff() {
338    RBRemoveClass(".rbsidebar_button", "rbsidebar_button_disabled");
339    RBAddClass(".rbsidebar_button", "rbsidebar_button_visibled");
340
341    RBRemoveClass(".rbsidebar_panel", "rbsidebar_panel_visibled");
342    RBAddClass(".rbsidebar_panel", "rbsidebar_panel_disabled");
343}
344
345function RBBodyOverlayClick() {
346    RBOnClick(".rb-overlay-click");
347    RBBodyOverlayOff();
348}
349
350function RBBodyOverlayOn(speclass) {
351    RBAddClass("html", "rb-html-overlay-on");
352    RBAddClass("body", "rb-overlay-on");
353    if (speclass)
354        RBAddClass("body", speclass);
355    SetVisible("#rb-overlay");
356}
357
358function RBUrlChangedOff() {
359    var urlchangeitems = $(document).find(".popup_panel .rb-urlchanged");
360    if (urlchangeitems.length > 0) {
361        RBRemoveClass(".rb-urlchanged", "rb-urlchanged");
362        window.history.back();
363    }
364}
365
366function RBBodyOverlayOff() {
367    RBUrlChangedOff();
368    RBRemoveClass(".popup_panel_on", "popup_panel_on");
369    // SetDisable(".popup_panel");
370    RBRemoveClass(".popup_panel", "rb-popuppanel-visibled");
371    RBAddClass(".popup_panel", "rb-popuppanel-disabled");
372    $(document).find(".popup_panel_body").html("");
373    RBRemoveClass("html", "rb-html-overlay-on");
374    RBRemoveClass("body", "rb-overlay-on");
375    /* RBRemoveClass("body", "rb-noblackoverlay-on");*/
376    RBRemoveClass(".rb-overlay-click", "rb-overlay-click");
377    /*SetDisable(".rb-overlay-disp");
378    RBRemoveClass(".rb-overlay-disp", "rb-overlay-disp");*/
379    RBSidebarOff();
380    RBPreviewSearchOff();
381    RBEditIdSearchOff();
382    SetDisable("#rb-overlay");
383    SetDisable("#rb-overlay2");
384    SetVisible(".popup_button_on");
385    SetDisable(".popup_button_off");
386    RBCameraOff();
387}
388
389function RBCameraOff() {
390    if (window.scannerVars && window.scannerVars.Quagga) {
391        window.scannerVars.Quagga.stop();
392    }
393}
394
395function RBSpecBodyOverlayOn(onpanel, specid, nooverlay, useoverlay2) {
396    // RBBodyOverlayOff();
397
398    if (!nooverlay) {
399        RBAddClass("html", "rb-html-specoverlay-on");
400        if (useoverlay2)
401            SetVisible("#rb-overlay2");
402        else
403            SetVisible("#rb-spec" + specid + "overlay");
404    }
405    if (onpanel) {
406        RBAddClass("." + onpanel, "popup_panel_on");
407        RBAddClass("." + onpanel, "specpanel-" + specid);
408    }
409}
410
411function RBSpecBodyOverlayClick(specid) {
412    RBOnClick(".rb-spec" + specid + "overlay-click");
413    RBSpecBodyOverlayOff(specid);
414}
415
416function RBSpecBodyOverlayOff(specid) {
417    RBRemoveClass("html", "rb-html-specoverlay-on");
418    SetDisable("#rb-spec" + specid + "overlay");
419    RBRemoveClass(".specpanel-" + specid, "popup_panel_on");
420    $(document).find(".specpanel-" + specid + " .popup_panel_body").html("");
421    RBRemoveClass(".specpanel-" + specid, "rb-popuppanel-visibled");
422    RBAddClass(".specpanel-" + specid, "rb-popuppanel-disabled");
423    SetVisible(".specpanel-" + specid + "_button_on");
424    SetDisable(".specpanel-" + specid + "_button_off");
425    RBRemoveClass(".specpanel-" + specid, "specpanel-" + specid);
426
427    // RBBodyOverlayOff();
428}
429
430function RBTreeViewSelectMaster(master, masterid, maxlevel) {
431    var masterid2 = $("#" + master + " ." + masterid).data("master");
432    if (masterid2) {
433        RBAddClass("#" + master + " ." + masterid2, "treeview_item_selected");
434        if (maxlevel > 0)
435            RBTreeViewSelectMaster(master, masterid2, maxlevel - 1);
436    }
437}
438
439function RBTreeViewSelect(master, id, masterid, clearifselected, moreTreeViewInOnePage) {
440    var selected = $("#" + master + " ." + id).hasClass("treeview_item_selected");
441    if (moreTreeViewInOnePage == "1")
442        RBRemoveClass(".treeview_item", "treeview_item_selected");
443    else
444        RBRemoveClass("#" + master + " .treeview_item", "treeview_item_selected");
445    if (!selected || (clearifselected != 1)) {
446        RBAddClass("#" + master + " ." + id, "treeview_item_selected");
447        if (masterid) {
448            RBAddClass("#" + master + " ." + masterid, "treeview_item_selected");
449            RBTreeViewSelectMaster(master, masterid, 10);
450        }
451    }
452    else {
453        RBAddClass("#" + master + " .treeview_item_level-0", "treeview_item_selected");
454    }
455}
456
457function RBTreeViewSearch(id, inputfield) {
458    var search = RBGetValue("#" + inputfield);
459    for (var k = 1; k < 4; k++)
460        SetDisable("#" + id + " .treeview_item_subitems-" + k);
461    var items = $("#" + id + " .treeview_item");
462    items.removeClass("treeview_item_selected");
463    if (search)
464        if (items.length > 0) {
465            search = RBNormalize(search.toUpperCase());
466            for (var i = 1; i <= items.length; i++) {
467                var item = $(items[i - 1]);
468                var datasearch = item.data("search");
469                if (datasearch) {
470                    var searchitems = search.split(' ');
471                    var findall = true;
472                    for (var j = 0; j < searchitems.length; j++) {
473                        var searchitem = searchitems[j];
474                        if (RBNormalize(datasearch.toUpperCase()).indexOf(searchitem) == -1)
475                            findall = false;
476                    }
477                    if (findall) {
478                        item.addClass("treeview_item_selected");
479                        var masterid = item.data("master");
480                        RBTreeViewOpen(id, masterid);
481                    }
482                }
483            }
484        }
485}
486
487function RBTreeViewOpen(id, masterid) {
488    if (!masterid)
489        return;    
490    var master = $("#" + id + " ." + masterid);
491    if (!master)
492        return;
493    level = master.data("level")
494    SetVisible("#" + id + " ." + masterid + " .treeview_item_subitems-" + level);
495
496    RBTreeViewOpen(id, master.data("master"));
497}
498
499function RBTreeViewPager(id, next, maxpage) {
500    var actPageField = $("#" + id + " .treeview_pagecounter");
501    var actPage = actPageField.data("actpage");
502    if (next == 1) {
503        if (actPage >= maxpage)
504            return;
505        actPage++;
506        RBRemoveClass("#" + id + " .treeview_pagerbutton-prev", "disableitem");
507        if (actPage >= maxpage) {
508            RBAddClass("#" + id + " .treeview_pagerbutton-next", "disableitem");
509        }
510    }
511    else {
512        if (actPage < 2)
513            return;
514        actPage--;
515        RBRemoveClass("#" + id + " .treeview_pagerbutton-next", "disableitem");
516        if (actPage < 2) {
517            RBAddClass("#" + id + " .treeview_pagerbutton-prev", "disableitem");
518        }
519    }
520    
521    RBAddClass("#" + id + " .treeview-pageitem", "treeview-pageitem-disable");
522    RBRemoveClass("#" + id + " .treeview-pageitem-" + actPage, "treeview-pageitem-disable");
523    actPageField.data("actpage", actPage);
524}
525
526function RBDivSearch(id, inputfield, finditem) {
527    var search = RBGetValue("#" + inputfield);
528
529    var items = $("#" + id + " ." + finditem);
530
531    if (!search) {
532        items.removeClass("disableitem");
533        return;
534    }
535
536    items.addClass("disableitem");
537    if (items.length > 0) {
538        search = RBNormalize(search.toUpperCase());
539        for (var i = 1; i <= items.length; i++) {
540            var item = $(items[i - 1]);
541            var datasearch = item.data("search");
542            if (datasearch) {
543                var searchitems = search.split(' ');
544                var findall = true;
545                for (var j = 0; j < searchitems.length; j++) {
546                    var searchitem = searchitems[j];
547                    if (RBNormalize(datasearch.toUpperCase()).indexOf(searchitem) == -1)
548                        findall = false;
549                }
550                if (findall) {
551                    item.removeClass("disableitem");
552                }
553            }
554        }
555    }
556}
557
558function RBSectionTabClick(master, id) {
559    RBRemoveClass("." + master + " .rb-section-tab-body-item", "rb-section-tab-body-item-selected");
560    RBAddClass("." + master + " .rb-section-tab-body-item-" + id, "rb-section-tab-body-item-selected");
561    RBRemoveClass("." + master + " .rb-section-tab-select-item", "rb-section-tab-select-item-selected");
562    RBAddClass("." + master + " .rb-section-tab-select-item-" + id, "rb-section-tab-select-item-selected");
563}
564
565function RBSectionNewsGroupSliderDescClick(id, newsgroupid) {
566    RBAddClass("#" + id + " .rb-section-newsgroupslider-desc-item", "disableitem");
567    RBRemoveClass("#" + id + " .rb-section-newsgroupslider-desc-item-" + newsgroupid, "disableitem");
568    RBRemoveClass("#" + id + " .rb-section-newsgroupslider-item", "rb-section-newsgroupslider-item-selected");
569    RBAddClass("#" + id + " .rb-section-newsgroupslider-item-" + newsgroupid, "rb-section-newsgroupslider-item-selected");
570}
571
572function RBLoadPopup(url, div, id) {
573    if (!div)
574        div = "input-popup";
575    RBBodyOverlayClick();
576    RBRemoveClass(".popup-" + div + "_panel", "rb-popuppanel-disabled");
577    RBAddClass(".popup-" + div + "_panel", "rb-popuppanel-visibled");
578    RBAjax_LoadChildDiv(url, id, "popup-" + div + "_panel_body", "", "", "");
579    RBBodyOverlayOn();
580}
581
582function RBLoadPopupData(div, data, specid, nooverlay, useoverlay2) {
583    var panel = "";
584    var panelbody = "";
585    if (specid) {
586        panel = "popupdata-panel";
587        panelbody = panel;
588
589    }
590    else {
591        panel = "popup-" + div + "_panel";
592        panelbody = panel + "_body";
593    }
594    RBRemoveClass("." + panel, "rb-popuppanel-disabled");
595    RBAddClass("." + panel, "rb-popuppanel-visibled");
596    var $origdiv = $("#" + panelbody);
597    $origdiv.html(data);
598    if (specid)
599        RBSpecBodyOverlayOn(panel, 1, nooverlay, useoverlay2);
600    else
601        RBBodyOverlayOn();
602    $origdiv.focus();
603}
604
605function RBLoadPopupInfo(url, param, specid, nooverlay, useoverlay2) {
606    if (specid)
607        RBSpecBodyOverlayOff(specid);
608    else
609        RBBodyOverlayClick();
610
611    $.post(url, {
612        param: param
613    },
614    function (response) {
615        if (response.error)
616            RBMessage(response.error);
617        else {
618            if (response.result) {
619                RBLoadPopupData("extra", response.result, specid, nooverlay, useoverlay2);
620            }
621            else {
622                if (response.url)
623                    RBLoadPage(response.url);
624            }
625        }
626    }).fail(function (response) {
627        RBAjaxPostError();
628    });
629}
630
631
632function RBPopupInput(inputazon, extdata) {
633    RBBodyOverlayClick();
634    SetVisible(".popup-input-popup_panel");
635    RBAjax_LoadDiv("/Home/PopUpInput?inputazon=" + inputazon + "&extdata=" + extdata, "popup-input-popup_panel_body", "", "", "");
636    RBBodyOverlayOn(); 
637    RBAddClass(".popup-input-popup_button_off", "rb-overlay-click");
638}
639
640function RBSetPopupInputClass(inputazon) {
641    var inputwrapper = $(document).find(".popup-input-popup_panel .popup_panel_wrapper");
642    var origClass = inputwrapper.data("inputazon");
643    if (origClass) {
644        inputwrapper.removeClass("popupinput-" + origClass);
645    }
646    inputwrapper.addClass("popupinput-" + inputazon);
647    inputwrapper.data("inputazon", inputazon);
648}
649
650function RBPageLodingStart() {
651    RBAddClass("#rb-loading-overlay", "rb-loading-overlay-on");
652    SetVisible("#rb-loading-overlay");
653}
654
655function RBPageLodingEnd() {
656    setTimeout(function () {
657        SetDisable("#rb-loading-overlay");
658        RBRemoveClass("#rb-loading-overlay", "rb-loading-overlay-on");
659    }, 1000);
660}
661
662function RBScrollToId(id) {
663    RBBodyOverlayOff();
664    RBScrollToDiv('#' + id, 0, 0, false);
665}
666
667function RBGoToId(id, offset) {
668    RBBodyOverlayOff();
669    RBJump('#' + id, offset);
670}
671
672function RBJump(id, offset) {
673    try {
674        var location = $(id).offset().top;
675        if (offset > 0)
676            location -= offset;
677        scrollTo(0, location);
678    }
679    catch (Ex) { }
680}
681
682function RBScrollToDiv(id, diff, speed, onlyifnotshowing) {    
683    try {
684        var top = $(id).offset().top;
685        if (onlyifnotshowing) {
686            var topOfWindow = $(window).scrollTop();
687            var windowHeight = jQuery(window).height();
688            if ((top > (topOfWindow + 150)) && (top < (topOfWindow + windowHeight - 150)))
689                return;            
690        }
691        if (diff != 0)
692            top = top + diff;
693        if (top < 0)
694            top = 0;
695        if (speed <= 0)
696            speed = 1600;
697        $("html, body").animate({ scrollTop: top }, speed,
698        function () {
699            if (diff == 0) {
700                var topagain = $(id).offset().top;
701                if (topagain < 0)
702                    topagain = 0;
703                if ((Math.round(topagain)) != (Math.round(top)))
704                    $("html, body").animate({ scrollTop: topagain }, 200);
705            }
706        }
707        );
708    }
709    catch (ex) { }
710}
711
712function RBOpacityAnimationInit(initclass, doneclass, iscounter, duration) {
713    RBOpacityAnimation(initclass, doneclass, iscounter, duration);
714    $(window).scroll(function () {
715        RBOpacityAnimation(initclass, doneclass, iscounter, duration);
716    });
717}
718
719function RBOpacityAnimation(initclass, doneclass, iscounter, duration) {
720    $("." + initclass).each(function () {
721        var thisPos = $(this).offset().top;
722        var topOfWindow = $(window).scrollTop();
723        var windowHeight = jQuery(window).height();
724        if (topOfWindow + windowHeight - 200 > thisPos) {
725            $(this).removeClass(initclass).addClass(doneclass);
726            if (iscounter)
727                RBCounterAnimationChilds($(this), duration);
728        }
729    });
730}
731
732function RBCounterAnimationChilds($item, duration) {
733    $item.find(".Count").each(function () {
734        RBCounterItemAnimation($(this), duration);
735    });
736}
737
738function RBCounterAnimation(item, duration) {
739    $(item).each(function () {
740        RBCounterItemAnimation($(this), duration);
741    });
742}
743
744function RBCounterItemAnimation($this, duration) {
745    $this.prop('Counter', 0).animate({
746        Counter: $this.text()
747    }, {
748        duration: duration,
749        easing: 'swing',
750        step: function (now) {
751            $this.text(Math.ceil(now));
752        }
753    });
754}
755
756var oncePopup = false;
757function RBOncePopup(checkurl, windowsheight, script, cookiename, exdays) {
758    if (windowsheight == 0) {
759        if (oncePopup)
760            return;
761        RBOncePopupRun(checkurl, script, cookiename, exdays);
762    }
763    else {
764        $(window).scroll(function () {
765            if (oncePopup)
766                return;
767            var topOfWindow = $(window).scrollTop();
768            if (topOfWindow >= windowsheight) {
769                RBOncePopupRun(checkurl, script, cookiename, exdays);
770            }
771        });
772    }
773}
774
775function RBOncePopupRun(checkurl, script, cookiename, exdays) {
776    var cookievalue = RBGetCookie(cookiename);
777    if (cookievalue == "1") {
778        oncePopup = true;
779        return;
780    }
781    oncePopup = true;
782    if (cookiename) {
783        RBCheckSessionCookie(checkurl, cookiename, script, exdays);
784    }
785    else {
786        eval(script);
787    }
788}
789
790var oncePopupUnLoad = false
791function RBOncePopupUnLoad(checkurl, script, cookiename, exdays) {
792    $(window).mouseout(function (e) {
793        if (e.clientY <= 0) {
794            if (oncePopupUnLoad)
795                return;
796            oncePopupUnLoad = true;
797            var cookievalue = RBGetCookie(cookiename);
798            if (cookievalue == "1")
799                return;                
800            if (cookiename) {
801                RBCheckSessionCookie(checkurl, cookiename, script, exdays, e)
802            }
803            else {
804                eval(script);
805                RBStopEvent(e);
806            }
807            return;
808        }
809    });
810}
811
812function RBCheckSessionCookie(checkurl, cookiename, script, exdays, e) {
813    $.post(checkurl, {
814        cookieAzon: cookiename
815    }, function (response) {
816        if (response)
817            if (response.result != '1') {
818                RBSetCookie(cookiename, "1", exdays);
819                eval(script);
820                if (e)
821                    RBStopEvent(e);
822            }
823    }).fail(function (response) {
824        RBAjaxPostError();
825    });
826}
827
828function RBSessionRedirectUrl(newguid, url, cookieazon, cookievalue) {
829    if (newguid != '') {
830        var cookiename = "RBSessionId";
831        var sessionid = RBGetCookie(cookiename);
832        if (!sessionid || (sessionid == ''))
833            RBSetCookie(cookiename, newguid, 1);
834    }
835    RBSetCookie(cookieazon, cookievalue, 0, 1);
836    RBRedirect(url);
837}
838
839function RBSetSessionGotoUrl(cookieazon, cookievalue, url) {
840    RBSetCookie(cookieazon, cookievalue, 1);
841    if (url)
842        RBRedirect(url);
843    else
844        RBReLoad();
845}
846
847function RBShowOldMessages() {
848    RBRemoveClass(".showoldmessage", "disableitem");
849    RBAddClass(".showmessage-showold", "disableitem");
850    RBRemoveClass(".showmessage-dispold", "disableitem");
851}
852
853function RBDispOldMessages() {
854    RBAddClass(".showoldmessage", "disableitem");
855    RBRemoveClass(".showmessage-showold", "disableitem");
856    RBAddClass(".showmessage-dispold", "disableitem");
857}
858
859function RBMessageResult(url, divid, descfield, descrequired, requirederror, messageid, messagerequestcode, messagecode) {
860    var descvalue = "";
861    if (descfield) {
862        descvalue = RBGetValue("#" + descfield);
863        if (descrequired == 1)
864            if (!descvalue) {
865                RBMessage(requirederror);
866                return;
867            }
868    }
869    $.post(url, {
870        messageid: messageid, messagerequestcode: messagerequestcode, messagecode: messagecode, descvalue: descvalue
871    }, function (response) {
872        if (response.error != '') {
873            RBMessage(response.error);
874            return;
875        }
876        var $item = $("#" + divid);
877        $item.html(response.result);
878    }).fail(function (response) {
879        RBAjaxPostError();
880    });
881}
882
883function RBImageSelect(field, fieldclass, itemclass, itemid, url, form) {
884    RBRemoveClass("." + fieldclass + " .inputpage_imageselect_item", "inputpage_imageselect_item_selected");
885    if (itemid > 0)
886        RBAddClass("." + fieldclass + " ." + itemclass, "inputpage_imageselect_item_selected");
887    RBSetValue("#" + field, itemid);
888    if (url)
889        RBAjax_InputValidate(url, field, form, '', '', '', '');
890}
891
892function RBVoteSelect(field, fieldclass, itemclass, value, maxvote, voteyes, voteno) {
893    RBSetValue("#" + field, value);
894    for (var i = 1; i < (maxvote + 1); i++) {
895        RBRemoveClass("." + fieldclass + " ." + itemclass + "_" + i, voteyes);
896        RBRemoveClass("." + fieldclass + " ." + itemclass + "_" + i, voteno);
897        if (value >= i)
898            RBAddClass("." + fieldclass + " ." + itemclass + "_" + i, voteyes);
899        else
900            RBAddClass("." + fieldclass + " ." + itemclass + "_" + i, voteno);
901    }
902}
903
904function RBSetInputFieldValueOrDisable(item, value, labelemptyifchanged) {
905    var field = $(document).find("#" + item);
906    if (field) {
907        if (labelemptyifchanged == 1)
908            if (field.val() != value)
909                RBSetValue("#" + item + "_Label", "");
910        field[0].value = value;
911        var inputfield = ".inputpage_field_" + item;
912        if (value) {
913            RBRemoveClass(inputfield, "inputpageitemajaxdisabled");
914        }
915        else {
916            RBAddClass(inputfield, "inputpageitemajaxdisabled");
917        }
918    }
919}
920
921function RBInputFunc(div, confirm, azon, action, data, url, ajaxloadingtitle, deletebutton, buttonloading) {
922    $('.inputbutton_one').addClass("disableitem");
923    $('.' + div).removeClass("disableitem");
924    if (confirm)
925        if (!RBConfirm(confirm)) {
926            $('.inputbutton_one').removeClass("disableitem");
927            return;
928        }
929    var ajaxurl = "/Home/RBInputFunc";
930    var origTitle = "";
931    if (buttonloading == 1)
932        origTitle = RBInputButtonAjaxStart(div, ajaxloadingtitle);
933    else
934        origTitle = RBAjax_AjaxLoadingStart('.' + div, false, ajaxloadingtitle);
935    $.post(ajaxurl, {
936        azon: azon, action: action, data: data
937    }, function (response) {
938        var needOrigTitleBack = true;
939        if (response) {
940            if (response.url)
941                needOrigTitleBack = false;
942            if (url)
943                needOrigTitleBack = false;
944        }
945        if (needOrigTitleBack) {
946            if (buttonloading == 1)
947                RBInputButtonAjaxEnd(div, origTitle);
948            else
949                RBAjax_AjaxLoadingEnd('.' + div, false, origTitle);
950        }
951        if (response) {
952            if (response.error) {
953                RBMessage(response.error, "", response.errorurl, response.closeerror == 1);
954                return;
955            }
956            var $origdiv = $('.' + div);
957            if (deletebutton == 1)
958                $origdiv.html("");
959            if (response.link) {
960                var linklist = response.link.split(',');
961                for (var i = 0; i < linklist.length; i++) {
962                    var linkitem = linklist[i];
963                    RBLoadPage(linkitem, "_blank");
964                }
965            }
966            if (response.url) {
967                if (response.message)
968                    RBMessage(response.message, "", response.url, true);
969                else
970                    RBLoadPage(response.url);
971                return;
972            }
973            if (url) {
974                if (response.message)
975                    RBMessage(response.message, "", url, true);
976                else
977                    RBLoadPage(url);
978                return;
979            }
980            if (response.message)
981                RBMessage(response.message, "", "", true);
982        }
983    }).fail(function (response) {
984        if (buttonloading == 1)
985            RBInputButtonAjaxEnd(div, origTitle);
986        else
987            RBAjax_AjaxLoadingEnd('.' + div, false, origTitle);
988        RBAjaxPostError();
989    });
990}
991
992function RBProcessUrl(div, ajaxloadingtitle, url) {
993    RBInputButtonAjaxStart(div, ajaxloadingtitle);
994    RBLoadPage(url);
995}
996
997function RBDivAddDel(item, adddel, minValue, maxValue, url, azon, divid) {
998    var $item = $(item);
999    var itemValue = Number($item.html());
1000    itemValue += adddel;
1001    if (itemValue < minValue)
1002        itemValue = minValue;
1003    if (maxValue)
1004        if (maxValue > 0)
1005            if (itemValue > maxValue)
1006                itemValue = maxValue;
1007    $item.html(itemValue);
1008
1009    if (url) {
1010        if (url != '')
1011            $.post(url, {
1012                azon: azon, quantity: itemValue
1013            }, function (response) {
1014                if (response.data != '') {
1015                    var infoitem = $('.' + divid);
1016                    infoitem.html(response.data);
1017                }
1018            });
1019    }
1020}
1021
1022function RBInputAddDel(item, adddel, minValue, maxValue) {
1023    var $item = $(item);
1024    var itemValue = Number($item.val());
1025    itemValue += adddel;
1026    if (itemValue < minValue)
1027        itemValue = minValue;
1028    if (maxValue)
1029        if (maxValue > 0)
1030            if (itemValue > maxValue)
1031                itemValue = maxValue;
1032    $item.val(itemValue);
1033}
1034
1035function IsValidDate(obj) {
1036    if (isNaN(obj))
1037        return false;
1038    return true;
1039}
1040
1041function RBTimeConvert(time) {
1042    time = time < 0 ? 0 : time;
1043
1044    var minutes = Math.floor(time / 60);
1045    var seconds = Math.floor(time % 60);
1046
1047    /*minutes = minutes < 10 ? "0" + minutes : minutes;*/
1048    seconds = seconds < 10 ? "0" + seconds : seconds;
1049
1050    return minutes + ":" + seconds;
1051}
1052
1053function RBTextToClipboard(field, message) {
1054    var fieldvalue = null;
1055    try {
1056        fieldvalue = RBGetValue("#" + field);
1057    } catch (ex) { }
1058    if (!fieldvalue) {
1059        try {
1060            fieldvalue = RBGetTextAreaValue(field, fieldvalue);
1061        } catch (ex) { }
1062    }
1063    if (fieldvalue) {
1064        try {
1065            navigator.clipboard.writeText(fieldvalue);
1066            if (message)
1067                RBMessage(message, "", "", true);
1068        } catch (ex) { }
1069    }
1070}
1071
1072function AttachEvent(element, type, handler) {
1073    if (element.addEventListener) element.addEventListener(type, handler, false);
1074    else element.attachEvent("on" + type, handler);
1075}
1076
1077function FireRefreshEventHandler(item, id, azon) {
1078    if (!id)
1079        if (!azon)
1080            id = "Reload";
1081    DoFireRefreshEventHandler(item, id, azon, 5);
1082}
1083
1084function FireRefreshEventHandlerField(item, id, field) {
1085    var comboitem = $(field);
1086    var val = comboitem.val();
1087    FireRefreshEventHandler(item, id, val);
1088}
1089
1090function DoFireRefreshEventHandler(item, id, azon, tryCount) {
1091    var el = $('#' + item);
1092    if (el) {
1093        var elroot = el[0];
1094        if (elroot) {
1095            if ((elroot.onchange || false) && typeof elroot.onchange == 'function') {
1096                // We have a valid onchange listener declared
1097                elroot.onchange({ id: id, azon: azon });
1098            }
1099            else {
1100                // Még nincsen inicializálva, ezért majd később fog lefutni
1101                if (tryCount > 0) {
1102                    tryCount--;
1103                    setTimeout(function () {
1104                        DoFireRefreshEventHandler(item, id, azon, tryCount);
1105                    }, 2000);  // <-- time in milliseconds
1106                }
1107                else {
1108                    elroot.title = azon;
1109                }
1110            }
1111        }
1112    }
1113}
1114
1115function FireRefreshEventHandlerValue(rbsliderid, fields) {
1116    var value = "";
1117    var ca = fields.split(';');
1118    for (var i = 0; i < ca.length; i++) {
1119        var c = ca[i];
1120        var fieldvalue = RBGetValue("#" + ca[i]);
1121        if (i != 0)
1122            value += ";";
1123        value += fieldvalue;
1124    }
1125    FireRefreshEventHandler(rbsliderid, "Parameters", value);
1126}
1127
1128function SetComboEditChangeButtons(master, item, readonly) {
1129    var comboitem = $(item);
1130    var val = comboitem.val();
1131    var lehetedit = false;
1132    if (val) {
1133        if (val != "")
1134            if (val != "0") {
1135                lehetedit = true;
1136            }
1137    }
1138    if (readonly) {
1139        lehetedit = true;
1140    }
1141    var s = comboitem[0].name;
1142    if (s) {
1143        if (readonly) {
1144            $(master).find("." + s + "_combo_button").addClass("combo_button_disabled");
1145        }
1146        else {
1147            $(document).find("." + s + "_combo_button").removeClass("combo_button_disabled");
1148            if (lehetedit)
1149                $(master).find("." + s + "_comboedititem_button").removeClass("combo_button_disabled");
1150            else
1151                $(master).find("." + s + "_comboedititem_button").addClass("combo_button_disabled");
1152        }
1153    }
1154}
1155
1156function RBInitUploadFile(id, field, initFieldName, uploadFieldName, rootfield, dirName, enableext, imageWidth, imageHeight, uploadAzon, autowatermark) {
1157    $('#' + id + ' #' + uploadFieldName).change(function () {
1158        RBRemoveErrorAfterChange(field, '');
1159        RBUploadFile(id, field, uploadFieldName, rootfield, dirName, enableext, imageWidth, imageHeight, uploadAzon, autowatermark);
1160    });
1161    $('#' + id + ' .inputpage_textimage-item-' + initFieldName).hover(function () {
1162        var image = $('#' + id + " #" + field).val();
1163        if (image)
1164            $('#' + id + ' .inputpage_textimage-item-' + initFieldName + " .inputpage_newfileupload-delete").removeClass("inputpage_newfileupload-delete-disable").addClass("inputpage_newfileupload-delete-visible");
1165    }, function () {
1166        var image = $('#' + id + " #" + field).val();
1167        if (image)
1168            $('#' + id + ' .inputpage_textimage-item-' + initFieldName + " .inputpage_newfileupload-delete").removeClass("inputpage_newfileupload-delete-visible").addClass("inputpage_newfileupload-delete-disable");
1169    });
1170    $('#' + id + ' #' + uploadFieldName + "-change").click(function () {
1171        $('#' + id + ' #' + uploadFieldName).click();
1172    });
1173    $('#' + id + ' #' + uploadFieldName + "-delete").click(function () {
1174        RBRemoveErrorAfterChange(field, '');
1175        $('#' + id + " #" + field).val("").change();
1176        $('#' + id + " #" + field + "_img").attr('src', "");
1177        $('#' + id + ' .inputpage_textimage-item-' + field + " .inputpage_newfileupload-delete").removeClass("inputpage_newfileupload-delete-data");
1178        $('#' + id + ' .inputpage_textimage-item-' + field + " .inputpage_newfileupload-delete").addClass("inputpage_newfileupload-delete-nodata");
1179        RBSetUploadFileData(id, uploadAzon, rootfield, autowatermark);
1180    });
1181}
1182
1183function RBSetUploadFileData(id, uploadAzon, field, autowatermark) {
1184    var ajaxurl = "/Home/SetUploadFileData";
1185    var value = RBGetMultipleValue('#' + id + ' .' + field);
1186    $.post(ajaxurl, {
1187        uploadAzon: uploadAzon, field: field, value: value
1188    }, function (response) {
1189        if (response.error != '') {
1190            RBMessage(response.error);
1191        }
1192        if (response.div != '') {
1193            $(document).find('#' + id + " ." + response.div).css("background-image", response.divimage);
1194        }
1195    });
1196}
1197
1198function RBUploadFile(id, field, uploadFieldName, rootfield, dirName, enableext, imageWidth, imageHeight, uploadAzon, autowatermark) {
1199    var file_data = $('#' + id + " #" + uploadFieldName).prop("files")[0];   // Getting the properties of file from file field
1200    var form_data = new FormData();           // Creating object of FormData class
1201    form_data.append("file", file_data);        // Appending parameter named file with properties of file_field to form_data
1202    form_data.append("dirName", dirName);
1203    form_data.append("enableext", enableext);
1204    form_data.append("imagewidth", imageWidth);
1205    form_data.append("imageheight", imageHeight);
1206    form_data.append("autowatermark", autowatermark);
1207    var pfield = field;
1208    if (rootfield == field)
1209        pfield += "1";
1210    var progressField = "#" + id + " .inputpage_textimage-item-" + pfield + " .inputpage_newfileupload-main";
1211    $(progressField).append("<div class='rbupload-progress-full'><div class='rbupload-progress-bar'></div></div>");
1212    $.ajax({
1213        url: "/FileUpload/NewFileUpload",
1214        dataType: 'json',
1215        cache: false,
1216        contentType: false,
1217        processData: false,
1218        data: form_data,                      // Setting the data attribute of ajax with file_data
1219        type: 'post',
1220        xhr: function () {
1221            var xhr = $.ajaxSettings.xhr();
1222            xhr.upload.onprogress = function (e) {
1223                $(progressField + " .rbupload-progress-bar").width(Math.floor(e.loaded / e.total * 100) + '%');
1224            };
1225            return xhr;
1226        },
1227        success: function (response) {
1228            if (response) {
1229                if (response.error) {
1230                    $('#' + id + ' #' + uploadFieldName).val('').change();
1231                    $('#' + id + ' #' + field).val('');
1232                    $('#' + id + ' #' + field + "_img").attr('src', '');
1233                    RBMessage(response.error);
1234                }
1235                else {
1236                    if (response.fileName) {
1237                        $('#' + id + ' #' + field).val(response.fileName).change();
1238                        $('#' + id + ' #' + field + "_img").attr('src', response.fileName);
1239                        if (response.fileName) {
1240                            $('#' + id + ' #' + uploadFieldName + "-delete").removeClass("inputpage_newfileupload-delete-nodata");
1241                            $('#' + id + ' #' + uploadFieldName + "-delete").addClass("inputpage_newfileupload-delete-data");
1242                        }
1243                        else {
1244                            $('#' + id + ' #' + uploadFieldName + "-delete").removeClass("inputpage_newfileupload-delete-data");
1245                            $('#' + id + ' #' + uploadFieldName + "-delete").addClass("inputpage_newfileupload-delete-nodata");
1246                        }
1247                        RBSetUploadFileData(id, uploadAzon, rootfield, autowatermark);
1248                    }
1249                }
1250            }
1251        },
1252        complete: function () {
1253            $(progressField + " .rbupload-progress-full").remove();
1254        }
1255    });
1256}
1257
1258function RBSetImageUploadData(field, value, cookieazon, thumbvalue, previewvalue) {
1259    var origfield = parent.document.getElementById(field);
1260    if (origfield) {
1261        /* RBSetFieldValueChange($(origfield), value);*/
1262        origfield.value = value;
1263        if (cookieazon)
1264            RBSetCookieDoc(parent.document, cookieazon, value, 0);
1265    }
1266    var imagevalue = value;
1267    if (previewvalue)
1268        if (previewvalue != '')
1269            imagevalue = previewvalue;
1270    if (thumbvalue)
1271        if (thumbvalue != '')
1272            imagevalue = thumbvalue;
1273    var fieldimg = parent.document.getElementById(field + '_img');
1274    if (fieldimg) {
1275        fieldimg.src = imagevalue;
1276    }
1277    var fieldbox = parent.document.getElementById(field + '_box');
1278    if (fieldbox) {
1279        fieldbox.href = imagevalue;
1280    }
1281}
1282
1283function ComboEditChangeInit() {
1284    $('.comboedititem').change(function () {
1285        SetComboEditChangeButtons(document, this, false);
1286    });
1287}
1288
1289function HoverCssChange(item, classhoverin, classhoverout) {
1290    $(item).hover(function () {
1291        $(this).removeClass(classhoverout).addClass(classhoverin);
1292    }, function () {
1293        $(this).removeClass(classhoverin).addClass(classhoverout);
1294    });
1295}
1296
1297function HoverChildCssChange(item, child, classhoverin, classhoverout) {
1298    $(item).hover(function () {
1299        $(this).find(child).removeClass(classhoverout).addClass(classhoverin);
1300    }, function () {
1301        $(this).find(child).removeClass(classhoverin).addClass(classhoverout);
1302    });
1303}
1304
1305function RBHoverChange(item, hoveritem, classhoverin, classhoverout) {
1306    $(item).hover(function () {
1307        $(hoveritem).removeClass(classhoverout).addClass(classhoverin);
1308    }, function () {
1309        $(hoveritem).removeClass(classhoverin).addClass(classhoverout);
1310    });
1311}
1312
1313function RBHoverAddClass(item, hoveritem, hoverclass) {
1314    $(item).hover(function () {
1315        $(hoveritem).addClass(hoverclass);
1316    }, function () {
1317        $(hoveritem).removeClass(hoverclass);
1318    });
1319}
1320
1321//Vote-nél nem csak a sajátot állítjuk át, hanem az előtte lévőket is
1322function VoteHoverCssChange(item, classhoverin, classhoverout, summavote, summavotefield) {
1323    $(item).hover(function () {
1324        var itemcount = $(this.parentNode).children().length;
1325        var itemindex = $(this.parentNode).children().index(this) + 1;
1326        for (var i = 1; i <= itemcount; i++) {
1327            if (i <= itemindex)
1328                $(this.parentNode.children[i - 1]).removeClass(classhoverout).addClass(classhoverin);
1329            else
1330                $(this.parentNode.children[i - 1]).removeClass(classhoverin).addClass(classhoverout);
1331        }
1332    }, function () {
1333        var itemcount = $(this.parentNode).children().length;
1334        if (summavotefield)
1335            summavote = RBGetValue(summavotefield);
1336        for (var i = 1; i <= itemcount; i++) {
1337            var isvote = false;
1338            if (summavote)
1339                if (i <= summavote)
1340                    isvote = true;
1341            if (isvote)
1342                $(this.parentNode.children[i - 1]).removeClass(classhoverout).addClass(classhoverin);
1343            else
1344                $(this.parentNode.children[i - 1]).removeClass(classhoverin).addClass(classhoverout);
1345        }
1346    });
1347}
1348
1349function Vote(divid, votetype, category, azon, rootclass, maxvote, itemindex, ajaxurl) {
1350    $.post(ajaxurl, {
1351        divid: divid, votetype: votetype, category: category, azon: azon, rootclass: rootclass, maxvote: maxvote, myvote: itemindex
1352    }, function (response) {
1353        if (response.message != '') {
1354            var items = $('.' + divid);
1355            items.html(response.message);
1356
1357            if (response.successmessage != '')
1358                RBMessage(response.successmessage, "", "", true);
1359        }
1360    });
1361}
1362
1363function RBAjax_VoteField(url, ajaxdivid, itemid, fieldradio) {
1364    var myRadio = $('input[name=' + fieldradio + ']:checked');
1365    myvote = "";
1366    if (myRadio) {
1367        myvote = myRadio.val();
1368    }
1369    else {
1370        return;
1371    }
1372    RBAjax_VoteFieldValue(url, ajaxdivid, itemid, myvote);
1373}
1374
1375function RBAjax_VoteFieldValue(url, ajaxdivid, itemid, myvote) {
1376    if (myvote) {
1377        $.post(url, {
1378            itemid: itemid, myvote: myvote
1379        }, function (response) {
1380            if (response) {
1381                var ajaxdiv = $('.' + ajaxdivid);
1382                ajaxdiv.html(response.result);
1383            }
1384        });
1385    }
1386}
1387
1388function RBAjax_Vote(url, ajaxdivid, itemid, myvote) {
1389    $.post(url, {
1390        itemid: itemid, myvote: myvote
1391    }, function (response) {
1392        if (response) {
1393            var ajaxdiv = $('.' + ajaxdivid);
1394            ajaxdiv.html(response.result);
1395        }
1396    });
1397}
1398
1399function RBAjax_SetVoteUserParam(div, countdiv, titlediv, voteType, entityAzon, entityId, rootcount, voteTitle, notVoteTitle) {
1400    $.post("/Home/SetVoteUserParam", {
1401        voteType: voteType, entityAzon: entityAzon, entityId: entityId
1402    }, function (response) {
1403        if (response) {
1404            if (!response.result)
1405                return;
1406            var count = rootcount;
1407            var title = notVoteTitle;
1408            if (response.result == 1) {
1409                SetVisibleValue(div, 'inline-block');
1410                count++;
1411                title = voteTitle;
1412            }
1413            if (response.result == 0) {
1414                SetDisable(div);
1415            }
1416            $(countdiv).html(count);
1417            $(titlediv).html(title);
1418        }
1419    });
1420}
1421
1422function RBVote(url, votetype, entityazon, entityid, title0, title1, onClickButton, showExtData, extraClass, reloadAfterVote) {
1423    var masterdiv = ".rbvote-" + votetype + "-" + entityid;
1424    if (extraClass)
1425        masterdiv = ".rbvote-" + extraClass + "-" + votetype + "-" + entityid;
1426    var div = masterdiv + " .rbvote-name";
1427    $.post("/Home/RBVote", {
1428        votetype: votetype, entityazon: entityazon, entityid: entityid, showextdata: showExtData
1429    }, function (response) {
1430        if (response.error != '') {
1431            RBMessage(response.error, focus);
1432            return;
1433        }
1434        var title = title0;
1435        if (response.vote == 1) {
1436            title = title1;
1437            $(masterdiv).removeClass(votetype + "-result0");
1438            $(masterdiv).addClass(votetype + "-result1");
1439        }
1440        else {
1441            $(masterdiv).removeClass(votetype + "-result1");
1442            $(masterdiv).addClass(votetype + "-result0");
1443        }
1444        $(div).html(title);
1445        if (onClickButton)
1446            $(onClickButton).click();
1447        if (response.message != '')
1448            RBMessage(response.message, "", "", true);
1449        if (response.extdata != '')
1450            $(masterdiv + " .rbvote-extdata").html(response.extdata);
1451        if (response.votediv != '')
1452            if (response.votevalue != '')
1453                $(response.votediv).html(response.votevalue);
1454        if (reloadAfterVote == 1)
1455            RBReLoad();
1456    });
1457}
1458
1459function RBWebStat(url, newsid, newsitemid) {
1460    $.post(url, {
1461        newsid: newsid, newsitemid: newsitemid
1462    }, function (response) {
1463    });
1464}
1465
1466function RBAjax_PublishItem(url, azon, id, publishid) {
1467    var publishtype = $('.' + publishid).find(".rb-publish-type").attr('class');
1468    $.post(url, {
1469        azon: azon, id: id, publishtype: publishtype
1470    }, function (response) {
1471        if (response) {
1472            if (response.error) {
1473                RBMessage(response.error);
1474            }
1475            else {
1476                $('.' + publishid).find(".rb-publish-type").attr('class', response.publishtype);
1477                $('.' + publishid).attr('title', response.title);
1478            }
1479        }
1480    });
1481}
1482
1483function RBAjax_RSSRefresh(div, url, refreshminute, showitems, enableBigImage, isSummaPage, hourDiff) {
1484    $.post("/Home/RSSRefresh", {
1485        url: url, refreshminute: refreshminute, showitems: showitems, enableBigImage: enableBigImage, isSummaPage: isSummaPage, hourDiff: hourDiff
1486    }, function (response) {
1487        if (response) {
1488            if (!response.result)
1489                return;
1490            if (!$("#" + div + " .rb-rss-header .rb-rss-title").html())
1491                if ($("#" + div + " .rb-rss-header").html() != response.header)
1492                    $("#" + div + " .rb-rss-header").html(response.header);
1493            if (!response.main)
1494                if ($("#" + div + " .rb-rss-main").html() != response.main)
1495                    $("#" + div + " .rb-rss-main").html(response.main);
1496            if ($("#" + div + " .rb-rss-items").html() != response.result)
1497                $("#" + div + " .rb-rss-items").html(response.result);
1498        }
1499    });
1500}
1501
1502function RBSetPersonData(confirm, personId, personDataTypeCode, startdate, enddate, value, allwaysInsert, url) {
1503    if (confirm)
1504        if (!RBConfirm(confirm))
1505            return;
1506    $.post("/Home/SetPersonData", {
1507        personId: personId, personDataTypeCode: personDataTypeCode, startdate: startdate, enddate: enddate,
1508        value: value, allwaysInsert: allwaysInsert
1509    }, function (response) {
1510        if (response.error != '') {
1511            RBMessage(response.error, focus);
1512            return;
1513        }
1514        if (url)
1515            RBRedirect(url);
1516    });
1517}
1518
1519function RBSetMessageStatus(partnerusername, statusId) {
1520    $.post("/Home/SetMessageStatus", {
1521        partnerusername: partnerusername, statusId: statusId
1522    }, function (response) {
1523        if (response.error != '') {
1524            RBMessage(response.error, focus);
1525            return;
1526        }
1527        RBReLoad();
1528    });
1529}
1530
1531function RBMessageTemplate(url, template, partnerusername, messagefield, extdata) {
1532    $.post(url, {
1533        template: template, partnerusername: partnerusername, extdata: extdata
1534    }, function (response) {
1535        if (response.error != '') {
1536            RBMessage(response.error, focus);
1537            return;
1538        }
1539        RBSetValue("#" + messagefield, response.message);
1540        $("#" + messagefield).keydown();
1541    });
1542}
1543
1544function RBConfirmClick(url, divclick) {
1545    $.post(url, {
1546    }, function (response) {
1547        if (response) {
1548            if (response.Error) {
1549                RBMessage(response.Error);
1550                return;
1551            }
1552            if (response.Confirm) {
1553                if (!RBConfirm(response.Confirm))
1554                    return;
1555            }
1556            if (response.Message) {
1557                RBMessage(response.Message);
1558                return;
1559            }
1560            if (divclick)
1561                RBOnClick(divclick);
1562        }
1563    });
1564}
1565
1566function OpenChild(url, myargs, height, width) {
1567    // var myargs = new Array(ParmA, ParmB, ParmC);
1568    if (!height)
1569        height = 500;
1570    if (!width)
1571        width = 500;
1572    var left = (screen.width / 2) - (width / 2);
1573    var top = (screen.height / 2) - (height / 2);
1574    // Nem mindenhol elég ez sajnos, ezért kell variálni - center:yes;
1575    var winsettings = "resizable:yes;dialogHeight:" + height + "px;dialogWidth:" + width + "px;dialogTop:" + top + "px;dialogLeft:" + left + "px";
1576    var result = window.showModalDialog(url, myargs, winsettings);
1577    return result;
1578}
1579
1580var RBMessageOn = false;
1581function RBMessage(message, focus, url, close, onclick, waittime) {
1582    RBMessage2(message, focus, url, close, onclick, false, waittime);
1583}
1584
1585function RBMessage2(message, focus, url, close, onclick, wait, waittime) {
1586    if (RBMessageOn) {
1587        setTimeout(function () {
1588            RBMessage2(message, focus, url, close, onclick, true, waittime);
1589        }, 500);     // <-- time in milliseconds
1590        return;
1591    }
1592    DoRBMessage(message, focus, url, close, onclick, wait, waittime);
1593}
1594
1595function DoRBMessage(message, focus, url, close, onclick, wait, waittime) {
1596    RBMessageOn = true;
1597    if (wait) {
1598        setTimeout(function () {
1599            DoRBMessage(message, focus, url, close, onclick, false, waittime);
1600        }, 500);     // <-- time in milliseconds
1601        return;
1602    }
1603    var oktitle = "";
1604    if (!close)
1605        oktitle = "Ok";
1606    if (!close)
1607        message += "<p class=\"btn-wrap\">";
1608    message += "<span id=\"msg_yes\">" + oktitle + "</span>";
1609    if (!close)
1610        message += "</p>";
1611
1612    $.msg({ content: message, autoUnblock: false, clickUnblock: false
1613       , afterBlock: function () {
1614           var self = this;
1615           $("#msg_yes").bind("click", function () {
1616               // self.method is not chainable
1617               self.unblock(0);
1618               RBMessageOn = false;
1619               if (focus)
1620                   SetFocus(focus);
1621               if (url)
1622                   RBRedirect(url);
1623               if (onclick)
1624                   RBOnClick(onclick);
1625           })
1626       }
1627    });
1628   if (close) {
1629       var closetime = 2000;
1630       if (waittime)
1631           closetime = waittime;
1632        setTimeout(function () {
1633            $("#msg_yes").click();
1634        }, closetime);   // <-- time in milliseconds
1635    }
1636}
1637
1638function RBMessageDiv(div, data, onclick, close, waittime) {
1639    var $item = $(div);
1640    $item.html(data);
1641    $item.removeClass("disableitem");
1642    if (close)
1643        RBDivClose(div, onclick, waittime);
1644}
1645
1646function RBDivClose(div, onclick, waittime) {
1647    var $item = $(div);
1648    var closetime = 2000;
1649    if (waittime)
1650        closetime = waittime;
1651    setTimeout(function () {
1652        RBBodyOverlayOff();
1653        $item.addClass("disableitem");
1654        $item.html("");
1655        if (onclick)
1656            RBOnClick(onclick);
1657    }, closetime);     // <-- time in milliseconds
1658}
1659
1660function RBDialog(message) {
1661    var dialogdiv = $('#rb_dialog');
1662    dialogdiv[0].innerHTML = message;
1663    $("#rb_dialog").dialog();
1664
1665    setTimeout(function () {
1666        $("#rb_dialog").dialog("close");
1667    }, 3000); // <-- time in milliseconds
1668}
1669
1670function SetOrCreateMetaTag(metaName, name, value) {
1671    var t = 'meta[' + metaName + '="' + name + '"]';
1672    var mt = $(t);
1673    if (mt.length === 0) {
1674        t = '<meta ' + metaName + '="' + name + '" />';
1675        mt = $(t).appendTo('head');
1676    }
1677    mt.attr('content', value);
1678}
1679
1680function UpdateMetaData(key, value) {
1681    SetOrCreateMetaTag("property", key, value);
1682    //var meta = $("meta[property=" + key + "]");
1683    //if (meta)
1684    //meta.attr("content", value);
1685    // $("meta[property=" + key + "]").attr("content", value);
1686}
1687
1688function UpdateMetaDataTitle(newtitle) {
1689    UpdateMetaData("og:title", newtitle);
1690}
1691
1692function UpdateMetaDataUrl(newurl) {
1693    UpdateMetaData("og:url", newurl);
1694}
1695
1696function UpdateMetaDataImage(newimage) {
1697    UpdateMetaData("og:image", newimage);
1698}
1699
1700function UpdateMetaDataDesc(newdesc) {
1701    UpdateMetaData("og:description", newdesc);
1702}
1703
1704function RBEncodeString(value) {
1705    // az escape nem jó sajnos!
1706    /*
1707    if (value) {
1708    value = value.replace(/\&/g, "&amp;");
1709    value = value.replace(/\'/g, "&#39;");
1710    value = value.replace(/\"/g, "&quot;");
1711    value = value.replace(/</g, "&lt;");
1712    value = value.replace(/>/g, "&gt;");
1713    }
1714    */
1715    value = Encoder.htmlEncode(value);
1716    value = escape(value);
1717    return value;
1718}
1719
1720function RBHasClass(element, classname) {
1721    if (!element)
1722        return false;
1723    if (!element.className)
1724        return false;
1725    return element.className.match(new RegExp('(\\s|^)' + classname + '(\\s|$)'));
1726}
1727
1728function RBGetIFrameElement(iframe, element) {
1729    var iframee = document.getElementById(iframe);
1730    if (iframee) {
1731        var frameDoc = iframe.contentDocument || iframee.contentWindow.document;
1732        if (frameDoc) {
1733            var el = frameDoc.getElementById(element);
1734            return el;
1735        }
1736    }
1737}
1738
1739function RBChildMenuInit() {
1740    $(document).find(".menu_haschildmenu").hover(function () {
1741        $(this).addClass("menu_childitems_active");
1742        $(this).find(".menu_childitems").removeClass("menu_childitems_disable");
1743    }, function () {
1744        $(this).removeClass("menu_childitems_active");
1745        $(this).find(".menu_childitems").addClass("menu_childitems_disable");
1746    });
1747}
1748
1749function RBCounterFieldModify(field, min, max, inc) {
1750    var item = $(document).find("#" + field);
1751    if (item[0]) {
1752        var val = $.trim(item[0].innerHTML);
1753        if (inc == "true") {
1754            if (val < max) {
1755                val++;
1756                item[0].innerHTML = val;
1757            }
1758        }
1759        else {
1760            if (val > min) {
1761                val--;
1762                item[0].innerHTML = val;
1763            }
1764        }
1765    }
1766}
1767
1768function RBFocusHelp(field, rootfield, message) {
1769    $(document).find("#" + field).focusin(function () {
1770        $(document).find(rootfield).append('<div class="input_focushelp">' + message + '</div>');
1771    });
1772    $(document).find("#" + field).focusout(function () {
1773        $(document).find(rootfield).find('.input_focushelp').remove();
1774    });
1775}
1776
1777function RBShowMenuGroup(groupid) {
1778    $(document).find(".rb-helpdata-menu-item").removeClass("rb-helpdata-menu-item-selected");
1779    $(document).find(".rb-helpdata-menu-item-" + groupid).addClass("rb-helpdata-menu-item-selected");
1780    $(document).find(".rb-helpdata-group").css("display", "none");
1781    $(document).find(".rb-helpdata-group-" + groupid).css("display", "block");
1782}
1783
1784function RBShowMenuGroupItem(itemid) {
1785    $(document).find(".rb-helpdata-group-item-desc").css("display", "none");
1786    $(document).find(".rb-helpdata-group-item-" + itemid + " .rb-helpdata-group-item-desc").css("display", "block");
1787}
1788
1789function RBPrint() {
1790    window.print();
1791    RBBodyOverlayClick();
1792}
1793
1794function RBTextAreaAutoSize(item) {
1795    var field = $(item);
1796    if (!field)
1797        return;
1798    if (!field[0])
1799        return;
1800    DoRBTextAreaAutoSize(field[0]);
1801
1802    $(item).keydown(function (event) {
1803        DoRBTextAreaAutoSize(this);
1804    });
1805}
1806
1807function DoRBTextAreaAutoSize(el) {
1808    setTimeout(function () {
1809        var lines = el.value.split('\n');
1810        el.style.cssText = 'height:auto; padding:0';
1811        // for box-sizing other than "content-box" use:
1812        // el.style.cssText = '-moz-box-sizing:content-box';
1813        var length = el.scrollHeight + 15;
1814        if (lines.length == 2)
1815            length += 15;
1816        el.style.cssText = 'height:' + length + 'px';
1817    }, 0);
1818}
1819// Define a global function - End
1820
1821// MediaState function - Start
1822var RBMediaState = "";
1823var RBOrientationState = "";
1824
1825function RBGetWindowsWidth() {
1826    //if (window.innerWidth)
1827        //return window.innerWidth;
1828    return $(window).width();
1829}
1830
1831function RBGetWindowsHeight() {
1832    //if (window.innerWidth)
1833    //return window.innerWidth;
1834    return $(window).height();
1835}
1836
1837function RBMediaState_CheckResize(mediapagesizelist) {
1838    var bestMediaState = -1;
1839    var bodyWidth = RBGetWindowsWidth();
1840    var bodyHeight = RBGetWindowsHeight();
1841    for (var i = 0; i < mediapagesizelist.length; i++) {
1842        var item = mediapagesizelist[i];
1843        if ((bodyWidth < item.width) || (item.width == 0))
1844            if ((bestMediaState == -1) || (item.width > mediapagesizelist[bestMediaState]))
1845                bestMediaState = i;
1846    }
1847    var newOrientation = "Landscape";
1848    if (bodyHeight > bodyWidth)
1849        newOrientation = "Portrait";
1850    if (bestMediaState != -1) {
1851        if ((RBMediaState != mediapagesizelist[bestMediaState].azon) || (newOrientation != RBOrientationState)) {
1852            if (RBMediaState != mediapagesizelist[bestMediaState].azon) {
1853                RBBodyOverlayClick();
1854                RBSpecBodyOverlayClick(1);
1855            }
1856
1857            $(document.body).removeClass("rb-mediastate-" + RBMediaState);
1858            RBMediaState = mediapagesizelist[bestMediaState].azon;
1859            $(document.body).addClass("rb-mediastate-" + RBMediaState);
1860
1861            $(document.body).removeClass("rb-orientation-" + RBOrientationState);
1862            RBOrientationState = newOrientation;
1863            $(document.body).addClass("rb-orientation-" + RBOrientationState);
1864
1865            $(document).trigger("mediastatechanged");
1866        }
1867    }
1868    RBSetFullScreenDiv();
1869}
1870
1871function RBUpdateViewPort() {
1872    if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
1873        var viewportmeta = document.querySelector('meta[name="viewport"]');
1874        if (viewportmeta) {
1875            viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
1876            document.body.addEventListener('gesturestart', function () {
1877                viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
1878            }, false);
1879        }
1880    }
1881}
1882
1883function RBMediaState_Resize(mediapagesizelist) {
1884    $(window).on('resize', function (event) { RBMediaState_CheckResize(mediapagesizelist); });
1885    RBUpdateViewPort();
1886
1887    RBMediaState_CheckResize(mediapagesizelist);
1888}
1889
1890function RBShowMediaStateInfo() {
1891    var s = "";
1892    /* s += "  windowAvailWidth: " + window.screen.availWidth;*/
1893    /*s += "  windowWidth: " + $(window).width();*/
1894    /* if (window.innerWidth)
1895        s += "  windowinnerWidth: " + window.innerWidth;*/
1896    /*s += "  documentWidth: " + $(document).width();*/
1897    /*s += "  bodyWidth: " + $("body").width();*/
1898    s += "MediaState: " + RBMediaState;
1899    var windowWidth = RBGetWindowsWidth();
1900    s += "  width: " + windowWidth;
1901    var windowHeight = RBGetWindowsHeight();
1902    s += "  height: " + windowHeight;
1903    RBMessage(s);
1904}
1905
1906function RBSetFullScreenDiv() {
1907    $(".rb-fullscreen").css('width', RBGetWindowsWidth() + 'px');
1908    $(".rb-fullscreen").css('height', RBGetWindowsHeight() + 'px');
1909}
1910// MediaState function - End
1911
1912// Position - Start
1913function RBFindPos(obj) {
1914    var curleft = curtop = 0;
1915    if (obj.offsetParent) {
1916        do {
1917            curleft += obj.offsetLeft;
1918            curtop += obj.offsetTop;
1919        } while (obj = obj.offsetParent);
1920    }
1921    return [curleft, curtop];
1922}
1923
1924function RBGetPageScroll() {
1925    var xScroll, yScroll;
1926    if (self.pageYOffset) {
1927        yScroll = self.pageYOffset;
1928        xScroll = self.pageXOffset;
1929    } else if (document.documentElement && document.documentElement.scrollTop) {
1930        yScroll = document.documentElement.scrollTop;
1931        xScroll = document.documentElement.scrollLeft;
1932    } else if (document.body) {// all other Explorers
1933        yScroll = document.body.scrollTop;
1934        xScroll = document.body.scrollLeft;
1935    }
1936    return [xScroll, yScroll];
1937}
1938
1939function RBFindPosRelativeToViewport(obj) {
1940    var objPos = RBFindPos(obj)
1941    var scroll = RBGetPageScroll()
1942    return [objPos[0] - scroll[0], objPos[1] - scroll[1]];
1943}
1944
1945function RBFindPosRelativeToViewportById(elementId) {
1946    var element = document.getElementById(elementId);
1947    if (!element)
1948        return null;
1949    return RBFindPosRelativeToViewport(element);
1950}
1951
1952function RBScrollToElement(elementId) {
1953    var pos = RBFindPosRelativeToViewportById(elementId);
1954    if (!pos)
1955        return;
1956    window.scrollTo(pos[0], pos[1]);
1957}
1958// Position - End
1959
1960// Form - Begin
1961function RBInputConfirm(message, myFormId) {
1962    if (RBConfirm(message))
1963        submitUrlAction("", myFormId, "ok", true, false);
1964}
1965
1966function RBConfirm(message) {
1967    if (confirm(message)) {
1968        return true;
1969    }
1970    return false;
1971}
1972
1973function RBConfirmUrl(message, url) {
1974    if (!RBConfirm(message))
1975        return false;
1976    RBRedirect(url);
1977}
1978
1979function RBConfirmUrl2(message, url, url2) {
1980    if (!RBConfirm(message))
1981        return RBRedirect(url2);
1982    RBRedirect(url);
1983}
1984
1985function RBConfirmFunc(confirmtitle, confirm, confirmtitleYes, confirmtitleNo, functionYes, confirmbuttons, functionNo) {
1986    var confirmnonbuttons = '{ "name": "' + confirmtitleNo + '", "class": "rbconfirm_no", "action": "' + functionNo + '" }';
1987    if (confirmbuttons)
1988        confirmnonbuttons = confirmbuttons + "," + confirmnonbuttons;
1989    var confirmparam = ' "title": "' + confirmtitle + '", "message" : "' + confirm + '", ' +
1990                        '"buttons" : [ {"name" : "' + confirmtitleYes + '", "class" : "rbconfirm_yes", "action": "' + functionYes + '" },' + confirmnonbuttons + ' ]';
1991    var obj = JSON.parse("{" + confirmparam + "}");
1992    $.confirm(obj);
1993}
1994
1995function RBConfirmFuncUserUrl(confirm, functionYesUrl, functionNoUrl) {
1996    functionYes = "RBLoadPage('" + functionYesUrl + "');";
1997    functionNo = "";
1998    if (functionNoUrl)
1999        functionNo = "RBLoadPage('" + functionNoUrl + "');";
2000    RBConfirmFuncUser(confirm, functionYes, functionNo);
2001}
2002
2003function submitForm(url) {
2004    RBDisableAfterSubmit(false);
2005    document.myForm.action = url;
2006    document.myForm.submit();
2007    RBDisableFieldSetAfterSubmit();
2008}
2009
2010function RBAddHiddenField(myForm, name, value) {
2011    var hiddenField = document.createElement("input");
2012    hiddenField.setAttribute("type", "hidden");
2013    hiddenField.setAttribute("name", name);
2014    hiddenField.setAttribute("value", value);
2015    myForm.appendChild(hiddenField);
2016}
2017
2018function RBDisableAfterSubmit(buttondisabled) {
2019    $('.inputform input:submit').attr("disabled", "disabled");
2020    $('.inputform .dropdownlist_button input:button').attr("disabled", "disabled");
2021    $('.inputform .submitbutton').addClass("button_disabled");
2022    if (buttondisabled)
2023        $('.inputform .submitbutton').attr("disabled", "disabled");
2024    $('.inputform .inputpage_item').addClass("input-readonly");
2025    $('.inputform .inputpage_field').addClass("inputpage_field_readonly");
2026    $('.inputform .inputpage_pagebutton').attr("disabled", "disabled");
2027}
2028
2029function RBDisableFieldSetAfterSubmit() {
2030    $('.inputform fieldset').attr("disabled", "disabled");
2031}
2032
2033function submitUrlAction(field, myFormId, action, afterConfirm, submited) {
2034    var myForm = document.getElementById(myFormId);
2035    if (!myForm)
2036        myForm = document.myForm;
2037
2038    RBAddHiddenField(myForm, "field", field);
2039    RBAddHiddenField(myForm, "action", action);
2040
2041    if (afterConfirm) {
2042        RBAddHiddenField(myForm, "afterConfirm", afterConfirm);
2043    }
2044    if (submited) {
2045        RBAddHiddenField(myForm, "submited", submited);
2046    }
2047    RBDisableAfterSubmit(false);
2048    myForm.submit();
2049    RBDisableFieldSetAfterSubmit();
2050}
2051
2052function RBInputFormTabChange(myFormId, page) {
2053    var myForm = document.getElementById(myFormId);
2054    if (!myForm)
2055        myForm = document.myForm;
2056
2057    myForm$ = $(myForm);    
2058
2059    myForm$.find(".inputpage_pagebutton").removeClass("inputpage_pagebuttonselected");
2060    myForm$.find(".inputpage_pagebutton_" + page).addClass("inputpage_pagebuttonselected");
2061
2062    myForm$.find(".inputpage_fieldpage").addClass("inputpage_fields_disabled");
2063    myForm$.find(".inputpage_fieldpage_" + page).removeClass("inputpage_fields_disabled");
2064}
2065
2066function RBGetSelectValue(element, enabletext) {
2067    for (var j = 0; j < element.options.length; j++) {
2068        var option = element.options[j];
2069        if (option.selected) {
2070            if (enabletext)
2071                return option.value ? option.value : option.text;
2072            return option.value;
2073        }
2074    }
2075    return "";
2076}
2077
2078function RBSetSelectValue(element, elementValue) {
2079    for (var j = 0; j < element.options.length; j++) {
2080        var option = element.options[j];
2081        var selected = option.value == elementValue;
2082        if (option.selected != selected) {
2083            option.selected = selected;
2084        }
2085    }
2086}
2087
2088function RBGetTextAreaValue(field, value) {
2089    if (typeof tinymce !== "undefined") {
2090        var fieldItem = tinymce.get(field);
2091        if (fieldItem)
2092            value = fieldItem.getContent();
2093    }
2094    return value;
2095}
2096
2097function getformquerystring(form, formparams) {
2098    // var qstr = "";
2099
2100    function GetElemValue(name, value) {
2101        formparams[name] = value;
2102        // formparams[RBEncodeString(name).replace(/\+/g, "%2B")] = RBEncodeString(value ? value : "").replace(/\+/g, "%2B");
2103    }
2104
2105    function IsTextAreaHiddenElement(name, type) {
2106        if (name.indexOf("$TD") != -1)
2107            return true;
2108        if (name.indexOf("_TD_T") != -1)
2109            return true;
2110        if (name.indexOf("_TCATI") != -1)
2111            return true;
2112        if (name.indexOf("$ClientState") != -1)
2113            return true;
2114        if (name.indexOf("$CssFiles") != -1)
2115            return true;
2116        if (name.indexOf("DXMVCEditorsValues") != -1)
2117            return true;
2118        if (name.indexOf("DXScript") != -1)
2119            return true;
2120        if (type != "HIDDEN")
2121            return false;
2122        return false;
2123    }
2124
2125    var elemArray = form.elements;
2126    for (var i = 0; i < elemArray.length; i++) {
2127        var element = elemArray[i];
2128        var elemType = element.type;
2129        if (elemType) {
2130            elemType = elemType.toUpperCase();
2131            var elemName = element.name;
2132            if (elemName) {
2133                if (!IsTextAreaHiddenElement(element.name, elemType))
2134                    if (elemType == "TEXT"
2135                    || elemType == "PASSWORD"
2136					|| elemType == "BUTTON"
2137					|| elemType == "RESET"
2138					|| elemType == "SUBMIT"
2139					|| elemType == "FILE"
2140					|| elemType == "IMAGE"
2141                    || elemType == "HIDDEN")
2142                        GetElemValue(elemName, element.value);
2143                    else if (elemType == "CHECKBOX")
2144                        GetElemValue(elemName + "-CB", element.checked ? "true" : "false");
2145                    else if (elemType == "TEXTAREA") {
2146                        GetElemValue(elemName, RBGetTextAreaValue(elemName, element.value));
2147                    }
2148                    else if (elemType == "RADIO" && element.checked)
2149                        GetElemValue(elemName, element.value);
2150                    else if (elemType.indexOf("SELECT") != -1)
2151                        GetElemValue(elemName, RBGetSelectValue(element, true));
2152            }
2153        }
2154    }
2155    return;
2156}
2157
2158function getInputValueFromInputData(inputData, field) {
2159    for (var i = 0; i < inputData.length; i++) {
2160        var data = inputData[i];
2161        if (data.Name == field) {
2162            return data;
2163        }
2164    }
2165    return null;
2166}
2167
2168function GetErrorField(field, error) {
2169    return "<span id='" + field + "-error' class='field-validation-error'>" + error + "</span>";
2170}
2171
2172function RBClearInput(myFormId) {
2173    try {
2174        var myForm = document.getElementById(myFormId);
2175        if (!myForm)
2176            myForm = document.myForm;
2177
2178        if (!myForm)
2179            return;
2180
2181        var elemArray = myForm.elements;
2182        for (var i = 0; i < elemArray.length; i++) {
2183            var element = elemArray[i];
2184            var elemType = element.type;
2185            if (elemType) {
2186                elemType = elemType.toUpperCase();
2187                if (elemType == "HIDDEN")
2188                    continue;
2189                var elemName = element.name;
2190                if (elemName) {
2191                    var elementValue = "";
2192                    if (elemType == "TEXT"
2193                    || elemType == "PASSWORD"
2194					|| elemType == "BUTTON"
2195					|| elemType == "RESET"
2196					|| elemType == "SUBMIT"
2197					|| elemType == "FILE"
2198                    || elemType == "TEXTAREA"
2199					|| elemType == "IMAGE") {
2200                        if (element.value != elementValue)
2201                            RBSetValueChange("#" + elemName, elementValue);
2202                    }
2203                    else if (elemType == "CHECKBOX") {
2204                        if (element.checked) {
2205                            RBSetCheckBoxValue("#" + elemName, false);
2206                        }
2207                    }
2208                    else if (elemType == "RADIO") {
2209                        if (element.checked != (elementValue == element.value)) {
2210                            RBSetValueChange("#" + elemName, (elementValue == element.value));
2211                        }
2212                    }
2213                    else if (elemType.indexOf("SELECT") != -1) {
2214                        RBSetValueChange("#" + elemName, "0");
2215                    }
2216                }
2217            }
2218        }
2219    }
2220    catch (ex) {        
2221    }
2222}
2223
2224function setFormInputValues(form, inputData) {
2225    try {
2226        var elemArray = form.elements;
2227        for (var i = 0; i < elemArray.length; i++) {
2228            var element = elemArray[i];
2229            var elemType = element.type;
2230            if (elemType) {
2231                elemType = elemType.toUpperCase();
2232                var elemName = element.name;
2233                if (elemName) {
2234                    var elementInputData = getInputValueFromInputData(inputData, elemName);
2235                    if (elementInputData) {
2236                        var elementValue = elementInputData.Value;
2237                        if (elemType == "TEXT"
2238                    || elemType == "PASSWORD"
2239					|| elemType == "BUTTON"
2240					|| elemType == "RESET"
2241					|| elemType == "SUBMIT"
2242					|| elemType == "FILE"
2243					|| elemType == "IMAGE"
2244                    || elemType == "HIDDEN")
2245                            element.value = elementValue;
2246                        else if (elemType == "TEXTAREA") {
2247                        element.value = elementValue;
2248                        }
2249                        else if (elemType == "CHECKBOX")
2250                            element.checked = (elementValue == "1");
2251                        else if (elemType == "RADIO")
2252                            element.checked = (elementValue == element.value);
2253                        else if (elemType.indexOf("SELECT") != -1) {
2254                            RBSetSelectValue(element, elementValue);
2255                        }
2256                        var erroritem = $(form).find("#" + elemName + "-error");
2257                        if (erroritem)
2258                            if (erroritem[0]) {
2259                                var errorstr = elementInputData.Error;
2260                                if (errorstr) {
2261                                    errorstr = errorstr.replace("\\n\\n", "<BR>");
2262                                    errorstr = errorstr.replace("\\r\\n", "<BR>");
2263                                    errorstr = errorstr.replace("\\n", "<BR>");
2264                                }
2265                                if (erroritem[0].innerHTML != errorstr)
2266                                    erroritem[0].innerHTML = errorstr;
2267                            }
2268                        /*if (elementInputData.Error) {
2269                            $(element).addClass("input-validation-error");
2270                        }*/
2271                        var globalfieldname = ".inputpage_field_" + elemName;
2272                        if (elementInputData.Disabled) {
2273                            $(form).find(globalfieldname).addClass("inputpageitemajaxdisabled");
2274                        }
2275                        else {
2276                            $(form).find(globalfieldname).removeClass("inputpageitemajaxdisabled");
2277                            if (elemType == "TEXTAREA") {
2278                                $(element).keydown();
2279                            }
2280                        }
2281                        if (elementInputData.Error) {
2282                            $(form).find(globalfieldname).find(".input-validation-errorfield").addClass("input-validation-error");
2283                            RBFieldValidate_SetIconError(elemName);
2284                            $(form).find(globalfieldname).find(".input-validation-errorfield").change(function () {
2285                                $(this).removeClass("input-validation-error");
2286                                $(document).find('#' + this.id + '-error').html('');
2287                            });
2288                        }
2289                        if (elementInputData.ReadOnly) {
2290                            $(element).addClass("input-readonly");
2291                            $(element).attr("disabled", "disabled");
2292                        }
2293                        else {
2294                            $(element).removeClass("input-readonly");
2295                            $(element).removeAttr("disabled");
2296                        }
2297                        if (elementInputData.IsEditId) {
2298                            SetComboEditChangeButtons(form, element, (elementInputData.ReadOnly) || (elementInputData.Disabled));
2299                        }
2300                        if (RBHasClass(element, "input-textimage")) {
2301                            $("#" + elemName + "_img").attr('src', element.value);
2302                        }
2303                        if (elementInputData.FireItem) {
2304                            FireRefreshEventHandler(elementInputData.FireItem, elementInputData.FireId, elementInputData.FireAzon);
2305                        }
2306                        if (elementInputData.IsListSelect) {
2307                            RBSetListItemsSelected(form, element.value);
2308                        }
2309                        if (elementInputData.ComboItems) {
2310                            RBSetComboItems(element, elementInputData.ComboItems);
2311                        }
2312                    }
2313                }
2314            }
2315        }
2316        for (var j = 0; j < inputData.length; j++) {
2317            var data = inputData[j];
2318            if (data.IsLabel) {
2319                RBSetLabelValue("#" + data.Name, data.Value);
2320            }
2321            if (data.IsTitle) {
2322                var globalfieldname2 = ".inputpage_field_" + data.Name;
2323                if (data.Disabled) {
2324                    $(form).find(globalfieldname2).addClass("inputpageitemajaxdisabled");
2325                }
2326                else {
2327                    $(form).find(globalfieldname2).removeClass("inputpageitemajaxdisabled");
2328                }
2329            }
2330            if (data.IsGoogleMap) {
2331                RBSetGoogleMapInput(data.Name, data.Value);
2332            }
2333        }
2334    }
2335    catch (ex) {
2336    }
2337}
2338
2339function RBSetListItemsSelected(form, id) {
2340    $(form).find(".rb-listselect-item-selected").removeClass("rb-listselect-item-selected");
2341    $(form).find(".rb-listselect-item-" + id.toString()).addClass("rb-listselect-item-selected");
2342}
2343
2344function RBSetComboItems(item, comboItems) {
2345    var $comboitem = $(item);
2346    $comboitem.empty();
2347
2348    for (var j = 0; j < comboItems.length; j++) {
2349        var option = comboItems[j];
2350        $comboitem.append($("<option></option>").attr("value", option.id).text(option.Name));
2351    }
2352}
2353
2354function RBRemoveErrorAfterChange(field, input) {
2355    $(".inputpage_field_" + field + " " + input).removeClass("input-validation-error");
2356    $(".inputpage_field_" + field + " .field-validation-error").html("");
2357    $(".validation-summary-errors-" + field).html("");
2358}
2359
2360function RBAjaxStartInputCall(myFormId) {
2361    RBAjax_AjaxLoadingStart('#' + myFormId, false);
2362    RBAjax_AjaxLoadingStart('#' + myFormId + " .inputpage_buttons", false);
2363    $('#' + myFormId + " fieldset").attr("disabled", "disabled");
2364}
2365
2366function RBAjaxEndInputCall(myFormId) {
2367    $('#' + myFormId + " fieldset").prop("disabled", false);
2368    RBAjax_AjaxLoadingEnd('#' + myFormId + " .inputpage_buttons", false);
2369    RBAjax_AjaxLoadingEnd('#' + myFormId, false);
2370}
2371
2372function RBAjaxPostError() {
2373    alert('Nem jött válasz a szervertől, próbálja meg újra');
2374}
2375
2376function RBAjax_InputResult(response, field, myFormId, popupbutton, backfield, submiturl, isvalidate, isteszt) {
2377    var myForm = document.getElementById(myFormId);
2378    if (!myForm)
2379        myForm = document.myForm;
2380
2381    var enablesubmit = false;
2382    var submited = false;
2383    var confirm = "";
2384    var confirmtitle = "";
2385    var confirmbuttons = "";
2386    var confirmtitleYes = "";
2387    var confirmtitleNo = "";
2388    var captcharefresh = false;
2389    var actionid = "";
2390    var backvalue = "";
2391    var backlabelvalue = "";
2392    var morebackvalues = null;
2393    var captchaurl = "";
2394    var globalerror = "";
2395    var globalmessage = "";
2396    var globalmessagewait = "";
2397    var validateonclick = "";
2398    var validateurlwithtarget = "";
2399    var submitonclick = "";
2400    var submitFocus = "";
2401    var submitGotoNextId = "";
2402    var reload = false;
2403    var refreshfunc = false;
2404    var posturl = "";
2405    var posturltarget = "";
2406    var focus = "";
2407    var focuspage = "";
2408    var scrollToId = "";
2409    if (isteszt)
2410        alert("Ajax-InputResult-Start");
2411    try {
2412        if (response) {
2413            captcharefresh = response.havecaptcha;
2414            submited = response.submited;
2415            backvalue = response.backvalue;
2416            morebackvalues = response.morebackvalues;
2417            backlabelvalue = response.backlabelvalue;
2418            validateonclick = response.validateonclick;
2419            validateurlwithtarget = response.validateurlwithtarget;
2420            submitonclick = response.submitonclick;
2421            submitFocus = response.submitFocus;
2422            submitGotoNextId = response.submitGotoNextId;
2423            reload = response.reload;
2424            posturl = response.posturl;
2425            posturltarget = response.posturltarget;
2426            refreshfunc = response.refreshfunc;
2427            globalmessage = response.globalmessage;
2428            globalmessagewait = response.globalmessagewait;
2429            $(myForm).find(".inputpage_item").removeClass("input-validation-error");
2430            $(myForm).find(".input-validation-errorfield").removeClass("input-validation-error");
2431            $(myForm).find(".inputpage_field_validate_icon").addClass("inputpage_field_validate_icon_disable");
2432            if (!submited) {
2433                globalerror = response.globalerror;
2434                if (response.inputData) {
2435                    if (isteszt)
2436                        alert("Ajax-SetFormInputValues-Start");
2437                    setFormInputValues(myForm, response.inputData);
2438                    if (isteszt)
2439                        alert("Ajax-SetFormInputValues-End");
2440                }
2441                focus = response.focus;
2442                focuspage = response.focuspage;
2443                scrollToId = response.scrollToId;
2444                if (field == "") {
2445                    enablesubmit = response.enablesubmit;
2446                    confirm = response.confirm;
2447                    confirmtitle = response.confirmtitle;
2448                    confirmbuttons = response.confirmbuttons;
2449                    confirmtitleYes = response.confirmtitleyes;
2450                    confirmtitleNo = response.confirmtitleno;
2451                }
2452                actionid = response.actionid;
2453                captchaurl = response.captchaurl;
2454            }
2455        }
2456        else {
2457            globalerror = "Nem érkezett válasz a szervertől!";
2458        }
2459    }
2460    catch (ex) {
2461        /*if (isteszt) {
2462            alert("Ajax-Exception");*/
2463            alert(ex);
2464        /*}*/
2465    }
2466    if (isteszt)
2467        alert("Ajax-InputResult-End");
2468    $(myForm).find(".validation-summary-globalerror").attr("disabled", true);
2469    if (submited) {
2470        RBAjaxEndInputCall(myFormId);
2471        if (popupbutton) {
2472            if (backfield) {
2473                if (morebackvalues) {
2474                    for (var n = 0; n < morebackvalues.length; n++) {
2475                        var morebackvalue = morebackvalues[n];
2476                        RBSetValueChange("#" + morebackvalue.Name, morebackvalue.Value);
2477                    }
2478                }
2479                else {
2480                    RBSetValueChange("#" + backfield, backvalue);
2481                    RBSetLabelValue("#" + backfield + "_Label", backlabelvalue);
2482                }
2483            }
2484            RBOnClick("." + popupbutton);
2485            if (globalmessage) {
2486                RBBodyOverlayOff();
2487                RBMessage(globalmessage, "", posturl, globalmessagewait != '1', submitonclick);
2488            }
2489            else {
2490                if (posturl) {
2491                    RBBodyOverlayOff();
2492                    if (posturltarget) {
2493                        RBLoadPage(posturl, posturltarget);
2494                    }
2495                    else {
2496                        RBAjaxStartInputCall(myFormId);
2497                        RBRedirect(posturl);
2498                    }
2499                }
2500                else {
2501                    if (submitonclick) {
2502                        RBBodyOverlayOff();
2503                        RBOnClick(submitonclick);
2504                        if (submitFocus)
2505                            $("#" + submitFocus).focus();
2506                    }
2507                    else {
2508                        if (reload) {
2509                            RBBodyOverlayOff();
2510                            RBReLoad();
2511                        }
2512                    }
2513                }
2514            }
2515        }
2516        else {
2517            if (submitGotoNextId) {
2518                $("#" + submitGotoNextId).trigger("change", [{ id: "GotoNext"}]);
2519            }
2520            else {
2521                if (globalmessage) {
2522                    RBBodyOverlayOff();
2523                    RBMessage(globalmessage, "", posturl, globalmessagewait != '1', submitonclick);
2524                }
2525                else {
2526                    if (posturl) {
2527                        RBBodyOverlayOff();
2528                        if (posturltarget) {
2529                            RBLoadPage(posturl, posturltarget);
2530                        }
2531                        else {
2532                            RBAjaxStartInputCall(myFormId);
2533                            RBRedirect(posturl);
2534                        }
2535                    }
2536                    else {
2537                        if (submitonclick) {
2538                            RBBodyOverlayOff();
2539                            RBOnClick(submitonclick);
2540                            if (submitFocus)
2541                                $("#" + submitFocus).focus();
2542                        }
2543                        else {
2544                            submitUrlAction("", myFormId, "ok", false, true);
2545                        }
2546                    }
2547                }
2548            }
2549        }
2550        return;
2551    }
2552    if (isteszt)
2553        alert("Ajax-InputResult-Submit-Check");
2554    var erroritem = $(myForm).find(".validation-summary-globalerror-item");
2555    if (erroritem)
2556        erroritem[0].innerHTML = globalerror;
2557    $(myForm).find(".validation-summary-globalerror").attr("disabled", !globalerror);
2558    if (enablesubmit) {
2559        if (confirm) {
2560            /*if (!RBConfirm(confirm))
2561            enablesubmit = false;*/
2562            enablesubmit = false;
2563            var functionYes = "";
2564            if (submiturl) {
2565                RBAjaxEndInputCall(myFormId);
2566                functionYes = "RBAjax_InputPost('" + submiturl + "', '" + myFormId + "', '" + popupbutton + "', '" + backfield + "');";
2567            }
2568            else {
2569                functionYes = "submitUrlAction('', '" + myFormId + "', 'ok', true, false);";
2570            }
2571            RBConfirmFunc(confirmtitle, confirm, confirmtitleYes, confirmtitleNo, functionYes, confirmbuttons);
2572        }
2573        if (enablesubmit) {
2574            if (submiturl) {
2575                RBAjaxEndInputCall(myFormId);
2576                RBAjax_InputPost(submiturl, myFormId, popupbutton, backfield);
2577            }
2578            else {
2579                submitUrlAction("", myFormId, "ok", true, false);
2580            }
2581            return;
2582        }
2583    }
2584    if (validateonclick)
2585        RBOnClick(validateonclick);
2586    if (validateurlwithtarget)
2587        RBLoadPage(validateurlwithtarget, "_blank");
2588    if (isteszt)
2589        alert("Ajax-InputResult-Finis");
2590    RBAjaxEndInputCall(myFormId);
2591    if (focus) {
2592        $("#" + focus).focus();
2593        if (focuspage) {
2594            RBInputFormTabChange(myFormId, focuspage);
2595        }
2596    }
2597    if (captcharefresh) {
2598        if ((actionid) && (captchaurl)) {
2599            RBAjax_GenNewCaptchaFocus(captchaurl, actionid, false);
2600        }
2601    }
2602    if (scrollToId)
2603        RBScrollToDiv(scrollToId, -150, 1000, true);
2604    if (globalerror) {
2605        RBMessage(globalerror);
2606    }
2607    if (refreshfunc) {
2608        try {
2609            RBAjax_InputRefresh();
2610        }
2611        catch (ex) {
2612        }
2613    }
2614}
2615
2616function RBAjax_InputValidateNeedCheck(event, field, fieldlength) {
2617    if (event.type != 'keyup')
2618        return true;
2619    var value = RBGetValue("#" + field);
2620    if (!value)
2621        return false;
2622    if (value.length != fieldlength)
2623        return false;
2624    return true;
2625}
2626
2627function RBAjax_InputValidate(url, field, myFormId, submiturl, popupbutton, backfield, submitspecvalue) {
2628    var myForm = document.getElementById(myFormId);
2629    if (!myForm)
2630        myForm = document.myForm;
2631    RBSetValue("#" + myFormId + " #SubmitSpecValue", submitspecvalue);
2632
2633    url += "?field=" + field;
2634    var formparams = {};
2635    getformquerystring(myForm, formparams);
2636    var isteszt = false;
2637    /*if (qstr.indexOf("[email protected]") > -1)
2638        isteszt = true;*/
2639    if (isteszt)
2640        alert("Ajax-Start");
2641    RBAjaxStartInputCall(myFormId);
2642    $.post(url, formparams, function (response) {
2643        if (isteszt)
2644            alert("Ajax-Response-Start");
2645        RBAjax_InputResult(response, field, myFormId, popupbutton, backfield, submiturl, true, isteszt);
2646        if (isteszt)
2647            alert("Ajax-Response-End");
2648    }).fail(function (response) {
2649        RBAjaxEndInputCall(myFormId);
2650        RBAjaxPostError();
2651    });
2652    if (isteszt)
2653        alert("Ajax-Posted");
2654}
2655
2656function RBAjax_InputPost(url, myFormId, popupbutton, backfield) {
2657    var myForm = document.getElementById(myFormId);
2658
2659    if (!myForm)
2660        myForm = document.myForm;
2661
2662    url += "?";
2663    var formparams = {};
2664    getformquerystring(myForm, formparams);
2665    var isteszt = false;
2666    /*if (qstr.indexOf("[email protected]") > -1)
2667        isteszt = true;*/
2668    RBAjaxStartInputCall(myFormId);
2669    $.post(url, formparams, function (response) {
2670        RBAjax_InputResult(response, "", myFormId, popupbutton, backfield, "", false, isteszt);
2671    }).fail(function (response) {
2672        RBAjaxEndInputCall(myFormId);
2673        RBAjaxPostError();
2674    });
2675}
2676
2677function RBFieldValidate_RemoveErrorSet(field) {
2678    var globalfieldname = ".inputpage_field_" + field;
2679    $(document).find(globalfieldname).find(".input-validation-errorfield").removeClass("input-validation-error");
2680    $(document).find('#' + field + '-error').html('');
2681    $(document).find(".validation-summary-globalerror").attr("disabled", true);
2682}
2683
2684function RBFieldValidate_SetError(field, errorStr) {
2685    RBFieldValidate_RemoveErrorSet(field);
2686    RBFieldValidate_SetIconError(field);
2687    var globalfieldname = ".inputpage_field_" + field;
2688    $(document).find(globalfieldname).find(".input-validation-errorfield").addClass("input-validation-error");
2689    if (errorStr) {
2690        $(document).find('#' + field + '-error').html(errorStr);
2691    }
2692}
2693
2694function RBFieldValidate_SetIconError(field) {
2695    $(document).find(".inputpage_field_validate_icon_" + field).removeClass("inputpage_field_validate_icon_disable");
2696    $(document).find(".inputpage_field_validate_icon_" + field).removeClass("input-fieldvalidation-ok");
2697    $(document).find(".inputpage_field_validate_icon_" + field).addClass("input-fieldvalidation-error");
2698}
2699
2700function RBFieldValidate_SetOk(field) {
2701    RBFieldValidate_RemoveErrorSet(field);
2702    $(document).find(".inputpage_field_validate_icon_" + field).removeClass("inputpage_field_validate_icon_disable");
2703    $(document).find(".inputpage_field_validate_icon_" + field).removeClass("input-fieldvalidation-error");
2704    $(document).find(".inputpage_field_validate_icon_" + field).addClass("input-fieldvalidation-ok");
2705}
2706
2707function RBFieldValidate_SetNothing(field) {
2708    RBFieldValidate_RemoveErrorSet(field);
2709    $(document).find(".inputpage_field_validate_icon_" + field).addClass("inputpage_field_validate_icon_disable");
2710}
2711
2712function RBFieldValidate_Empty(field, valueField, requiredErrorStr) {
2713    $("#" + field).change(function () {
2714        RBFieldValidate_Change_CheckEmpty(field, valueField, requiredErrorStr);
2715    });
2716}
2717
2718function RBFieldValidate_EMail(field, valueField, required, invalidErrorStr, requiredErrorStr) {
2719    $("#" + field).change(function () {
2720        RBFieldValidate_Change_CheckEMail(field, valueField, required, invalidErrorStr, requiredErrorStr);
2721    });
2722}
2723
2724function RBFieldValidate_Change_CheckEmpty(field, valueField, requiredErrorStr) {
2725    var value = RBGetValue("#" + valueField);
2726    if (value) {
2727        RBFieldValidate_SetOk(field);
2728    }
2729    else {
2730        RBFieldValidate_SetError(field, requiredErrorStr);
2731    }
2732}
2733
2734function RBFieldValidate_Change_CheckEMail(field, valueField, required, invalidErrorStr, requiredErrorStr) {
2735    var value = RBGetValue("#" + valueField);
2736    if (value) {
2737        if (RBValidateEmail(value)) {
2738            RBFieldValidate_SetOk(field);
2739        }
2740        else {
2741            RBFieldValidate_SetError(field, invalidErrorStr);
2742        }
2743    }
2744    else {
2745        if (required == 1) {
2746            RBFieldValidate_SetError(field, requiredErrorStr);
2747        }
2748        else {
2749            RBFieldValidate_SetNothing(field);
2750        }
2751    }
2752}
2753
2754function RBFieldEmptyCheck(field, length) {
2755    var value = RBGetValue("#" + field);
2756    if (!value) {
2757        RBMessage("Kötelező kitölteni!", "#" + field);
2758        return false;
2759    }
2760    if (length)
2761        if (value.length < length) {
2762            RBMessage("Legalább " + length + " karakert adj meg!", "#" + field);
2763            return false;
2764        }
2765    return true;
2766}
2767
2768function RBFieldEmptyCheckSubmit(field, length, form) {
2769    if (!RBFieldEmptyCheck(field, length))
2770        return false;
2771    $('#' + form).submit();
2772}
2773
2774function RBValidateEmail(email) {
2775    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
2776    return re.test(email);
2777} 
2778
2779function SetImgSrc(id, imgid) {
2780    var item = document.getElementById(id);
2781    if (item) {
2782        var src = item.value;
2783        var img = document.getElementById(imgid);
2784        if (img) {
2785            if (img.src != src)
2786                img.src = src;
2787        }
2788    }
2789}
2790
2791function RBSaveImage(url, field, saveazon, saveparam) {
2792    var image = RBGetValue("#" + field);
2793    $.post(url, {
2794        saveazon: saveazon, saveparam: saveparam, image: image
2795    }, function (response) {
2796        if (response) {
2797            if (response.error) {
2798                RBMessage(response.error, "", "", true);
2799                return;
2800            }
2801            if (response.updateimage) {
2802                RBSetValue("#" + field, response.updateimage);
2803                SetImgSrc(field, field + "_img");
2804            }
2805        }
2806    });
2807};
2808
2809function RBSetInputDataToCookie(fieldid, azon) {
2810    var item = document.getElementById(fieldid);
2811    if (item) {
2812        {
2813            RBSetCookie(azon, item.value, 0);
2814        }
2815    }
2816}
2817
2818function RBExportReport(reportid, dik, exporttype) {
2819    var $grid = $("#grid_Report_" + dik);
2820    var sortfield = $grid.data("sortfield");
2821    var sorttype = $grid.data("sorttype");
2822    var filter = $grid.data("filter");
2823    var div = "reportresult_result_item_" + dik + " .reportresult_result_item_" + exporttype;
2824    RBAjax_AjaxLoadingStart('.' + div, false);
2825    $.post("/Report/ExportReport", {
2826        reportid: reportid, dik: dik, exporttype: exporttype, sortfield: sortfield, sorttype: sorttype, filter: filter
2827    }, function (response) {
2828        RBAjax_AjaxLoadingEnd('.' + div, false);
2829        if (response) {
2830            if (response.error) {
2831                RBMessage(response.error, "", "", true);
2832                return;
2833            }
2834            $("." + div).html(response.work);
2835            if (response.file)
2836                RBLoadPage(response.file, "_blank");
2837        }
2838    }).fail(function (response) {
2839        RBAjax_AjaxLoadingEnd('.' + div, false);
2840        RBAjaxPostError();
2841    });
2842}
2843
2844function RBFilterComboChange(selected) {
2845    var url = $("#" + selected).val();
2846    RBLoadPage(url);
2847}
2848
2849function RBDateInputComboChange(combofield, startfield, endfield) {
2850    var div = "inputdateinter_combo_" + startfield;
2851    var combovalue = $("#" + combofield).val();
2852    RBAjax_AjaxLoadingStart('.' + div, false);
2853    $.post("/Home/DateInputComboChange", {
2854        combovalue: combovalue
2855    }, function (response) {
2856        RBAjax_AjaxLoadingEnd('.' + div, false);
2857        if (response) {
2858            if (response.error) {
2859                RBMessage(response.error, "", "", true);
2860                return;
2861            }
2862            if (response.startvalue)
2863                $("#" + startfield).val(response.startvalue);
2864            if (response.endvalue)
2865                $("#" + endfield).val(response.endvalue);
2866        }
2867    }).fail(function (response) {
2868        RBAjax_AjaxLoadingEnd('.' + div, false);
2869        RBAjaxPostError();
2870    });
2871}
2872
2873function RBSetCookieDoc(doc, cname, cvalue, exdays, exhours) {
2874    value = encodeURIComponent(cvalue);    
2875    RBSetCookieDocValue(doc, cname, value, exdays, exhours);
2876}
2877
2878function RBSetCookieDocValue(doc, cname, value, exdays, exhours) {
2879    if (exdays < 1)
2880        if (exhours < 1)
2881            exdays = 360;
2882    if (!exhours)
2883        exhours = 1;
2884    if (!exdays)
2885        exdays = 360;
2886    var d = new Date();
2887    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000) + (exhours * 60 * 60 * 1000));
2888    var expires = "expires=" + d.toUTCString();
2889    doc.cookie = cname + "=" + value + "; " + expires+";path=/";
2890}
2891
2892function RBSetCookie(cname, cvalue, exdays, exhours) {
2893    RBSetCookieDoc(document, cname, cvalue, exdays, exhours)
2894}
2895
2896function RBGetCookie(cname) {
2897    var name = cname + "=";
2898    var ca = document.cookie.split(';');
2899    for (var i = 0; i < ca.length; i++) {
2900        var c = ca[i];
2901        while (c.charAt(0) == ' ') c = c.substring(1);
2902        if (c.indexOf(name) != -1) {
2903            var cookievalue = c.substring(name.length, c.length);
2904            if (cookievalue)
2905                cookievalue = decodeURIComponent(cookievalue);
2906            return cookievalue;
2907        }
2908    }
2909    return "";
2910}
2911
2912function RBGetConsentCookieValue(azon) {
2913    var cookievalue = RBGetCookie(azon);
2914    if (!cookievalue)
2915        return 'granted';
2916    if (cookievalue.endsWith("False"))
2917        return 'granted';
2918    if (cookievalue.endsWith("True"))
2919        return 'denied';
2920    return granted;
2921}
2922
2923function RBUpdateConsentState(CookieName_DisableGoogleCookie_AdStorage, CookieName_DisableGoogleCookie_AdUserData, CookieName_DisableGoogleCookie_AdPersonalization, CookieName_DisableGoogleCookie_AnalyticsStorage, CookieName_DisableGoogleCookie_FunctionalityStorage, CookieName_DisableGoogleCookie_PersonalizationStorage, id, cookiename) {
2924    var ad_storage = 'granted';
2925    var ad_user_data = 'granted';
2926    var ad_personalization = 'granted';
2927    var analytics_storage = 'granted';
2928    var functionality_storage = 'granted';
2929    var personalization_storage = 'granted';
2930
2931    if (CookieName_DisableGoogleCookie_AdStorage)
2932        ad_storage = RBGetConsentCookieValue(CookieName_DisableGoogleCookie_AdStorage);
2933    if (CookieName_DisableGoogleCookie_AdUserData)
2934        ad_user_data = RBGetConsentCookieValue(CookieName_DisableGoogleCookie_AdUserData);
2935    if (CookieName_DisableGoogleCookie_AdPersonalization)
2936        ad_personalization = RBGetConsentCookieValue(CookieName_DisableGoogleCookie_AdPersonalization);
2937    if (CookieName_DisableGoogleCookie_AnalyticsStorage)
2938        analytics_storage = RBGetConsentCookieValue(CookieName_DisableGoogleCookie_AnalyticsStorage);
2939    if (CookieName_DisableGoogleCookie_FunctionalityStorage)
2940        functionality_storage = RBGetConsentCookieValue(CookieName_DisableGoogleCookie_FunctionalityStorage);
2941    if (CookieName_DisableGoogleCookie_PersonalizationStorage)
2942        personalization_storage = RBGetConsentCookieValue(CookieName_DisableGoogleCookie_PersonalizationStorage);
2943
2944    gtag('consent', 'update', { 'ad_storage': ad_storage, 'ad_user_data': ad_user_data, 'ad_personalization': ad_personalization, 'analytics_storage': analytics_storage, 'functionality_storage': functionality_storage, 'personalization_storage': personalization_storage, 'security_storage': 'granted' });
2945    $('.' + id).remove();
2946}
2947
2948function RBCheckCookieAlert2(cookiename, id, headertitle, headerdescription, headerlinktitle, headerlink, okbuttontitle, buttonclass, settingsbuttontitle, onclick, url, code, disableAllButtonTitle, disableAllCode, disableAllCookieName, earlyExpire) {
2949    var cookievalue = RBGetCookie(cookiename);
2950    if (cookievalue == "1")
2951        return;
2952    RBAddDiv('body', id);
2953    RBAddDiv('.' + id, id + '-header');
2954    var headerclass = '.' + id + '-header';
2955    RBAddDiv(headerclass, "rb-cookiealert-title", headertitle);
2956    RBAddDiv(headerclass, "rb-cookiealert-image");
2957    if (headerlink) {
2958        RBAddA(headerclass, headerlinktitle, headerlink, "_blank");
2959    }
2960
2961    RBAddDiv('.' + id, id + '-info');
2962    var infoclass = '.' + id + '-info';
2963    if (headerdescription) {
2964        RBAddDiv(infoclass, "rb-cookiealert-description", headerdescription);
2965    }
2966
2967    RBAddDiv('.' + id, id + '-buttons');
2968    var buttonclassname = '.' + id + '-buttons';
2969    if (onclick) {
2970        RBAddDivOnClick(buttonclassname, buttonclass + " " + buttonclass + "-settings", "<div class='" + buttonclass + "-title'>" + settingsbuttontitle + "</div>", onclick);
2971    }
2972    if (disableAllButtonTitle) {
2973        RBAddDiv('.' + id + '-buttons', id + '-buttons_choice');
2974        buttonclassname = '.' + id + '-buttons_choice';
2975        RBAddDiv(buttonclassname, buttonclass + " " + buttonclass + "-disable", disableAllButtonTitle);
2976    }
2977    RBAddDiv(buttonclassname, buttonclass + " " + buttonclass + "-ok", okbuttontitle);
2978    $(buttonclassname + " ." + buttonclass + "-ok").click(function () {
2979        $('.' + id).remove();
2980        RBSetCookie(cookiename, "1", 20 * 365);
2981        if (disableAllButtonTitle) {
2982            RBSetCookie(disableAllCookieName, "False", days);
2983        }
2984        RBUpdateConsentState();
2985        if (url) {
2986            if (code) {
2987                RBChangeData(url, code, 0);
2988            }
2989        }
2990    });
2991    if (disableAllButtonTitle) {
2992        $(buttonclassname + " ." + buttonclass + "-disable").click(function () {
2993            $('.' + id).remove();
2994            var days = 365;
2995            if (earlyExpire)
2996                days = 1;
2997            RBSetCookie(cookiename, "1", days);
2998            RBSetCookie(disableAllCookieName, "True", days);
2999            if (url) {
3000                if (disableAllCode) {
3001                    RBChangeData(url, disableAllCode, 0);
3002                }
3003            }
3004        });
3005    }
3006}
3007
3008function RBCheckCookieAlert(cookiename, id, title, linktitle, link, buttontitle, buttonclass, settingsbuttontitle, onclick) {
3009    var cookievalue = RBGetCookie(cookiename);
3010    if (cookievalue == "1")
3011        return;
3012    RBAddDiv('body', id);
3013    RBAddDiv('.' + id, "rb-cookingalert-title", title);
3014    if (link) {
3015        RBAddA('.' + id, linktitle, link, "_blank");
3016    }
3017    RBAddDiv('.' + id, buttonclass + " " + buttonclass + "-ok", buttontitle);
3018
3019    if (onclick) {
3020        RBAddDivOnClick('.' + id, buttonclass + " " + buttonclass + "-settings", "<div class='" + buttonclass + "-title'>" + settingsbuttontitle + "</div>", onclick);
3021    }
3022
3023    $('.' + id + " ."+buttonclass + "-ok").click(function () {
3024        $('.' + id).remove();
3025        RBSetCookie(cookiename, "1", 20 * 365);
3026    });
3027}
3028
3029function RBPrgInfo(cookiename, id, title, linktitle, link, buttontitle) {
3030    var cookievalue = RBGetCookie(cookiename);
3031    if (cookievalue == "1")
3032        return;
3033    RBSetCookie(cookiename, "1", 20 * 365);
3034    RBAddDiv('body', id);
3035    RBAddDiv('.' + id, "rb-prginfoalert-title", title);
3036    if (link)
3037        RBAddA('.' + id, linktitle, link, "_blank");
3038    RBAddDiv('.' + id, "rb-prginfoalert-button", buttontitle);
3039    $('.' + id + " .rb-prginfoalert-button").click(function () {
3040        $('.' + id).remove();
3041    });
3042}
3043
3044function RBAddDivOnClick(item, classname,data, onclick){
3045    var div = "<div class='" + classname + "' onclick='" + onclick + "'>";
3046    if (data)
3047        div += data;
3048        div +="</div>";
3049    $(item).append(div);
3050}
3051
3052function RBAddDiv(item, divclass, data) {
3053    var div = "<div class='" + divclass + "'>";
3054    if (data)
3055        div += data;
3056        div +="</div>";
3057    $(item).append(div);
3058}
3059
3060function RBAddData(item, data) {
3061    $(item).append(data);
3062}
3063
3064function RBAddA(item, title, link, target) {
3065    var data = "<a href='" + link + "'";
3066    if (target)
3067        data += " target='" + target + "'";
3068    data += ">" + title + "</a>";
3069    $(item).append(data);
3070}
3071
3072function RBUpdateItemHRefAttr(item, param, value) {
3073    var $link = $(item);
3074    var currentUrl = $link.attr('href');
3075    if (!currentUrl)
3076        return;
3077    var newUrl = RBUpdateUrl(currentUrl, param, value);
3078    if (!newUrl)
3079        return;
3080    $link.attr('href', newUrl);
3081}
3082
3083function RBUpdateUrl(currentUrl, param, value) {
3084    var urlObj = new URL(currentUrl, window.location.href);
3085    if (!urlObj.searchParams)
3086        return;
3087    urlObj.searchParams.set(param, value);
3088    return urlObj.toString();
3089}
3090
3091function RBImagePropChange(myFormId, imageField, widthField, heightField) {
3092    var myForm = document.getElementById(myFormId);
3093    if (!myForm)
3094        myForm = document.myForm;
3095    if (widthField) {
3096        var widthitem = RBGetIFrameElement("iframe_" + imageField, "imageWidth");
3097        if (widthitem) {
3098            var widthFieldItem = $(myForm).find("#" + widthField);
3099            if (widthFieldItem)
3100                widthitem.value = widthFieldItem[0].value;
3101        }
3102    }
3103    if (heightField) {
3104        var heightitem = RBGetIFrameElement("iframe_" + imageField, "imageHeight");
3105        if (heightitem) {
3106            var heightFieldItem = $(myForm).find("#" + heightField);
3107            if (heightFieldItem)
3108                heightitem.value = heightFieldItem[0].value;
3109        }
3110    }
3111}
3112
3113function RBImageLoad(divId, imageUrl, enableZoom) {
3114    var html = "<div class='rbinfo-image'><img class='rbinfo-image-img' src='" + imageUrl + "' border='0' />";
3115    var script = "";
3116    if (enableZoom == 1) {
3117        var zoomId = "rb2-image-zoom-full";
3118        var beforeImage = "<div id='" + zoomId + "' class='rb2-image-zoom'>";
3119        var zoomField = "rb2-image-zoomitem";
3120        var afterImage = "<div class='" + zoomField + "'></div>";
3121        afterImage += "</div>";
3122        html = beforeImage + html + afterImage;
3123        script = "RBZoomerImage('" + zoomId + "','rbinfo-image-img','" + zoomField + "');";
3124    }
3125    html += "</div>";
3126    $('#' + divId).html(html);
3127    if (script != '')
3128        eval(script);
3129}
3130
3131function RBCopyToClipboard(text, msg, addTo) {
3132    var $temp = $("<input>");
3133    if (addTo)
3134        $(addTo).append($temp);
3135    else
3136        $("body").append($temp);
3137    $temp.val(text).select();
3138    document.execCommand("copy");
3139    $temp.remove();
3140    if (msg)
3141        alert(msg);
3142}
3143
3144function RBCompare(a, b) {
3145    for (var i = 0; i < Math.max(a.length, b.length); i++) {
3146        //alert(a[i]+' '+b[i]);
3147        var x = RBCharCompare(a[i], b[i]);
3148        if (x != 0)
3149            return x;
3150    }
3151
3152    return 0;
3153}
3154
3155function RBCharCompare(a, b) {
3156    // TODO: culture type alapján beküldeni
3157    var str = "0123456789aábcdeéfghiíjklmnoóöőpqrstuúüűvwxyz";
3158    var ai = -1;
3159    if (a) { ai = str.indexOf(a.toLowerCase()); }
3160    var bi = -1;
3161    if (b) { bi = str.indexOf(b.toLowerCase()); }
3162
3163    //alert(ai);
3164    //alert(bi);
3165
3166    if (ai < bi) return 1;
3167    if (ai == bi) return 0;
3168    if (ai > bi) return -1;
3169}
3170
3171var accentMap = {
3172    "á": "a", "à": "a", "â": "a", "é": "e", "è": "e", "ê": "e", "ë": "e",
3173    "í": "i", "ï": "i", "î": "i", "ó": "o", "ô": "o", "ö": "o", "ő": "o",
3174    "ú": "u", "û": "u", "ù": "u", "ü": "u", "ű": "u",
3175    "Á": "A", "É": "E", "Í": "I", "Ó": "O", "Ö": "O", "Ő": "O", 
3176    "Ú": "U", "Ü": "U", "Ű": "U"
3177};
3178
3179function RBNormalize(term) {
3180    var ret = "";
3181    for (var i = 0; i < term.length; i++) {
3182        ret += accentMap[term.charAt(i)] || term.charAt(i);
3183    }
3184    return ret;
3185};
3186
3187function RBNewsLetterSubscribe(code, subscribetypecode, needconfirmok) {
3188    $(document).find("#newsletter_name").removeClass("input-validation-error");
3189    $(document).find("#newsletter_email").removeClass("input-validation-error");
3190    $(document).find("#newsletter_surname").removeClass("input-validation-error");
3191    $(document).find("#newsletter_forename").removeClass("input-validation-error");
3192    $(document).find("#newsletter_nickname").removeClass("input-validation-error");
3193    $(document).find("#newsletter_confirmok").removeClass("input-validation-error");
3194    $(document).find("#newsletter_datahandlingok").removeClass("input-validation-error");    
3195
3196    var name = RBGetValue("#newsletter_name");
3197    var email = RBGetValue("#newsletter_email");
3198    var surname = RBGetValue("#newsletter_surname");
3199    var forename = RBGetValue("#newsletter_forename");
3200    var nickname = RBGetValue("#newsletter_nickname");
3201    var confirmok = RBGetValue("#newsletter_confirmok");
3202    var datahandlingok = RBGetValue("#newsletter_datahandlingok");
3203
3204    var isError = false;
3205    if (!name)
3206        if (!surname) {
3207            $(document).find("#newsletter_name").addClass("input-validation-error");
3208            $(document).find("#newsletter_surname").addClass("input-validation-error");
3209            isError = true;
3210        }
3211    if (!email || !RBValidateEmail(email)) {
3212        $(document).find("#newsletter_email").addClass("input-validation-error");
3213        isError = true;
3214    }
3215    if (!isError) {
3216        if (datahandlingok != 1) {
3217            $(document).find("#newsletter_datahandlingok").addClass("input-validation-error");
3218            isError = true;
3219        }
3220    }
3221    if (!isError) {
3222        if (needconfirmok == 1)
3223            if (confirmok != 1) {
3224                $(document).find("#newsletter_confirmok").addClass("input-validation-error");
3225                isError = true;
3226            }
3227    }
3228    if (isError)
3229        return false;
3230
3231    $.post("/hirlevel-feliratkozas", {
3232        code: code, subscribetypecode: subscribetypecode, name: name, surname: surname, forename: forename, nickname: nickname, email: email
3233    }, function (response) {
3234        if (response) {
3235            if (response.error)
3236                RBMessage(response.error);
3237            if (response.message) {
3238                RBSetValue("#newsletter_name", "");
3239                RBSetValue("#newsletter_email", "");
3240                RBSetValue("#newsletter_surname", "");
3241                RBSetValue("#newsletter_forename", "");
3242                RBSetValue("#newsletter_nickname", "");
3243                RBSetValue("#newsletter_confirmok", "");
3244                RBSetValue("#newsletter_datahandlingok", "");                
3245                RBMessage(response.message);
3246            }
3247        }
3248    });
3249}
3250
3251function RBSendNewsLetter(ajaxurl, divid, newsletterid, url, confirm) {
3252    if (confirm)
3253        if (!RBConfirm(confirm))
3254            return;
3255    var $origdiv = $('.' + divid);
3256    var $ajaxloading = $origdiv;
3257    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
3258    $.post(ajaxurl, {
3259        newsletterid: newsletterid
3260    }, function (response) {
3261        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3262        if (response) {
3263            if (response.error) {
3264                RBMessage(response.error);
3265                return;
3266            }
3267            if (response.message) {
3268                RBMessage(response.message, "", url, false);
3269            }
3270            else {
3271                if (url)
3272                    RBLoadPage(url);
3273            }
3274        }
3275    }).fail(function (response) {
3276        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3277        RBAjaxPostError();
3278    });
3279}
3280
3281function RBQuickNewsItemPosChange(url, divid, masterField, masterId, prevId, nextId, culturetype, notEnableEditPosition, rootClass) {
3282    var $origdiv = $("#" + divid);
3283    var $ajaxloading = $origdiv;
3284    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
3285    $.post(url, {
3286        divid: divid, masterField: masterField, masterId: masterId, prevId: prevId, nextId: nextId, culturetype: culturetype, notEnableEditPosition: notEnableEditPosition,
3287        rootClass: rootClass
3288    }, function (response) {
3289        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3290        if (response) {
3291            if (response.error) {
3292                RBMessage(response.error, "", "", true);
3293                if (!response.changed)
3294                    return;
3295            }
3296            if (response.result) {
3297                var ajaxdiv = $("#" + divid);
3298                ajaxdiv.html(response.result);
3299            }
3300        }
3301    }).fail(function (response) {
3302        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3303        RBAjaxPostError();
3304    });
3305}
3306
3307function RBQuickNewsItemDelete(url, divid, masterField, masterId, newsItemId, culturetype, confirmStr, notEnableEditPosition, rootClass) {
3308    if (confirmStr)
3309        if (!RBConfirm(confirmStr))
3310            return;
3311    var $origdiv = $("#" + divid);
3312    var $ajaxloading = $origdiv;
3313    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
3314    $.post(url, {
3315        divid: divid, masterField: masterField, masterId: masterId, newsItemId: newsItemId, culturetype: culturetype, notEnableEditPosition: notEnableEditPosition,
3316        rootClass: rootClass
3317    }, function (response) {
3318        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3319        if (response) {
3320            if (response.error) {
3321                RBMessage(response.error, "", "", true);
3322                if (!response.changed)
3323                    return;
3324            }
3325            if (response.result) {
3326                var ajaxdiv = $("#" + divid);
3327                ajaxdiv.html(response.result);
3328            }
3329        }
3330    }).fail(function (response) {
3331        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3332        RBAjaxPostError();
3333    });
3334}
3335
3336function RBQuickNewsItemInsertNew(url, divid, masterField, masterId, prevId, nextId, culturetype, notEnableEditPosition, rootClass) {
3337    var $origdiv = $("#" + divid);
3338    var $ajaxloading = $origdiv;
3339    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
3340    $.post(url, {
3341        divid: divid, masterField: masterField, masterId: masterId, prevId: prevId, nextId: nextId, culturetype: culturetype, notEnableEditPosition: notEnableEditPosition,
3342        rootClass: rootClass
3343    }, function (response) {
3344        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3345        if (response) {
3346            if (response.error) {
3347                RBMessage(response.error, "", "", true);
3348                if (!response.inserted)
3349                    return;
3350            }
3351            if (response.result) {
3352                var ajaxdiv = $("#" + divid);
3353                ajaxdiv.html(response.result);
3354            }
3355        }
3356    }).fail(function (response) {
3357        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3358        RBAjaxPostError();
3359    });
3360}
3361
3362function RBLoadNewsItem(url, url2, masterdivid, masterField, masterId, newsItemId, dik, culturetype, notEnableEditPosition, rootClass) {
3363    RBBodyOverlayClick();
3364    var divid = "newsitem-id-" + newsItemId;
3365    var $origdiv = $('.' + divid);
3366    $origdiv.html("");
3367    var $ajaxloading = $origdiv;
3368    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
3369    $.post(url, {
3370        masterField: masterField, newsItemId: newsItemId, masterId: masterId, dik: dik, culturetype: culturetype, rootClass: rootClass
3371    }, function (response) {
3372        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3373        if (response) {
3374            if (response.error) {
3375                RBMessage(response.error, "", "", true);
3376                return;
3377            }
3378            if (response.result) {
3379                var ajaxdiv = $("#" + masterdivid + " ." + divid);
3380                ajaxdiv.html(response.result);
3381            }
3382            else {
3383                RBLoadNewsNewsItems(masterdivid, masterField, masterId, culturetype, notEnableEditPosition);
3384            }
3385        }
3386    }).fail(function (response) {
3387        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3388        RBAjaxPostError();
3389    });
3390}
3391
3392function RBLoadNewsNewsItems(url, divid, masterField, masterId, culturetype, notEnableEditPosition) {
3393    var $origdiv = $("#" + divid);
3394    $origdiv.html("");
3395    var $ajaxloading = $origdiv;
3396    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
3397    $.post(url, {
3398        divid: divid, masterField: masterField, masterId: masterId, culturetype: culturetype, notEnableEditPosition: notEnableEditPosition
3399    }, function (response) {
3400        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3401        if (response) {
3402            if (response.error) {
3403                RBMessage(response.error, "", "", true);
3404                return;
3405            }
3406            var ajaxdiv = $("#" + divid);
3407            ajaxdiv.html(response.result);
3408        }
3409    }).fail(function (response) {
3410        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3411        RBAjaxPostError();
3412    });
3413}
3414
3415function RBLoadReportData(url, azon, divid) {
3416    var $origdiv = $("#" + divid);
3417    $origdiv.html("");
3418    var $ajaxloading = $origdiv;
3419    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
3420    $.post(url, {
3421        azon: azon
3422    }, function (response) {
3423        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3424        if (response) {
3425            if (response.error) {
3426                RBMessage(response.error, "", "", true);
3427                return;
3428            }
3429            var ajaxdiv = $("#" + divid);
3430            ajaxdiv.html(response.result);
3431        }
3432    }).fail(function (response) {
3433        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
3434        RBAjaxPostError();
3435    });
3436}
3437// Form - End
3438
3439// Ajax - Start
3440function RBAjax_AjaxLoadingStart(item, isDiv, ajaxloadingtitle) {
3441    return RBAjax_AjaxLoadingItemStart($(item), isDiv, ajaxloadingtitle);
3442}
3443function RBAjax_AjaxLoadingItemStart($item, isDiv, ajaxloadingtitle) {
3444    $item.addClass("ajax-loading");
3445    if (isDiv)
3446        $item.addClass("ajax-loading-div");
3447    if (ajaxloadingtitle) {
3448        var origTitle = $item.html();
3449        $item.html(ajaxloadingtitle);
3450        return origTitle;
3451    }    
3452}
3453
3454function RBAjax_AjaxLoadingEnd(item, isDiv, origTitle) {
3455    RBAjax_AjaxLoadingItemEnd($(item), isDiv, origTitle);
3456}
3457
3458function RBAjax_AjaxLoadingItemEnd($item, isDiv, origTitle) {
3459    $item.removeClass("ajax-loading");
3460    $item.removeClass("ajax-loading-div");
3461    if (origTitle)
3462        $item.html(origTitle);
3463}
3464
3465function RBInputButtonAjaxStart(divid, ajaxloadingtitle) {
3466    var $origdiv = $('.' + divid);
3467    var $origbuttondiv = $('.' + divid + " .inputbutton");
3468    $origbuttondiv.attr("disabled", "disabled");
3469    var origTitle = $origbuttondiv.val();
3470    $origbuttondiv.val(ajaxloadingtitle);
3471    RBAjax_AjaxLoadingItemStart($origdiv, true);
3472    return origTitle;
3473}
3474
3475function RBInputButtonAjaxEnd(div, origTitle) {
3476    var $origdiv = $('.' + div);
3477    var $origbuttondiv = $('.' + div + " .inputbutton");
3478    RBAjax_AjaxLoadingItemEnd($origdiv, true);
3479    $origbuttondiv.val(origTitle);
3480    $origbuttondiv.removeAttr("disabled");
3481}
3482
3483function RBAjax_ListBoxRefresh(url, listboxidvalue, idvalue, displayazonvalue, titlevalue, pagevalue, sortvalue, shortpagervalue, showtypevalue, searchazonvalue, searchvalue, pagesizevalue) {
3484    $.post(url, {
3485        listboxid: listboxidvalue, id: idvalue, displayazon: displayazonvalue, title: titlevalue, page: pagevalue, sort: sortvalue, shortPager: shortpagervalue, showtype: showtypevalue,
3486        searchazon: searchazonvalue, search: searchvalue, pagesize: pagesizevalue
3487    }, function (response) {
3488        if (response) {
3489            var ajaxdiv = $('#' + listboxidvalue);
3490            ajaxdiv[0].innerHTML = response.result;
3491            if (response.kellajaxrefresh) {
3492                ListBoxAfterAjaxRequest();  // ToDo Egyedi kellene, hogy legyen pl listboxidvalueListBoxAjaxRefresh();
3493            }
3494        }
3495    });
3496};
3497
3498function RBAjax_ListBoxPageOrder(url, listboxidvalue, idvalue, displayazonvalue, titlevalue, pagevalue, sortfield, shortpagervalue, showtypevalue, searchazonvalue, searchvalue, pagesizevalue) {
3499    var sortvalue = $("#" + sortfield).val();
3500    RBAjax_ListBoxRefresh(url, listboxidvalue, idvalue, displayazonvalue, titlevalue, pagevalue, sortvalue, shortpagervalue, showtypevalue, searchazonvalue, searchvalue, pagesizevalue);
3501};
3502
3503function RBAjax_ListBoxPageSize(url, listboxidvalue, idvalue, displayazonvalue, titlevalue, pagevalue, sortvalue, shortpagervalue, showtypevalue, searchazonvalue, searchvalue, pagesizefield) {
3504    var pagesizevalue = $("#" + pagesizefield).val();
3505    RBAjax_ListBoxRefresh(url, listboxidvalue, idvalue, displayazonvalue, titlevalue, pagevalue, sortvalue, shortpagervalue, showtypevalue, searchazonvalue, searchvalue, pagesizevalue);
3506};
3507
3508function RBAjax_ListBoxSearch(url, listboxidvalue, idvalue, displayazonvalue, titlevalue, pagevalue, sortvalue, shortpagervalue, showtypevalue, searchazonvalue, searchfield, pagesizevalue) {
3509    var searchvalue = $("#" + searchfield).val();
3510    RBAjax_ListBoxRefresh(url, listboxidvalue, idvalue, displayazonvalue, titlevalue, pagevalue, sortvalue, shortpagervalue, showtypevalue, "", searchvalue, pagesizevalue);
3511};
3512
3513function RBAjax_ListBoxRefreshIfOnChange(url, listboxidvalue, idvalue, displayazonvalue, titlevalue, pagevalue, sortvalue, shortpagervalue, showtypevalue, searchazonvalue, searchvalue, pagesizevalue, onchangefield, bodyfield) {
3514    $.post(url, {
3515        listboxid: listboxidvalue, id: idvalue, displayazon: displayazonvalue, title: titlevalue, page: pagevalue, sort: sortvalue, shortPager: shortpagervalue, showtype: showtypevalue,
3516        searchazon: searchazonvalue, search: searchvalue, pagesize: pagesizevalue
3517    }, function (response) {
3518        if (response)
3519            if (response.result) {
3520                var ajaxdiv = $('#' + listboxidvalue);
3521                var onchangeorig = $(ajaxdiv).find("." + onchangefield);
3522                if (onchangeorig[0]) {
3523                    var onchangenew = $(response.result).find("." + onchangefield);
3524                    if (onchangenew[0])
3525                        onchangeorig[0].innerHTML = onchangenew[0].innerHTML;
3526                }
3527
3528                // Csak akkor szabad a listát frissíteni, ha az első oldalon van
3529                var ajaxprevdiv = $('#' + listboxidvalue + " .listpager_prevlink");
3530                if (ajaxprevdiv)
3531                    if (!ajaxprevdiv[0] || RBHasClass(ajaxprevdiv[0], "listpager_disabled")) {
3532                        var bodyorig = $(ajaxdiv).find("." + bodyfield);
3533                        if (bodyorig[0]) {
3534                            var bodynew = $(response.result).find("." + bodyfield);
3535                            if (bodynew[0]) {
3536                                bodyorig[0].innerHTML = bodynew[0].innerHTML;
3537                            }
3538                        }
3539                        if (response.kellajaxrefresh) {
3540                            ListBoxAfterAjaxRequest();  // ToDo Egyedi kellene, hogy legyen pl listboxidvalueListBoxAjaxRefresh();                        
3541                        }
3542                    }
3543            }
3544    });
3545};
3546
3547function RBAjax_NewPage(url, listboxidvalue, idvalue, newpagevalue) {
3548    $.post(url, {
3549        listboxid: listboxidvalue, id: idvalue, page: newpagevalue
3550    }, function (response) {
3551        if (response) {
3552            var ajaxdiv = $('#' + listboxidvalue);
3553            ajaxdiv[0].innerHTML = response.result;
3554        }
3555    });
3556};
3557
3558function RBGetMultipleValue(field) {
3559    var result = "";
3560    var items = $(field);
3561    if (items.length > 0) {
3562        for (var i = 1; i <= items.length; i++) {
3563            var item = $(items[i - 1]);
3564            var itemvalue = item.val();
3565            if (itemvalue) {
3566                if (result)
3567                    result += ";";
3568                result += itemvalue;
3569            }
3570        }
3571    }
3572    return result;
3573}
3574
3575function RBAjax_AddComment(url, listboxidvalue, idvalue, commentTypeValue, commentedItemAzonValue, commentedTableAzonValue, commentedIdAzonValue, answerId, commentFieldId) {
3576    var descriptionValue = RBGetValue('#' + listboxidvalue + '-description');
3577    var imageValue = RBGetMultipleValue('.' + listboxidvalue + '-image');
3578    var linkValue = RBGetValue('#' + listboxidvalue + '-link');
3579    var productValue = RBGetValue('#' + listboxidvalue + '-product');
3580    var postasprogramValue = RBGetCheckBoxValue('#' + listboxidvalue + '-postasprogram');
3581    if (descriptionValue || imageValue || linkValue || productValue) {
3582        RBAjax_AjaxLoadingStart('#' + listboxidvalue, false);
3583        SetDisable('#' + listboxidvalue + " .comment_new");
3584        $.post(url, {
3585            listboxid: listboxidvalue, id: idvalue, commentType: commentTypeValue, commentedItemAzon: commentedItemAzonValue, commentedTableAzon: commentedTableAzonValue,
3586            commentedIdAzon: commentedIdAzonValue, description: descriptionValue, image: imageValue, link: linkValue, product: productValue, postasprogram: postasprogramValue,
3587             answerId: answerId
3588        }, function (response) {
3589            RBAjax_AjaxLoadingEnd('#' + listboxidvalue, false);
3590            if (response) {
3591                var ajaxdiv = $('#' + listboxidvalue);
3592                ajaxdiv[0].innerHTML = response.result;
3593            }
3594        }).fail(function (response) {
3595            RBAjax_AjaxLoadingEnd('#' + listboxidvalue, false);
3596            RBAjaxPostError();
3597        });
3598    }
3599};
3600
3601function RBAjax_RBSlider2AddComment(url, rbsliderid, listboxidvalue, idvalue, commentTypeValue, commentedItemAzonValue, commentedTableAzonValue, commentedIdAzonValue, answerId, commentFieldId) {
3602    var descriptionValue = RBGetValue('#' + commentFieldId + ' #' + listboxidvalue + '-description');
3603    var imageValue = RBGetMultipleValue('#' + commentFieldId + ' .' + listboxidvalue + '-image');
3604    var linkValue = RBGetValue('#' + commentFieldId + ' #' + listboxidvalue + '-link');
3605    var productValue = RBGetValue('#' + commentFieldId + '-' + listboxidvalue + '-product');
3606    var postasprogramValue = RBGetCheckBoxValue('#' + commentFieldId + ' #' + listboxidvalue + '-postasprogram');
3607    if (descriptionValue || imageValue || linkValue || productValue) {
3608        RBAjax_AjaxLoadingStart('#' + commentFieldId + ' #' + listboxidvalue, false);
3609        SetDisable('#' + commentFieldId + ' #' + listboxidvalue + " .comment_new");
3610        $.post(url, {
3611            listboxid: listboxidvalue, id: idvalue, commentType: commentTypeValue, commentedItemAzon: commentedItemAzonValue, commentedTableAzon: commentedTableAzonValue,
3612            commentedIdAzon: commentedIdAzonValue, description: descriptionValue, image: imageValue, link: linkValue, product: productValue, postasprogram: postasprogramValue, 
3613            answerId: answerId
3614        }, function (response) {
3615            RBAjax_AjaxLoadingEnd('#' + commentFieldId + ' #' + listboxidvalue, false);
3616            if (response) {
3617                if (response.Error) {
3618                    RBMessage(response.Error);
3619                }
3620                else {
3621                    $('#' + commentFieldId + ' .' + listboxidvalue + '-image').val("");
3622                    $('#' + commentFieldId + ' #' + listboxidvalue + '-link').val("");
3623                    $('#' + commentFieldId + '-' + listboxidvalue + '-product').val("");
3624                    $('#' + commentFieldId + '-' + listboxidvalue + '-product_Label').val("");
3625                    $('#' + commentFieldId + ' #' + listboxidvalue + '-description').val("").keyup();
3626                    $('#' + commentFieldId + ' #' + listboxidvalue + '-image-close').click();
3627                    $('#' + commentFieldId + ' #' + listboxidvalue + '-link-close').click();
3628                    $('#' + commentFieldId + ' #' + listboxidvalue + '-product-close').click();
3629                    SetVisible('#' + commentFieldId + ' #' + listboxidvalue + " .comment_new");
3630                    FireRefreshEventHandler(rbsliderid, "-1", "Reload");
3631                    $(".comment_answer_new").html("");
3632                }
3633            }
3634        }).fail(function (response) {
3635            RBAjax_AjaxLoadingEnd('#' + commentFieldId + ' #' + listboxidvalue, false);
3636            RBAjaxPostError();
3637        });
3638    }
3639};
3640
3641function RBSetCommentButtonEnabled(buttonid, commentedItemAzonValue, commentFieldId) {
3642    var memoid = "commentlistboxid-description";
3643    $('#' + commentFieldId + ' #' + memoid).keyup(function () {
3644        var memovalue = RBGetValue('#' + commentFieldId + ' #' + memoid);
3645        if (memovalue) {
3646            if ($(document).find(buttonid).hasClass("commentbutton-disabled")) {
3647                RBRemoveClass('#' + commentFieldId + ' ' + buttonid, "commentbutton-disabled");
3648            }
3649        }
3650        else {
3651            if (!$(document).find('#' + commentFieldId + ' ' + buttonid).hasClass("commentbutton-disabled")) {
3652                RBAddClass('#' + commentFieldId + ' ' + buttonid, "commentbutton-disabled");
3653            }
3654        }
3655    });   
3656}
3657
3658function RBAjax_NewsCommentListBoxRefresh(url, listboxidvalue, commentedItemAzonvalue, titlevalue, commentTypevalue, actPagevalue, pageSizevalue, displayAzonvalue) {
3659    $.post(url, {
3660        listboxid: listboxidvalue, commentedItemAzon: commentedItemAzonvalue, title: titlevalue, commentType: commentTypevalue, actPage: actPagevalue, pageSize: pageSizevalue, displayAzon: displayAzonvalue
3661    }, function (response) {
3662        if (response) {
3663            var ajaxdiv = $('#' + listboxidvalue);
3664            ajaxdiv[0].innerHTML = response.result;
3665            if (response.kellajaxrefresh) {
3666                ListBoxAfterAjaxRequest();  // ToDo Egyedi kellene, hogy legyen pl listboxidvalueListBoxAjaxRefresh();
3667            }
3668        }
3669    });
3670};
3671
3672function RBAjax_CreateAnswer(url, idvalue, fieldvalue, rootClass, sliderId, commentlistboxid) {
3673    var answerHtml = $('#' + fieldvalue).html();
3674    $(".comment_answer_new").html("");
3675    if (answerHtml)
3676        if (answerHtml.includes("<"))
3677            return;
3678    $.post(url, {
3679        id: idvalue, rootClass: rootClass, sliderId: sliderId
3680    }, function (response) {
3681        if (response) {
3682            if (response.error) {
3683                RBMessage(response.error, "", "", true);
3684                return;
3685            }
3686            if (response.result) {
3687                $('#' + fieldvalue).html(response.result);
3688                if (response.commentfieldid)
3689                    $('#' + response.commentfieldid + ' #' + commentlistboxid + "-description").focus();
3690            }
3691        }
3692    });
3693};
3694
3695function RBAjax_DeleteComment(url, idvalue, fieldvalue, userName) {
3696    if (!RBConfirm("Törölhetjük " + userName + " bejegyzését"))
3697        return;
3698    $.post(url, {
3699        id: idvalue
3700    }, function (response) {
3701        if (response) {
3702            if (response.result) {
3703                SetDisable('.' + fieldvalue);
3704            }
3705        }
3706    });
3707};
3708
3709function RBAjax_UserAction(url, userName) {
3710    $.post(url, {
3711        userName: userName
3712    }, function (response) {
3713        if (response) {
3714            if (response.message) {
3715                RBMessage(response.message);
3716            }
3717        }
3718    });
3719};
3720
3721function RBAjax_UserBan(url, message, userName, fieldvalue, deleteComments, deleteUser) {
3722    if (message)
3723        if (!RBConfirm(message))
3724            return;
3725    $.post(url, {
3726        userName: userName, deleteComments: deleteComments, deleteUser: deleteUser
3727    }, function (response) {
3728        if (response) {
3729            if (response.message) {
3730                RBMessage(response.message);
3731                if (fieldvalue)
3732                    SetDisable('.' + fieldvalue);
3733            }
3734        }
3735    });
3736};
3737
3738function RBAjax_MembershipPropertyAction(url, displayitem, code, fieldname, fieldvalue, propertyvalue, isdelete) {
3739    $.post(url, {
3740        code: code, fieldname: fieldname, fieldvalue: fieldvalue, propertyvalue: propertyvalue, isdelete: isdelete
3741    }, function (response) {
3742        if (response.error != '') {
3743            RBMessage(response.error);
3744            return;
3745        }
3746        if (isdelete == "1") {
3747            $(displayitem).removeClass("membershipuserproperty_status_on").addClass("membershipuserproperty_status_off");
3748        }
3749        else {
3750            $(displayitem).removeClass("membershipuserproperty_status_off").addClass("membershipuserproperty_status_on");
3751        }
3752        if (response.message != '') {
3753            RBMessage(response.message);
3754        }
3755    });
3756}
3757
3758function RBAjax_GenNewCaptcha(url, actionid) {
3759    RBAjax_GenNewCaptchaFocus(url, actionid, true);
3760}
3761
3762function RBAjax_GenNewCaptchaFocus(url, actionid, setfocus) {
3763    $.post(url, {
3764        actionId: actionid
3765    }, function (response) {
3766        if (response.message != '') {
3767            var imageid = actionid + "_captcha";
3768            var image = $('#' + imageid);
3769            image[0].src = response.message;
3770            try {
3771                var captchafield = $('.input-captcha');
3772                if (captchafield) {
3773                    captchafield[0].value = "";
3774                    if (setfocus)
3775                        $(captchafield).focus();
3776                }
3777            }
3778            catch (ex) { }
3779        }
3780    });
3781    return false;
3782}
3783
3784function RBAjax_GetFBShareCount(url, div) {
3785    $.getJSON('http://graph.facebook.com/' + url, function (data) {
3786        if (data)
3787            $(div).html(data.share.share_count);
3788    });
3789}
3790
3791function RBAjax_GetFBShareCountNew(url, div) {
3792    $.getJSON('https://api.facebook.com/method/links.getStats?urls="' + url + '"&format=json', function (data) {
3793        if (data[0])
3794            $(div).html(data[0].share_count);
3795    });
3796}
3797
3798function RBAjax_GetFBLikeCountNew(url, div) {
3799    $.getJSON('https://api.facebook.com/method/links.getStats?urls="' + url + '"&format=json', function (data) {
3800        if (data[0])
3801            $(div).html(data[0].like_count);
3802    });
3803}
3804
3805// https: //api.facebook.com/method/links.getStats?urls=%22http://www.pmfc.hu/hir/vegre-a-helyen-van%22&format=json
3806
3807function RBAjax_GetFBShareCountFBId(id, div) {
3808    $.getJSON('http://graph.facebook.com/' + id + "?fields=shares", function (data) {
3809        /*var fb_likes = addCommas(data.likes);
3810        $('#fb-likes-count').text(fb_likes);*/
3811        if (data)
3812            if (data.shares)
3813                if (data.shares.count)
3814                    $(div).html(data.shares.count);
3815    });
3816}
3817
3818function RBAjax_GetFBLikeCountFBId(id, div, accesstoken, useraccesstoken) {
3819    $.getJSON('https://graph.facebook.com/' + id + "/likes?access_token=" + accesstoken + "&summary=true&fields=summary&limit=1", function (data) {
3820        if (data)
3821            if (data.summary)
3822                if (data.summary.total_count) {
3823                    $(div).html(data.summary.total_count);
3824                    if (useraccesstoken) {
3825                        $.getJSON('https://graph.facebook.com/me/likes/' + id + "?access_token=" + useraccesstoken, function (data) {
3826                            if (data)
3827                                if (data.length == 1)
3828                                    $(div).html((data.summary.total_count - 1) + " +Én");
3829                        });
3830                    }
3831                }
3832    });
3833}
3834
3835function RBPopupFBLikeShare(div, url, likeurl) {
3836    $.post(url, {
3837        div: div, likeurl: likeurl
3838    }, function (response) {
3839        if (response.error != '') {
3840            RBMessage(response.error);
3841            return;
3842        }
3843        RBBodyOverlayClick();
3844        $("." + div).html(response.data);
3845        RBBodyOverlayOn();
3846    });
3847}
3848
3849
3850function RBAjax_FBRefresh() {
3851    try {
3852        FB.XFBML.parse();
3853    } catch (ex) { }
3854
3855    try {
3856        if (twttr)
3857            twttr.widgets.load();
3858    } catch (ex) { }
3859
3860    try {
3861        if (gapi)
3862            gapi.plusone.go();
3863    } catch (ex) { }
3864}
3865
3866$(document).ajaxComplete(function () {
3867    RBAjax_FBRefresh();
3868});
3869
3870function RBAjax_InitLightBoxRefresh(element) {
3871    if (!element.getElementsByTagName) { return; }
3872    var anchors = element.getElementsByTagName("a");
3873
3874    // loop through all anchor tags
3875    for (var i = 0; i < anchors.length; i++) {
3876        var anchor = anchors[i];
3877
3878        if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "lightbox")) {
3879            anchor.onclick = function () { showLightbox(this); return false; }
3880        }
3881    }
3882}
3883
3884function RBAjax_RBSliderGotoPage(rbslider2id, dik, desktoppagesize, tabletpagesize, mobilepagesize, masterclass, itemclass, selectedclass) {
3885    if (itemclass) {
3886        $("." + masterclass + " ." + itemclass).removeClass(selectedclass);
3887        $("." + masterclass + " ." + itemclass + "-" + dik).addClass(selectedclass);
3888    }
3889    var pagesize = desktoppagesize;
3890    if (RBMediaState == "Tablet")
3891        pagesize = tabletpagesize;
3892    if (RBMediaState == "Mobile")
3893        pagesize = mobilepagesize;
3894    var pageNum = dik;
3895    if (pagesize > 1)
3896        pageNum = Math.floor(dik / pagesize);
3897    FireRefreshEventHandler(rbslider2id, "GotoPage", pageNum);
3898}
3899
3900function RBAjax_SetRBSliderSort(displayazon, sortazon, rbslider2id) {
3901    $.post('/Home/SetRBSliderSort', {
3902        displayazon: displayazon, sortazon: sortazon, rbslider2id: rbslider2id
3903    }, function (response) {
3904        RBBodyOverlayClick();
3905        if (response) {
3906            if (response.error) {
3907                RBMessage(response.error);
3908                return;
3909            }
3910            if (rbslider2id)
3911                FireRefreshEventHandler(rbslider2id, "Reload", "");
3912        }
3913    });
3914}
3915
3916function RBAjax_RBSliderSortComboChange(item, displayazon, rbslider2id, url) {
3917    var comboitem = $(item);
3918    var val = comboitem.val();
3919    $.post('/Home/SetRBSliderSort', {
3920        displayazon: displayazon, sortazon: val, rbslider2id: rbslider2id
3921    }, function (response) {
3922        RBBodyOverlayClick();
3923        if (response) {
3924            if (response.error) {
3925                RBMessage(response.error);
3926                return;
3927            }
3928            if (rbslider2id) {
3929                FireRefreshEventHandler(rbslider2id, "Reload", "");
3930            }
3931            else {
3932                if (url)
3933                    location.href = url;
3934            }
3935        }
3936    });
3937}
3938
3939function RBAjax_SetRBSliderSearchField(displayazon, field, rbslider2id) {
3940    var value = RBGetValue("#" + field);
3941    $.post('/Home/SetRBSliderSearch', {
3942        displayazon: displayazon, field: field, value: value
3943    }, function (response) {
3944        if (response) {
3945            if (response.error) {
3946                RBMessage(response.error);
3947                return;
3948            }
3949            if (rbslider2id)
3950                FireRefreshEventHandler(rbslider2id, "Reload", "");
3951        }
3952    });
3953}
3954
3955function RBAjaxDivAction(id, div, azon, data, tabitem, thisitem, selecteditem) {
3956    RBAjax_AjaxLoadingStart("#" + id + " ." + div, false);
3957    $.post("/Home/RBAjaxDivAction", {
3958        azon: azon, data: data
3959    }, function (response) {
3960        RBAjax_AjaxLoadingEnd("#" + id + " ." + div, false);
3961        if (response) {
3962            if (response.error) {
3963                RBMessage(response.error, "", "", true);
3964                return;
3965            }
3966            if (tabitem && selecteditem) {
3967                $("#" + id + " ." + tabitem).removeClass(selecteditem);
3968                $("#" + id + " ." + thisitem).addClass(selecteditem);
3969            }
3970            $("#" + id + " ." + div).html(response.work);
3971        }
3972    }).fail(function (response) {
3973        RBAjax_AjaxLoadingEnd("#" + id + " ." + div, false);
3974        RBAjaxPostError();
3975    });
3976}
3977
3978function RBSelectNextEventsDay(fullid, listsliderid, dayazon, eventid, clicktype) {
3979    $("#" + fullid + " .rb-nexteventsdaytab-day").removeClass("rb-nexteventsdaytab-day-selected");
3980    $("#" + fullid + " .rb-nexteventsdaytab-day-" + dayazon).addClass("rb-nexteventsdaytab-day-selected");
3981    $("#" + fullid + " .rb-nexteventsdaytab-preview").addClass("disableitem");
3982    $("#" + fullid + " .rb-nexteventsdaytab-preview-" + eventid).removeClass("disableitem");
3983    FireRefreshEventHandler(listsliderid, "Select", eventid);
3984}
3985
3986/* CropImage - Start */
3987function RBCropInit(field, width, height) {
3988    var image = RBGetValue("#" + field);
3989    if (!image) {
3990        RBSpecBodyOverlayOff(1);
3991        return;
3992    }
3993
3994    var img = document.getElementById("rb-cropimage-target");
3995    if (!img) {
3996        RBSpecBodyOverlayOff(1);
3997        return;
3998    }
3999    img.src = image;
4000    var imgwidth = $(img).width();
4001    var imgheight = $(img).height();
4002    if ((imgwidth == 0) || (imgheight == 0)) {
4003        RBSpecBodyOverlayOff(1);
4004        return;
4005    }
4006    if (((width > 0) && (imgwidth < width)) || ((height > 0) && (imgheight < height))) {
4007        RBMessage('Nem megfelelő  kép mérete!');
4008        RBSpecBodyOverlayOff(1);
4009    }
4010    $('#rb-cropimage-coord-desc-w').html(width);
4011    $('#rb-cropimage-coord-desc-h').html(height);
4012    $('#rb-cropimage-coord-orig-w').html(imgwidth);
4013    $('#rb-cropimage-coord-orig-h').html(imgheight);
4014    if ((imgwidth == width) && (imgheight == height)) {
4015        RBMessage('A kép pont méretre van már vágva!');
4016        RBSpecBodyOverlayOff(1);
4017        return;
4018    }
4019    var sizechange = false;
4020    if ((imgwidth + 300) > RBGetWindowsWidth()) {
4021        var widthratio = RBGetWindowsWidth() / (imgwidth + 300);
4022        imgwidth = imgwidth * widthratio;
4023        imgheight = imgheight * widthratio;
4024        width = width * widthratio;
4025        height = height * widthratio;
4026        sizechange = true;
4027    }
4028    if ((imgheight + 400) > RBGetWindowsHeight()) {
4029        var heighratio = RBGetWindowsHeight() / (imgheight + 400);
4030        imgwidth = imgwidth * heighratio;
4031        imgheight = imgheight * heighratio;
4032        width = width * heighratio;
4033        height = height * heighratio;
4034        sizechange = true;
4035    }
4036    if (sizechange) {
4037        $(img).width(imgwidth);
4038        $(img).height(imgheight);
4039    }
4040
4041    //$(".rb-fullscreen").css('width', RBGetWindowsWidth() + 'px');
4042    //$(".rb-fullscreen").css('height', RBGetWindowsHeight() + 'px');
4043
4044    //if (imgwidth < 240)
4045    //  imgwidth = 240;
4046    //if (imgheight < 200)
4047    //  imgheight = 200;
4048    //$(".inputpage_textimage_crop .popup_panel").css({ width: (imgwidth + 60) + 'px', height: (imgheight + 60 + 60) + 'px',
4049    //'margin-left': -((imgwidth + 60) / 2) + 'px', 'margin-top': -((imgheight + 60 + 60) / 2) + 'px'
4050    //});
4051    var ratio = 0;
4052    if (height > 0)
4053        ratio = width / height;
4054    var selwidth = imgwidth;
4055    var selheight = 0;
4056    if (ratio != 0)
4057        selheight = selwidth / ratio;
4058    if (selheight > imgheight) {
4059        selheight = imgheight;
4060        selwidth = selheight * ratio;
4061    }
4062    var minWidth = width;
4063    var minHeight = height;
4064    if (minWidth == 0)
4065        minWidth = 10;
4066    if (minHeight == 0)
4067        minHeight = 10;
4068    if (selwidth == 0)
4069        selwidth = 50;
4070    if (selheight == 0)
4071        selheight = 50;
4072
4073    $('#rb-cropimage-target').Jcrop({
4074        setSelect: [0, 0, selwidth, selheight],
4075        minSize: [minWidth, minHeight],
4076        aspectRatio: ratio,
4077        onChange: RBCropShowCoords,
4078        onSelect: RBCropShowCoords
4079    });
4080
4081    // $pcnt.css({ width: xsize + 'px', height: ysize + 'px' });
4082    // $pimg.css({ width: xsize + 'px', height: ysize + 'px' });
4083}
4084
4085function RBCropShowCoords(c) {
4086    $('#rb-cropimage-coord-x1').html(c.x);
4087    $('#rb-cropimage-coord-y1').html(c.y);
4088    $('#rb-cropimage-coord-x2').html(c.x2);
4089    $('#rb-cropimage-coord-y2').html(c.y2);
4090    $('#rb-cropimage-coord-w').html(c.w);
4091    $('#rb-cropimage-coord-h').html(c.h);
4092};
4093
4094function RBCropImageSave(field) {
4095    x1 = $('#rb-cropimage-coord-x1').html();
4096    y1 = $('#rb-cropimage-coord-y1').html();
4097    x2 = $('#rb-cropimage-coord-x2').html();
4098    y2 = $('#rb-cropimage-coord-y2').html();
4099    w = $('#rb-cropimage-coord-w').html();
4100    h = $('#rb-cropimage-coord-h').html();
4101    origwidth = $('#rb-cropimage-coord-orig-w').html();
4102    origheight = $('#rb-cropimage-coord-orig-h').html();
4103    descwidth = $('#rb-cropimage-coord-desc-w').html();
4104    descheight = $('#rb-cropimage-coord-desc-h').html();
4105    imgwidth = 0;
4106    imgheight = 0;
4107    var img = document.getElementById("rb-cropimage-target");
4108    if (img) {
4109        imgwidth = $(img).width();
4110        imgheight = $(img).height();
4111    }
4112
4113    image = RBGetValue("#" + field);
4114
4115    $.post("/FileUpload/ImageCropSave", {
4116        image: image, x1: x1, y1: y1, x2: x2, y2: y2, width: w, height: h, origwidth: origwidth, origheight: origheight, imgwidth: imgwidth, imgheight: imgheight,
4117        descwidth: descwidth, descheight: descheight
4118    }, function (response) {
4119        if (response) {
4120            if (response.error) {
4121                RBMessage(response.error);
4122                return false;
4123            }
4124            if (response.image) {
4125                RBSetValueChange("#" + field, response.image);
4126                RBSpecBodyOverlayOff(1);
4127            }
4128        }
4129    });
4130}
4131/* CropImage - End */
4132
4133/* WaterMarkImage - Start */
4134function RBCreateWaterMarkImage(url, field) {
4135    var image = RBGetValue("#" + field);
4136    RBAjax_AjaxLoadingStart("#" + field, false);
4137    $.post(url, {
4138        image: image
4139    }, function (response) {
4140        RBAjax_AjaxLoadingEnd("#" + field, false);
4141        if (response) {
4142            if (response.error) {
4143                RBMessage(response.error, "", "", true);
4144                return;
4145            }
4146            RBSetValueChange("#" + field, response.image);
4147        }
4148    }).fail(function (response) {
4149        RBAjax_AjaxLoadingEnd("#" + field, false);
4150        RBAjaxPostError();
4151    });
4152}
4153/* WaterMarkImage - End */
4154
4155/* Video - Start */
4156var loadtryyoutubeplayer = 0;
4157var startnewvideoafterload = 0;
4158var youtubeplayers = {}
4159
4160function RBAjax_VideoGallery(url, idvalue, galleryidvalue, titlevalue, actimagevalue, imagegrouptypevalue, fromitemvalue, itemcountvalue, showNameOnPreviewvalue,
4161   isAjaxOnlyThumbRequestvalue, widthvalue, heightvalue, actualDataOnTopValue, dik, autoplay, listplay, detailMediaType) {
4162    $.post(url, {
4163        id: idvalue, galleryid: galleryidvalue, title: titlevalue, actimage: actimagevalue, imagegrouptype: imagegrouptypevalue,
4164        fromitem: fromitemvalue, itemcount: itemcountvalue, showNameOnPreview: showNameOnPreviewvalue, isAjaxOnlyThumbRequest: isAjaxOnlyThumbRequestvalue,
4165        width: widthvalue, height: heightvalue, actualDataOnTop: actualDataOnTopValue, autoplay: autoplay, listplay: listplay, detailMediaType: detailMediaType
4166    }, function (response) {
4167        if (response) {
4168            if (isAjaxOnlyThumbRequestvalue == "1") {
4169                var thumbdiv = $('#' + galleryidvalue + ' .videogallery-previewitems-full');
4170                thumbdiv.html(response.result);
4171                RB_YouTubePlayerSetActualInPreviewPanel(galleryidvalue);
4172                if (autoplay)
4173                    if (startnewvideoafterload == 1)
4174                        RB_YouTubePlayerAutoStart(galleryidvalue);
4175            }
4176            else {
4177                if (response.result) {
4178                    var ajaxdiv = $('#' + galleryidvalue);
4179                    var $result = $("<div>" + response.result + "</div>");
4180                    ajaxdiv.find(".videogallery-right").html($result.find(".videogallery-right").html());
4181                    ajaxdiv.find(".videogallery-left-data").html($result.find(".videogallery-left-data").html());
4182                    ajaxdiv.find(".videogallery-left-ext").html($result.find(".videogallery-left-ext").html());
4183
4184                    var videoplayerid = "youtubeplayer_videoplayerid";
4185
4186                    var videoid = $result.find(".videogallery-actual-video").data("videoid");
4187                    if (videoid) {
4188                        var ytplayer = youtubeplayers[videoplayerid];
4189                        if (ytplayer) {
4190                            ytplayer.loadVideoById(videoid);
4191                            if (autoplay == "1")
4192                                ytplayer.playVideo();
4193                        }
4194                    }
4195
4196                    /*ajaxdiv.html(response.result);*/
4197                    $('#' + galleryidvalue + ' .videogallery-previewitem-selected').removeClass("videogallery-previewitem-selected");
4198                    $('#' + galleryidvalue + ' .videogallery-previewitem').eq(dik).addClass("videogallery-previewitem-selected");
4199                }
4200            }
4201        }
4202    });
4203};
4204
4205function RB_Alert(kakukk) {
4206    RBMessage(kakukk);
4207}
4208
4209function RB_NewVideoGallery(url, galleryidvalue, actimagevalue, imagegrouptypevalue, fromitemvalue, itemcountvalue, showNameOnPreviewvalue,
4210   isAjaxOnlyThumbRequestvalue, widthvalue, heightvalue, actualDataOnTopValue, dik, autoplay, listplay, detailMediaType) {
4211    var idvalue = "";
4212    var titlevalue = "";
4213    var ajaxdiv = $('#' + galleryidvalue);
4214    idvalue = ajaxdiv.data("newlistid");
4215    RBAjax_VideoGallery(url, idvalue, galleryidvalue, titlevalue, actimagevalue, imagegrouptypevalue, fromitemvalue, itemcountvalue,
4216        showNameOnPreviewvalue, isAjaxOnlyThumbRequestvalue, widthvalue, heightvalue, actualDataOnTopValue, dik, autoplay, listplay, detailMediaType);
4217}
4218
4219function RB_LoadNewVideoListToGallery(galleryid, id) {
4220    var $gallery = $('#' + galleryid);
4221    $gallery.data("newlistid", id);
4222    
4223    $newlistbutton = $gallery.find(".videogallery-newlistbutton");
4224    if ($newlistbutton) {
4225        if ($newlistbutton.length > 0)
4226            $newlistbutton[0].click();
4227    }
4228}
4229
4230function RB_YouTubePlayerSetActualInPreviewPanel(playerId) {
4231    $videoplayer = $(document).find("#" + playerId);
4232    if ($videoplayer) {
4233        var videoId;
4234
4235        $actualvideo = $videoplayer.find(".videogallery-actual-video");
4236        if ($actualvideo)
4237            videoId = $actualvideo.data("videoid");
4238
4239        if (videoId) {
4240            $videogallery = $videoplayer.find(".videogallery-previewitems");
4241            if ($videogallery) {
4242                $previewitems = $videogallery.children();
4243                if ($previewitems.length == 0)
4244                    return;
4245                for (var i = 1; i <= $previewitems.length; i++) {
4246                    var previewvideo = $($previewitems[i - 1]);
4247                    var previewvideoid = previewvideo.data("videoid");
4248                    if (previewvideoid == videoId) {
4249                        previewvideo.addClass('videogallery-previewitem-selected');
4250                    }
4251                }
4252            }
4253        }
4254    }
4255}
4256
4257function RB_YouTubeAPIReady(playerId, videoId, height, width, autoplay, loop, starttime, stateChangeFunc) {
4258    if (YT.loaded == 0) {
4259        loadtryyoutubeplayer++;
4260        if (loadtryyoutubeplayer > 20)
4261            return;
4262        setTimeout(function () {
4263            RB_YouTubeAPIReady(playerId, videoId, height, width, autoplay, loop, starttime, stateChangeFunc);
4264        }
4265        , 100);
4266        return;
4267    }
4268    loadtryyoutubeplayer = 0;
4269    var events = {};
4270    if (stateChangeFunc)
4271        events = {
4272            'onStateChange': stateChangeFunc
4273        };
4274    if (RBMediaState == "Mobile")
4275        autoplay = 0;
4276    var player = new YT.Player(playerId, {
4277        height: height,
4278        width: width,
4279        videoId: videoId,
4280        playerVars: { 'autoplay': autoplay, 'start': starttime, wmode: "opaque", 'loop': loop, 'playlist': videoId },
4281        events: events
4282    });
4283    youtubeplayers[playerId] = player;
4284}
4285
4286function RB_YouTubePlayerAutoStart(playerId) {
4287    startnewvideoafterload = 0;
4288
4289    $videogallerymain = $(document).find("#" + playerId);
4290    $videogallery = $videogallerymain.find(".videogallery-previewitems");
4291    if ($videogallery) {
4292        $previewitems = $videogallery.children();
4293        if ($previewitems.length == 0)
4294            return;
4295        $previewitems[0].click();
4296    }
4297}
4298
4299function RB_YouTubePlayerStateChange(playerId, playlistid, event) {
4300    if (event.data == 0) {
4301        $videogallerymain = $(document).find("#" + playlistid);
4302        $videogallery = $videogallerymain.find(".videogallery-previewitems");
4303        if ($videogallery) {
4304            RB_VideoGalleryPlayPrevNext($videogallery, true);
4305        }
4306    }
4307}
4308
4309function RB_VideoGalleryPlayPrev() {
4310    $videogallery = $(document).find(".videogallery-previewitems");
4311    if ($videogallery) {
4312        RB_VideoGalleryPlayPrevNext($videogallery, false);
4313    }
4314}
4315
4316function RB_VideoGalleryPlayNext() {
4317    $videogallery = $(document).find(".videogallery-previewitems");
4318    if ($videogallery) {
4319        RB_VideoGalleryPlayPrevNext($videogallery, true);
4320    }
4321}
4322
4323function RB_VideoGalleryPlayPrevNext($videogallery, isNext) {
4324    if ($videogallery) {
4325        startnewvideoafterload = 0;
4326        $previewitems = $videogallery.children();
4327        if ($previewitems.length == 0)
4328            return;
4329        var actual;
4330        var newactual;
4331        var prev;
4332        for (var i = 1; i <= $previewitems.length; i++) {
4333            if (actual) {
4334                newactual = $previewitems[i - 1];
4335                break;
4336            }
4337            if (RBHasClass($previewitems[i - 1], 'videogallery-previewitem-selected')) {
4338                actual = $previewitems[i - 1];
4339                if (!isNext) {
4340                    newactual = prev;
4341                    break;
4342                }
4343            }
4344            prev = $previewitems[i - 1];
4345        }
4346        if (newactual) {
4347            newactual.click();
4348        }
4349        else {
4350            if (actual) {
4351                var $prevnextitem;
4352                if (isNext)
4353                    $prevnextitem = $videogallerymain.find(".videogallery-previewitem-next-activ");
4354                else
4355                    $prevnextitem = $videogallerymain.find(".videogallery-previewitem-prev-activ");
4356                if ($prevnextitem && ($prevnextitem.length != 0)) {
4357                    startnewvideoafterload = 1;
4358                    $prevnextitem.click();
4359                }
4360                else {
4361                    RBSetCookie("VideoGallery_CurrentImage", "", 0);
4362                }
4363            }
4364            else {
4365                RBSetCookie("VideoGallery_CurrentImage", "", 0);
4366            }
4367        }
4368    }
4369}
4370
4371function RB_LoadDivVideo(div, playerid, videoId, autoplay) {
4372    $(document).find(div).html("<div id='" + playerid + "' class='youtubeplayer'></div>");
4373    RB_YouTubeAPIReady(playerid, videoId, '355px', '425px', autoplay, 0, '', '');
4374}
4375
4376function RB_StopDivVideo(div) {
4377    $(document).find(div).html("");
4378}
4379
4380function RBStopAllVideo() {
4381    var videos = document.querySelectorAll('iframe, video');
4382    Array.prototype.forEach.call(videos, function (video) {
4383        if (video.tagName.toLowerCase() === 'video') {
4384            video.pause();
4385        } else {
4386            var src = video.src;
4387            video.src = src;
4388        }
4389    });
4390}
4391
4392/* Video - End */
4393
4394function RBAjax_LoadDiv(url, divid, extparamfield, focus, fieldname) {
4395    var $origdiv = $('#' + divid);
4396    $origdiv.html("");
4397    var $ajaxloading = $origdiv.parent();
4398    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
4399    extparamsvalue = "";
4400    if (extparamfield) {
4401        var isradio = false;
4402        if (extparamfield.length > 6)
4403            if (extparamfield.substring(0, 6) == 'radio-') {
4404                isradio = true;
4405                extparamfield = extparamfield.substring(6);
4406            }
4407        if (isradio)
4408            extparamsvalue = RBRadioGetValue(extparamfield);
4409        else
4410            extparamsvalue = RBGetValue(extparamfield);
4411    }
4412    fieldvalue = "";
4413    if (fieldname)
4414        fieldvalue = RBGetValue(fieldname);
4415    $.post(url, {
4416        extparams: extparamsvalue, fieldvalue: fieldvalue, mediaState: RBMediaState, orientationState: RBOrientationState
4417    }, function (response) {
4418        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
4419        if (response) {
4420            $origdiv.html(response);
4421            //$('#' + divid).click(function (event) {
4422            // event.stopPropagation();
4423            //});
4424            if (response.indexOf('.focus()') < 0)
4425                $origdiv.focus();
4426            if (focus)
4427                SetFocus(focus);
4428            try {
4429                RBAjaxLoadDivInit();
4430            }
4431            catch (ex) { }
4432        }
4433        else {
4434            RBBodyOverlayClick();
4435        }
4436    }).fail(function (response) {
4437        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
4438        RBAjaxPostError();
4439    });
4440}
4441
4442function RBAjax_LoadDivAnimate(url, divid, extparamfield, focus, animateSpeed, width) {
4443    var $origdiv = $('#' + divid);
4444    $origdiv.html("");
4445    $origdiv.css('width', "");
4446    SetVisible('#' + divid);
4447    $origdiv.animate({ width: width }, animateSpeed, function () {
4448        // Animation complete.
4449        RBAjax_LoadDiv(url, divid, extparamfield, focus);
4450    });
4451}
4452
4453function RBAjax_LoadChildDiv(url, id, divid, extparamfield, focus, urlChange) {
4454    RBUrlChangedOff();
4455    var $origdiv = $('#' + divid);
4456    $origdiv.html("");
4457    var $ajaxloading = $origdiv.parent();
4458    if ($ajaxloading)
4459        $ajaxloading = $ajaxloading.parent();
4460    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
4461    extparamsvalue = "";
4462    if (extparamfield)
4463        extparamsvalue = RBGetValue(extparamfield);
4464    $.post(url, {
4465        id: id, extparams: extparamsvalue, mediaState: RBMediaState, orientationState: RBOrientationState
4466    }, function (response) {
4467        RBAjax_AjaxLoadingEnd($ajaxloading, true);
4468        if (response) {
4469            $origdiv.html(response);
4470            //$('#' + divid).click(function (event) {
4471            // event.stopPropagation();
4472            //});
4473            if (urlChange) {
4474                RBChangeUrl("111", urlChange);
4475                RBAddClass('#' + divid, "rb-urlchanged");
4476            }
4477            if (response.indexOf('.focus()') < 0)
4478                $origdiv.focus();
4479            if (focus)
4480                SetFocus(focus);
4481            try {
4482                RBAjaxLoadDivInit();
4483            }
4484            catch (ex) { }
4485        }
4486        else {
4487            RBBodyOverlayClick();
4488        }
4489    }).fail(function (response) {
4490        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
4491        RBAjaxPostError();
4492    });
4493}
4494
4495function RBAjax_LoadPartial(url, id, divid, extparamsvalue, extparamfield) {
4496    var $origdiv = $('#' + divid);
4497    $origdiv.html("");
4498    var $ajaxloading = $origdiv.parent();
4499    if ($ajaxloading)
4500        $ajaxloading = $ajaxloading.parent();
4501    RBAjax_AjaxLoadingItemStart($ajaxloading, true);
4502    if (extparamfield)
4503        extparamsvalue = RBGetValue(extparamfield);
4504    $.post(url, {
4505        id: id, extparams: extparamsvalue, mediaState: RBMediaState, orientationState: RBOrientationState
4506    }, function (response) {
4507        RBAjax_AjaxLoadingEnd($ajaxloading, true);
4508        if (response) {
4509            if (response.error)
4510                RBMessage(response.error);
4511            else
4512                $origdiv.html(response.result);
4513        }
4514    }).fail(function (response) {
4515        RBAjax_AjaxLoadingItemEnd($ajaxloading, true);
4516        RBAjaxPostError();
4517    });
4518}
4519
4520function RBLogger(message) {
4521    url = "/Home/JSLogger";
4522    $.post(url, {
4523        message: message
4524    });
4525};
4526
4527function RBSetSliderFilterParam(rbslider2id, azon, param, value, field, rbslider, filtersId, rbsliderchild, onofffieldid, clearfield) {
4528    if (field) {
4529        value = RBGetValue('#' + field);
4530    }
4531    if (filtersId) {
4532        $('#' + filtersId + ' .rbslider-headerfilter-item_selected').removeClass("rbslider-headerfilter-item_selected");
4533        var filtervalue = value;
4534        if (!filtervalue)
4535            filtervalue = "all";
4536        $('#' + filtersId + ' .rbslider-headerfilter-item_' + filtervalue).addClass("rbslider-headerfilter-item_selected");
4537    }
4538    if (onofffieldid) {
4539        value = "1";
4540        if ($('#' + onofffieldid).hasClass("rbslider-headerfilter-item_selected"))
4541            value = "0";
4542    }
4543    $.post('/Home/SetSliderFilterParam', {
4544        rbslider2id: rbslider2id, azon: azon, param: param, value: value
4545    }, function (response) {
4546        if (response) {
4547            if (response.error)
4548                RBMessage(response.error);
4549            else {
4550                if (rbslider) {
4551                    FireRefreshEventHandler(rbslider, "Reload", "");
4552                    if (rbsliderchild)
4553                        FireRefreshEventHandler(rbsliderchild, "Reload", "");
4554                }
4555                if (onofffieldid) {
4556                    if (value == "1")
4557                        $('#' + onofffieldid).addClass("rbslider-headerfilter-item_selected");
4558                    else
4559                        $('#' + onofffieldid).removeClass("rbslider-headerfilter-item_selected");
4560                }
4561                if (clearfield)
4562                    RBSetValue('#' + clearfield, "");
4563            }
4564        }
4565    });
4566};
4567
4568function RBGetDivParamData(divid, azon, extracode, value, field, resultdiv) {
4569    if (field) {
4570        value = RBGetValue('#' + field);
4571    }
4572    $.post('/Home/GetDivParamData', {
4573        azon: azon, extracode: extracode, value: value
4574    }, function (response) {
4575        if (response) {
4576            if (response.error)
4577                RBMessage(response.error);
4578            else {
4579                if (response.result)
4580                    $(resultdiv).html(response.result);
4581            }
4582        }
4583    });
4584};
4585
4586function RBDocumentumDelete(url, confirm, filename) {
4587    if (confirm)
4588        if (!RBConfirm(confirm))
4589            return;
4590    $.post(url, {
4591        fileName: filename
4592    }, function (response) {
4593        if (response) {
4594            if (response.error)
4595                RBMessage(response.error);
4596            else {
4597                if (response.message)
4598                    RBMessage(response.message, "", document.location.href, true);
4599            }
4600        }
4601    }).fail(function (response) {
4602        RBAjaxPostError();
4603    });
4604};
4605
4606function RBSetSelected(divid, item, selecteditem, selectclass) {
4607    $('#' + divid + ' .' + item).removeClass(selectclass);
4608    $('#' + divid + ' .' + selecteditem).addClass(selectclass);
4609}
4610
4611function RBStopAllAudio() {
4612    try {
4613        var sounds = document.getElementsByTagName('audio');
4614        for (i = 0; i < sounds.length; i++)
4615            sounds[i].pause();
4616    }
4617    catch (ex) { }
4618}
4619
4620function RBChangeData(url, code, reload) {
4621    $.post(url, {
4622        code: code
4623    }, function (response) {
4624        if (response) {
4625            if (response.error)
4626                RBMessage(response.error);
4627            else {
4628                if (reload == 1)
4629                    RBReLoad();
4630            }
4631        }
4632    }).fail(function (response) {
4633        RBAjaxPostError();
4634    });
4635}
4636
4637// Ajax - End
4638
4639// Google - Start
4640var googleinfowindow;
4641var googlemarker;
4642var googlemap;
4643var googlemarkers = [];
4644var googlemarkersinfowindows = [];
4645
4646function RBNewGoogleMap(mapid) {
4647    if (!googlemap)
4648        return true;
4649    if (googlemap) {
4650        var googlemapitem = $('#' + mapid);
4651        if (!googlemapitem || (googlemapitem.children().length == 0))
4652            return true;
4653    }
4654    return false;
4655}
4656
4657function RBGetGoogleMap(mapid, xcode, ycode, zoom) {
4658    if (RBNewGoogleMap(mapid)) {
4659        var mapDiv = document.getElementById(mapid);
4660        googlemap = new google.maps.Map(mapDiv, {
4661            center: new google.maps.LatLng(ycode, xcode),
4662            zoom: zoom,
4663            mapTypeId: google.maps.MapTypeId.ROADMAP
4664        });
4665    }
4666    return googlemap;
4667}
4668
4669function RBGoogleMapInit(mapid, xcode, ycode, zoom, content, icon) {
4670    var map = RBGetGoogleMap(mapid, xcode, ycode, zoom);
4671    
4672    var infoOptions = {};
4673    if (content) {
4674        content = ReplaceAll(content, "MACRO", "'");
4675        infoOptions = $.extend(infoOptions, {
4676            content: content
4677        });
4678    }
4679    if (content)
4680        googleinfowindow = new google.maps.InfoWindow(infoOptions);
4681
4682    googlemarker = new google.maps.Marker({
4683        map: map,
4684        position: map.getCenter(),
4685        draggable: false,
4686        icon: icon
4687    });
4688    if (content)
4689        googleinfowindow.open(map, googlemarker);
4690
4691    google.maps.event.addListener(googlemarker, 'click', function () {
4692        RBGoogleCloseMarkersinfowindows();
4693        if (content)
4694            googleinfowindow.open(map, googlemarker);
4695    });
4696}
4697
4698function RBAddGoogleMapMarker(xcode, ycode, icon, title, content) {
4699    if (!googlemap)
4700        return;
4701    var myLatlng = new google.maps.LatLng(ycode, xcode);
4702    var marker = new google.maps.Marker({
4703        map: googlemap,
4704        position: myLatlng,
4705        title: title,
4706        icon: icon,
4707        clickable: true
4708    });
4709    if (content) {
4710        content = ReplaceAll(content, 'MACRO', '"');
4711        var infoWindow = new google.maps.InfoWindow({
4712            content: content
4713        });
4714        google.maps.event.addListener(marker, 'click', function () {
4715            RBGoogleCloseMarkersinfowindows();
4716            infoWindow.open(googlemap, marker);
4717        });
4718        googlemarkersinfowindows.push(infoWindow);
4719    }
4720    googlemarkers.push(marker);
4721}
4722
4723function RBGoogleCloseMarkersinfowindows() {
4724    try {
4725        for (var i = 0; i < googlemarkersinfowindows.length; i++) {
4726            googlemarkersinfowindows[i].close();
4727        }
4728        if (googleinfowindow)
4729            googleinfowindow.close();
4730    }
4731    catch (ex) { }
4732}
4733
4734function RBGoogleDeleteMarkers() {
4735    for (var i = 0; i < googlemarkers.length; i++) {
4736        googlemarkers[i].setMap(null);
4737    }
4738    googlemarkers = [];
4739    googlemarkersinfowindows = [];
4740}
4741
4742function RBGoogleGetAddressComponent(address_components, type) {
4743    for (var j = 0; j < address_components.length; j++) {
4744        var att = address_components[j].types[0];
4745        if (att)
4746            if (att == type) {
4747                return address_components[j].long_name;
4748            }
4749    }
4750    return "";
4751}
4752
4753function RBSetGoogleMapInput(field, value) {
4754    var xcode = RBGetValue('#' + field + '_XCode');
4755    if (!xcode)
4756        return;
4757    var ycode = RBGetValue('#' + field + '_YCode');
4758    if (!ycode)
4759        return;
4760    var mapid = "input-map-canvas-" + field;
4761    RBGoogleSetMapData(mapid, xcode, ycode, value);
4762}
4763
4764function RBGoogleSetMapData(mapid, xcode, ycode, content) {
4765    var map = RBGetGoogleMap(mapid, xcode, ycode, 15);
4766
4767    /*if (place.geometry.viewport) {
4768        map.fitBounds(place.geometry.viewport);
4769    }
4770    else {*/
4771    map.setCenter(new google.maps.LatLng(ycode, xcode));
4772    map.setZoom(15);
4773
4774    if (googleinfowindow) {
4775        googleinfowindow.close();
4776    }
4777    else {
4778        googleinfowindow = new google.maps.InfoWindow();
4779    }
4780    if (googlemarker) {
4781        googlemarker.setVisible(false);
4782    }
4783    else {
4784        googlemarker = new google.maps.Marker({
4785            map: map,
4786            position: map.getCenter(),
4787            draggable: false
4788        });
4789    }
4790    if (content) {
4791        googlemarker.setPosition(new google.maps.LatLng(ycode, xcode));
4792        googlemarker.setVisible(true);
4793        googleinfowindow.setContent(content);
4794        googleinfowindow.open(map, googlemarker);
4795    }
4796}
4797
4798function RBGoogleClearMapData(field) {
4799    RBSetValue('#' + field + '_Country_I', "");
4800    RBSetValue('#' + field + '_Country', "");
4801    RBSetValue('#' + field + '_PostCode_I', "");
4802    RBSetValue('#' + field + '_PostCode', "");
4803    RBSetValue('#' + field + '_State_I', "");
4804    RBSetValue('#' + field + '_State', "");
4805    RBSetValue('#' + field + '_Locality_I', "");
4806    RBSetValue('#' + field + '_Locality', "");
4807    RBSetValue('#' + field + '_Route_I', "");
4808    RBSetValue('#' + field + '_Route', "");
4809    RBSetValue('#' + field + '_XCode_I', "");
4810    RBSetValue('#' + field + '_XCode', "");
4811    RBSetValue('#' + field + '_YCode_I', "");
4812    RBSetValue('#' + field + '_YCode', "");
4813}
4814
4815var rbGoogleAutoCompleteInit = false;
4816
4817function RBGoogleAutoCompleteInitializationOnce() {
4818    rbGoogleAutoCompleteInit = false;
4819}
4820
4821function RBGoogleAutoCompleteInitialization(field, mapid, xcode, ycode, content) {
4822    if (rbGoogleAutoCompleteInit)
4823        return;
4824    rbGoogleAutoCompleteInit = true;
4825    if (mapid) {
4826        // 47.1611615, 19.5057542
4827        var startxcode = xcode;
4828        var startycode = ycode;
4829        var startzoom = 15;
4830        if ((startxcode == 0) && (startycode == 0)) {
4831            startxcode = 19.5057542;
4832            startycode = 47.1611615;            
4833            startzoom = 6;
4834        }
4835        var map = RBGetGoogleMap(mapid, startxcode, startycode, startzoom);
4836    }
4837    var input = document.getElementById(field);
4838    if (!input)
4839        return;
4840    $('#' + field).change(function () {
4841        RBGoogleClearMapData(field);
4842    });
4843    var options = {
4844        types: ['geocode'],
4845        componentRestrictions: { country: 'hu'}  // csak Magyarország
4846    };
4847    var autocomplete = new google.maps.places.Autocomplete(input, options);
4848    if (mapid) {
4849        autocomplete.bindTo('bounds', map);
4850
4851        googleinfowindow = new google.maps.InfoWindow();
4852        googlemarker = new google.maps.Marker({
4853            map: map,
4854            anchorPoint: new google.maps.Point(0, -29)
4855        });
4856
4857        if (content) {
4858            if (xcode) {
4859                googlemarker.setPosition(new google.maps.LatLng(ycode, xcode));
4860                googlemarker.setVisible(true);
4861                googleinfowindow.setContent(content);
4862                googleinfowindow.open(map, googlemarker);
4863            }
4864        }
4865    }
4866
4867    google.maps.event.addListener(autocomplete, 'place_changed', function () {
4868        if (mapid) {
4869            googleinfowindow.close();
4870            googlemarker.setVisible(false);
4871        }
4872        var place = autocomplete.getPlace();
4873        if (!place.geometry) {
4874            return;
4875        }
4876        if (mapid) {
4877            if (place.geometry.viewport) {
4878                map.fitBounds(place.geometry.viewport);
4879            }
4880            else {
4881                map.setCenter(place.geometry.location);
4882                map.setZoom(15);
4883            }
4884
4885            googlemarker.setIcon(({
4886                url: place.icon,
4887                size: new google.maps.Size(71, 71),
4888                origin: new google.maps.Point(0, 0),
4889                anchor: new google.maps.Point(17, 34),
4890                scaledSize: new google.maps.Size(35, 35)
4891            }));
4892            googlemarker.setPosition(place.geometry.location);
4893            googlemarker.setVisible(true);
4894
4895            RBGetLocationData(place, field);
4896
4897            var address = '';
4898            if (place.address_components) {
4899                address = [(RBGoogleGetAddressComponent(place.address_components, 'postal_code') || ''),
4900                                (RBGoogleGetAddressComponent(place.address_components, 'administrative_area_level_1') || ''),
4901                                (RBGoogleGetAddressComponent(place.address_components, 'locality') || '')].join(' ');
4902                var country = RBGoogleGetAddressComponent(place.address_components, 'country');
4903                if (country)
4904                    address = address + '<br>' + country;
4905            }
4906
4907            googleinfowindow.setContent('<div><strong>' + place.name + '</strong><br>' + address);
4908            googleinfowindow.open(map, googlemarker);
4909        }
4910    });
4911    var radioButton = document.getElementById(field + "_RoW");
4912    if (radioButton)
4913        google.maps.event.addDomListener(radioButton, 'click', function () {
4914            if (this.checked) {
4915                autocomplete.setComponentRestrictions([]);
4916            }
4917            else {
4918                autocomplete.setComponentRestrictions({ 'country': 'hu' });
4919            }
4920        });
4921}
4922
4923function RBGetLocationData(place, field) {
4924    var country = '';
4925    var postalcode = '';
4926    var state = '';
4927    var city = '';
4928    var route = '';
4929    var coorX = '';
4930    var coorY = '';
4931    if (place.address_components) {
4932        country = RBGoogleGetAddressComponent(place.address_components, 'country');
4933        postalcode = RBGoogleGetAddressComponent(place.address_components, 'postal_code');
4934        state = RBGoogleGetAddressComponent(place.address_components, 'administrative_area_level_1');
4935        city = RBGoogleGetAddressComponent(place.address_components, 'locality');
4936        route = RBGoogleGetAddressComponent(place.address_components, 'route');
4937        var streetnumber = RBGoogleGetAddressComponent(place.address_components, 'street_number');
4938        if (streetnumber)
4939            route = route + " " + streetnumber;
4940        address = [(postalcode || ''), (state || ''), (city || '')].join(' ');
4941        if (country)
4942            address = address + '<br>' + country;
4943        coorY = place.geometry.location.lat();
4944        coorX = place.geometry.location.lng();
4945    }
4946    RBSetValue('#' + field + '_Country_I', country);
4947    RBSetValue('#' + field + '_Country', country);
4948    RBSetValue('#' + field + '_PostCode_I', postalcode);
4949    RBSetValue('#' + field + '_PostCode', postalcode);
4950    RBSetValue('#' + field + '_State_I', state);
4951    RBSetValue('#' + field + '_State', state);
4952    RBSetValue('#' + field + '_Locality_I', city);
4953    RBSetValue('#' + field + '_Locality', city);
4954    RBSetValue('#' + field + '_Route_I', route);
4955    RBSetValue('#' + field + '_Route', route);
4956    RBSetValue('#' + field + '_XCode_I', coorX);
4957    RBSetValue('#' + field + '_XCode', coorX);
4958    RBSetValue('#' + field + '_YCode_I', coorY);
4959    RBSetValue('#' + field + '_YCode', coorY);
4960}
4961
4962function RBSetCodeAddress(mapid, address, content) {
4963    var geocoder = new google.maps.Geocoder();
4964    geocoder.geocode({ 'address': address }, function (results, status) {
4965        if (status == google.maps.GeocoderStatus.OK) {
4966            RBGoogleSetMapData(mapid, results[0].geometry.location.lng(), results[0].geometry.location.lat(), content);
4967        }
4968    });
4969}
4970
4971var setMyLocation = false;
4972function RBSetMyLocation(field, mapid, content) {
4973    if (field) {
4974        var city = RBGetValue('#' + field + '_Locality');
4975        if (city) {
4976            if (!setMyLocation || RBNewGoogleMap(mapid)) {
4977                RBSetCodeAddress(mapid, city, content);
4978            }
4979            setMyLocation = true;
4980            return;
4981        }
4982    }
4983    setMyLocation = true;
4984    if (field) {
4985        var cookiecity = RBGetCookie('RBMapMyLocation');
4986        if (cookiecity) {
4987            cookiecity = cookiecity.replace("+", " ");
4988            RBSetCheckBoxValue('#' + field, true);
4989            RBSetValue('#' + field + '_Locality', cookiecity);
4990            RBSetCodeAddress(mapid, cookiecity, content);
4991            return;
4992        }
4993    }
4994
4995    //If HTML5 Geolocation Is Supported In This Browser
4996    if (navigator.geolocation) {
4997
4998        //Use HTML5 Geolocation API To Get Current Position
4999        navigator.geolocation.getCurrentPosition(function (position) {
5000
5001            // RBSetValue('#' + field, "1");
5002            if (field) {
5003                RBSetCheckBoxValue('#' + field, true);
5004            }
5005
5006            //Get Latitude From Geolocation API
5007            var latitude = position.coords.latitude;
5008
5009            //Get Longitude From Geolocation API
5010            var longitude = position.coords.longitude;
5011
5012            RBSetCookie("latitude", latitude, 0);
5013            RBSetCookie("longitude", longitude, 0);
5014
5015            var latlng = new google.maps.LatLng(latitude, longitude);
5016
5017            var geocoder = new google.maps.Geocoder();
5018
5019            if (field) {
5020                geocoder.geocode({ 'latLng': latlng }, function (results, status) {
5021                    if (status == google.maps.GeocoderStatus.OK) {
5022                        if (results[1]) {
5023                            RBGetLocationData(results[1], field);
5024                        }
5025                    }
5026                });
5027            }
5028
5029            if (mapid) {
5030                RBAddGoogleMapMarker(longitude, latitude, "", "", content);
5031                // RBGoogleSetMapData(mapid, longitude, latitude, content);
5032                //googlemap = null;
5033                //RBGoogleMapInit(mapid, longitude, latitude, 15, content);
5034            }
5035        });
5036
5037    } else {
5038
5039        //Otherwise - Gracefully Fall Back If Not Supported... Probably Best Not To Use A JS Alert Though :)
5040        alert("Geolocation API is not supported in your browser.");
5041    }
5042}
5043
5044function RBGoogleMapManualDataUpdater(field, mapcanvas) {
5045}
5046
5047// Google - End
5048
5049// TinyMCE - Start
5050function RBTinyMCEInit(field) {
5051    tinymce.init({
5052        selector: field,
5053        height: 400,
5054        menubar: false,
5055        statusbar: false,
5056        language: 'hu_HU',
5057        plugins: [
5058        'advlist autolink lists link image charmap print preview anchor emoticons',
5059        'searchreplace visualblocks code hr anchor',
5060        'media table paste code'],
5061        toolbar: 'undo redo | bold italic underline forecolor backcolor | ' +
5062          'alignleft aligncenter alignright alignjustify | lineheight bullist numlist outdent indent hr | fontselect fontsizeselect | paste pastetext | ' +
5063          'table tabledelete | anchor link charmap emoticons | removeformat code',
5064        toolbar_mode: 'wrap',
5065        convert_urls: false,
5066        content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'
5067    });
5068}
5069// TinyMce - End
5070
5071var rbenablesubmit = true;
5072
5073$(document).ready(function () {
5074    $('form').submit(function () {
5075        RBDisableAfterSubmit(false);
5076        if (!rbenablesubmit)
5077            return false;
5078        rbenablesubmit = false;
5079    });
5080});
5081
5082function CheckDocumentItemExists(checkitem, warningitem, warningdata) {
5083    var field = $(document).find(checkitem);
5084    if (field)
5085        return;
5086    var warningfield = $(document).find(warningitem);
5087    if (warningfield)
5088        warningfield.append(warningdata);
5089    return false;
5090}
5091
5092function RBCountdownTimerPadding(n) {
5093    return (n < 10 ? "0" + n : n);
5094}
5095
5096function RBCountdownTimerSetStyleByIdIfNotAlready(style, id) {
5097    var div = document.getElementById(id);
5098    if (div != null) {
5099        if (div.style.display != style) {
5100            div.style.display = style;
5101        }
5102    }
5103    var title = document.getElementById(id + "-title");
5104    if (title != null) {
5105        if (title.style.display != style) {
5106            title.style.display = style;
5107        } 
5108    }
5109
5110}
5111
5112function RBCountdownTimer(dayId, hourId, minId, secId, clear, iterationnumber, infoId, url, timerDivId, entityId, year, month, day, hour, minute, second, needSeconds) {
5113    var clearEl = document.getElementById(clear);
5114    if (!clearEl)
5115        return;
5116    var clearId = clearEl.innerHTML;
5117    if (!year || !month || !day)
5118        return
5119    if (!hour)
5120        hour = 0;
5121    if (!minute)
5122        minute = 0;
5123    if (!second)
5124        second = 0;
5125
5126    var now = new Date().getTime();
5127    var end = new Date(year, month - 1, day, hour, minute, second).getTime();
5128    var seconds = Math.max(0, Math.floor((end - now) / 1000));
5129
5130    var days = Math.floor(seconds / 24 / 60 / 60);
5131    var hoursLeft = Math.floor((seconds) - (days * 86400));
5132    var hours = Math.floor(hoursLeft / 3600);
5133    var minutesLeft = Math.floor((hoursLeft) - (hours * 3600));
5134    var minutes = Math.floor(minutesLeft / 60);
5135    var remainingSeconds = seconds % 60;
5136
5137    document.getElementById(dayId).innerHTML = RBCountdownTimerPadding(days);
5138    document.getElementById(hourId).innerHTML = RBCountdownTimerPadding(hours);
5139    document.getElementById(minId).innerHTML = RBCountdownTimerPadding(minutes);
5140    document.getElementById(secId).innerHTML = RBCountdownTimerPadding(remainingSeconds);
5141
5142    if (seconds < 86400) {
5143        RBCountdownTimerSetStyleByIdIfNotAlready('none', dayId);
5144        RBCountdownTimerSetStyleByIdIfNotAlready('block', secId);
5145    }
5146    else {
5147        if (needSeconds != 1)
5148            RBCountdownTimerSetStyleByIdIfNotAlready('none', secId);
5149    }
5150    if (seconds < 3600) {
5151        RBCountdownTimerSetStyleByIdIfNotAlready('none', hourId);
5152    }
5153    if (seconds < 60) {
5154        RBCountdownTimerSetStyleByIdIfNotAlready('none', minId);
5155    }
5156    if (seconds == 0) {
5157        if (url) {
5158            updateRevealingCode(url, timerDivId, entityId);
5159        } else {
5160        if (needSeconds != 1)
5161            RBCountdownTimerSetStyleByIdIfNotAlready('none', secId);
5162            if (clearId != 0)
5163                clearInterval(clearId);
5164            RBCountdownTimerSetStyleByIdIfNotAlready('block', infoId);
5165        }
5166        return;
5167    }
5168    if (clearId == 0) {
5169        // nincs elindítva
5170        if ((seconds <= 86460) || (needSeconds == 1)) {
5171            var newClearId1 = setInterval(function () { RBCountdownTimer(dayId, hourId, minId, secId, clear, 1, infoId, url, timerDivId, entityId, year, month, day, hour, minute, second, needSeconds); }, 1000); // másodperc
5172            document.getElementById(clear).innerHTML = newClearId1;
5172 // leállításhoz
5173            iterationnumber = 1;
5174            // return;
5175        } else {
5176            var newClearId2 = setInterval(function () { RBCountdownTimer(dayId, hourId, minId, secId, clear, 60, infoId, url, timerDivId, entityId, year, month, day, hour, minute, second, needSeconds); }, 60000); // perc
5177            document.getElementById(clear).innerHTML = newClearId2; // leállításhoz
5178            // return;
5179        }
5180    } else {
5181        // itt váltunk "nap óra perc" ről "perc másodpercre"
5182        if (seconds <= 86460 && iterationnumber == 60) {
5183            clearInterval(clearId);
5184            var newClearId = setInterval(function () { RBCountdownTimer(dayId, hourId, minId, secId, clear, 1, infoId, url, timerDivId, entityId, year, month, day, hour, minute, second, needSeconds); }, 1000);
5185            document.getElementById(clear).innerHTML = newClearId;
5186            return;
5187        }
5188    }
5189}
5190
5191function updateRevealingCode(url, timerDivId, entityId) {
5192    var eventOver = false;
5193
5194    $.post(url, {
5195        entityId: entityId
5196    }, function (response) {
5197        if (response.result) {
5198            $('#' + timerDivId).html(response.result);
5199            eventOver = response.eventOver;
5200            if (!eventOver) {
5201                setTimeout(function () { updateRevealingCode(url, timerDivId, entityId); }, 1000);
5202            }
5203        }
5204    });
5205}
5206
5207function RBDragAndDrop(containerClass, itemClass, ajaxUrl, productListId, handleId) {
5208    var $container = $(document).find(containerClass);
5209    if ($container.length > 0) {
5210
5211        var containerEl = $container.get(0);
5212
5213        new Sortable(containerEl, {
5214            draggable: itemClass,
5215            handle: handleId,
5216            delay: 50,
5217            delayOnTouchOnly: true,
5218            touchStartThreshold: 5,
5219            ghostClass: "sortable-ghost",
5220
5221            onEnd: function (evt) {
5222                if (evt.oldIndex === evt.newIndex) return;
5223
5224                var $movedItem = $(evt.item);
5225                var movedItemId = $movedItem.attr("id");
5226                var prevItemId = $movedItem.prev(itemClass).attr("id") || "";
5227                var nextItemId = $movedItem.next(itemClass).attr("id") || "";
5228
5229                if (ajaxUrl) {
5230                    $.ajaxSettings.traditional = true;
5231                    $.post(ajaxUrl, {
5232                        productListId: productListId,
5233                        movedItemId: movedItemId,
5234                        prevItemId: prevItemId,
5235                        nextItemId: nextItemId
5236                    }, function (response) {
5237                        console.log(response);
5238                        if (response && response.error) {
5239                            RBMessage(response.error);
5240                            cancelSortable(evt);
5241                        }
5242                    }).fail(function () {
5243                        RBAjaxPostError();
5244                        cancelSortable(evt);
5245                    });
5246                }
5247            }
5248        });
5249
5250        function cancelSortable(evt) {
5251            var from = evt.from;
5252            var item = evt.item;
5253            if (evt.oldIndex < from.children.length) {
5254                from.insertBefore(item, from.children[evt.oldIndex]);
5255            } else {
5256                from.appendChild(item);
5257            }
5258        }
5259    }
5260}
5261    

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.