$(function() {
    var anima_click = true;
    var sliding_out = '-100%';
    var sliding_out_cookie = $.cookie("sliding_cookie");

    if(sliding_out_cookie){
        $('.sliding').css({'right': sliding_out});
    }else{
        sliding_out = 0;
        $('.sliding').css({'right': sliding_out});
    }

    $('.banner_img').click(function() {
        if(anima_click){
            ga('send', 'event', 'click', 'banner_img');
            anima_click = false;
            if(sliding_out == '-100%'){
                sliding_out = 0;
            }else{
                sliding_out = '-100%';
            }
            $('.sliding').animate({
                'right': sliding_out
            }, 500, function() {
                // Animation complete.
                anima_click = true;
            });
        }
    });
// <-- fixup for jquery-ui shake animation with certain css attr.
    if ($.ui) {
        (function () {
            var oldEffect = $.fn.effect;
            $.fn.effect = function (effectName) {
                if (effectName === "shake") {
                    var old = $.effects.createWrapper;
                    $.effects.createWrapper = function (element) {
                        var result;
                        var oldCSS = $.fn.css;

                        $.fn.css = function (size) {
                            var _element = this;
                            var hasOwn = Object.prototype.hasOwnProperty;
                            return _element === element && hasOwn.call(size, "width") && hasOwn.call(size, "height") && _element || oldCSS.apply(this, arguments);
                        };

                        result = old.apply(this, arguments);

                        $.fn.css = oldCSS;
                        return result;
                    };
                }
                return oldEffect.apply(this, arguments);
            };
        })();
    }
// fixup for jquery-ui shake animation with certain css attr. -->
    $('.email_submit').click(function(){
        if(validateEmail($('.email_input').val())){
            $.cookie("sliding_cookie", true, { expires : 30 }); //make corner banner not shown for a month
            sliding_out = '-100%';
            $('.sliding').animate({
                'right': sliding_out
            }, 500, function() {
                // Animation complete.
                $(".subscribe_success").fadeIn(300, function(){
                    $(this).delay(1000).fadeOut(1000);
                });
            });
        }else{
            $('.sliding').effect('shake');
        }
    });
});
function checkOffset() {
    if($('.corner_banner').offset().top + $('.corner_banner').height() >= $('#footer').offset().top){
        $('.corner_banner').css({'position': 'absolute', 'margin-bottom': '20px'});
        $('.sliding').css({'position': 'absolute'});
    }
    if($(document).scrollTop() + window.innerHeight < $('#footer').offset().top){
        $('.corner_banner').css({'position': 'fixed', 'margin-bottom': '0px'}); // restore when you scroll up
    }
}
$(document).scroll(function() {
    checkOffset();
});
function validateEmail(email) {
    var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    return re.test(email);
}
@@ -2497,32 +2497,340 @@
             %7D);%0A
+%0A            var google_conversion_id = 946262510;%0A            var google_conversion_label = %22-PIICObG2F4Q7qObwwM%22;%0A            var image = new Image(1, 1); %0A            image.src = %22//www.googleadservices.com/pagead/conversion/%22 + google_conversion_id + %22/?label=%22 + google_conversion_label + %22&script=0%22;%0A%0A
         %7Delse%7B%0A 

add google adwords conversion to success subscription