HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/ERPApps/media/system/js/erp.js
// Add "*" to mandatory fields
$(document).ready(function() {
  $("#p_lt_zoneContent_pageplaceholder_pageplaceholder_lt_zoneContact_pageplaceholder_pageplaceholder_lt_zoneLeft_BizForm_pnlUpdate label")
  .each(function(){
    $(this).html($(this).html().replace(":", "")+"*:");
  });
});


// Tags in detail
$(document).ready(function() {
  if ($('.app-tags .hiddenValue').length) {
    if ($('.app-tags .hiddenValue').html().length > 200)
      $('.app-tags .value').html($('.app-tags .hiddenValue').html().substr(0, 199) + " ... <a href='#' class='app-tags-more'>more</a>");
    else
      $('.app-tags .value').html($('.app-tags .hiddenValue').html());

    $('.app-tags a').click(function(){
      var tags = $('.app-tags .hiddenValue').html();
      
      /*if ($(this).hasClass('app-tags-more'))
      {
        $('.app-tags .value').html(tags + " ... <a href='#' class='app-tags-less' onClick='return false;'>less</a>");
      } else {
        $('.app-tags .value').html(tags.substr(0, 199) + " ... <a href='#' class='app-tags-more' onClick='return false;'>more</a>");
      }*/
      
      $('.app-tags .value').html(tags);
      
      return false;
    });
  }
});

/*
// Vendor's graph
//$(document).ready(function() {
function graphOn() {
  $('.graph1, .graph2, .graph3, .graph4').mouseenter(function(){
    if ($(this).attr('class') == 'graph1')
    {
      $(this).css('background-image', 'url("/ERPApps/media/system/images/vendorGraph1.png")');
      $(this).html('<span>1. Lorem ipsum dolor sit amet, consectetur.<br>2. Duis nibh est, tempor id, tempus sit amet, in.<br>3. Mauris fringilla, eros at gravida dapibus, libero.</span>');
    }
    if ($(this).attr('class') == 'graph2')
    {
      $(this).css('background-image', 'url("/ERPApps/media/system/images/vendorGraph2.png")');
      $(this).html('<span>1. Lorem ipsum dolor sit amet, consectetur.<br>2. Duis nibh est, tempor id, tempus sit amet, in.<br>3. Mauris fringilla, eros at gravida dapibus, libero.</span>');
    }
    if ($(this).attr('class') == 'graph3')
    {
      $(this).css('background-image', 'url("/ERPApps/media/system/images/vendorGraph3.png")');
      $(this).html('<span>1. Lorem ipsum dolor sit amet, consectetur.<br>2. Duis nibh est, tempor id, tempus sit amet, in.<br>3. Mauris fringilla, eros at gravida dapibus, libero.</span>');
    }
    if ($(this).attr('class') == 'graph4')
    {
      $(this).css('background-image', 'url("/ERPApps/media/system/images/vendorGraph4.png")');
      $(this).html('<span>1. Lorem ipsum dolor sit amet, consectetur.<br>2. Duis nibh est, tempor id, tempus sit amet, in.<br>3. Mauris fringilla, eros at gravida dapibus, libero.</span>');
    }
    $(this).css('width', '350px').css('height', '210px').css('left', '400px').css('z-index', '99');
  });                               
}

function graphOut() {
  $('.graph1, .graph2, .graph3, .graph4').mouseleave(function(){
    if ($(this).attr('class') == 'graph1')
    {
      $(this).css('background-image', 'url("/ERPApps/media/system/images/vendorGraph1_blank.png")');
      $(this).html('');
    }
    if ($(this).attr('class') == 'graph2')
    {
      $(this).css('background-image', 'url("/ERPApps/media/system/images/vendorGraph2_blank.png")');
      $(this).html('');
    }
    if ($(this).attr('class') == 'graph3')
    {
      $(this).css('background-image', 'url("/ERPApps/media/system/images/vendorGraph3_blank.png")');
      $(this).html('');
    }
    if ($(this).attr('class') == 'graph4')
    {
      $(this).css('background-image', 'url("/ERPApps/media/system/images/vendorGraph4_blank.png")');
      $(this).html('');
    }
    $(this).css('width', '161px').css('height', '124px').css('left', '589px').css('z-index', '1');
  });
}
*/

window.erp = window.erp || { };

// filter
erp.filter = {};
erp.filter.selects = [];
erp.filter.suggest = [];
erp.filter.selectsLinks = {};

