


// getQueryParamValue - read query string parameter
// @param  name to retrieve.
function getQueryParamValue(param) { 
var q = document.location.search; 
var detectIndex = q.indexOf(param); 
var endIndex = (q.indexOf("&", detectIndex) != -1) ? q.indexOf("&", detectIndex) : q.length; 
if(q.length > 1 && detectIndex != -1) { 
		return unescape(q.substring(q.indexOf("=", detectIndex)+1, endIndex)); 
	} else { 
		return ""; 
	} 
}


// iv_fsaGC - Cookie reading fucntion. Only to be used for arrival code.
// @param Cookie name to retrieve.
// @param Cookie value; null of it doesn't exist.
function iv_fsaGC(cookieName) {
    var tCookie = document.cookie;
    var cName = cookieName + "=";
    var sIndex = tCookie.indexOf(cName, 0); if (sIndex == -1) return null;
    var eIndex = tCookie.indexOf(";", sIndex); if (eIndex == -1) eIndex = tCookie.length;
    return unescape(tCookie.substring(sIndex + cName.length, eIndex));
}

// iv_fsaDC - Cookie deletion function (current domain only). Only to be used for arrival code.
// @param name Cookie name.
function iv_fsaDC(name) {
    if (iv_fsaGC(name)) {
        document.cookie = name + "=; path=/; domain=; expires=Thu, 01-Jan-1970 00:00:01 GMT";
    }
}

// iv_fsaSetIntervalCookie - Sets cookies. Only to be used for arrival code.
// @param name Cookie name.
// @param value Cookie value.
// @param interval Time interval for cookie expiration.
// @param mode Interval mode. Can be days/hours/minutes.
function iv_fsaSetIntervalCookie(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 24 hours)
        now.setTime(now.getTime() + ((interval - 1) * aDay) + (24 - now.getHours()) * aHour + aMinute);
    } else if (mode == "hours") {
        now.setTime(now.getTime() + interval * aHour);
    } else if (mode == "minutes") {
        now.setTime(now.getTime() + interval * aMinute);
    }

    // now set the cookie
    document.cookie = name + "=" + escape(value) + "; expires=" + now.toGMTString() + "; path=/";
}

// iv_fsaQS - Reads a query string from the URL. Only to be used for arrival code.
// @param keyName Name of key to retrieve. Not case sensitive. If key name is FULLQS, returns entire querystring.
// @return Key value; "" if it doesn't exist.
function iv_fsaQS(keyName) {
    var kValue = "";
    var tHREF = window.location.href;
    var qStringBegin = tHREF.indexOf("?");
    if (qStringBegin == -1) return "";
    var qString = tHREF.substring(qStringBegin + 1, tHREF.length);

    if (keyName == "FULLQS") { return qString; }

    var arrKV = qString.split("&");
    for (i = 0; i < arrKV.length; i++) {
        var KV = arrKV[i].split("=");
        if (KV[0].toUpperCase() == keyName.toUpperCase()) { kValue = KV[1]; }
    }

    pPos = kValue.indexOf('+');  
    while (pPos != -1) {
        kValue = kValue.substring(0, pPos) + " " + kValue.substring(pPos + 1, kValue.length); pPos = kValue.indexOf('+');
    }

    return unescape(kValue);
}

// Cobrand information, needed here before lost to arrival ad redirect.
iv_cobrandRef = 0;
if (document.referrer.indexOf('women.msn.com') > 0) { 
    iv_cobrandRef = 'msnwomen'; 
} else if (document.referrer.indexOf('health.msn.com') > 0) { 
    iv_cobrandRef = 'msndiet'; 
} else if (document.referrer.indexOf('lycos.com') > 0) {
    iv_cobrandRef = 'lycos';
}

document.write('<s'+'cript src="http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/cobrand/jscobrand.js" language="javascript" type="text/javascript"></s' + 'cript>');

