/************** 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]; }


/************** GLOBAL VARIABLES **************/

var loc = new String(location);
var dmn =  'http://' + location.hostname;

var onGoogle = (loc.contains('googlebot'));
var googleDev = (loc.contains('dev.xsl'));
if ((onGoogle) && (googleDev)) { dmn = "http://dev.lifetimetv.com"; }
if ((onGoogle) && (!googleDev)) { dmn = "http://www.lifetimetv.com"; }
var onDev = loc.contains('http://dev.');

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' : 'Why I Wore Lipstick ', 'url' : domain + '/movies/originals/whyiworelipstick.php' },
{ 'header' : 'SHOWS', 'url' : '#' },
{ 'label' : 'Angela\'s Eyes', 'url' : domain + '/shows/angela/index.html' }, 
{ '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' : 'Golden Girls', 'url' : domain + '/shows/golden/index.html' },
{ 'label' : 'Golden Palace', 'url' : domain + '/shows/golden/palace/index.html' },
{ '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' : 'Lovespring International', 'url' : domain + '/shows/lovespring/index.php' },
{ 'label' : 'Medium', 'url' : domain + '/shows/medium/index.html' },
{ 'label' : 'MISSING', 'url' : domain + '/shows/missing/index.html' },
{ 'label' : 'Off the Leash', 'url' : domain + '/shows/offtheleash/index.php' },
{ 'label' : 'Reba', 'url' : domain + '/shows/reba/index.html' },
{ 'label' : 'Still Standing', 'url' : domain + '/shows/stillstanding/index.html' },
{ 'label' : 'Strong Medicine', 'url' : domain + '/shows/strongmed/index.html' },
{ 'label' : 'The Division', 'url' : domain + '/shows/division/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' : 'Why I Wore Lipstick', 'url' : '/movies/originals/whyiworelipstick.php' },
{ 'label' : '', 'url' : '' },
{ 'label' : ' LIFETIME SHOWS ', 'url' : '/shows/index.html' },
{ 'label' : 'Angela\'s Eyes', 'url' : '/shows/angela/index.html' },
{ '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' : 'Golden Girls', 'url' : '/shows/golden/index.html' },
{ 'label' : 'Golden Palace', 'url' : '/shows/golden/palace/index.html' },
{ 'label' : 'How Clean', 'url' : '/shows/clean/index.html' },
{ 'label' : '&nbsp; &nbsp;  Is Your House?', 'url' : '/shows/clean/index.html' },
{ 'label' : '"I Do" Diaries', 'url' : '/shows/weddings/index.html' },
{ 'label' : 'Intimate Portrait', 'url' : '/shows/ip/index.html' },
{ 'label' : 'Lovespring', 'url' : '/shows/lovespring/index.php' },
{ 'label' : '&nbsp; &nbsp; International', 'url' : '/shows/lovespring/index.php' },
{ 'label' : 'Medium', 'url' : '/shows/medium/index.html' },
{ 'label' : 'MISSING', 'url' : '/shows/missing/index.html' },
{ 'label' : 'Off the Leash', 'url' : '/shows/offtheleash/index.php' },
{ 'label' : 'Reba', 'url' : '/shows/reba/index.html' },
{ 'label' : 'Still Standing', 'url' : '/shows/stillstanding/index.html' },
{ 'label' : 'Strong Medicine', 'url' : '/shows/strongmed/index.html' },
{ 'label' : 'The Division', 'url' : '/shows/division/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=golden','Golden Girls',
	'/cgi/scripts/tv_byshow.pl?show=lovespring','Lovespring International',
	'/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=unsolved','Unsolved Mysteries',
	'/cgi/scripts/tv_byshow.pl?show=willgrace','Will & Grace'
	];
}