erp.filter.onChange = function () {
    var s = "";
    var index = 0;
    //debugger;

    var selects = erp.filter.selects;
    var suggest = erp.filter.suggest;
    var possibilitiesCount = suggest.length;
    var selectsLength = selects.length;

    var selectsValue = {};
    var selectsLinks = {};

    for (var i = 0; i < selectsLength; i++) {
        // cache values of all selectboxes
        selectsValue[i] = selects.eq(i).val();

        if (selects.eq(i).get(0) == $(this).get(0)) {
            index = i;
            continue;
        }

        var options = selects.eq(i).data('selectBox-control').data('selectBox-options');
        if (!options)
            continue;

        options.find('li').addClass('selectBox-disabled');
        //options.find('li.selectBox-selected').removeClass('selectBox-disabled');
        options.find('li:eq(0)').removeClass('selectBox-disabled');
    }

    for (var i = 0; i < selectsLength; i++) {
        for (var j = 0; j < possibilitiesCount; j++) {
            var match = true;

            for (var k = 0; k < selectsLength; k++) {
                if (k == i || selectsValue[k] == 0)
                    continue;

                if (suggest[j][k] != selectsValue[k]) {
                    // possibility not matching selected value
                    match = false;

                    break;
                }
            }

            if (match && erp.filter.selectsLinks[i][suggest[j][i]]) {
                // enable selected combination
                erp.filter.selectsLinks[i][suggest[j][i]].parent().removeClass('selectBox-disabled');
                //selects.eq(i).data('selectBox-control').data('selectBox-options').find('a[rel=' + suggest[j][i] + ']').parent().removeClass('selectBox-disabled');
            }
        }
    }
};

erp.filter.init = function() {
    erp.filter.selects = $('.erp-app-filter select');
    if (!erp.filter.selects.length)
        return;

    erp.filter.selects.eq(0).data('type', 'industry');
    erp.filter.selects.eq(1).data('type', 'process');
    erp.filter.selects.eq(2).data('type', 'platform');

    var l = erp.filter.selects.length;

    var selectBox = $(".erp-app-filter select").selectBox();

    var exists = Boolean(erp.filter.selects.eq(0).data('selectBox-control'));

    if(!exists)
    {
        // iPad, iPod - no selectbox
        return;
    }

    // onChange event
    selectBox.change(erp.filter.onChange);

    // init
    for(var i = 0; i < l; i++) {
        // save links "rel" atributtes to memory for faster iteration
        erp.filter.selectsLinks[i] = {};

        var els = erp.filter.selects.eq(i).data('selectBox-control').data('selectBox-options').find('a');
        var total = els.length;
        for (var j = 0; j < total; j++) {
            if ($(els[j]).attr('rel')) {
                erp.filter.selectsLinks[i][$(els[j]).attr('rel')] = $(els[j]);
            }
        }
    }

    if (erp.filter.selects.eq(0).data('selectBox-control')) {
        erp.filter.onChange.call(erp.filter.selects.eq(0));
    }
};

erp.cart = {};
erp.cart.fix = function() {
    //if ($('.PaymentGatewayDataContainer').length && !$('.CartStepNavigation .btn-green-small input').length) {
    if ($('.PaymentGatewayDataContainer').length) {
        // button container with no button - hide the container
        //$('.CartStepNavigation .btn-green-small').parent('td').remove();
        $('.CartStepNavigation td:eq(0)').remove();
        $('.CartStepNavigation td').removeClass('alignright').addClass('center');
        //$('.CartStepNavigation .btn-green-small').remove();
    }
}

