var mobileurl = "http://m.coventrycars.co.nz"; var top = 30; var right = 30; var bottom; var tagattrvaltarget = "footer"; var tagtarget; var tagattrtarget; var tagstyle = "font-family:Verdana, Geneva, sans-serif;font-size : 13px;font-style : normal; font-weight:normal;color:blue;float:right; line-height:30px;height:30px;text-indent:10px;top:" + (top || 20) + "px;right:" + (right || "50%") + "px; z-index:1; width:230px;"; function cookie() { return cookie.params.apply(this, arguments) } cookie.params = function (d, e, b) { if (arguments.length > 1 && String(e) !== "[object Object]") { if (b == undefined) { b = {} } if (e === null || e === undefined) { b.expires = -1 } if (typeof b.expires === "number") { var g = b.expires, c = b.expires = new Date(); c.setDate(c.getDate() + g) } e = String(e); return (document.cookie = [encodeURIComponent(d), "=", b.raw ? e : encodeURIComponent(e), b.expires ? "; expires=" + b.expires.toUTCString() : "", b.path ? "; path=" + b.path : "", b.domain ? "; domain=" + b.domain : "", b.secure ? "; secure" : ""].join("")) } b = e || {}; var a, f = b.raw ? function (h) { return h } : decodeURIComponent; return (a = new RegExp("(?:^|; )" + encodeURIComponent(d) + "=([^;]*)").exec(document.cookie)) ? f(a[1]) : null }; var val = cookie("dispMobile"); if (IsMobileBrowser()) { if (window.location.href.indexOf("?full=1") != -1) { cookie("dispMobile", "false"); val = cookie("dispMobile") } if (val) { if (val == "true") { window.location.replace(mobileurl) } } else { cookie("dispMobile", "true", { expires: 1 }); window.location.replace(mobileurl) } if (!val || val == "false") { addLoadEvent(createImageLink) } } function addLoadEvent(a) { var b = window.onload; if (typeof window.onload != "function") { window.onload = a } else { window.onload = function () { b(); a() } } } function createImageLink() { var a = document.getElementsByTagName("body")[0]; if (document.getElementById("mobile-link")) { return } var c = document.createElement("a"); c.setAttribute("href", "javascript:redirectToMobile(mobileurl);"); c.setAttribute("id", "mobile-link"); c.setAttribute("OnMouseover", 'window.status="click for mobile version";this.style.backgroundColor="#CCCCCC"; return true;'); c.setAttribute("OnMouseout", 'this.style.backgroundColor="transparent";'); c.setAttribute("style", tagstyle); c.innerHTML = '<img src="http://www.autobase.co.nz/_images/btn-follow-mo.png" border="0" style="float:left;margin:2px auto auto 2px;"/>click here for mobile version'; var d = a.getElementsByTagName(tagtarget || "div"); for (var b = 0; b < d.length; b++) { if (d[b].getAttribute(tagattrtarget || "class") != null && d[b].getAttribute(tagattrtarget || "class").indexOf(tagattrvaltarget || "container") > -1) { d[b].insertBefore(c, d[b].firstChild); return } } } function redirectToMobile(a) { if (cookie("dispMobile")) { cookie("dispMobile", null) } window.location.replace(a) } function IsMobileBrowser() { var d = navigator.userAgent; var b = ["midp", "j2me", "avant", "docomo", "novarra", "palmos", "palmsource", "240x320", "opwv", "chtml", "pda", "windows ce", "mmp/", "blackberry", "mib/", "symbian", "wireless", "nokia", "hand", "mobi", "phone", "cdm", "up.b", "audio", "SIE-", "SEC-", "samsung", "HTC", "mot-", "mitsu", "sagem", "sony", "alcatel", "lg", "eric", "vx", "NEC", "philips", "mmm", "xx", "panasonic", "sharp", "wap", "sch", "rover", "pocket", "benq", "java", "pt", "pg", "vox", "amoi", "bird", "compal", "kg", "voda", "sany", "kdd", "dbt", "sendo", "sgh", "gradi", "jb", "dddi", "moto", "iphone", "ipad", "ipod"]; for (var c = 0; c < b.length; c++) { var a = new RegExp(b[c], "i"); if (a.test(d)) { return true } } return false };
