﻿
function setCookie(c_name, value, exdays) {var exdate = new Date();exdate.setDate(exdate.getDate() + exdays);var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());document.cookie = c_name + "=" + c_value;}

function getCookie(c_name) { var i, x, y, ARRcookies = document.cookie.split(";"); for (i = 0; i < ARRcookies.length; i++) { x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("=")); y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1); x = x.replace(/^\s+|\s+$/g, ""); if (x == c_name) { return unescape(y); } } }

function isValidWP7() { return (navigator.userAgent.indexOf("IEMobile/7.0") != -1) }; function isValidiOS() { var a = navigator.userAgent.toLowerCase(); return a.indexOf("iphone") >= 0 || a.indexOf("ipod") >= 0 };function isValidAndroid() { return (navigator.userAgent.indexOf("Android") != -1 && navigator.userAgent.indexOf("Android 1") == -1) };

var cookieName = 'TopCashBackMobileCookie'; var cookieValue = getCookie(cookieName); var confirmMsg = "Have you downloaded our app yet? We think it's a much better way of viewing Top CashBack on your phone and it's totally FREE!";

function AlertMobileUsers() {

    if (cookieValue != 'true') {
        if (isValidiOS()) { if (confirm(confirmMsg)) {window.location.href = 'http://itunes.apple.com/gb/app/top-cashback/id408175694?mt=8&source=TCBGadgetsPage&affId=1131200&ign-mpt=uo%3D4#';}}
        if (isValidAndroid()) {if ((confirm(confirmMsg))) {window.location.href = 'market://details?id=uk.co.topcashback.topcashback';}}
        if (isValidWP7()) {if ((confirm(confirmMsg))) {window.location.href = 'http://social.zune.net/redirect?type=phoneApp&id=d8522432-ead8-df11-a844-00237de2db9e';}}
        setCookie(cookieName, true, 100);
    }
};