erp.adsWizard = {};
erp.adsWizard.init = function () {
    if (!$('#ad-wizard').length)
        return;

    // hide all steps except the first one
    $('#ad-wizard .wizard-step').hide();
    $('#ad-wizard .wizard-step:eq(0)').show();

    // add button to next step (<span><span><input /></span></span>)
    var btnWrapper = $(document.createElement('p'));
    var btn = $(document.createElement('span'));
    btn.addClass('btn-orangeSmall');
    btn.append('<span><input type="submit" value="Next step" /></span>');

    var totalSteps = $('#ad-wizard .wizard-step').length;

    btn.click(function () {
        var p = $(this).parents('.wizard-step');

        // show next step
        var stepIndex = p.index('.wizard-step');

        // validations
        if (stepIndex == 0) {
            var inputName = p.find('input[type="text"]');
            if (!jQuery.trim(inputName.val())) {
                // name of ad not selected
                inputName.focus();
                p.find('label').addClass('EditingFormErrorLabel');

                return false;
            } else {
                p.find('label').removeClass('EditingFormErrorLabel');
            }
        }

        // show next step
        stepIndex++;
        if (stepIndex < totalSteps) {
            // show next step
            $('#ad-wizard .wizard-step:eq(' + stepIndex + ')').show();
            // move button to the next step
            $('#ad-wizard .wizard-step:eq(' + stepIndex + ')').append($(this).parent());
        }

        if (stepIndex == totalSteps - 1) {
            // last step
            $(this).hide();
        }

        return false;
    });

    // append button to the first step
    btnWrapper.append(btn);
    $('#ad-wizard .wizard-step:eq(0)').append(btnWrapper);
    erp.adsWizard.initOnChange();
}

erp.adsWizard.initOnChange = function() {
    $('#ad-wizard-select-type select').change(erp.adsWizard.onTypeSelectChange);
}

erp.adsWizard.onTypeSelectChange = function() {
    // wizard selects for industries, processes, platforms
    $('.wizard-step-select').hide();

    switch($('#ad-wizard-select-type select').val()) {
        case '1':
            // homepage
            break;
        case '2':
            // industry
            $('.wizard-step-industry').show();
            break;
        case '3':
            // process
            $('.wizard-step-process').show();
            break;
        case '4':
            // platform
            $('.wizard-step-platform').show();
            break;
    }
}

erp.dialogs = {};
erp.dialogs.show = function(el) {
  var params = {
    autoOpen: true,
    modal: true,
    closeText: $(document.createElement('div')).html("&times; hide").text(),
    dialogClass: 'ui-dialog-delete'
  };
  
  if (el.hasClass('wide')) {
    params.dialogClass = 'ui-dialog-delete wide';
  }

  el.dialog(params);
}

erp.dialogs.initDeleteDialog = function(dialog, tthis) {
    if (!dialog)
        return;

    // clone dialog
    var div = $(document.createElement('div'));
    div.html(dialog.html());
    $('body').append(div);

    erp.dialogs.show(div);

    // set cancel button to close the dialog
    $('.cancel', div).click(function() {
        div.dialog('close');
        div.remove();

        return false;
    });

    // create confirmation button
    var confirmButt = $('.dlg-cfr-yes', div);
    confirmButt.html(tthis.text());
    confirmButt.click(function() {
        // perform delete request
        eval(tthis.attr('href'));

        div.dialog('close');

        return false;
    });
}

erp.dialogs.init = function() {
    $('.ui-dialog-content').on('click', 'input[type="submit"]', function() {
        if ($(this).parents('form').length) {
            // inside <form> element
            return;
        }

        // move to <form> element and submit again with small delay
        $('.ui-dialog').appendTo($('form:eq(0)'));
        var el = $(this);
        setTimeout(function() { 
            /* delayed submit */
            el.trigger('click');
          }, 100);

        return false;
    });
  
    if ($('#delete-app-confirm-dialog').length) {
        var dialog = $('#delete-app-confirm-dialog');
        dialog.hide();

        $('#vendor-app-list').on('click', 'a.delete', function() {
            erp.dialogs.initDeleteDialog(dialog, $(this));

            return false;
        });
    }

    if ($('#delete-ad-confirm-dialog').length) {
        var dialog = $('#delete-ad-confirm-dialog');
        dialog.hide();

        $('#vendor-ad-list').on('click', 'a.delete', function() {
            erp.dialogs.initDeleteDialog(dialog, $(this));

            return false;
        });
    }
    
    erp.dialogs.onPageLoad();
} 

erp.dialogs.onPageLoad = function() {
    if($('.to-dialog').length) {
        erp.dialogs.show($('.to-dialog'));
        $('.to-dialog').removeClass('to-dialog');
    }
}

/*erp.contact = {};
erp.contact.init = function() {
    var textClose = $("<div/>").html("&times; close contact form").text();

    $("#dialog-contact").dialog({
        autoOpen: false,
        show: { effect: 'drop', direction: "up" },
        hide: { effect: 'drop', direction: "up" },
        dialogClass: 'ui-dialog-position',
        closeText: textClose
    });

    $("#contact").click(function () {
        $("#dialog-contact").dialog("open");

        // move dialog inside <form>
        /*setTimeout(function() {
            $('.ui-dialog').appendTo($('form:eq(0)'));
        }, 2000);*/

