/*
	Stempora Web Framework
	Copyright (c) 2002-2018 Stempora. 
	All rights reserved.
		web:  www.stempora.com
		mail: support@stempora.com				
*/

var STBCookies = Object.create(STBModule.prototype);

STBCookies.name = "Cookies";
STBCookies.showAccept = function() {
    try {
        if (jQuery('.cookies-bar').length > 0) {
            
			var cookieBtn = jQuery(".cookies-bar button"),
				holder = jQuery(".cookies-bar"),
				over = jQuery(".cookies-bar .generic-text"),
				buttons = jQuery(".cookies-bar .buttons");


			if (jQuery("html").attr("dir") == "rtl") {
				over.css("padding-left" , buttons.width() + 20);
			} else {
				over.css("padding-right" , buttons.width() + 20);
			}
			
			cookieBtn.click(function() {

                ajaxForm = jQuery.ajax({
                    url: cookieBtn.attr("data-click"),
                    type: "post",
                    data: "set=1"
                }).done(function(msg){
					holder.fadeOut(function() {
						holder.remove();
					});
				});

			});		
        }

    } catch (e) {
        getStack(0, e);
    }
}

STBCookies.runOnReady = function() {
	STBCookies.showAccept();
}

site.registerModule(STBCookies);
