var typeDevice = "desktop"; if (navigator.userAgent!=null){ var userAgentVerify = navigator.userAgent.toLowerCase(); if ( userAgentVerify.indexOf("ipad") != -1 || (userAgentVerify.indexOf("tablet") != -1 && userAgentVerify.indexOf("tablet pc") == -1) || userAgentVerify.indexOf("playbook") != -1 || (userAgentVerify.indexOf("android") != -1 && userAgentVerify.indexOf("mobile") == -1) ){ typeDevice = "tablet"; } if ( userAgentVerify.indexOf("ipod") != -1 || userAgentVerify.indexOf("iphone") != -1 || (userAgentVerify.indexOf("android") != -1 && userAgentVerify.indexOf("mobile") != -1) || userAgentVerify.indexOf("windows phone") != -1 || userAgentVerify.indexOf("windows ce") != -1 || userAgentVerify.indexOf("fennec") != -1 || userAgentVerify.indexOf("maemo") != -1 || userAgentVerify.indexOf("symbian") != -1 ){ typeDevice = "smartphone"; } } keepDesk=getCookieDevice("keepDesk"); function setCookieDevice(cookieName,cookieValue,nDays) { var today = new Date(); var expire = new Date(); if (nDays==null || nDays==0) nDays=1; expire.setTime(today.getTime() + 3600000*24*nDays); document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString(); } function getCookieDevice(cookieName) { var theCookie=" "+document.cookie; var ind=theCookie.indexOf(" "+cookieName+"="); if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"="); if (ind==-1 || cookieName=="") return ""; var ind1=theCookie.indexOf(";",ind+1); if (ind1==-1) ind1=theCookie.length; return unescape(theCookie.substring(ind+cookieName.length+2,ind1)); } if( top != null && top.document != null && top.document.referrer!=null ){ if ( top.document.referrer.indexOf("http://m.chiesacattolica.it")!=-1 || top.document.referrer.indexOf("0")!=-1 ) { if(keepDesk!=1){ keepDesk = 1; setCookieDevice("keepDesk",keepDesk,(1/12)); } } } if (navigator.userAgent!=null){ if ( typeDevice != "desktop" ){ if ( typeDevice == "smartphone" ){ if(keepDesk!=1){ top.location.href="http://m.chiesacattolica.it"; } } } }