/*        return false;
    });

    var contactPlaceholder = function() {
        $('#dialog-contact label').each(function() {
            $(this).next('.EditingFormControlNestedControl').find('input, textarea').attr('placeholder', $(this).text().replace(/:$/, ''));
            $(this).hide();
        });
    }
    
    contactPlaceholder();

    $('#dialog-contact input[type="submit"]').click(function() {
        if (!$(this).data('callbackRegistered')) {
            erp.prm.add_endRequest(function (e) {
                contactPlaceholder();
            });

            $(this).data('callbackRegistered', true);
        }
    });
};  */

erp.pages = {};
erp.pages.appdetail = function() {
    var formLoaded = false;

    erp.getPageMgr().add_endRequest(function (e) {
        // after ajax request
        if (!formLoaded) {
            $('#review-form').hide();
            $('#review-form').slideDown(2500);

            formLoaded = true;
            
        } else {
            $('#review-form').show();
        }
      });
      

    $(document).ready(function() {
        var setData = function() {
          $('.popup-window input').each(function() {
            // before opening popup window load and prefill input values from cookie
            var attr = $(this).attr('data-cookie-name');
            if (!attr)
              return;

            $(this).val(pux.cookie.get('Contact' + $(this).attr('data-cookie-name')));
          });
        }

        $(".popup-window-container").click(function(){
          if (!$(event.target).hasClass('popup-window-container')) {
            return;
          }
          
          $(".popup-window-container").fadeOut();
        });
        
        $("#download-brochure").click(function() {
            setData();
            $("#download-brochure-popup-window").fadeIn(200);
            event.stopPropagation();
            
            return false;
        });
        
        $("#view-online-presentation").click(function() {
            setData();
            $("#online-presentation-popup-window").fadeIn(200);
            event.stopPropagation();

            return false;
        });
    });

   


   
    /*
    function errorLabel() {
       $(".error-message").html("All fields are required. E-mail in the form email@domain.com")
    }
    
    function validEmailAddress(emailAddress) {
      var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
      return pattern.test(emailAddress);
    };
  
    $(".popup-window").find("input[type=submit]").on("click", function(){
         var nameVal = $(this).parent().parent().parent().find("input").eq(0).val();
         var emailVal = $(this).parent().parent().parent().find("input").eq(1).val();
         var companyNameVal = $(this).parent().parent().parent().find("input").eq(2).val();
         
         if (validEmailAddress(emailVal)) { 
            if ((emailVal.length > 0) && !validEmailAddress(emailVal)) {
                  //sidebarerrorLabels();
                  errorLabel();
                  return false;
            }
            
            if ((nameVal.length < 1 ) || (companyNameVal.length < 1)) {
                errorLabel();
                return false;
            }
            return true;
         } 
         else {
             //sidebarerrorLabels();
             errorLabel();
             return false;
         }
       return true;
     });
     */

}

function handleFormCookies() {
    $('.popup-window input[type=text]').on('keyup', function () {
        // on filling inputs in popup window set text value into cookies
        var attr = $(this).attr('data-cookie-name');
        if (attr.length > 0) {
            var date = new Date();
            pux.cookie.set('Contact' + attr, $(this).val(), date.getTime() + 3600 * 24 * 30);
        }
    });
}
$(document).ready(function () {
    handleFormCookies();
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function (e) {
        handleFormCookies();
    });
});

