


 

<!-- hide
// Begin Version Detection
isDOM  = (document.getElementById);
isNS4  = (document.layers);
isIE   = (document.all);
isIE4  = (isIE && !isDOM);
isMac  = (navigator.appVersion.indexOf("Mac") != -1);
isIE4M = (isIE4 && isMac);
isIE5M = isDOM && isIE && isMac;
isIE5W = isDOM && isIE && !isMac;
isNS6 =  isDOM && (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));
// End Version Detection
iv_verticalID = "";

// Scriptlets
if (typeof iv_scriptletIncluded_cta == "undefined") { document.write("<scr"+"ipt language=\"javascript\" type=\"text/javascript\" src=\"http://www.ivillage.com/shared/js/scriptlets/0,,cta,00.js\"></scr" + "ipt>"); var iv_scriptletIncluded_cta = 1; }
if (typeof iv_scriptletIncluded_utilities == "undefined") { document.write("<scr"+"ipt language=\"javascript\" type=\"text/javascript\" src=\"http://www.ivillage.com/shared/js/scriptlets/0,,utilities,00.js\"></scr" + "ipt>"); var iv_scriptletIncluded_utilities = 1; }
if (typeof iv_scriptletIncluded_json == "undefined") { document.write("<scr"+"ipt language=\"javascript\" type=\"text/javascript\" src=\"http://www.ivillage.com/shared/js/scriptlets/0,,json,00.js\"></scr" + "ipt>"); var iv_scriptletIncluded_json = 1; }

// Reads a query string from the URL. Pass in the key name and get back the value. */ 
function queryString(keyName) { 
var keyValue = ""; 
keyName = keyName.toUpperCase() + "="; 

if (window.location.href.indexOf("?") != -1) { 
     var queryString = window.location.href.substring(window.location.href.indexOf("?")+1); 
     var searchString = queryString.toUpperCase(); 
     if (searchString.indexOf(keyName) != -1) { 
      var keyValueStart = parseInt(searchString.indexOf(keyName)) + keyName.length; 
      var keyValueEnd = searchString.indexOf("&", keyValueStart); 
      var keyValueEnd = (keyValueEnd != -1) ? keyValueEnd : searchString.length; 
      keyValue = queryString.substring(keyValueStart,keyValueEnd); 
     }

     var plusPos = keyValue.indexOf('+');
     while (plusPos != -1) {
         keyValue = keyValue.substring(0, plusPos) + " " + keyValue.substring(plusPos + 1, keyValue.length);
         plusPos = keyValue.indexOf('+');
     }
} 
return unescape(keyValue); 
} 

// Verifies search input. To be deleted.
// @param Form to be checked.
// @return true/false depending on validation.
function processFindIt (box) {
    mt = box.qry.value;
    if (mt.length == 0) {
        alert ('Your search could not be completed because no search words were entered.');
        return false;
    }
}

// To be deleted
// Submit handler. Verifies search input. Alters action depending on button pushed.
// Script will check for optional global shadow tags (shadowTagAJ & shadowTagG)
// @param inputForm Form object to be checked.
// @return boolean value if form is valid or not.
function handleSearchSubmit(inputForm) {
    // Check for shadow tags
    var shadowAJ = typeof(shadowTagAJ) == 'undefined' ? "" : shadowTagAJ;
    var shadowG = typeof(shadowTagG) == 'undefined' ? "" : shadowTagG;

    mt = inputForm.qry.value;
    if (mt.length == 0) {
        alert ('Your search could not be completed because no search words were entered.');
        inputForm.qry.focus();
        inputForm.qry.select();
        return false;
    }

    for (var i = 0; i < inputForm.alias.length; i++) {
        if (inputForm.alias[i].checked) {
            var selectedValue = inputForm.alias[i].value;
        }
    }

    if (selectedValue == "google") {
        inputForm.action = shadowG + "http://search.ivillage.com/google/";
    } else {
        inputForm.action = shadowAJ + "http://findit.ivillage.com/find/";
    }

    return true;
}


