var loc = new String(location);
var dmn =  'http://' + location.hostname;
if (!remoteDomain) { var remoteDomain = '';}

/************** PROTOTYPE DEFINITIONS **************/
/* Array.push() from arrayprototype.js at dhtmllab.com, tweaked a little */
P = Array.prototype;
if (P.push && ([0].push(true) == true)) P.push = null;
	if (!P.push) {
		P.push = function() {
		for (var i = 0; i < arguments.length; i++) { this[this.length] = arguments[i]; }
		return this.length;
    }
}

String.prototype.contains = function (str) { return( (this.indexOf(str)==-1) ?  false : true) } 

//Parse values from querystring - creates a hash "vars" - ex. vars['pet']="cat"
var parseStr = location.search.toString().substring(1,location.search.toString().length);	
var parsedVars = parseStr.split('&'), vars = [];
for (i=0;i<parsedVars.length;i++) { vars[parsedVars[i].split('=')[0]] = parsedVars[i].split('=')[1]; }

document.write('<script type="text/javascript" language="javascript" src="' + remoteDomain + '/js/common/javascript_wrapper.php?q=' + escape(loc) + '&PHPSESSID=' + Get_Cookie('PHPSESSID') + '"></scr' + 'ipt>');
// document.write('<script type="text/javascript" language="javascript" src="/js/common/javascript_wrapper.php?q=' + escape(loc) + '&PHPSESSID=' + vars['PHPSESSID'] + '"></scr' + 'ipt>');
// document.write('<script type="text/javascript" language="javascript" src="/js/common/javascript_wrapper.php?q=' + escape(loc) + '"></scr' + 'ipt>');
// document.write('<script type="text/javascript" language="javascript" src="/js/common/javascript_wrapper.php?PHPSESSID=' + Get_Cookie('PHPSESSID') + '"></scr' + 'ipt>');
document.write('<SCRIPT TYPE="text/javascript" src="' + remoteDomain + '/js/common/javascript_targeter.php"></scr' + 'ipt>');


/************** GLOBAL VARIABLES **************/

// var loc = new String(location);  // Moved above
// var dmn =  'http://' + location.hostname; // Moved above

var onGoogle = (loc.contains('googlebot'));
var googleDev = (loc.contains('dev.xsl'));
if ((onGoogle) && (googleDev)) { dmn = "http://devwww.mylifetime.com"; }
if ((onGoogle) && (!googleDev)) { dmn = "http://www.mylifetime.com"; }
var onDev = loc.contains('http://dev.');
var onQa  = loc.contains('http://qa');  // added 5/11/07
var onStage  = loc.contains('http://stage');  // added 4/29/08
var onLRW = loc.contains('/lrw');

var domain = dmn;

//Global Nav Links
var gNavLinks = new Array();
var headerLinks = new Array();
var tvschedLinks = new Array();

var divider = " &nbsp; &nbsp; --------------- ";

//Global site right nav
gNavLinks = 
[
{ 'header' : 'ORIGINAL MOVIE', 'url' : '#' },
{ 'label' : 'Write &amp; Wrong', 'url' : domain + '/movies/originals/writewrong.php' },
{ 'header' : 'SHOWS', 'url' : '#' },
{ 'label' : 'Army Wives', 'url' : domain + '/shows/armywives/index.php' },
{ 'label' : 'Blood Ties', 'url' : domain + '/shows/bloodties/index.php' },
{ 'label' : 'Cheerleader Nation', 'url' : domain + '/shows/cheerleader/index.html' },
{ 'label' : 'Denise Austin', 'url' : domain + '/reallife/df/index.html' },
{ 'label' : 'Designing Women', 'url' : domain + '/shows/deswomen/index.html' },
{ 'label' : 'Desperate Housewives', 'url' : domain + '/shows/dh/index.html' },
{ 'label' : 'Frasier', 'url' : domain + '/shows/frasier/index.html' },
{ 'label' : 'Gay, Straight or Taken', 'url' : domain + '/shows/gaystraightortaken/index.php' },
{ 'label' : 'Golden Girls', 'url' : domain + '/shows/golden/index.html' },
{ 'label' : 'Grey\'s Anatomy', 'url' : domain + '/shows/greysanatomy/index.php' },
{ 'label' : 'How Clean Is Your House?', 'url' : domain + '/shows/clean/index.html' },
{ 'label' : '"I Do" Diaries', 'url' : domain + '/shows/weddings/index.html' },
{ 'label' : 'Intimate Portrait', 'url' : domain + '/shows/ip/index.html' },
{ 'label' : 'Lisa Williams', 'url' : domain + '/shows/lisawilliams/index.php' },
{ 'label' : 'Lovespring International', 'url' : domain + '/shows/lovespring/index.php' },
{ 'label' : 'Medium', 'url' : domain + '/shows/medium/index.html' },
{ 'label' : 'Monarch Cove', 'url' : domain + '/shows/monarchcove/index.php' },
{ 'label' : 'Off the Leash', 'url' : domain + '/shows/offtheleash/index.php' },
{ 'label' : 'Reba', 'url' : domain + '/shows/reba/index.html' },
{ 'label' : 'Spotlight 25', 'url' : domain + '/shows/spotlight25/' },
{ 'label' : 'Still Standing', 'url' : domain + '/shows/stillstanding/index.html' },
{ 'label' : 'Strong Medicine', 'url' : domain + '/shows/strongmed/index.html' },
{ 'label' : 'The Nanny', 'url' : domain + '/shows/nanny/index.html' },
{ 'label' : 'Unsolved Mysteries', 'url' : domain + '/shows/unsolved/index.html' },
{ 'label' : 'Weddings', 'url' : domain + '/shows/weddings/index.html' },
{ 'label' : 'Will & Grace', 'url' : domain + '/shows/wg/index.html' }
];

//Header pulldown list
headerLinks = [
{ 'label' : '', 'url' : '' },
{ 'label' : 'TV SCHEDULE', 'url' : getTVScheduleLink() },
{ 'label' : '', 'url' : '' },
{ 'label' : 'LIFETIME MOVIES', 'url' : '/movies/index.html' },
{ 'label' : 'Write &amp; Wrong', 'url' : '/movies/originals/writewrong.php' },
{ 'label' : '', 'url' : '' },
{ 'label' : ' LIFETIME SHOWS ', 'url' : '/shows/index.html' },
{ 'label' : 'Army Wives', 'url' : '/shows/armywives/index.php' },
{ 'label' : 'Blood Ties', 'url' : '/shows/bloodties/index.php' },
{ 'label' : 'Cheerleader Nation', 'url' : '/shows/cheerleader/index.html' },
{ 'label' : 'Denise Austin', 'url' : '/reallife/df/index.html' },
{ 'label' : 'Designing Women', 'url' : '/shows/deswomen/index.html' },
{ 'label' : 'Desperate Housewives', 'url' : '/shows/dh/index.html' },
{ 'label' : 'Frasier', 'url' : '/shows/frasier/index.html' },
{ 'label' : 'Gay, Straight or Taken', 'url' : '/shows/gaystraightortaken/index.php' },
{ 'label' : 'Golden Girls', 'url' : '/shows/golden/index.html' },
{ 'label' : 'Grey\'s Anatomy', 'url' : '/shows/greysanatomy/index.php' },
{ 'label' : 'How Clean', 'url' : '/shows/clean/index.html' },
{ 'label' : '&nbsp; &nbsp;  Is Your House?', 'url' : '/shows/clean/index.html' },
{ 'label' : 'Intimate Portrait', 'url' : '/shows/ip/index.html' },
{ 'label' : 'Lisa Williams', 'url' : '/shows/lisawilliams/index.php' },
{ 'label' : 'Lovespring', 'url' : '/shows/lovespring/index.php' },
{ 'label' : '&nbsp; &nbsp; International', 'url' : '/shows/lovespring/index.php' },
{ 'label' : 'Medium', 'url' : '/shows/medium/index.html' },
{ 'label' : 'Monarch Cove', 'url' : '/shows/monarchcove/index.php' },
{ 'label' : 'Off the Leash', 'url' : '/shows/offtheleash/index.php' },
{ 'label' : 'Reba', 'url' : '/shows/reba/index.html' },
{ 'label' : 'Spotlight 25', 'url' : '/shows/spotlight25/' },
{ 'label' : 'Still Standing', 'url' : '/shows/stillstanding/index.html' },
{ 'label' : 'Strong Medicine', 'url' : '/shows/strongmed/index.html' },
{ 'label' : 'The Nanny', 'url' : '/shows/nanny/index.html' },
{ 'label' : 'Unsolved Mysteries', 'url' : '/shows/unsolved/index.html' },
{ 'label' : 'Weddings', 'url' : '/shows/weddings/index.html' },
{ 'label' : 'Will & Grace', 'url' : '/shows/wg/index.html' }
];

