(function($) {    var posting_adress = "http://www.lifecake.com/lifecake/user/signups",        messages = {            success: "Thanks, we'll keep you posted",            user_exists: "Its seems that user with this email adress is already present",            error: "An error occured while trying to reach the server!<br/><br/>Please try again later.",            other_error: "Sorry! Your request failed with message: "        };    var bubble_texts = [        "His first tooth",        "Her favourite toy",        "His first word",        "Her favourite story",        "His first time on a bike",        "Her beautiful artwork",        "His favourite food"    ];    var current = 0,        bubble = $('#bubble-id'),        txt_el = bubble.find('.bubble-content'),        transition_time = 150,        showing_time = 4000,        pause_time = 1500;    function get_next(){        bubble.css("height", "auto");        txt_el.html( bubble_texts[current] );        var h = bubble.height(),            ww = -19,            wh = 3;        bubble.height(0);        if(current > bubble_texts.length -1) {           current = 0;        }        bubble.css({ "top": wh+"px", "left": ww+"px",  "-moz-transform": "scale(0.7)", "-webkit-transform": "scale(0.7)","-ms-transform": "scale(0.7)", "-o-transform": "scale(0.7)"  }).               animate({                    "opacity":1               },{                    duration: transition_time,                    queue: true,                    step: function(now,fx){                        $(this).css({                            "-moz-transform": "scale(" + (0.7+(now*0.3)) + ")",                            "-webkit-transform": "scale("+(0.7+(now*0.3))+")",                            "-ms-transform": "scale("+(0.7+(now*0.3))+")",                            "-o-transform": "scale("+(0.7+(now*0.3))+")",                            "top": (-1*(wh-(now*wh))) +'px',                            "left": (ww-(now*ww)) +'px',                        });                    },                    easing: "swing"               }).               /*animate({ "top": "-2px", "left": "-1px"},{duration: 100, queue: true, easing: "linear"}).               animate({ "top": "0px", "left": "0px"},{duration: 100, queue: true,easing: "linear"}).*/               animate({"foo":"1"},{duration: showing_time, queue: true}).               animate({"opacity":0},{                    duration: transition_time,                    queue: true,                    step: function(now,fx){                        $(this).css({                            "-moz-transform": "scale("+((now*0.3)+0.7)+")",                            "-webkit-transform": "scale("+((now*0.3)+0.7)+")",                            "-ms-transform": "scale("+((now*0.3)+0.7)+")",                            "-o-transform": "scale("+((now*0.3)+0.7)+")",                            "left": (-19*(1-now))+'px'                        });                    },                    easing: "swing"               }).               animate({"foo":"1"},{duration: pause_time, queue: true, complete: function() {                    current++;                    get_next();                    $(this).css({"left": "-=10px", "top": "-=5px"});               }});    }    function signup_submit(){        var ww = $(window).width(),            wh = $(window).height(),            el = $('.signup-notify'),            w = el.outerWidth(),            h = el.outerHeight(),            email = $('#my-email').val(),            valid = ( email.indexOf('@') > -1 ),            data = { "email": email };        if(!valid){            el.html('Email seems invalid!');            el.fadeIn();            setTimeout(function(){ el.fadeOut(); }, 3000);        } else {            el.fadeIn();            $.support.cors = true;            $.ajax({                url: posting_adress,                type: "POST",                data: JSON.stringify(data),                dataType: "json",                success: function(data, textStatus, jqXHR){                    switch(jqXHR.status) {                        case 200:                            el.html( messages.success );                            setTimeout(function(){ el.fadeOut(); }, 4000);                            _gaq.push(['_trackEvent', 'email', 'signup', 'success']);                        break;                        case 208:                            el.html( messages.user_exists );                            _gaq.push(['_trackEvent', 'email', 'signup', 'duplicate']);                            setTimeout(function(){ el.fadeOut(); }, 4000);                        break;                        default:                            el.html( messages.error );                            _gaq.push(['_trackEvent', 'email', 'signup', 'failed']);                            setTimeout(function(){ el.fadeOut(); }, 4000);                        break;                    }                },                error: function(response, textStatus, jqXHR){                    _gaq.push(['_trackEvent', 'email', 'signup', 'failed']);                    if(response.status == "404"){                        el.html( messages.error );                        setTimeout(function(){ el.fadeOut(); }, 5000);                    } else {                        el.html( messages.other_error + response.getResponseHeader('Error') );                        setTimeout(function(){ el.fadeOut(); }, 5000);                    }                }            });        }        return false;    }    window.signup_submit = signup_submit;    setTimeout(get_next,pause_time);})(jQuery);