erp.pages.appForm = function () {
    var dynamicTextareaLimit = 50;

    $('.dynamic-textareas').each(function() {
        var target = $(this);

        var textarea = target.find('textarea');

        // copy text from custom textareas to the original one
        var copyText = function() {
            var textareas = target.find('textarea');
            var l = textareas.length;

            textarea.val('');
            for (var i = 0; i < l; i++) {
                if (!$(textareas[i]).data('custom') || !$(textareas[i]).val())
                    continue;

                textarea.val(textarea.val() + $(textareas[i]).val().substr(0, dynamicTextareaLimit).replace(/\r?\n/, '') + "\r\n");
            }

            textarea.val(textarea.val().replace(/[\r\n]$/, ''));

            textarea.trigger('keyup');
        }

        var resize = function(el) {
            var rows = el.val().length / 25;
            if (rows > el.attr('rows')) {
                el.attr('rows', rows);
            }
        }

        var addTextarea = function(value) {
            var t = $(document.createElement('textarea'));
            t.val(value);
            t.attr('rows', '2');
            t.data('custom', true);

            t.keydown(function(e) {
                if ((e.keyCode || e.which) == 13) {
                    //addTextarea('').focus();

                    return false;

                }/* else if (e.which == 8 || e.which == 46) {
                    // backspace or delete
                    if (!t.val().replace(/[ \n]/, '')) {
                        // remove empty textarea
                        var previous = t.parent().prev('.textarea').find('textarea');
                        if (previous.length && previous.data('custom')) {
                            t.parent().remove();
                            previous.focus();

                            return false;
                        }
                    }
                }*/
            });

            t.keyup(function() {
                copyText();
                //resize(t);
            });

            //resize(t);
            //target.find('.counter').before($(document.createElement('div')).addClass('textarea add-textarea-counter').append(t));
            var newTextareaWrapper = $(document.createElement('div')).addClass('textarea add-textarea-counter');
            var counter = $(document.createElement('p')).addClass('counter').attr('data-limit', dynamicTextareaLimit);
            t.appendTo(newTextareaWrapper);
            counter.appendTo(newTextareaWrapper);
            newTextareaWrapper.appendTo(target);
            erp.createLiveCounter(counter, t);

            return t;
        }

        var bullets = textarea.val().replace(/\r\n/, "\n").split(/\n/);
        var l = 5; //bullets.length;
        for (var i = 0; i < l; i++) {
            addTextarea(bullets[i]);
        }

        textarea.hide();
    });
}

erp.ajax = {};
erp.ajax.init = function() {
    $('body').append('<div id="ajax-loader"></div>');

    erp.getPageMgr().add_beginRequest(function (e) {
        // after ajax request
        $('#ajax-loader').fadeIn();
        $('#ajax-loader').css('left', mouseXPos + 20).css('top', mouseYPos + 20);
    });

    erp.getPageMgr().add_endRequest(function (e) {
        // after ajax request
        $('#ajax-loader').fadeOut();

        erp.dialogs.onPageLoad();
    });
}

erp.getPageMgr = function() {
    if (!erp.prm)
        erp.prm = Sys.WebForms.PageRequestManager.getInstance();

    return erp.prm;
}

erp.createLiveCounter = function(counter, element) {
    var limit = counter.data('limit');
    var run = function() {
        // add length with \r\n on windows - 2 chars for each line
        var current = limit - element.val().length - (element.val().split("\n").length-1)*2;
        counter.text('You have ' + Math.max(current, 0) + ' characters left.');
        if (current <= 0) {
            counter.append(' Allowed are ' + limit + ' characters.');
        }

        return Math.max(current, 0);
    }
    var strictRun = function() {
        var result = run();
        if (result <= 0) {
            element.val(element.val().substr(0, limit));
            // remove new lines
            var offset = limit - (element.val().split("\n").length-1)*2;
            element.val(element.val().substr(0, offset));
        }
    }

    var allowedKeys = [37, 38, 39, 40, 27, 8, 46];
    element.keypress(function(e) {
        if (run() == 0 && $.inArray(e.keyCode || e.which, allowedKeys) < 0) {
             return false;
        }
    });
    element.keyup(function(e) {
        if (run() == 0 && $.inArray(e.keyCode || e.which, allowedKeys) < 0) {
             return false;
        }
    });
    element.change(function(e) { run(); });
    element.bind('paste', function(e) { setTimeout(function() { strictRun(); }, 5); });
    element.bind('cut', function(e) { setTimeout(function() { strictRun(); }, 5); });
    run();
}

