(function() { function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires=" + date.toGMTString(); } else var expires = ""; document.cookie = name + "=" + value + expires + "; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } /* */ var geoAdvisoryCC="FR"; /* */ var tdays = 3; var cookieVal = readCookie('geoadvisory'); var debugCookie = readCookie('debugGeo'); if (debugCookie) { console.log("** geoAdvisoryPopup: FOUND debugGeo COOKIE: " + debugCookie); geoAdvisoryCC = debugCookie; cookieVal = 0; } if ((cookieVal !== '1') && (navigator.appVersion.indexOf("MSIE 6")===-1)) { var popFlag; do { //Canada if (geoAdvisoryCC==='CA') { popFlag = true; popImg = 'Redirect_CA_V7.jpg'; popUrl = 'http://www.foodnetwork.ca/?omnisource=gid_ca'; stayQ = 'c1=foodnetworkUS'; break; } //US if (geoAdvisoryCC==='US') { //in case it gets through -- esi in html should prevent popFlag = false; break; } //UK if (geoAdvisoryCC === 'GB'||geoAdvisoryCC==='IE') { popFlag = true; popImg = 'Redirect_UK.jpg'; popUrl = 'http://www.foodnetwork.co.uk/?omnisource=gid_uk'; stayQ = 'c1=gid_uk'; break; } //Asia var asia="BD BT BN KH CN TW HK IN ID JP KR KP LA MY MV MN MM NP PK PH SG LK TH VN"; if (asia.indexOf(geoAdvisoryCC)!==-1){ popFlag = true; popImg = 'Redirect_Asia.jpg'; popUrl = 'http://www.foodnetworkasia.com/?omnisource=gid_asia'; stayQ = 'c1=gid_asia'; break; } //Europe var eu="AL AD AM AT AZ BY BE BA BG HR CY CZ DK EE FO FI FR FX GE DE GI GR GL HU IS IT KZ KG LV LI LT LU MK MT MD MC NL NO PL PT RO RU SM LS SK SI ES SJ SE CH TJ TR TM UA UZ VA"; if(eu.indexOf(geoAdvisoryCC)!==-1) { popFlag = true; popImg = 'Redirect_Europe.jpg'; popUrl = 'http://www.foodnetworktv.com/?omnisource=gid_europe'; stayQ = 'c1=gid_europe'; break; } //Middle East var me="BH IO IR IQ IL JO KW LB PS QA RE SA AE YE"; if(me.indexOf(geoAdvisoryCC)!==-1) { popFlag = true; popImg = 'Redirect_Middle-East.jpg'; popUrl = 'http://www.foodnetworktv.com/?omnisource=gid_me'; stayQ = 'c1=gid_me'; break; } //africa var af="DZ AO BJ BW BV BF BI CM CV CF TD KM CG CD CI DJ EG GQ ER ET GA GM GH GN GW KE LS LR LY MG MW ML MR MU YT MA MZ NA NE NG OM RW ST SN SC SL SO ZA SZ TZ TG TN UG EH ZM ZW"; if(af.indexOf(geoAdvisoryCC)!==-1) { popFlag = true; popImg = 'Redirect_Africa.jpg'; popUrl = 'http://www.foodnetworktv.com/?omnisource=gid_africa'; stayQ = 'c1=gid_africa'; break; } //pacific var pf="AS AU CX CC CK FJ PF GU KI FM MP NR NC NZ NU NF MH PW PG WS SB TO TV VU WF"; if(pf.indexOf(geoAdvisoryCC)!==-1) { popFlag = true; popImg = 'Redirect_Asia.jpg'; popUrl = 'http://www.foodnetworkasia.com/?omnisource=gid_pacific'; stayQ = 'c1=gid_pacific'; break; } //Brazil var br="BR"; if(br.indexOf(geoAdvisoryCC)!==-1) { //if(debugCookie) { popFlag = true; popImg = 'Redirect-Brazil.jpg'; popUrl = 'http://www.foodnetwork.com.br/?omnisource=gid_brazil'; stayQ = 'c1=gid_brazil'; break; } //if nothing matches no popup popFlag = false; } while (false); if (debugCookie) { popFlag = true; } if (popFlag) { // added to prevent newsletter from popping up on top of the international popup. createCookie('email_collect_displayed', 'true', tdays); document.write(''); var geoPop = document.createElement('div'); geoPop.className = 'geoAdvisoryPopup'; var geoPopChild = document.createElement('div'); geoPopChild.setAttribute('id', 'geoAdvisoryInner'); geoPopChild.style.cssText = 'background-image:url(http://images.foodnetwork.com/webfood/fn20/imgs/' + popImg + ');'; var geoPopLeft = document.createElement('a'); //if (window.location.href.indexOf('?')==-1) {sep='?';} // else {sep='&';} geoPopLeft.setAttribute('href', window.location.href);//make mouseover show current page geoPopLeft.setAttribute('id', 'geoAdvisoryContinue'); geoPopLeft.onclick = function() {//hide popup geoPop.style.display = "none"; // if the user hits cancel, delete the newsletter cookie to allow newsletter popup on next page createCookie('email_collect_displayed', 'true', -1); return false; }; geoPopChild.appendChild(geoPopLeft); var geoPopRight = document.createElement('a'); geoPopRight.setAttribute('href', popUrl); //redirect link geoPopRight.setAttribute('id', 'geoAdvisoryTransfer'); geoPopChild.appendChild(geoPopRight); geoPop.appendChild(geoPopChild); document.body.appendChild(geoPop); }//popflag if }//cookie if createCookie('geoadvisory', 1, tdays); })();