//TV Schedule pages. Only load if in TV Schedule.
if ((loc.indexOf('/shows/tvschedule/')!=-1)||(loc.indexOf('/cgi/scripts/')!=-1)) 
{
	tvschedLinks = [
	'/cgi/scripts/tv_byshow.pl?show=cheerleader','Cheerleader Nation',
	'/cgi/scripts/tv_byshow.pl?show=designingw','Designing Women',
    '/cgi/scripts/tv_byshow.pl?show=desperate','Desperate Housewives',
	'/cgi/scripts/tv_byshow.pl?show=frasier','Frasier',
	'/cgi/scripts/tv_byshow.pl?show=gaystraight','Gay, Straight or Taken?',
	'/cgi/scripts/tv_byshow.pl?show=golden','Golden Girls',
	'/cgi/scripts/tv_byshow.pl?show=lisa','Lisa Williams',
    '/cgi/scripts/tv_byshow.pl?show=lovespring','Lovespring International',
	'/cgi/scripts/tv_byshow.pl?show=medium','Medium',
	'/cgi/scripts/tv_byshow.pl?show=reba','Reba',
	'/cgi/scripts/tv_byshow.pl?show=stillstanding','Still Standing',
	'/cgi/scripts/tv_byshow.pl?show=strongmedicine','Strong Medicine',
	'/cgi/scripts/tv_byshow.pl?show=division','The Division',
	'/cgi/scripts/tv_byshow.pl?show=nanny','The Nanny',
	'/cgi/scripts/tv_byshow.pl?show=willgrace','Will & Grace',
	'/cgi/scripts/tv_byshow.pl?show=unsolved','Unsolved Mysteries'

	];
}

//Browser Detect Variables
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_opera = (agt.contains("opera")); var is_webtv = (agt.contains("webtv"));
var is_nav  = ((agt.contains('mozilla')) && (agt.contains('spoofer')) && (agt.contains('compatible')) && (agt.contains('opera')) && (agt.contains('webtv'))||
((agt.contains("Netscape")||agt.contains("netscape")))
);
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly = (is_nav && ((agt.contains(";nav"))||(agt.contains("; nav"))));
var is_nav5 = (is_nav && (is_major == 5));
var is_nav5up = (is_nav && (is_major >= 5));
var is_ie   = (agt.contains("msie"));
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5  = (is_ie && (is_major == 4) && (agt.contains("msie 5.0")));
var is_ie5up = "";
var agtArr = agt.split(" ");
var bVersion = agtArr[3];
if (bVersion.substring(0,1) >= 5) is_ie5up = true;
var is_aol   = (agt.contains("aol"));

//JAVASCRIPT
var is_js = 1.0
if (is_opera) is_js = 1.1
else if (is_nav4 && (is_minor <= 4.05)) is_js = 1.2
else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3
else if (is_nav5) is_js = 1.4
else if (is_nav && (is_major > 5)) is_js = 1.4
else if (is_ie && (is_major > 5)) is_js = 1.3
else is_js = 0.0;

//PLATFORM
var is_win   = ((agt.contains("win")) || (agt.contains("16bit")));
var is_win95 = ((agt.contains("win95")) || (agt.contains("windows 95")));
var is_win98 = ((agt.contains("win98")) || (agt.contains("windows 98")));
var is_winnt = ((agt.contains("winnt")) || (agt.contains("windows nt")));
var is_win32 = (is_win95 || is_winnt || is_win98 || ((is_major >= 4) && (navigator.platform == "Win32")) || (agt.contains("win32")) || (agt.contains("32bit")));

var is_mac    = (agt.contains("mac"));
var is_fox = (agt.contains("Firefox")||agt.contains("firefox"));
var is_safari = (agt.contains("Safari")||agt.contains("safari"));

var dev = (loc.contains('//dev')) ? true : false;
var netscape4 = is_nav4;


//RIGHT NAV
var crn;
var scenario = 0;  //this tells me what branch was hit so i can adjust in nl box draw -km070706



/************** GLOBAL FUNCTIONS **************/

function openWindow(myURL,myWinName,myWidth,myHeight,myOptions) 
{
	var w = myWidth;
	var h = myHeight;
	var o = myOptions;
	var wName = myWinName;
	var tools = "";
	var theURL = myURL;
	
	if ((wName=="")||(wName==null)) { wName = "popup"; }
	
	if ((o==0)||(o=="default")||(o==null)) { tools = "toolbars=0,scrollbars=0,location=0"; }
	else { tools = myOptions; }
	
	var features=tools+",width="+w+",height="+h;
	
	window.open(theURL,wName,features);
}  

//this returns the string you need to set cookie for x number of days
function getGMTDate(days)
{
	var today = new Date();
	today.setTime( today.getTime() );
	
	var dateStr = days * 1000 * 60 * 60 * 24;
	var gmtDateStr = new Date( today.getTime() + (dateStr) );
	
	return gmtDateStr;
}

