var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } }; var removeParameter = function(url, parameter) { var urlparts= url.split('?'); if (urlparts.length>=2) { var urlBase=urlparts.shift(); //get first part, and remove from array var queryString=urlparts.join("?"); //join it back up var prefix = encodeURIComponent(parameter)+'='; var pars = queryString.split(/[&;]/g); for (var i= pars.length; i-->0;) //reverse iteration as may be destructive if (pars[i].lastIndexOf(prefix, 0)!==-1) //idiom for string.startsWith pars.splice(i, 1); url = urlBase+'?'+pars.join('&'); } if ((url.substring(url.length-1)) == "?") { url = url.substring(0, url.length-1); } return url; }; var currentImage = 1; var imageTimings = [1200, 4000, 1500, 500]; var image1Ele = document.getElementById("img1"); var image2Ele = document.getElementById("img2"); var image3Ele = document.getElementById("img3"); var image4Ele = document.getElementById("img4"); var cheapoAnimation = function() { console.log("cheapo") try { image1Ele.style.display = "none"; image2Ele.style.display = "none"; image3Ele.style.display = "none"; image4Ele.style.display = "none"; var currentImageEle = eval("image" + currentImage + "Ele"); currentImageEle.style.display = "block"; currentImage ++; if (currentImage > 4) { currentImage = 1; } } catch(e) {}; setTimeout(cheapoAnimation, imageTimings[currentImage-1]); }; setTimeout(cheapoAnimation, imageTimings[0]); // $(function(){ // window.ink = window.ink || {}; // window.ink.fn = window.ink.fn || {}; // window.ink.initTimeout = null; // var windowHeight = $(window).height(); // var windowWidth = $(window).width(); // var imageHeight; // function cheapoParallax() { // // Scroll about half of the way up. // var scrollDistanceRatio = ($(window).scrollTop()/windowHeight); // if (scrollDistanceRatio < 1) { // var new_top = scrollDistanceRatio * imageHeight * 0.4 * -1; // $(".parallax_image").css({"top": new_top, "opacity": 1}); // } else { // $(".parallax_image").css({"opacity": 0}); // } // } // function cheapoParallaxSetup() { // windowHeight = $(window).height(); // windowWidth = $(window).width(); // // alert(windowHeight + "," + windowWidth); // if ($(".type_4").length === 0) { // if (windowWidth == 1024) { // // iPad Landscape // imageHeight = 550; // // Just not figuring out why media queries are being a bitch tonight. // $(".post .text_and_title").css({"padding-top": 20}); // } else { // if (windowWidth == 568) { // imageHeight = 360; // } else { // if (windowWidth < 600 ) { // // mobile // imageHeight = 160; // } else { // if (windowWidth > windowHeight) { // imageHeight = windowHeight*windowWidth / 1500; // } else { // imageHeight = windowHeight * 0.4; // } // } // } // } // $(".single_post .text_and_title").css({"margin-top": imageHeight}); // // $(window).scrollTop(64); // cheapoParallax(); // $(window).scroll(cheapoParallax); // } // } // if ($(".single_post .text_and_title").length > 0) { // cheapoParallaxSetup(); // $(window).resize(cheapoParallaxSetup); // } // function letterParallax() { // // Shift up about 300 px, max. // if (windowWidth > 600) { // var st = $(window).scrollTop(); // if (st < 0) { // st = 0; // } // if (st < 200) { // $(".snapshot").css({"top": st + 60}); // } else { // $(".snapshot").css({"top": 260}); // } // } // } // function letterParallaxSetup() { // windowHeight = $(window).height(); // windowWidth = $(window).width(); // if (windowWidth > 600) { // $(window).scrollTop(160); // letterParallax(); // $(window).scroll(letterParallax); // } // } // if ($(".letter_header").length > 0) { // letterParallaxSetup(); // $(window).resize(letterParallaxSetup); // } // window.ink.event = function(type, data) { // if (!data) { // data = {}; // } // if (window.ink.dev_mode) { // console.log("event"); // console.log(type); // console.log(data); // console.log(window.ink.uid); // console.log(window.ink.page_url); // } else { // if (window.ink.uid && window.ink.page_url) { // firebaseRef.child("events").push({ // "uid": window.ink.uid, // "timestamp": new Date().getTime(), // "url": window.ink.page_url, // "type": type, // "data": data, // }); // firebaseRef.child("users").child(window.ink.uid).child("events").push({ // "uid": window.ink.uid, // "timestamp": new Date().getTime(), // "url": window.ink.page_url, // "type": type, // "data": data, // }); // if (woopra) { // var woopra_data = data || {}; // woopra_data.page_url = window.ink.page_url; // woopra_data.title = document.title; // woopra_data.timestamp = new Date().getTime(); // if (type == "facebook_referral") { // woopra_data.fb_campaign = data.page_name; // woopra.identify({fb_campaign: woopra_data.fb_campaign}).push(); // } // if (type != "loaded") { // woopra.track(type, woopra_data); // } // } // } else { // setTimeout(function(){ // window.ink.event(type, data); // }, 250); // } // } // }; // window.ink.mark_piece = function(mark, truthy) { // if (window.ink.dev_mode) { // console.log("mark piece"); // console.log(window.ink.uid); // console.log(window.ink.page_url); // console.log(window.ink.loaded); // console.log("marking " + mark + " " + window.ink.page_url); // } else { // if (!window.ink.loaded || !window.ink.uid || !window.ink.page_url) { // setTimeout(function(){window.ink.mark_piece(mark, truthy);}, 250); // return; // } // if (truthy === undefined) { // truthy = true; // } // var data = {}; // data[mark] = truthy; // firebaseRef // .child("users") // .child(window.ink.uid) // .child("pieces") // .child(window.ink.page_url) // .update(data); // // data = {}; // // data[window.ink.uid] = truthy; // firebaseRef // .child("pieces") // .child(window.ink.page_url) // .child(mark) // .child(window.ink.uid) // .set(true); // if (woopra) { // woopra.track(mark, { // mark: (truthy) ? mark : "un" + mark, // page_url: window.ink.page_url, // title: document.title, // timestamp: new Date().getTime(), // }); // } // } // }; // window.ink.loaded = false; // if (getUrlParameter('cke') && getUrlParameter('cke').indexOf("@") != -1 && getUrlParameter('cke').indexOf(".") != -1) { // window.ink.list_email = getUrlParameter('cke'); // var clean_uri = removeParameter(window.location.toString(), 'cke'); // window.history.replaceState({}, document.title, clean_uri); // } // window.ink.init = function() { // if (window.ink.initTimeout) { // clearInterval(window.ink.initTimeout); // } // window.firebaseRef = new Firebase('https://inkandfeet.firebaseio.com'); // firebaseRef.onAuth(function(authData) { // if (window.location.href.indexOf("inkandfeet") == -1) { // window.ink.dev_mode = true; // } else { // window.ink.dev_mode = false; // } // if (authData) { // // Client is logged in, so check if it's anonymous or a real user // if (authData.provider === 'anonymous') { // // user is anonymous // // console.log(authData.uid) // if ($.jStorage) { // $.jStorage.set('uid', authData.uid); // } // window.ink.uid = authData.uid; // window.fire = firebaseRef.child("users").child(authData.uid); // window.ink.loaded = true; // // save authData.uid to some local session info, to keep track of data // } else { // // user is logged in // // transfer any data that you had stored from the anonymous session to // // this new authUser.uid // // console.log(authData.uid) // if ($.jStorage) { // $.jStorage.set('uid', authData.uid); // } // window.ink.uid = authData.uid; // window.fire = firebaseRef.child("users").child(authData.uid); // window.ink.loaded = true; // } // if (window.ink.loaded) { // // ?utm_source=Ink+and+Feet+Letter&utm_campaign=7fe17eef0c-Ink_and_Feet_2015_10_04&utm_medium=email&utm_term=0_ec93255dd4-7fe17eef0c-209471669&goal=0_ec93255dd4-7fe17eef0c-209471669 // window.fire.child("profile").once('value', function(dataSnapshot) { // window.ink.profile = {}; // if (dataSnapshot) { // window.ink.profile = dataSnapshot.val(); // try { // if (woopra) { // var woopra_data = { // uid: window.ink.uid, // }; // if (window.ink.profile && window.ink.profile.email) { // woopra_data.email = window.ink.profile.email; // woopra_data.name = window.ink.profile.first_name; // } // woopra.identify(woopra_data).push(); // } // } catch(e) {} // } // window.ink.profile_loaded = true; // if (window.ink.profile && window.ink.profile.subscribed) { // $(".letters .share").show(); // $(".letters .signup_blurb").hide(); // } // }, function(err) { // window.ink.profile_loaded = true; // }); // try { // if (undefined !== woopra && woopra && window.ink.list_email) { // woopra.identify({email: window.ink.list_email}); // woopra.track('convertkit_click'); // } // } catch (e) {} // if (getUrlParameter('fb')) { // // Store FB referrals for tracking. // window.ink.event("facebook_referral", {"page_name": getUrlParameter('fb')}); // var clean_uri = removeParameter(window.location.toString(), 'fb'); // window.history.replaceState({}, document.title, clean_uri); // } else { // if (getUrlParameter('utm_source')) { // window.ink.event("utm_referral", { // "source": getUrlParameter('utm_source'), // "campaign": getUrlParameter('utm_campaign') || "", // "medium": getUrlParameter('utm_medium') || "", // "term": getUrlParameter('utm_term') || "", // }); // firebaseRef.child("users").child(authData.uid).child("profile").update({ // "mailchimp_term": getUrlParameter('utm_term') || "", // "mailchimp_campaign": getUrlParameter('utm_campaign') || "", // "mailchimp_source": getUrlParameter('utm_source') || "", // "subscribed": true, // }); // } // } // } // } else { // // Client is unauthenticated // // console.log("unauthenticated") // // This would be a good spot to create the anonymous login // firebaseRef.authAnonymously(function(error, authData) { // if (error) { // // handle login failure // console.log(error); // } else { // // you are now anonymously logged in, but you really don't need to do anything // // here, because your onAuth() listener is already going to catch this auth change // } // }); // } // }); // ink.event('loaded'); // var first_name; // } // window.ink.handleSubscribeClick = function () { // window.ink.ouibounce_showing = false; // var parent = $(this).parents("form"); // var email = $("#ck_emailField", parent).val(); // first_name = $("#ck_firstNameField", parent).val(); // if (!first_name) { // first_name = ""; // } // if (email) { // $("#mce-error-response", parent).html(""); // if (!first_name) { // ink.event('subscribe_start', {"location": "modal"}); // } else { // ink.event('subscribe_start', {"location": "bottom"}); // } // if (window.ink.uid) { // firebaseRef.child("users").child(window.ink.uid).child("profile").update({ // "uid": window.ink.uid, // "email": email, // "first_name": first_name, // "subscribe_started": true, // "subscribed_at": new Date().getTime(), // }); // window.ink.ckInterval = window.setInterval(window.ink.watchCkFinish, 50); // window.ink.watchCkFinish(); // return true; // } else { // setTimeout(window.ink.handleSubscribeClick, 250); // } // } else { // $("#mce-error-response", parent).html("Missing email or first name!"); // return false; // } // }; // window.ink.watchCkFinish = function() { // if ($("#ck_success_msg").is(':visible')) { // clearInterval(window.ink.ckInterval); // $(".pre_success").hide(); // if (!first_name) { // ink.event('subscribe_finish', {"location": "modal"}); // } else { // ink.event('subscribe_finish', {"location": "bottom"}); // } // } // }; // window.ink.handleFormChange = function() { // var form = $(this).parents("form"); // // console.log("changed") // var email = $("#ck_emailField", form).val(); // if (email === "") { // email = false; // } // var first_name = $("#ck_firstNameField", form).val(); // if (first_name === "") { // first_name = false; // } // // console.log(email) // // console.log(first_name) // $("#ck_emailField", form).toggleClass("valid", !((!email || email.indexOf("@") == -1 || email.indexOf(".") === -1))); // $("#ck_firstNameField", form).toggleClass("valid", !(!first_name)); // $("#ck_emailField", form).parents(".field_block").toggleClass("valid", !((!email || email.indexOf("@") == -1 || email.indexOf(".") === -1))); // $("#ck_firstNameField", form).parents(".field_block").toggleClass("valid", !(!first_name)); // $(".subscribe_btn", form).toggleClass("valid", !(!first_name || !email || email.indexOf("@") == -1 || email.indexOf(".") === -1)); // }; // if (Firebase) { // window.ink.init(); // } else { // setInterval(window.ink.init(), 250); // } // $.getJSON(window.ink.site_data_url, function(json) { // window.ink.site_data = json; // }); // $(".depression_book_signup .subscribe_btn").on('click', window.ink.handleSubscribeClick); // $(".one_line_signup .subscribe_btn").on('click', window.ink.handleSubscribeClick); // $(".one_line_signup input").on('change', window.ink.handleFormChange); // $(".one_line_signup input").on('keyup', window.ink.handleFormChange); // window.ink.handleFormChange(); // }); // Ractive.DEBUG = false;