//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() 
{
	//replaced regex replace for boards w/simpler loc string check - km032603
	//updated w/ HTMLTemplate - km042105
	var onExternalSite = (
								(!location.hostname.contains('www.lifetimetv.com')) &&
								(!location.hostname.contains('dev.lifetimetv.com'))
								) ? 1 : -1;

	//For external sites, make relative links point back to ltv.com
	if (onExternalSite==1) { domain="http://www.lifetimetv.com" }

	var footerHTML = [];
	
//				'<td align="center" class="brands"><a href="<%domain%>/index.html">Lifetime</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="<%domain%>/lmn/index.html">Lifetime Movie Network</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="<%domain%>/lrw/index.html">Lifetime Real Women</a> <br><div class="spacer5p"></div> <a href="<%domain%>/mobile/index.php">Lifetime Mobile</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="http://www.lifetimetv.com/community/olc/index.html">Our Lifetime Commitment</a></td>',
	footerHTML.push(
		'<br><br>',
			'<table cellpadding="0" cellspacing="0" border="0" width="<%footwidth%>" align="center">',
			'<tr>',
				'<td align="center" class="brands"><a href="<%domain%>/index.html">Lifetime Television</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="<%domain%>/lmn/index.html">Lifetime Movie Network</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="<%domain%>/lrw/index.html">Lifetime Real Women</a> <br><div class="spacer5p"></div> <a href="<%domain%>/mobile/index.php">Lifetime Mobile</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="http://www.lifetimetv.com/breastcancer/index.php">Breast Cancer Awareness Month</a></td>',
			'</tr>',
			'<tr>',
				'<td height="10"><spacer type="block" height="10" width="1"</td>',
			'</tr>',
			'<tr>',
				'<td height="1" bgcolor="#DAEAF0"><img src="<%domain%>/images/common/spacer.gif" width="1" height="1"></td>',
			'</tr>',
		'</table>',
		'<table cellpadding="0" cellspacing="0" border="0" width="<%footwidth%>" align="center">',
			'<tr>',
				'<td height="40">&nbsp;</td>',
			'</tr>',
		'</table>'
	);
	
	footerHTML.push(
		'<table cellpadding="0" cellspacing="0" valign=bottom align=center>',
			'<tr>',
				'<td align="center" class="copyrighttext"><br />',
				'<a href="<%domain%>/about/index.html">About Lifetime</a> |', 
				'<a href="<%domain%>/about/advertise.html">Advertise</a> |',
				'<a href="<%domain%>/about/closed_caption.html">Closed Captioning</a> |',
                '<a href="<%domain%>/cgi/tv_spanish.pl">Spanish/SAP</a> |',
				'<a href="<%domain%>/feedback/index.php">Help</a> |',
				'<a href="<%domain%>/about/jobs.html">Jobs</a><br />',
				'<a href="http://www.lifetimepress.com" target=/"_blank">Press Room</a> |',
				'<a href="<%domain%>/about/privacy.html">Privacy Policy</a> |',
				'<a href="<%domain%>/about/terms.html">Terms of Use</a> |',
				'<a href="<%domain%>/cgi/tv_videodescrip.pl">Video Descriptions</a> |',
				'<a href="<%domain%>/feedback/index.php">Write to Us</a><br><br> ', 
				'<span class=copyrighttext>Learn more about parental controls from <a href="http://mytv.controlyourtv.org/lifetime/?topicId=4177" style="text-decoration:underline" target="_blank">ControlYourTV.org</a>.<br><br> ',
				'&copy; 2006 Lifetime Entertainment Services. All rights reserved.</span><br><br></td>',
//				'<span class=copyrighttext>&copy; 2006 Lifetime Entertainment Services. All rights reserved.</span><br><br></td>',
			'</tr>',
		'</table>'
	);

	if (  
	//if you're on the homepage, show the wide version of the brands row
	(loc == 'http://dev.lifetimetv.com/') ||
	(loc == 'http://dev.lifetimetv.com/index.html') ||
	(loc == 'http://www.lifetimetv.com/index.html') ||
	(loc == 'http://www.lifetimetv.com') ||
	(loc == 'www.lifetimetv.com') ||
	(loc == 'dev.lifetimetv.com') ||
	(loc == 'lifetimetv.com')
	) {
		footwidth = 600;
	}
	//medium length
	else if (
	(loc.contains('/shows/')) ||
	(loc.contains('/movies/entertain/')) ||
	(loc.contains('/movies/originals/')) ||
	(loc.contains('/movies/index')) ||
	(loc.contains('/games/'))
	)
	{
		footwidth = 560;
	} 
	//short
	else 
	{
		footwidth = 400;
	}
	
	var footer = new Class_HTMLTemplate(footerHTML);
	footer.addParams( 
		{
		'domain' : domain,
		'footwidth' : footwidth
		}
	);
	footer.fillTemplate();
	footer.printTemplate();
	footer=null;
}

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 = "http://www.lifetimetv.com/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.lifetimetv.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
						'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,'/','lifetimetv.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/');
	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 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 startMemberTracking()
{
	var tc = new Class_MemberTrackingCookie();
}
/************** 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
};

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'] = '';
		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 Lifetimetv.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 Lifetimetv.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="http://www.lifetimetv.com/community/members/exclusive/index.html">Lifetime Member Center!</a><br><br>',
					
	'more newsletters':
	'<a href="http://www.lifetimetv.com/cgi/community/members/nlsignup.pl">Click here</a> for more newsletters.<br><br>',
	
	'be a full member':
	'<a href="http://www.lifetimetv.com/community/members/member_intro.html">Click here</a> to become a full member.<br><br>',
	
	'be a full member 99':
	'<a href="http://www.lifetimetv.com/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) {
	var sWidth, sHeight;
	var xyPosition = '0';
	
	var vw = 900;
	var vh = 600;
	
	if (window.screen) 
	{
		sWidth = screen.width;
		sHeight = screen.height;
		
		
		var x = (sWidth/2) - (vw/2);
		var y = (sHeight/2) - (vh/2);
		
		xyPosition = 'left='+x+',top='+y;
	}
	
	if (vid != '') {
		openWindow(domain + '/videolounge/videolounge.php?vid='+ vid ,'videolounge',vw,vh,xyPosition);
	}
	else {
		openWindow(domain + '/videolounge/videolounge.php','videolounge',vw,vh,xyPosition);
	}
}

/****************** CLASS DEFINITIONS ******************/

function Class_EmailAFriend() 
{
	//request params	
	this.scriptURL = "http://www.lifetimetv.com/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="http://www.lifetimetv.com/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() {	
		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="http://www.lifetimetv.com/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="http://www.lifetimetv.com/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="http://www.lifetimetv.com/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._sendClientCode();
		}
		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._setTrackingVariable();
				this._sendClientCode();
			}
		}
	}

	this._setTrackingVariable = function() 
	{
		if (typeof(mep1) != 'undefined')
		{
			if (userProfile['ssid'] != "") 
			{
				Set_Cookie('ltv_client_id', userProfile['ssid'], getGMTDate(3650), '/', '.lifetimetv.com', '');
			}
		}
	}
	
	this._sendClientCode = function()
	{
		if (this._ssid != "")
		{
			mep1+='&if_clientCode='+this._ssid;
		}
	}

	this._init();
}