function Get_Cookie(name) 
{
	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
	if (start == -1) return null;
	var end = document.cookie.indexOf(";",len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) 
{
	document.cookie = name + "=" +escape(value) +
	( (expires) ? ";expires=" + expires.toGMTString() : "") +
	( (path) ? ";path=" + path : "") + 
	( (domain) ? ";domain=" + domain : "") +
	( (secure) ? ";secure" : "");
	//alert('trying to set a cookie now');
}

function Delete_Cookie(name,path,domain) 
{
	if (Get_Cookie(name)) document.cookie = name + "=" +
	( (path) ? ";path=" + path : "") +
	( (domain) ? ";domain=" + domain : "") +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function show_Ad_Once(adURL,pageCode,width,height,atts) 
{
	if (tempWindow==null){	var tempWindow = pageCode; }
	else { var tempWindow = eval(Get_Cookie("tempWindow")+".closed"); }
	
	//get what's in cookie currently (if anything)
	var adServe = "";
	adServe += Get_Cookie("adServe");
	//look for this pagecode given
	var adPresent = adServe.indexOf(pageCode);
	
	//if pagecode is not in the cookie, show the ad... but save a record of that in the cookie!
	if (adPresent==-1) {            
		Set_Cookie("adServe",adServe+pageCode+":");
		eval("var " + pageCode + "=openWindow(adURL,'mywin',width,height,atts);");
		Set_Cookie("tempWindow",pageCode);
	}            
}

function drawFooter() 
{
	if (onLRW) {
		drawRemoteFooter();
	}else{
		return "&nbsp;";
	}
}

function print_me() 
{
	if (window.print) { window.print() } 
	else {
		var platform = navigator.platform.toUpperCase()
		var browser = navigator.appName.toUpperCase()
		
		if (platform == "MACPPC" && browser == "NETSCAPE") { alert('Please use command-p to print.') } 
		else { alert('Please use control-p to print.') }
	 }
}
        
function printDate(format) 
{
	var dayArray = new Array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
	var monthArray = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	
	var dateObj = new Date();
	var yearStr = dateObj.getYear();
	if (is_nav) yearStr+=1900;
	
	var currYear = yearStr;
	//hack
	if (currYear.toString().charAt(0)==1) { currYear+=1900 }
	var currMon = monthArray[dateObj.getMonth()];
	var currDay = dateObj.getDate();

	if (format==1) { document.write(currMon + " " + currDay + ", " + currYear); }
	//default
	else { document.write(currMon + " " + currDay + ", " + currYear); }
}

function emailFriend(emfURL,emfDescr,emfType) 
{
	myArguments = {};
	
	if ((emfURL=="defaultURL") || (emfURL==null)) myArguments['article_url'] = escape(location);
	else if (emfURL=="previousURL") myArguments['article_url'] = escape(document.referrer);
	else myArguments['article_url'] = emfURL;
	
	if ((emfDescr=="defaultTitle") || (emfDescr==null)) myArguments['title'] = escape(document.title);
	else myArguments['title'] = emfDescr;

	if (arguments[3]) { myArguments['tracking_id'] = arguments[3]; }	
	
	emailAFriend(myArguments);
}

function emailAFriend(args) 
{
	//upgraded email a friend functionality - march 2005 km
	/*examples:
	javascript:emailAFriend();
	javascript:emailAFriend({'article_url':'/newurl/newpage.html' });
	javascript:emailAFriend({'article_url':'/newurl/newpage.html', 'title':'My Title Override', 'message_id':2});
	
	1. basic, uses captured page title and referrer url
	javascript:emailAFriend();
	
	2. using previous page (url) instead of current one:
	javascript:emailAFriend({'article_url':'previousURL'}) OR
	javascript:emailAFriend({'article_url':'/shows/golden/index.html'})
	
	3. using a given page title (title) instead of the default one
	javascript:emailAFriend({'title':'Lifetimetv.com: My New Title'})
	
	4. changing to refer a friend mode (type), bringing up different window
	javascript:emailAFriend({'type':'referafriend'})
	
	5. to use tracking, you need a token that will serve as a marker for these requests in Insight
	javascript:emailAFriend({'tracking_id':'golden'})
	
	6. to use a custom message and subject line in the recipient email, you need a message_id
	javascript:emailAFriend({'message_id':'2'})
	*/

	var emaf = new Class_EmailAFriend();  //Create a new Class_EmailAFriend object w/ default attributes.
	
	//Possible arguments supplied from function call. please add any new args here w/ description.
	//Also add the member to the Class_EmailAFriend
	//'article_url' 		//url that should be sent to friend
	//'title' 					//(document) Title of the page
	//'type' 					//standard, referfriend or custom value
	//'mode' 				//form or headless
	//'tracking_id' 		//used a 'tag' or identifier for Insight
	//'message_id' 		//message_id for db
	//'usermsg' 			//if set to false, the message box will not appear on the form and user can't add custom msg

	//if i find one long string of variables (a querystring), it will become the args hash
	if ((args) && (arguments.length==1)) {
		if ((args['mode']) && (args['mode']!=emaf.mode)) { emaf.mode = args['mode']; }
		if ((args['article_url']) && (args['article_url']!=emaf.url)) { emaf.url = escape(args['article_url']); }
		if ((args['title']) && (args['title']!=emaf.title)) { emaf.title = escape(args['title']);  }
		if ((args['type']) && (args['type']!=emaf.type)) { emaf.type = args['type']; }
		if ((args['message_id']) && (args['message_id']!=emaf.message_id)) { emaf.message_id = args['message_id']; }
	
		//track the number of users sending emafs for a given site. sid = site id (used in legacy call so i'll keep it)
		if ((args['tracking_id']) && ((args['tracking_id']!="")) && (args['tracking_id']!=null)) { emaf.addQueryParam('sid',args['tracking_id']); }
			
		//if there is a custom message to be used, pass the message_id
		if ((args['message_id']) && (args['message_id']!="") && (args['message_id']!=null)) { emaf.addQueryParam('message_id',args['message_id']); }
		
		//to turn off the user's ability to send their own message, pass usermsg = false
		if ((args['usermsg']) && (args['usermsg']!="") && (args['usermsg']!=null)) { emaf.addQueryParam('usermsg','false'); }
	}
	//this section is for backward compatibilty with emailFriend
	if (arguments.length>1) {
		if (arguments[0] != 'defaultURL') { emaf.url = arguments[0]; }
		if (arguments[1] != 'defaultTitle') { emaf.title = arguments[1]; }
		if (arguments[2] != 'defaultType') { emaf.type = arguments[2]; }
		if ((arguments[3]) && (vars["article_url"]!="")) { emaf.addQueryParam('sid',arguments[3]); }
	}
	
	if (emaf.url=="previousURL") { emaf.url = escape(document.referrer); }
		
	//make the absolute if it isn't already
	if (!emaf.url.contains("http")) { emaf.url = "http://"+location.hostname+emaf.url }

	emaf.start();
}

//for legacy calls - not yet
//function emailFriend(emfURL,emfDescr,emfType) { emailAFriend(emfURL,emfDescr,emfType); }

function tvReminder(lineinfo) 
{
	var longInfo = lineinfo;	
	var reminderRequest = "/cgi/movies_reminder.pl?" + longInfo + "=" + lineinfo + "&action=get-email";

	openWindow(reminderRequest,'pop',460,320,0);
}

function changeBaseWindow(thisURL,closeOption) 
{	
	window.opener.location = thisURL;
	if (closeOption!="no") { self.close(); }
}

var rmpre = "http://mfile.akamai.com/2718/rm/video.lifetimetv.com/media";
var wmvpre = "http://mfile.akamai.com/2718/wmv/video.lifetimetv.com/media";
	
function playMedia(medialoc,datestamp) 
{
	var mfilename = medialoc.substring(0,medialoc.lastIndexOf('.'));
	var mediaLink = "";

	if ((medialoc.indexOf('.ram')!=-1) || (medialoc.indexOf('.rm')!=-1) || (medialoc.indexOf('.ra')!=-1))  {
		medialoc = mfilename + ".ram";
		mediaLink = rmpre + medialoc + "?obj=" + datestamp;
	}
	if ((medialoc.indexOf('.wmv')!=-1) || (medialoc.indexOf('.asx')!=-1) || (medialoc.indexOf('.asf')!=-1) || (medialoc.indexOf('.wmf')!=-1)) {
		medialoc = mfilename + ".asx";
		mediaLink = wmvpre + medialoc + "?obj=" + datestamp;
	}
	
	window.location = mediaLink;	
}
	
function changeURL(list)
{
	var mylocation = list.options[list.selectedIndex].value;

	//if this is not the divider, change the location
	if (!mylocation.contains('-----'))
	{
		list.selectedIndex = 0;
		location.href = mylocation;
	}
}

//Map of Hope
function loadMap() 
{
		//var pick = getServer(11,17);	
		//var mapURL = 'http://209.208.145.'+pick + '/community/olc/bc/map/index.html';
		var mapURL = 'http://www.mylifetime.com/community/olc/bc/map/index.html';
		window.open(mapURL,'Map','width=720,height=550');
}	
	
function getServer(min,max) { return (Math.round(Math.random()*(max-min)))+min }

//Checks if the registration source identifier is valid before sending it along
var validRSRC = [
						'sn', //site nav
						'sw', //sweeps
						'nl', //newsletters
						'bb', //banners,buttons
						'sp', //special promotions
						'mb', //message boards
						'hp', //homepage
						'ez', //ez sweeps
						'gg', //Google
						'wl', //wireless
						'lmn', //lmn
						'nantriv',  //Nanny Trivia Game
						'puzzle',  //Puzzle Pieces Game
						'willgrace',  //Puzzle Pieces Game
						'sudoku',  //Sudoku Game
                        			'golden',  //Golden Girls Game
						'mymakeover', //My Story Is Makeover Game
						'nora', //Nora Trivia Game (resides in nora site)
						'tiara'  //Princess Tiara Game
						];
						
//external referrer list						
var validXREF = [
						'msn', //msn
						'iwon', //iwon
						'google', //google
						'luckysurf', //luckysurf
						'sweepsonl', //Sweepstakes Online
						'womenforum', //WomensForum
						'tmg', //TMG
						'realarc', //RealArcade
						'bb', //banners, buttons
						'nl', //newsletters
						'family', //Familyfun
						'denise', //deniseaustin
						'perfectm', //Perfect Match
						'LIES', //angelas eyes
						'FBI', //angelas eyes
						'ANGELA' //angelas eyes
						];

function isValidRSRC(src) 
{
	var i = 0;
	while (i<validRSRC.length) {
		if (src == validRSRC[i])     { return true }
		if ('sw' == src.substr(0,2)) { return true }
		i++;
	}
	return false;	
}
        
function isValidXREF(ref) 
{
	var i = 0;
	while (i<validXREF.length) {
		if (ref == validXREF[i]) { return true }
		i++;
	}
	return false;	
}        

function resetUser(cookiename) 
{
	Delete_Cookie(cookiename,'/','mylifetime.com');
	//location.reload();
	if (location.search != '') {
		if (location.search.contains('message=')) {
			var re = /message=[a-zA-Z]*/;
			location.search = location.search.replace(re,'message=userreset');
		} else {
			location.search += "&message=userreset";
		}
	} else {
		location.search = "?message=userreset";	
	}
}

//for removing ourselves from a frame. doesn't work in safari. tfc 8/27/03
function bustTheFrame() 
{
	if (is_mac && !is_nav) {
		if (self.location.search=='') {
		document.write('<form method=get name="buster" action="'+unescape(self.location)+'" target="_top"><input type=hidden name=frame value=no></form>');
		document.buster.submit();
		}
	} else {
		top.location.replace(self.location.href)
	}
}

if ((top != self) && (!dev)) 
{
	var dontBustList = new Array('sweeps/','whoknows/','facefacts/','fortune/','wkyb/','womenshistory/ecard/','ez_index.html','ezsweeps.html','penpals','/games/','/dedications/','/mobile/','/feedback','/frame');
	var bustFrame = true;
	for (i=0;i<dontBustList.length;i++) {
		if (self.location.href.indexOf(dontBustList[i])!=-1) {
			bustFrame = false;
		}	
	}
	if (bustFrame) {
		bustTheFrame(); 
	}
}

function validateNLBox(f) 
{
	var regexp= /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!regexp.test(f.email.value)) {
		alert('Please enter a valid e-mail address.');
		return false;
	}
	else { return true; }
}

//for realarcade errors
function debugOutput(str) { alert(str); }

//pops up local default mail client on client machine with the given parameters
function prepareEmail(to,subject,msg) 
{
	var to = to || '';
	var subject = subject || '';
	var msg = msg || '';
	
	var mailstr = "mailto:"+to+"?subject="+subject+"&body="+msg;
	
	window.location = mailstr;
}

function goToRecipe(url)
{
	url = URLEncode(url);
	window.location = '/shopping/recipes/index.php?r='+url;
}
	 
function drawRightNav() 
{
	//hack for late rendering on ip
	if (loc.contains('/shows/ip'))
	{
		crn.addHTML('<div id="portraitlist">');
		crn.addHTML(getPortraitPulldown());  
		crn.addHTML('</div>');
		crn.addKeyLine();
		crn.addHTML(getIPSearchBox());
		crn.addKeyLine();
		crn.addRightAds();
	}

	//fail safe for legacy
	if (typeof(crn) == 'undefined')
	{
		rn.drawRightNav();
	}
	else 
	{
		drawColorRightNav();
	}
}

function drawColorRightNav() 
{
	//the rightnav should have created and defined this object "crn"
	if (typeof(crn)!='undefined')
	{
		crn.drawRightNav();	
		crn.makeAdjustments();
	}
}


function drawRightAds() { }

function drawRightBanners()
{
	
	//this is the variable set in the right_ads.js file for this section
	if (typeof(adlist) != 'undefined')
	{	
		var thisAdlist = adlist;
		//alert(adlist.length);
		var ac = new Class_AdContainer(thisAdlist);
		ac.drawContainer();				
	}
}

function URLEncode(value)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = value;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
}