erp.layout = {};
erp.layout.init = function() {
    $('body').addClass('js-enabled');

    if (!$('body').hasClass('DesignMode')) {
        //erp.contact.init();
    }

    // contact -> move item inside the UL menu
    //$('#menu ul').append($(document.createElement('li')).append($('#contact')));
    //$('#menu a').append('<span></span>');

    // sign out button move to menu
    if ($('#sign-out-btn').length) {
        $('#vendor-navigation ul').append($(document.createElement('li')).append($('#sign-out-btn')));
    }

    // newsletter layout fix
    var s = $('#newsletter input[type=submit]');
    if (s.length) {
        s.wrap('<span class="btn">');
        s.wrap('<span>');
    }
    $('#newsletter label').hide();
    $('#newsletter input[type=text]').attr('placeholder', 'enter your e-mail address');
    
    // search box
    $('#header .search-box input[type="text"]').attr('placeholder', 'search...');
    
    // vendor orders
    if ($('#vendor-orders').length) {
        $('#vendor-orders .MyOrders .EvenRow a, #vendor-orders .MyOrders .OddRow a,').wrap('<span class="btn-green-small"><span>');
    }


    // placeholders (labels in input fields)
    erp.layout.initPlaceholders($('body'));

    // live counters in textareas
    $('.add-textarea-counter').each(function() {
        var text = $(this).find('textarea');
        var counter = $(this).find('.counter');
        
        if (text.length && counter.length) {
            erp.createLiveCounter(counter, text);
        }
    });
    
    // "select all" buttons
    $('a.js-select-all').click(function() {
        var target = $(this).attr('rel');
        if ($('#' + target).length) {
            $('#' + target + ' input[type="checkbox"]').attr('checked', 'checked');
        }

        return false;
    });

    // "deselect all" button
    $('a.js-deselect-all').click(function() {
        var target = $(this).attr('rel');
        if ($('#' + target).length) {
            $('#' + target + ' input[type="checkbox"]').removeAttr('checked');
        }

        return false;
    });
    
    // datepickers
    var datepickers = $('#detail-contact .term input[type=text]');
    if (datepickers.length) {
      var init = function() {
          var datepickers = $('#detail-contact .term input[type=text]');
        datepickers
          .datepicker({ minDate: new Date(), maxDate: "+1m +1w", dateFormat: "dd/mm/y" })
          .closest('body').find('#ui-datepicker-div').wrap('<div class="dp-d"></div>');
      }
      erp.getPageMgr().add_pageLoaded(function (e) { init(); });
    }
    
    // commercial profile click
    $('div.commercial-profile-overview').click(function() {
      window.location = $(this).parents('.app:eq(0)').find('a:eq(0)').attr('href');
    });
}

erp.layout.initPlaceholders = function(rootNode) {
    rootNode.find('.add-placeholder').each(function() {
        var input = $(this).find('input[type="text"]');
        input.attr('placeholder', $(this).data('placeholder'));
  
        // default value
        var def = $(this).data('default');
        if (def) {
            // default value
            input.focus(function() {
                if(!$(this).val()) {
                    $(this).val(def);
                }
            });
            input.blur(function() {
                if ($(this).val() == def) {
                    $(this).val('');
                }
            });
        }
    });
}

// Cookie helper to get and set cookies
pux = window.pux || {};
pux.cookie = {};
pux.cookie.set = function(name, value, expiration) {
  var date = new Date();
  var expires = "";
  if (expiration) {
    date.setTime(expiration);
    expires += "; expires="+date.toGMTString();
  }

  document.cookie = name + "=" + value + expires + "; path=/";
}

pux.cookie.get = function(name) {
  var name = name + "=";
  var ca = document.cookie.split(';');
  for (var i=0; i<ca.length; i++) {
    var c = ca[i].trim();
    if (c.indexOf(name)==0) return c.substring(name.length,c.length);
  }

  return "";
}

pux.firstTimeAlert = function () {
    $(".first-time-alert-close").click(function () {
        var date = new Date();
        pux.cookie.set("firstTimeUse", false, date.getTime() + 3600 * 24 * 60);
        $(this).parent().fadeOut();
    });

    var firstTimeUse = pux.cookie.get("firstTimeUse");
    if (firstTimeUse == "") {
        $(".first-time-alert").show();
    }
}

function hidePopupWindow () {
    $(".popup-window-container").hide();
}

$(function () {
    if (!window.$ && window.$j) {
        // kentico changed jquery function -> change it back
        $ = jQuery;
    }

    $(document).ready(function () {
        pux.firstTimeAlert();

       $(".downloadSuccessful a").attr("onclick", "function(){alert('test');} return true;");

       $(document).mousemove(function(e){
          window.mouseXPos = e.pageX;
          window.mouseYPos = e.pageY;
       }); 
    });

    erp.dialogs.init();

    // init filter
    erp.filter.init();

    // init ads wizard
    erp.adsWizard.init();

    erp.cart.fix();

    erp.ajax.init();

    erp.layout.init();
});