var lotd_html = ''; var newsletterCookieName = 'lookoftheday'; var get_cookie_contents = getCookie(newsletterCookieName); if (get_cookie_contents == 'alreadyOffered') { var lotd_html = "
"; } if (get_cookie_contents != 'alreadyOffered') { var lotd_html = "

Get Look of the Day E-mail

Be the first to see what the stars are wearing — every day. Subscribe to our Look of the Day e-mail.
 
"; } function validate(myForm) { var flag = 0; e = myForm.elements; for (i=0; i < myForm.length; i++) { if ((e[i].name == 'email') && (ValidEmail(e[i].value) == false)) { alert('Please provide a valid email address.'); e[i].focus(); e[i].select(); return false; } } var set_cookie_contents = setCookie(newsletterCookieName, 'alreadyOffered'); /* var newPath = 'https://www.timeinc.net/instyleuk/secure/sweeps/lookoftheday/index.html' + '?email_address=' + myForm.email.value; msgWindow=open(newPath, 'window2', 'height=500,width=400,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes'); return false; if (msgWindow.opener == null) msgWindow.opener = self; */ return true; } function ValidEmail(s) { var Count; var s2; // empty or blank email if (EmptyString(s) == true) return (false); // email with whitespace if (s.indexOf(' ') != -1) return (false); // email without @ if (s.indexOf('@') == -1) return (false); // email with @ as the 1st char if (s.indexOf('@') == 0) return (false); // email with @ as the last char if ((s.indexOf('@')+1) == s.length) return (false); // email without . if (s.indexOf('.') == -1) return (false); // email with . as the 1st char if (s.indexOf('.') == 0) return (false); // email with . as the last char if ((s.indexOf('.')+1) == s.length) return (false); // Now look for the first . after the first @ // s2 = string after the first @ s2=s.substring(s.indexOf('@')+1,s.length); // email without a dot after the first @ if (s2.indexOf('.') == -1) return (false); // email dot right after the first @ if (s2.indexOf('.') == 0) return (false); return (true); } function EmptyString(s) { var Count; var Nblank = 0; if (s.length == 0) return (true); // empty string // count the number of blank chars for (Count = 0; Count < s.length; Count++) { if (s.charAt(Count) == ' ') Nblank++; } if (Nblank == s.length) return (true); else return (false); } function setCookie (name, value) { document.cookie = name + "=" + escape(value); } function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } function clearText(theField) { theField.value = ""; }