function URLDecode(value)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = value;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
	
   return plaintext;
}

function getTVScheduleLink() 
{
	var now = new Date();
 	var site = ''; 
    var link = '/cgi/scripts/tv_daily_filter'+site+'.pl?timeZoneOffset=' + now.getTimezoneOffset() + '&hours_mins=' + now.getHours() + '_' + now.getMinutes();
    return link;
}

function getTVScheduleLrwLink() 
{
	var now = new Date();
	var link = '/cgi/scripts/tv_daily_filter_lrw.pl?timeZoneOffset=' + now.getTimezoneOffset() + '&hours_mins=' + now.getHours() + '_' + now.getMinutes();
    return link;
}


function makeHomePage(l)
{
	if (is_ie && is_win)
	{
		l.style.behavior='url(#default#homepage)';
		l.setHomePage(location.href);
		return false;
	}
	else
	{
		return false;
	}
}

/************** GOOGLE AJAX ****************************************/

function $(e){if(typeof e=='string')e=document.getElementById(e);return e};
function collect(a,f){var n=[];for(var i=0;i<a.length;i++){var v=f(a[i]);if(v!=null)n.push(v)}return n};

ajax={};
ajax.x=function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}};
ajax.serialize=function(f){var g=function(n){return f.getElementsByTagName(n)};var nv=function(e){if(e.name)return encodeURIComponent(e.name)+'='+encodeURIComponent(e.value);else return ''};var i=collect(g('input'),function(i){if((i.type!='radio'&&i.type!='checkbox')||i.checked)return nv(i)});var s=collect(g('select'),nv);var t=collect(g('textarea'),nv);return i.concat(s).concat(t).join('&');};
ajax.send=function(u,f,m,a){var x=ajax.x();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseText)};if(m=='POST')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a)};
ajax.get=function(url,func){ajax.send(url,func,'GET')};
ajax.gets=function(url){var x=ajax.x();x.open('GET',url,false);x.send(null);return x.responseText};
ajax.post=function(url,func,args){ajax.send(url,func,'POST',args)};
ajax.update=function(url,elm){var e=$(elm);var f=function(r){e.innerHTML=r};ajax.get(url,f)};
ajax.submit=function(url,elm,frm){var e=$(elm);var f=function(r){e.innerHTML=r};ajax.post(url,f,ajax.serialize(frm))};

/************** CC AJAX ****************************************/
/*
Cross-Browser XMLHttpRequest v1.2
=================================

Emulate Gecko 'XMLHttpRequest()' functionality in IE and Opera. Opera requires
the Sun Java Runtime Environment <http://www.java.com/>.

by Andrew Gregory
http://www.scss.com.au/family/andrew/webdesign/xmlhttprequest/

This work is licensed under the Creative Commons Attribution License. To view a
copy of this license, visit http://creativecommons.org/licenses/by/1.0/ or send
a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305,
USA.

Not Supported in Opera
----------------------
* user/password authentication
* responseXML data member

Not Fully Supported in Opera
----------------------------
* async requests
* abort()
* getAllResponseHeaders(), getAllResponseHeader(header)

*/
// IE support
if (window.ActiveXObject && !window.XMLHttpRequest) {
  window.XMLHttpRequest = function() {
    var msxmls = new Array(
      'Msxml2.XMLHTTP.5.0',
      'Msxml2.XMLHTTP.4.0',
      'Msxml2.XMLHTTP.3.0',
      'Msxml2.XMLHTTP',
      'Microsoft.XMLHTTP');
    for (var i = 0; i < msxmls.length; i++) {
      try {
        return new ActiveXObject(msxmls[i]);
      } catch (e) {
      }
    }
    return null;
  };
}
// Gecko support
/* ;-) */
// Opera support
if (window.opera && !window.XMLHttpRequest) {
  window.XMLHttpRequest = function() {
    this.readyState = 0; // 0=uninitialized,1=loading,2=loaded,3=interactive,4=complete
    this.status = 0; // HTTP status codes
    this.statusText = '';
    this._headers = [];
    this._aborted = false;
    this._async = true;
    this._defaultCharset = 'ISO-8859-1';
    this._getCharset = function() {
      var charset = _defaultCharset;
      var contentType = this.getResponseHeader('Content-type').toUpperCase();
      val = contentType.indexOf('CHARSET=');
      if (val != -1) {
        charset = contentType.substring(val);
      }
      val = charset.indexOf(';');
      if (val != -1) {
        charset = charset.substring(0, val);
      }
      val = charset.indexOf(',');
      if (val != -1) {
        charset = charset.substring(0, val);
      }
      return charset;
    };
    this.abort = function() {
      this._aborted = true;
    };
    this.getAllResponseHeaders = function() {
      return this.getAllResponseHeader('*');
    };
    this.getAllResponseHeader = function(header) {
      var ret = '';
      for (var i = 0; i < this._headers.length; i++) {
        if (header == '*' || this._headers[i].h == header) {
          ret += this._headers[i].h + ': ' + this._headers[i].v + '\n';
        }
      }
      return ret;
    };
    this.getResponseHeader = function(header) {
      var ret = getAllResponseHeader(header);
      var i = ret.indexOf('\n');
      if (i != -1) {
        ret = ret.substring(0, i);
      }
      return ret;
    };
    this.setRequestHeader = function(header, value) {
      this._headers[this._headers.length] = {h:header, v:value};
    };
    this.open = function(method, url, async, user, password) {
      this.method = method;
      this.url = url;
      this._async = true;
      this._aborted = false;
      this._headers = [];
      if (arguments.length >= 3) {
        this._async = async;
      }
      if (arguments.length > 3) {
        opera.postError('XMLHttpRequest.open() - user/password not supported');
      }
      this.readyState = 1;
      if (this.onreadystatechange) {
        this.onreadystatechange();
      }
    };
    this.send = function(data) {
      if (!navigator.javaEnabled()) {
        alert("XMLHttpRequest.send() - Java must be installed and enabled.");
        return;
      }
      if (this._async) {
        setTimeout(this._sendasync, 0, this, data);
        // this is not really asynchronous and won't execute until the current
        // execution context ends
      } else {
        this._sendsync(data);
      }
    }
    this._sendasync = function(req, data) {
      if (!req._aborted) {
        req._sendsync(data);
      }
    };
    this._sendsync = function(data) {
      this.readyState = 2;
      if (this.onreadystatechange) {
        this.onreadystatechange();
      }
      // open connection
      var url = new java.net.URL(new java.net.URL(window.location.href), this.url);
      var conn = url.openConnection();
      for (var i = 0; i < this._headers.length; i++) {
        conn.setRequestProperty(this._headers[i].h, this._headers[i].v);
      }
      this._headers = [];
      if (this.method == 'POST') {
        // POST data
        conn.setDoOutput(true);
        var wr = new java.io.OutputStreamWriter(conn.getOutputStream(), this._getCharset());
        wr.write(data);
        wr.flush();
        wr.close();
      }
      // read response headers
      // NOTE: the getHeaderField() methods always return nulls for me :(
      var gotContentEncoding = false;
      var gotContentLength = false;
      var gotContentType = false;
      var gotDate = false;
      var gotExpiration = false;
      var gotLastModified = false;
      for (var i = 0; ; i++) {
        var hdrName = conn.getHeaderFieldKey(i);
        var hdrValue = conn.getHeaderField(i);
        if (hdrName == null && hdrValue == null) {
          break;
        }
        if (hdrName != null) {
          this._headers[this._headers.length] = {h:hdrName, v:hdrValue};
          switch (hdrName.toLowerCase()) {
            case 'content-encoding': gotContentEncoding = true; break;
            case 'content-length'  : gotContentLength   = true; break;
            case 'content-type'    : gotContentType     = true; break;
            case 'date'            : gotDate            = true; break;
            case 'expires'         : gotExpiration      = true; break;
            case 'last-modified'   : gotLastModified    = true; break;
          }
        }
      }
      // try to fill in any missing header information
      var val;
      val = conn.getContentEncoding();
      if (val != null && !gotContentEncoding) this._headers[this._headers.length] = {h:'Content-encoding', v:val};
      val = conn.getContentLength();
      if (val != -1 && !gotContentLength) this._headers[this._headers.length] = {h:'Content-length', v:val};
      val = conn.getContentType();
      if (val != null && !gotContentType) this._headers[this._headers.length] = {h:'Content-type', v:val};
      val = conn.getDate();
      if (val != 0 && !gotDate) this._headers[this._headers.length] = {h:'Date', v:(new Date(val)).toUTCString()};
      val = conn.getExpiration();
      if (val != 0 && !gotExpiration) this._headers[this._headers.length] = {h:'Expires', v:(new Date(val)).toUTCString()};
      val = conn.getLastModified();
      if (val != 0 && !gotLastModified) this._headers[this._headers.length] = {h:'Last-modified', v:(new Date(val)).toUTCString()};
      // read response data
      var reqdata = '';
      var stream = conn.getInputStream();
      java.lang.System.err.println(stream);
      if (stream) {
        var reader = new java.io.BufferedReader(new java.io.InputStreamReader(stream, this._getCharset()));
        var line;
        while ((line = reader.readLine()) != null) {
          if (this.readyState == 2) {
            this.readyState = 3;
            if (this.onreadystatechange) {
              this.onreadystatechange();
            }
          }
          reqdata += line + '\n';
        }
        reader.close();
        this.status = 200;
        this.statusText = 'OK';
        this.responseText = reqdata;
        this.readyState = 4;
        if (this.onreadystatechange) {
          this.onreadystatechange();
        }
        if (this.onload) {
          this.onload();
        }
      } else {
        // error
        this.status = 404;
        this.statusText = 'Not Found';
        this.responseText = '';
        this.readyState = 4;
        if (this.onreadystatechange) {
          this.onreadystatechange();
        }
        if (this.onerror) {
          this.onerror();
        }
      }
    };
  };
}
// ActiveXObject emulation
// Removed for header compatiability
/*
if (!window.ActiveXObject && window.XMLHttpRequest) {
  window.ActiveXObject = function(type) {
    switch (type.toLowerCase()) {
      case 'microsoft.xmlhttp':
      case 'msxml2.xmlhttp':
      case 'msxml2.xmlhttp.3.0':
      case 'msxml2.xmlhttp.4.0':
      case 'msxml2.xmlhttp.5.0':
        return new XMLHttpRequest();
    }
    return null;
  };
}
*/