// Submit handler. Verifies search input. Alters action depending on button pushed.
// @param inputForm Form object to be checked.
// @return boolean value if form is valid or not.
function handleGoogleSubmit(inputForm) {
    mt = inputForm.q.value;
    if (mt.length == 0) {
        alert ('Your search could not be completed because no search words were entered.');
        inputForm.q.focus();
        inputForm.q.select();
        return false;
    }

    for (var i = 0; i < inputForm.restrict.length; i++) {
        if (inputForm.restrict[i].checked) {
            var selectedValue = inputForm.restrict[i].value;
        }
    }
	var skin = inputForm.sk.value;

    if (selectedValue == "") {
		if (skin == "ivi") {
        	inputForm.action = "http://search.ivillage.com/search/web";
		} else if (skin == "gur") {
			inputForm.action = "http://search.ivillage.com/search/webgurl";
		} else if (skin == "wom") {
			inputForm.action = "http://search.ivillage.com/search/webwomen";
		} else if (skin == "ast") {
			inputForm.action = "http://search.ivillage.com/search/web";
		}
		return true;
    } else if (selectedValue == "Astrology") {
		inputForm.action = "http://search.ivillage.com/search/ivillage";
	} else if (selectedValue == "gURL") {
		inputForm.action = "http://search.ivillage.com/search/gurl";
	} else if (selectedValue == "Women") {
		inputForm.action = "http://search.ivillage.com/search/women";
	} else {
		inputForm.action = "http://search.ivillage.com/search/ivillage";	
    }
	myInput = document.createElement("INPUT");    
	myInput.name="filter";
	myInput.id="idFilter";
	myInput.value="p";
	myInput.type="hidden";
	inputForm.appendChild(myInput);
    return true;
}

// interstitial for tool front ends
function popAdTFE (subForm) {
  if (subForm.useCookie != null) {
    if (GetCookie('ivQuiz') == null) {
      SetCookie('ivQuiz', 'yes', '', '', '.ivillage.com');
    } else {
      return true;
    }
  }
  ivAD=window.open('/interquizzal/frame/0,,'+subForm.hidden_ID.value+',00.html' ,'ivAd',"WIDTH=480,HEIGHT=515");
  quizForm = subForm;
  setInterval("ivAD.close();",15000);
  if (navigator.platform == 'MacPPC') {
    timerID = setInterval("if (ivAD.closed || !ivAD) {quizForm.submit(); clearInterval(timerID);}",1000);
  } else {
    setInterval("quizForm.submit();",15100);
  }
  return false;
}

// Select box redirector (opens in same window)
function newpage(box) {
  if (box.options[box.selectedIndex].value == '') { return; }
  document.location.href = box.options[box.selectedIndex].value;
}

function pleasedontGo(box) {
  if (box.selectedIndex == -1) { alert('Please select a value first.'); return; }
  val = box.options[box.selectedIndex].value; window.open (val,'_top'); }

// Select box redirector (opens in new window)
function windowRedirect (selectBox) {
  if (selectBox.selectedIndex == -1) {
    alert("Please select a value first.");
    return;
  }
  
  val = selectBox.options[selectBox.selectedIndex].value;
  window.open (val,'_top');
}

// 4th Column redirector (opens in new window)
function pleasedoGo(box) {
  if (box.selectedIndex == -1) {
    alert('Please select a value first.');
    return;
  }
  
  if (box.options[box.selectedIndex].value == '') { return; }
  val = box.options[box.selectedIndex].value;
  window.open (val,'sponsor');
}

// Generic window opener (need to pass html)
function newWin(width, height, bgcolor, lcolor, name, title, content) {
  popupWin = window.open("", name, "scrollbars,width=" + width + ",height=" + height);
  if (popupWin == null) {window.open("", name, "width=" + width + ",height=" + height);}
  // the funkiness below is to prevent nesting of the scr*pt tags
  var m = "<html>\n<head><title>" + title + "</title>\n<scrip" + "t language=javascript>function t() {}</scrip" + "t></head>\n<body bgcolor=#" + bgcolor + " link=#" + lcolor + " alink=#" + lcolor + " vlink=#" + lcolor + ">\n";
  m += content;
  m += "</body>\n</html>";
  popupWin.document.write(m);
  popupWin.document.close();
  popupWin.focus();
}

// CIMS form handler.  
// Checks the email field, and sets cid and cid fields. All CIMS forms MUST have 
// these fields.
function processCIMS (theForm,popUp) {
   // See if we have any spaces.
	var space = theForm.email.value.indexOf(" ");
	if (space != -1) { 
	alert("Please check your email address");
	return false; 
	}
	
	var pos1 = theForm.email.value.indexOf("@");
    if (pos1 < 1) { 
	alert("Please check your email address");
	return false; 
	}
    var email = theForm.email.value.substr(pos1 + 1);
    var pos2 = theForm.email.value.indexOf(".");
    if (pos2 < 1 || theForm.email.value.substr(pos2 + 1) == "" || (pos2 - pos1) == 1) { 
	alert("Please check your email address");
	return false; 
	}
	

  if (typeof(cimsCid) != 'undefined') {
    theForm.cid.value=cimsCid;
  }
  
  if (typeof(cimsUid) != 'undefined') {
	theForm.uid.value=cimsUid;
  }
  
  // Append the email address to the rurl.
  //theForm.rurl.value += "?email=" + theForm.email.value;
  
  // If popUp is specified, open CIMS in a new window.
  if (popUp == 'y') {
    cimsWindow = window.open('','cimsWindow',"WIDTH=770,HEIGHT=600,scrollbars=yes,toolbar=yes,resizable=yes,location=yes,menubar=yes,statusbar=yes"); 
    theForm.target = 'cimsWindow';
    return true;
  } else {
    return true;
  }
}



