/**
 * @author ryanturner
 */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20142723-1']);
_gaq.push(['_trackPageview']);

(function(){
    var ga = document.createElement('script');
    ga.type = 'text/javascript';
    ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(ga, s);
})();

//DETECT AND REDIRECT MOBILE VERSIONS
function detectAppStore(){
    if (document.location.pathname != "\/iphonefaq.html") {
        if (document.cookie.indexOf("appstore_redirect=false") < 0) {
            if (!navigator.userAgent.match(/Opera/i)) {
                if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
                    if (confirm("Dotti has Gone Mobile!\r\n On Sale for News Years Resolution.")) {
                        document.cookie = "appstore_redirect=false";
                        window.location = "http://itunes.apple.com/us/app/dottis-food-score/id371335878?mt=8";
                    }
                    else {
                        setAppStoreCookies();
                    }
                }
                else 
                    if (navigator.userAgent.match(/android/i)) {
                        if (confirm("Dotti has Gone Mobile!\r\n On Sale for News Years Resolution.")) {
                            document.cookie = "appstore_redirect=false";
                            window.location = "market://search?q=pname:com.bizmosis.dwlz";
                        }
                        else {
                            setAppStoreCookies();
                        }
                    }
            }
        }
        
    }
}

function setAppStoreCookies(){
    var date = new Date();
    date.setTime(date.getTime() + (90000));
    var expires = "; expires=" + date.toGMTString();
    document.cookie = "appstore_redirect=false" + expires;
}

detectAppStore();