/************** MEMBERSHIP AND NEWSLETTER FUNCTIONALITY   **************/

//Newsletter list contains:
//Full NL name, NL freq, hash of url paths where this NL is available 
//against that path's list_site name for Insight tracking - separated by commas

var newsletterList = new Array(
[], //placeholder. starts all nths at 1 instead of 0.
['Tune-In Alerts','weekly', {'/shows/tvschedule/':'hilites'} ],
['Breast Self-Examination Reminder','monthly', {} ],
['Updates','monthly', {} ],
['Movies','monthly', {'/movies/':'movies'} ],
['Golden Girls','monthly', {'/shows/golden/':'golden'} ],
['Health','monthly', {} ],
['Denise Austin','monthly', {} ],
['Sweeps and Special Offers Reminder','monthly', {'/sweeps/':'sweeps'} ],
['What Should You Do? Tips','monthly', {'/shows/wsyd/':'wsyd'} ],
['','', {} ],
['Astrology','monthly', {'/astro/':'astro'} ],
['LMN','monthly', {} ],
['Lifetime Magazine','monthly', {'www.lifetimemag.com':'magazine'} ],
['Healthy Living','weekly', 
	{	
	'/reallife/health/':'health',
	'/reallife/df/':'df',
	'/extra/womenrock/':'wr'
	} ],
['Relationships','monthly',  {'/reallife/relation/':'relation'} ],
['Champions for Change','monthly',  
	{
	'/community/olc/':'olc',
	'/reallife/bc/':'bc'
	} ],
['Champions for Change: College Corps','monthly', {'/community/olc/college/':'college'} ],
['Games','monthly', {'/games/':'games'} ]
);

//START INITIALIZATION - CLIENT-SIDE USER PROFILE
//initialization routine
//returns profile of this user, all info rolled up in one
//are they logged in, what member type, 
//and whatever other features are saved in the cookie(s)
//saves each needed name/value to userProfile hash

var userProfile = {
	'loggedIn':0,
	'subscriptionList':'',
	'featureList':'',
	'ssPendingList':'',
	'memberType':0,
	'screenName':'',
	'firstname':'',
	'lastname':'',
	'city':'',
	'zip':'',
	'cookiePersistent':0,
	'gender' : '',
	'age' : ''
};

if (Get_Cookie('LoginCode')) 
{ 
	var CookieValue = Get_Cookie('LoginCode');
	CookieValue = unescape(CookieValue);
	var lArr = CookieValue.split(',');
	//var lArr = Get_Cookie('LoginCode').split(',');
	var formatCorrect = (lArr[9]) ? true : false;

	if (formatCorrect) 
	{
		userProfile['loggedIn'] = 1;
		userProfile['subscriptionList'] = lArr[9].split('');
		userProfile['featureList'] = lArr[8].split('');
		userProfile['memberType'] = lArr[7];
		userProfile['screenName'] = lArr[0].substring(1,lArr[0].length);
		userProfile['firstname'] = lArr[2];
		userProfile['lastname'] = lArr[3];
		userProfile['city'] = lArr[5];	
		userProfile['zip'] = lArr[6];
		userProfile['cookiePersistent'] = lArr[10].substring(0,1);
		userProfile['ssid'] = '';
		userProfile['gender'] = '';
		userProfile['age'] = '';
		
		if (lArr.length >= 12)
		{
			userProfile['ssid'] = lArr[11].replace('|','');
		}
	}
	else 
	{
		resetUser('LoginCode');
	}
	
}

if (Get_Cookie('SubscriptionStatus')) 
{ 
	var ssArr = Get_Cookie('SubscriptionStatus').split(',');
	userProfile['email'] = ssArr[0].substring(1,ssArr[0].length);
	userProfile['ssPendingList'] = ssArr[1].split('');
}

//debug
/*alert('loggedIn='+userProfile['loggedIn']+'\n'+
'subscriptionList='+userProfile['subscriptionList']+'\n'+
'featureList='+userProfile['featureList']+'\n'+
'memberType='+userProfile['memberType']+'\n'+
'screenName='+userProfile['screenName']+'\n'+
'firstname='+userProfile['firstname']+'\n'+
'lastname='+userProfile['lastname']+'\n'+
'city='+userProfile['city']+'\n'+	
'zip='+userProfile['zip']+'\n'+
'cookiePersistent='+userProfile['cookiePersistent']);
*/

var thisNewsletter = 0;
var listSite = "";
var nlFullname = "";
var nlFrequency = "";

//find out what newsletter is offered on this page.
var i = 1;
while (i<newsletterList.length) 
{
	for (itm in newsletterList[i][2]) 
	{
		//if you find the current path in the hash, then that newsletter is available on this page
		if (loc.indexOf(itm)!=-1) 
		{
			thisNewsletter=i;
			listSite=newsletterList[i][2][itm];
			nlFullname=newsletterList[i][0];
			nlFrequency=newsletterList[i][1];
			break;
		}
	}
	i++;
}

//is this page's newsletter pending?
var thisNewsletterPending = (userProfile['ssPendingList'][thisNewsletter]=='P') ? 1 : 0;

//does the user already have this page's newsletter?
var hasNewsletter = (
					//if logged in, you're registered - check to see if there is a flag for this newsletter...
					(userProfile['loggedIn']) && (userProfile['subscriptionList'][thisNewsletter]==1) 
					|| 
					//or if i'm a level 1 and i'm signed up...
					(userProfile['ssPendingList'][thisNewsletter]==1) ||
					(userProfile['ssPendingList'][thisNewsletter]=="P")
					) ? 1 : 0;
					
var exitPage = ((vars['message']=="requestnewsletter") || (vars['message']=="registernewsletter") || (vars['newsletter']=="requested")) ? 1 : 0;

//END INTIALIZATION						
						

//Message Alerts for Newsletter box
var responseMsg = 
{
	'default' : 'Enter your e-mail address to get our free ' + getNLBox_Attribute('nl_frequency') + ' ' + getNLBox_Attribute('nl_fullname') + ' newsletter.',
	
	'new thank you':
	'Thank you for requesting the ' + nlFullname + ' newsletter. We\'ve sent you a confirmation e-mail to verify your address.<br><br>If you\'d like to re-enter your e-mail address or enter a different \
	e-mail address, please <a href="javascript:resetUser(\'LoginCode\');resetUser(\'SubscriptionStatus\')">click here.</a><br><br>',
	
	'registered thank you':
	'Thank you for registering for the ' + nlFrequency + ' ' + nlFullname + ' newsletter. <br><br>',
	
	'already requested':
	'The ' + nlFullname + ' newsletter has been requested.  If you\'d like to enter a new e-mail address to receive this newsletter, <a href="javascript:resetUser(\'LoginCode\');resetUser(\'SubscriptionStatus\')">click here</a>.<br><br>',
	
	'logged in, already subscribed':
	//'You have already subscribed to this newsletter. If you\'d like to enter a different e-mail address, please <a href="javascript:resetUser(\'LoginCode\');resetUser(\'SubscriptionStatus\')">click here</a>.<br><br>',
	userProfile['screenName'] + ', you\'ve subscribed to myLifetime.com\'s ' + nlFullname + ' newsletter.   If you\'d like to enter a new e-mail address, <a href="javascript:resetUser(\'LoginCode\');resetUser(\'SubscriptionStatus\')">click here</a>.<br><br>', 
	
	'not logged in, already subscribed':
	//'You have already subscribed to this newsletter. If you\'d like to enter a different e-mail address, please <a href="javascript:resetUser(\'LoginCode\');resetUser(\'SubscriptionStatus\')">click here</a>.<br><br>',
	'You\'ve subscribed to myLifetime.com\'s ' + nlFullname + ' newsletter.   If you\'d like to enter a new e-mail address, <a href="javascript:resetUser(\'LoginCode\');resetUser(\'SubscriptionStatus\')">click here</a>.',
	
	'personalized hello':
	'Hello <b>' + userProfile['screenName'] + '</b>!<br><br>',
	
	'if not you, reset':
	'If this is not you, <a href="javascript:resetUser(\'LoginCode\');resetUser(\'SubscriptionStatus\')">click here</a>.<br><br>',
	
	'exclusive index':
	'Visit the <a href="/community/members/exclusive/index.html">Lifetime Member Center!</a><br><br>',
					
	'more newsletters':
	'<a href="/cgi/community/members/nlsignup.pl">Click here</a> for more newsletters.<br><br>',
	
	'be a full member':
	'<a href="/community/members/member_intro.html">Click here</a> to become a full member.<br><br>',
	
	'be a full member 99':
	'<a href="/cgi/community/members/registration.pl?mode=edit">Click here</a> to become a full member.<br><br>'
}