function isValidEmail(email) {
    // See if we have any spaces.
	var space = email.indexOf(" ");
	if (space != -1) { return false; }
	
	var pos1 = email.indexOf("@",1);
    if (pos1 < 1) { return false; }
    var email = email.substr(pos1 + 1);
    var pos2 = email.indexOf(".",1);
    if (pos2 < 1 || email.substr(pos2 + 1) == "") { return false; }
    return true;
}
// @param thisForm Form object to be tested
// @param popUp checks for popUp window
// @return true/false
function doNewsletterSubmit(theForm,popUp) {
    theForm.ip.value = document.location.href;
    theForm.action="https://subscriber.ivillage.com/sagews"    //Get Server Environment
	if (!isValidEmail(theForm.email.value)) {
	  alert("Enter valid email address");
	  return false;
    }	

    if (theForm.r.value == "") { theForm.r.value = "http://www.ivillage.com/ivillage/thankyou/newsletters"; }
	if (popUp == 'y') {
	    sageWindow = window.open('','sageWindow',"WIDTH=500,HEIGHT=500,scrollbars=yes,toolbar=yes,resizable=yes,location=yes,menubar=yes,statusbar=yes"); 
    	theForm.target = 'sageWindow';
		theForm.submit();
    	return false;
  	} else {
		theForm.submit();
    	return false;
  	}

}

// @param thisForm Form object to be tested
// @param popUp checks for popUp window
// @return true/false
function doFunnel4Submit(theForm,popUp) {
    theForm.action="https://subscriber.ivillage.com/funnels/4/" 
	if (!isValidEmail(theForm.email.value)) {
	  alert("Enter valid email address");
	  return false;
    }	

    if (popUp == 'y') {
	    sageWindow = window.open('','sageWindow',"WIDTH=720,HEIGHT=500,scrollbars=yes,toolbar=yes,resizable=yes,location=yes,menubar=yes,statusbar=yes"); 
    	theForm.target = 'sageWindow';
		theForm.submit();
    	return false;
  	} else {
    	return true;
  	}
}


// ===== Cookie Code =====
var ckToday = new Date();

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) { endstr = document.cookie.length; }
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) { return getCookieVal (j); }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      "; path=" + ((path) ? path : "/") +
      ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-1970 00:00:01 GMT";
  }
}
 
function SetCookie (name,value,expires,path,domain) {
  // expires represents a value in days
  var ckToday = new Date();
  if (expires != null) { var exp = new Date(ckToday.getTime() + expires * 24 * 60 * 60 * 1000); }
  document.cookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + exp.toGMTString() : "") +
    "; path=" + ((path) ? path : "/") +
    ((domain) ? "; domain=" + domain : "");
}

function setIntervalCookie (name, value, interval, mode) {
  var now = new Date();
  var aDay = 86400000
  var aHour = 3600000
  var aMinute = 60000
  var aSec = 1000
  
  if (mode == 'days') {
    //this gets the precise seconds to set the cookie, calculating the days (not 24hours)
    now.setTime(now.getTime() + ((interval-1)*aDay)+(24-now.getHours())*aHour+aMinute)
  } else if (mode == 'hours') {
	now.setTime(now.getTime() + interval * aHour)
  }
 
  //now set the cookie
  document.cookie = name+"="+escape(value)+"; expires="+now.toGMTString()+"; path=/";
}
// ===== End Cookie Code =====




if(!window.saveInnerWidth) {
  window.onresize = resize;
  window.saveInnerWidth = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
}

function resize() {
    if (saveInnerWidth < window.innerWidth || 
        saveInnerWidth > window.innerWidth || 
        saveInnerHeight > window.innerHeight || 
        saveInnerHeight < window.innerHeight ) 
    {
        window.history.go(0);
    }
}

// Feedroom video popup
function iv_FRPop(url) {
    popupWindow = window.open(url,"videoPopup","width=800,height=500,location=yes,toolbar=yes,status=yes,resizable=yes,scrollbars=yes,menubar=yes,left=10,top=10");
    popupWindow.focus();
}

function challengeUser() {
	// Validate user
	if (GetCookie('temp_auth') != "logged" && (queryString("pp_user") == "" && queryString("pp_ticket") == "")) {
		document.location = "https://subscriber.ivillage.com/funnels/7?vrt=pp&prd=pregcl&dd="+escape(document.location);
	} else {
	  SetCookie('temp_auth','logged');
	}
}

// end hide -->