//RIGHT NAV NEWSLETTER BOX LOGIC >2006  -km 06/2006
function getNLBox_Message()
{
	var msg_content = [];
	
	//THANK YOU TEXT FOR USER WHO CLICKS THRU TO REQUEST NEWSLETTER
	if (exitPage) 
	{
		if (userProfile['loggedIn']) 
		{
			msg_content.push
			(
			responseMsg['registered thank you'], 
			responseMsg['more newsletters']
			);
			scenario = 1;
		}
		else 
		{
			msg_content.push
			( 
			responseMsg['new thank you']
			);
			scenario = 2;
		}
	}
	//POSSIBLE ENTRY PAGE
	else 
	{
		if (userProfile['loggedIn']) 
		{
			//LEVEL 2
			if ( (userProfile['memberType']==2) && (hasNewsletter) ) 
			{
				//alert('lvl2 w/ nl');
				msg_content.push
				( 
				responseMsg['personalized hello'],
				responseMsg['already requested'],
				responseMsg['more newsletters'],
				responseMsg['exclusive index']
				);
				scenario = 3;
			}
			//LEVEL 99
			else if ( (userProfile['memberType']==99) && (hasNewsletter) ) 
			{
				//alert('lvl99 w/ nl');
				msg_content.push
				( 
				responseMsg['personalized hello'],
				responseMsg['already requested'],
				responseMsg['be a full member 99']
				);
				scenario = 4;
			}
			//else draw the blank form
			else 
			{
				//alert('default');
				msg_content.push
				( 
				responseMsg['default']
				);
				scenario = 5;
			}	
		}
		else 
		{
			//person has signed up but not verified yet - check against pending cookie
			if (thisNewsletterPending) 
			{  
				//alert('lvl1 pending');
				msg_content.push 
				(
				responseMsg['already requested'],
				responseMsg['be a full member']
				);		
				scenario = 6;
			}
			//is not logged in, but has this newsletter means this is a lvl 1
			else if (hasNewsletter) 
			{
				//alert('lvl1 newsletter confirmed');
				msg_content.push
				( 
				responseMsg['already requested'],
				responseMsg['be a full member']
				);	
				scenario = 7;
			}
			//Not logged in/not signed up, show 'em everything
			else 
			{
				//alert('no login, no pending, draw form');
				msg_content.push
				( 
				responseMsg['default']
				);
				scenario = 8;
				//start Insight transaction - set a variable for global bottom to capture at the bottom of the page
			}
		}
	}

	return msg_content;
}

function getNLBox_Attribute(attr)
{	
	var rval = "";
	
	switch (attr)
	{
		case 'list_id' : 
			rval = thisNewsletter;
			break;
		case 'list_site' : 
			rval = listSite;
			break;
		case 'nl_fullname' : 
			rval = nlFullname;
			break;
		case 'nl_frequency' : 
			rval = nlFrequency;
			break;
		default: rval = '';
	}

	return rval;
}

function getRandom(ceil)
{
    var ranNum= Math.floor(Math.random()*ceil);
    return ranNum;
}

/* videolounge code moved here 8/9/06 tfc */
function launchVideoLounge(vid) {
    // modified for feedroom 5/17/07
    // if (vid.NaN == false)  { vid = null; }
	var bln_allowVideoView = allowVideoView();
	if (bln_allowVideoView==true){
	    if (vid == null || vid.toString().length <= 4) {
	        document.location.replace('http://videos.mylifetime.com');
		}
		else {
			//chose greater-than-zero, rather than greater-than-or-equlat-to-zero, because an equal in the first position woudl be an ivalid request.
			if (vid.indexOf("=")>0 ){
				document.location.replace('http://videos.mylifetime.com?' + vid);
	        }else{
				document.location.replace('http://videos.mylifetime.com?fr_chl=' + vid);
			}
		}
	}else{
		alert("Sorry, viewers outside of the United States and it\'s territories are \nunable to view the Lifetime video lounge");
	}
}


/****************** CLASS DEFINITIONS ******************/

function Class_EmailAFriend() 
{
	//request params	
	this.scriptURL = "/common/emailafriend.php?";
	this.url = escape(document.location);	
	this.title = escape(document.title);
	//this.caller = (window.opener()) ? window.opener() : 'none';
	this.mode = 'form';
	this.type = 'emailafriend';
	this.tracking_id;
	this.message_id = 1;
	this.querystring = "";
	
	var re =/refer(a)?friend/i;
	
	//pop-up window params
	this.left = 200;
	this.top = 0;	
	this.height = (re.test(this.type)) ? 600 : 650;
	if ((is_mac) && (is_ie)) { this.height+=28; } //mac ie adjust
	this.width = (this.type=='referafriend') ? 550 : 481;
	this.optionsStr;
	this.usermsg;

	this.start = function() {
		this.querystring+="&mode=" + this.mode + "&article_url=" + this.url + "&title=" + this.title + "&type=" + this.type;
		window.open(this.scriptURL+this.querystring,'emailAFriend','left='+this.left+',top='+this.top+',width='+this.width+',height='+this.height+','+this.optionsStr);
	}
	
	this.addQueryParam = function(name,value) {
		var param = "&" + name + "=" + value;
		this.querystring+=param;
	}
}

//allows for substitutions within js text
function Class_HTMLTemplate(text) 
{
	if (text.length>1) { text = text.join("\n"); }
	this.text = text;
	this.variables = {};
	
	this.addParams = function(vars) { 
		this.variables = vars; 
	}
	
	this.printTemplate = function() { 
		document.write(this.text); 
	}	
	
	this.fillTemplate = function() {
		var re; 
		var result = this.text.toString();
		var variables = this.variables;
		
		for (token in variables) 
		{
			re = new RegExp('<%'+token+'%>',"g");
			if (re.test) {
				result = result.replace(re,variables[token]);
			}
		}
		this.text = result;
	}
}

function Class_RightNav()  
{
	this._rnHTML = [];
	this._textRow = [];
	this._subRow = [];
	this._imgRow = [];
	this._keyLine = [];
	this._newsletterBox = false;
	this._moreHTML = []; //HTML written after rightnav links
	this._indent = "&nbsp; &nbsp;";
	
	//initialize
	this._rnHTML.push('<table cellpadding=0 cellspacing=0 border=0 bgcolor="#6699cc" width=195 background="">');
	
	this._textRow.push(
			'<tr>',
				'<td width=1 bgcolor="#6799CD" rowspan=3 height="18"><spacer type="block" width=1 height=1></td>',
				'<td width=1 bgcolor="#72ABE4" rowspan=3><spacer type="block" width=1 height=1></td>',
				'<td width=5 bgcolor="99CCFF"><spacer type="block" width=5 height=1></td>',
				'<td width=178 class=rightnav bgcolor="99CCFF"><a href="<%linkurl%>" target="<%target%>"><%linktext%></td>',
				'<td width=9><img src="/images/common/rightnav_arrow.gif" width="9" height="18"></td>',
				'<td width=1 bgcolor="#6799CD" rowspan=3><spacer type="block" width=1 height=1></td>',
			'</tr>',
			'<tr><td height=1 bgcolor="#6799CD" colspan=3><spacer type="block" width=1 height=1></td></tr>',
			'<tr><td height=1 bgcolor="#C2E2FF" colspan=3><spacer type="block" width=1 height=1></td></tr>'
		);
	
	this._subRow.push(	
			'<tr>',
				'<td width=1 bgcolor="#6799CD" height="18"><spacer type="block" width=1 height=1></td>',
				'<td width=1 bgcolor="#72ABE4"><spacer type="block" width=1 height=1></td>',
				'<td width=5 bgcolor="#CDE7FF"><spacer type="block" width=5 height=1></td>',
				'<td width=178 class=rightnav bgcolor="#CDE7FF"><%indent%><a href="<%linkurl%>" target="<%target%>"><%linktext%></td>',
				'<td width=9 bgcolor="#CDE7FF">&nbsp;</td>',
				'<td width=1 bgcolor="#6799CD"><spacer type="block" width=1 height=1></td>',
			'</tr>'
		);
			
	this._imgRow.push(
			'<tr><td width=195 height=20 colspan=6><a href="<%linkurl%>" target="<%target%>"><img src="<%imgsrc%>" border=0></a></td></tr>'
		);
		
	this._keyLine.push(
			'<tr><td height=1 bgcolor="#6799CD" colspan=6><spacer type="block" width=1 height=1></td></tr>',
			'<tr>',
				'<td width=1 bgcolor="#6799CD"><spacer type="block" width=1 height=1></td>',
				'<td width=1 bgcolor="#6799CD"><spacer type="block" width=1 height=1></td>',
				'<td height=1 bgcolor="#C2E2FF" colspan=3><spacer type="block" width=1 height=1></td>',
				'<td width=1 bgcolor="#6799CD"><spacer type="block" width=1 height=1></td>',
			'</tr>'
		);
	
	this.addTextHeader = function() { 
		//rowVars = hash of label/link
		for (i=0;i<arguments.length;i++) {
			var textObj = arguments[i];
			var textRowHTML = new Class_HTMLTemplate(this._textRow);
			textRowHTML.addParams( 
					{  
					linkurl 		: textObj['url'],
					target 		: textObj['target'] || '_self',
					linktext 	: textObj['label']	
					} 
				);
			textRowHTML.fillTemplate();
			this._rnHTML.push(textRowHTML.text);
		}
	}
	
	this.addImgHeader = function(imgObj) { 
		//imgURL = location of img hdr
		var imgRowHTML = new Class_HTMLTemplate(this._imgRow);
		imgRowHTML.addParams( 
				{  
				linkurl 		: imgObj['url'] || '#',
				target 		: imgObj['target'] || '_self',
				imgsrc		: imgObj['imgsrc']	
				} 
			);
		imgRowHTML.fillTemplate();
		this._rnHTML.push(imgRowHTML.text);
	}
	
	this.addLinks = function() { 
		//argument length may vary. each arg is an array of link info
		for (i=0;i<arguments.length;i++) {
			var linkObj = arguments[i];
			var linkrowHTML = new Class_HTMLTemplate(this._subRow);
			linkrowHTML.addParams( 
					{  
					linkurl 		: linkObj['url'],
					target 		: linkObj['target'] || '_self',
					linktext 	: linkObj['label'],
					indent		: (linkObj['indent']=='no') ? '' : this._indent
					} 
				);
			linkrowHTML.fillTemplate();
			this._rnHTML.push(linkrowHTML.text);
		}
	}
	
	this.addKeyLine = function() {
		this._rnHTML.push(this._keyLine.join('\n'));
	}
	
	this.addNewsletterBox = function() {
		this._newsletterBox = true;
	}
	
	this.addHTML = function(HTML) {
		//alert(HTML);
		//HTML is an array of lines of HTML
		this._moreHTML = HTML;
	}
	
	this.drawRightNav = function() {
		this._rnHTML.push('</table>');	
		if (this._newsletterBox) {
			this._rnHTML.push(getNewsletterBox(thisNewsletter));
		}
		if (this._moreHTML.length>0) {
			this._rnHTML.push(this._moreHTML.join('\n'));
		}
		document.write(this._rnHTML.join('\n'));
	}
	
}

//This allows my new ColorRightNav to inherit from my RightNav Class
Class_ColorRightNav.prototype = new Class_RightNav();

function Class_ColorRightNav()  
{
	this._newsletter = thisNewsletter;//thisNewsletter; //this value comes onload
	this._rnHTML = [];
	this._textRow = [];
	this._textRow2 = [];
	this._textRow3 = [];
	this._textRow4 = [];
	this._subRow = [];
	this._subRow2 = [];
	this._imgRow = [];
	this._keyLine = [];
	this._newsletterBox = (this._newsletter >0);
	this._nlmsg = new String();
	this._list_id = new String();
	this._list_site = new String();
	this._moreHTML = []; //HTML written after rightnav links
//	this._indent = "&nbsp; &nbsp;";
	
	this._rnHTML.push('<div id="rightnav">');

	//no doctype, no standards? hack it! :-D
	var hack192 = (is_ie) ? ' style="width:192px"' : '';

	this._textRow.push(
		'<div class="menuhdr"'+hack192+'>',
			'<span class="mtext"><a href="<%linkurl%>" target="<%target%>"><%linktext%></a></span>',
		'</div>'
	);
	
	this._textRow2.push(
		'<div class="menuhdr2"'+hack192+'>',
			'<span class="mtext"><%linktext%></span>',
		'</div>'
	);
	
	this._textRow3.push(
		'<div class="menuhdr3"'+hack192+'>',
			'<span class="mtext"><a href="<%linkurl%>" target="<%target%>"><%linktext%></a></span>',
		'</div>'
	);
	
	this._textRow4.push(
		'<div class="menuhdr4"'+hack192+'>',
			'<span class="mtext"><%linktext%></span>',
		'</div>'
	);

	this._subRow.push(	
		'<div class="menuitem"'+hack192+'>',
			'<span class="mtext"><a href="<%linkurl%>" target="<%target%>"><%linktext%></a></span>',
		'</div>',
		'<%keyline%>'
	);

	this._subRow2.push(	
		'<div class="menuitem2"'+hack192+'>',
			'<span class="mtext"><a href="<%linkurl%>" target="<%target%>"><%linktext%></a></span>',
		'</div>',
		'<%keyline%>'
	);
	
	this._keyLine.push('<div class="menukeyline"'+hack192+'><div id="keyline"><spacer type="block" height="1" width="1" /></div></div>' );

	this.addTextHeader = function() { 
		//rowVars = hash of label/link
		for (i=0;i<arguments.length;i++) 
		{
			var textObj = arguments[i];
			
			var rowTemplate = this._textRow;
			
			if (textObj['url'].length<1 || textObj['url']=='#') 
			{
				rowTemplate = this._textRow2;
			}
			
			if ( (textObj['url'].length<1 || textObj['url']=='#') && textObj['label'].length>25)
			{
				rowTemplate = this._textRow4;
			}
			
			var textRowHTML = new Class_HTMLTemplate(rowTemplate);
			textRowHTML.addParams( 
					{  
					linkurl 		: textObj['url'],
					target 		: textObj['target'] || '_self',
					linktext 	: textObj['label']	
					} 
				);
			textRowHTML.fillTemplate();
			this._rnHTML.push(textRowHTML.text);
		}
	}

	this.addLinks = function() { 
		//argument length may vary. each arg is an array of link info
		for (i=0;i<arguments.length;i++) 
		{
			var linkObj = arguments[i];
			
			var rowTemplate = (linkObj['label'].length>30) ? this._subRow2 : this._subRow;
			
			var linkrowHTML = new Class_HTMLTemplate(rowTemplate);
			linkrowHTML.addParams( 
					{  
					linkurl 		: linkObj['url'],
					target 		: linkObj['target'] || '_self',
					linktext 	: linkObj['label'],
					indent		: (linkObj['indent']=='no') ? '' : this._indent,
					keyline		: (i<arguments.length-1) ? this._keyLine : ''
					} 
				);
			linkrowHTML.fillTemplate();
			this._rnHTML.push(linkrowHTML.text);
		}
	}

	this.addHTML = function(HTML) {
		this._rnHTML.push(HTML);
	}

	this.drawRightNav = function() {
		this._rnHTML.push('</div>');
		document.write(this._rnHTML.join('\n'));
		this.makeAdjustments();
	}
	
	this.addNewsletterBox = function() {
		this._newsletterBox = true;
		this._nlmsg = getNLBox_Message();
		this._list_id = getNLBox_Attribute('list_id');
		this._list_site = getNLBox_Attribute('list_site');

		var nlb = [];
		
		nlb.push
		(
			'<div id="rightnavnl">',
			'<div class="menuhdr" ' + hack192 + '>',
			'<span class="nl">NEWSLETTER SIGN-UP</span></div>',
			'<div id="nlbox"'+hack192+'>',
			'	<div id="nlcontainer">',
			'		<div id="nlmsg"><%nlmsg%><\/div>',
			'		<div id="nlformbox">',
			'			<form id="nlform" name="newsletterbox" method=POST action="/cgi/subscription_verif.pl" onSubmit="return validateNLBox(this)">',
			'					<div id="nlinputs">',
			'						<input type="text" name="email" value="" size=15 id="emailfield">',
			'						<input type=image src="/images/common/nl_sendbtn.gif" border=0 width="40" height="20" name="nlbtn" id="nlbtn">',
			'					<\/div>',
			'					<input type="hidden" name="thankyou_url" value="<%thankyou_location%>">',
			'					<input type="hidden" name="list_id" value="<%listID%>">',
			'					<input type="hidden" name="list_site" value="<%listSite%>">',
			'			<\/form>',
			'		<\/div>',
			'		<div id="nlprivacy"><a href="/about/privacy.html">Privacy Policy<\/a><\/div>',
			'	<\/div>',
			'<\/div>',
			'</div>'
		);
		
		var nlbHTML = new Class_HTMLTemplate(nlb);
		nlbHTML.addParams(
				{
				'nlmsg' 		: this._nlmsg.join('\n'),
				'listID' 		: this._list_id,
				'listSite' 	: this._list_site,
				'thankyou_location' : location				
				}
			);
		nlbHTML.fillTemplate();

		//return nlbHTML.text;
		this._rnHTML.push(nlbHTML.text);
	}
	
	this.makeAdjustments = function() {
		//aesthetic adjustment for ie
		if (is_ie && is_win && (document.getElementById("nlbtn"))) 
		{ 
			document.getElementById("nlbtn").style.margin = "-21px 0px 0px 0px"; 
		}
			
		//newsletter form inputs showing or not?
		switch (scenario) {
			case 3: 
				this.removeNLInputs();
				break;
			case 4: 
				this.removeNLInputs();
				break;
			case 6: 
				this.removeNLInputs();
				break;
			default : var blah = '';
		}
	}
	
	this.addRightAds = function() {
		this._rnHTML.push('<table cellspacing=0 cellpadding=0 width="100%"><tr><td align="center"><script>drawRightBanners()</script></td></tr></table>');
	}
	
	this.removeNLInputs = function() {
		document.getElementById("nlform").style.display = "none";
		document.getElementById("nlprivacy").style.display = "none";
	}
	
	//this takes the global list and adds the links via the methods of this class
	this.addGlobalLinks = function() {
		if (typeof(gNavLinks)!="undefined")
		{
			var objCount = 0;
		
			for (obj in gNavLinks)
			{
				if (typeof(gNavLinks[obj]['header']) != 'undefined')
				{
					crn.addTextHeader( 
						{ 
							'label' : gNavLinks[obj]['header'], 
							'url' : gNavLinks[obj]['url'] 
						}
					);
				}
				if (typeof(gNavLinks[obj]['label']) != 'undefined')
				{
					crn.addLinks( 
						{ 
							'label' : gNavLinks[obj]['label'], 
							'url' : gNavLinks[obj]['url'] 
						}
					);
					
					//this solves the keyline before the next header problem
					var objSeek = objCount+1;
					
					if (objCount < gNavLinks.length-1 && gNavLinks[objSeek]['header'] == null)
					{
						crn.addKeyLine();
					}
				}
				
				objCount++;
			}
		}
	}
}

function Class_AdContainer(oaspos)
{
	//list of OAS positions
	this.adlist = oaspos;
	
	this._acTop = '<center><table cellpadding=0 cellspacing=0 border=0><tr><td height=200 align=center><br>';
	this._acBottom = '</td></tr></table></center>';
	
	this.drawContainer = function() {
		document.writeln(this._acTop);
		if (this.adlist!=null) 
		{
			for (i=0;i<this.adlist.length;i++) 
			{
				if (this.adlist[i].charAt(0)!="<") 
				{
					OAS_AD(this.adlist[i]);
					document.writeln('<br><br>');
				}
				else { 
					document.write(this.adlist[i]); 
				}
			}
		}
		document.writeln(this._acBottom);
	}
}

//Get the window dimensions for this browser
function Class_WindowDimensions()  
{
	//source: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
	 this.width = 0, 
	 this.height = 0;
	 
	if ( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		this.width = window.innerWidth;
		this.height = window.innerHeight;
	} 
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		this.width = document.documentElement.clientWidth;
		this.height = document.documentElement.clientHeight;
	} 
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		this.width = document.body.clientWidth;
		this.height = document.body.clientHeight;
	}
}

//Draws the what's on content on the HP
function Class_HPWhatsOn() 
{
	this._woHTML = [];

	this.addShow = function(time, title) {
		this._woHTML.push
		(
			'<p>',
			'<span class="time">'+time+'</span><br />',
			'<span class="showtitle">'+title+'</span>',
			'</p>'
		);
	}
	
	this.addBlurb = function(text) {
		this._woHTML.push
		(
			'<p>',
			'<span class="showtitle">'+text+'</span>',
			'</p>'
		);
	}
	
	this.print = function() {
		if (this._woHTML.length>0)
		{
			document.write(this._woHTML.join('\n'));
		}
	}
}

function Class_MemberTrackingCookie()
{
	this._ssid = (Get_Cookie('ltv_client_id')) ? Get_Cookie('ltv_client_id') : "";

	this._init= function()
	{
		if (Get_Cookie('ltv_client_id'))
		{
			this._setClientCode();
		}
		else 
		{
			//if login code is set and ltv client id is not, set ltv client id
			if (
			Get_Cookie('LoginCode') && 
			!Get_Cookie('ltv_client_id') && 
			typeof(userProfile['screenName'] != 'undefined') &&
			userProfile['screenName']!=""
			)
			{
				this._setTrackingCookie();
				this._setClientCode();
			}			
		}
	}

	this._setTrackingCookie = function() 
	{
		if (typeof(mep1) != 'undefined')
		{
			if (userProfile['ssid'] != "") 
			{
				Set_Cookie('ltv_client_id', userProfile['ssid'], getGMTDate(3650), '/', '.mylifetime.com', '');
			}
		}
	}

	this._setClientCode = function()
	{
		if (this._ssid != "")
		{
			mep1+='&if_clientCode='+this._ssid;
		}
	}

	this._init();
}

function Class_MemberExtendedInfoCookie()
{
	this._ssid = "";
	this._cookieStr = "";
	this.gender = "";
	this.age = "";
	
	this._init = function()
	{
		if (typeof(userProfile['ssid'])!='undefined' && userProfile['ssid']!="")
		{
			this._getMemberInfo(userProfile['ssid']);
		}
		
		if (Get_Cookie("ltv_client_id"))
		{
			this._getMemberInfo(Get_Cookie("ltv_client_id"));
		}
	}
	
	this._getAge = function(dateString)
	{
		/*
		   source: http://www.cybercoded.com/faqdetails.asp?r=131&c=JScript
		   dateString is a date passed as a string in the following formats:
		   type 1 : 19970529
		   type 2 : 970529
		   type 3 : 29/05/1997
		   type 4 : 29/05/97
		
		   dateType is a numeric integer from 1 to 4, representing
		   the type of dateString passed, as defined above.
		*/
	
		var now = new Date();
		var today = new Date(now.getFullYear(),now.getMonth(),now.getDate());
	
		var yearNow = now.getFullYear();
		var monthNow = now.getMonth();
		var dateNow = now.getDate();
	
		var dchops = dateString.split('/');
		var dob = new Date();
		dob.setFullYear(dchops[2],dchops[0]-1,dchops[1]);
		
		var yearDob = dob.getFullYear();
		var monthDob = dob.getMonth();
		var dateDob = dob.getDate();
	
		yearAge = yearNow - yearDob;
	
		if (monthNow >= monthDob)
		{
			var monthAge = monthNow - monthDob;
		}
		else 
		{
		   yearAge--;
			var monthAge = 12 + monthNow -monthDob;
		}
	
		if (dateNow >= dateDob)
		{
			var dateAge = dateNow - dateDob;
		}
		else 
		{
			monthAge--;
			var dateAge = 31 + dateNow - dateDob;
	
			if (monthAge < 0) 
			{
				monthAge = 11;
				yearAge--; 
			}
		}
	
		//return yearAge + ' years ' + monthAge + ' months ' + dateAge + ' days';
		return yearAge;
	}
	
	this._getValue = function(n)
	{
		//gets value from pipe-delimited string chopped as array
		//n = which nth to retrieve
		return this._cookieStr.split('|')[n];		
	}

	//just returns a reference to this object. i need this because i lose object scope in ajax.
	this._getObjRef = function() { return this; }
	
	this._setMemberInfoCookie = function(str)
	{
		this._cookieStr = str;
		this.gender = this._getValue(0);
		this.age = this._getAge(this._getValue(1));

		Set_Cookie('ltv_client_info', str, getGMTDate(3650), '/', '.mylifetime.com', '');
	}
	
	this._getMemberInfo = function(ssid)
	{
		var thisObj = this._getObjRef();
	
		//if client info is not set, get the data and set it. 
		//if it is set, read from the cookie and populate the attributes
		if (!Get_Cookie('ltv_client_info'))
		{
			//ajax: get sex(gender) and birthdate from db
			var xmlhttp = new XMLHttpRequest();
			xmlhttp.open("POST","/common/getsubinfo.php",true);
			xmlhttp.onreadystatechange = function()
			{
				if (xmlhttp.readyState==4)
				{
					r = xmlhttp.responseText;		
					if (xmlhttp.status == 200)
					{
						thisObj._setMemberInfoCookie(r);	
						thisObj._updateUserProfile(r);
					}
				}
			}	
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.send('ssid='+ssid);
		}
		else
		{
			this._cookieStr = Get_Cookie('ltv_client_info');
			this.gender = this._getValue(0);
			this.age = this._getAge(this._getValue(1));
		}
	}	
	
	this._updateUserProfile = function(str)
	{
		this._cookieStr = str;
		userProfile['gender'] = this._getValue(0);
		userProfile['age'] = this._getAge(this._getValue(1));
	}
	
	this._init();
}
/*
if (Get_Cookie('ltv_client_id'))
{
	var ssid = Get_Cookie('ltv_client_id');
	var memberInfoCookie = new Class_MemberExtendedInfoCookie(ssid);
} 
*/
