var tfjLockToggle = false;

function tfj_getCookies() {
	var hash = new Array;
	if ( document.cookie ) {
		var cookies = document.cookie.split( '; ' );
		for ( var i = 0; i < cookies.length; i++ ) {
			var namevaluePairs = cookies[i].split( '=' );
			hash[namevaluePairs[0]] = unescape( namevaluePairs[1] ) || null;
		}
	}
	return hash;
}

function tfj_parseCookieData( cookieDataString ) {
	var cookieValues = new Object();
	var separatePairs = cookieDataString.split( '&' );
	for ( var i = 0; i < separatePairs.length; i++  ) {
		var separateValues = separatePairs[i].split( ':' );
		cookieValues[separateValues[0]] = separateValues[1] || null;
	}
	return cookieValues;
}

function tfj_setCookie( name, value, hours, path, domain, secure ) {
		var numHours = 0;

		if ( hours) {
			if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
				numHours = hours;
			} else if ( typeof(hours) == 'number' ) { // calculate Date from number of hours
				numHours = ( new Date((new Date()).getTime() + hours*3600000) ).toGMTString();
			}
		}

		document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.

}


function tfj_killCookie( name, path, domain ) {
	var allCookies = tfj_getCookies();

	var theValue = allCookies[ name ] || null; // We need the value to kill the cookie
	if ( theValue ) {
		document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
	}
}


var allCookies = tfj_getCookies();
var tfjDomainArray = location.hostname.split( '.' );
var tfjCurrDomain = ( tfjDomainArray.length > 1 ) ? '.' + tfjDomainArray[tfjDomainArray.length-2] + '.' + tfjDomainArray[tfjDomainArray.length-1] : '';

var pagetypeTS="";

function tfjRenderTimeStamp(date,timeString) {
	var tfjIsIntl = (location.hostname.indexOf('edition.') > -1) ? true : false;
	tfjStoryPublishTime = (date) ? new Date(date) : tfjStoryPublishTime;
	var days = new Array('Sun','Mon','Tue','Wed','Thur','Fri','Sat');
	var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

    var tfjTimeStampDiff = tfjCurrTime.getTime() - tfjStoryPublishTime.getTime();

    var daysDifference = Math.floor(tfjTimeStampDiff/1000/60/60/24);

    tfjTimeStampDiff -= daysDifference*1000*60*60*24

    var hoursDifference = Math.floor(tfjTimeStampDiff/1000/60/60);

    tfjTimeStampDiff -= hoursDifference*1000*60*60

    var minutesDifference = Math.floor(tfjTimeStampDiff/1000/60);

    tfjTimeStampDiff -= minutesDifference*1000*60

	var tfjDays = (daysDifference > 1) ? "days" : "day";
	var tfjHours = (hoursDifference > 1) ? "hours" : "hour";
	var tfjMinutes = (minutesDifference > 1) ? "minutes" : "minute";
	var tfjHPMinutes = "min";
	var tfjCMSTimeString = '';
	var tfjBlankString = "";

	if (timeString) {
		tfjCMSTimeString = (tfjIsIntl) ? timeString[0] : timeString[1];
	}	else { //for legacy support
		tfjCMSTimeString = "updated " + (!tfjIsIntl ? days[tfjStoryPublishTime.getUTCDay()] : '') + " " + months[tfjStoryPublishTime.getUTCMonth()] + " " + tfjStoryPublishTime.getUTCDate() + ", " + tfjStoryPublishTime.getUTCFullYear();
	}


	if (hoursDifference > 4 && daysDifference >= 0 || daysDifference >= 1) {
		switch(pagetypeTS) {
			case "homepage": //t2 formatted
				return tfjBlankString;
			break;
			case "mosaic":
				return "<div class=\"tfjGryTmeStmp\">" + tfjCMSTimeString + "<\/div>";
			break;
			case "section":
			default:
				if (pagetypeTS == 'section' && tfjIsIntl) {
					return "<div class=\"tfjGryTmeStmp\">" + tfjCMSTimeString + "<\/div>";
				} else {
					return "<div class=\"tfjGryTmeStmp\">updated " + (!tfjIsIntl ? days[tfjStoryPublishTime.getUTCDay()] : '') + " " + months[tfjStoryPublishTime.getUTCMonth()] + " " + tfjStoryPublishTime.getUTCDate() + ", " + tfjStoryPublishTime.getUTCFullYear() + "<\/div>";
				}
		}
	} else if( hoursDifference <= 4 && hoursDifference >= 1) {
		switch(pagetypeTS) {
			case "homepage": //t2 formatted
				return tfjBlankString;
			break;
			case "mosaic":
			default:
				if (minutesDifference > 0) {
					return "<div class=\"tfjGryTmeStmp\">updated " + hoursDifference + " "+tfjHours+", " + minutesDifference + " "+tfjMinutes+" ago<\/div>";
				} else {
					return "<div class=\"tfjGryTmeStmp\">updated " + hoursDifference + " "+tfjHours+" ago<\/div>";
				}
		}
	} else {
		switch(pagetypeTS) {
			case "homepage": //t2 formatted
				if(hoursDifference < 1 && minutesDifference > 0){
					return '<span>' + minutesDifference + " min<\/span>";
				} else {
					return "<span>1 min<\/span>";
				}
			break;
			case "mosaic":
			default:
				if(hoursDifference < 1 && minutesDifference > 0){
					return "updated " + minutesDifference + " "+tfjMinutes+" ago";
				} else {
					return "updated 1 minute ago";
				}
		}

	}
}


function tfjRenderT1TimeStamp(date,useLongFormat) {

	tfjStoryPublishTime = (date) ? new Date(date) : tfjStoryPublishTime;
	var tfjTimeStampString;
	var nullString="";



    var tfjTimeStampDiff = tfjCurrTime.getTime() - tfjStoryPublishTime.getTime();

    var daysDifference = Math.floor(tfjTimeStampDiff/1000/60/60/24);

    tfjTimeStampDiff -= daysDifference*1000*60*60*24

    var hoursDifference = Math.floor(tfjTimeStampDiff/1000/60/60);

    tfjTimeStampDiff -= hoursDifference*1000*60*60

    var minutesDifference = Math.floor(tfjTimeStampDiff/1000/60);

    tfjTimeStampDiff -= minutesDifference*1000*60

    var secondsDifference = Math.floor(tfjTimeStampDiff/1000);


	var tfjDays = (daysDifference > 1) ? "days" : "day";
	var tfjHours = (hoursDifference > 1) ? "hours" : "hour";
	var tfjMinutes = (minutesDifference > 1) ? "minutes" : "minute";
	var tfjSeconds = (secondsDifference > 1) ? "seconds" : "second";
	var tfjHPMinutes = (minutesDifference > 1) ? "minutes" : "minute";
	var tfjHPSeconds = (secondsDifference > 1) ? "secs" : "sec";

	if (pagetypeTS=='homepage') {

			tfjTimeStampString = 'updated ';

		if(hoursDifference < 1 && minutesDifference > 0){
			tfjTimeStampString += minutesDifference + " "+(useLongFormat?tfjMinutes:tfjHPMinutes)+" ago";
		} else if(hoursDifference < 1 && minutesDifference < 1) {
			tfjTimeStampString += secondsDifference + " "+(useLongFormat?tfjSeconds:tfjHPSeconds)+" ago";
		} else if(hoursDifference >= 1) {
			return nullString;
		}
		return '<span>'+tfjTimeStampString+'</span>';
	}

}


function tfj_submitUserComment(form) {
var tfjSubmitForm = true;

if(typeof(tfjThread) != "undefined") {
	$(form).threadName.value = tfjThread;
}
if(typeof(tfjForum) != "undefined") {
  $(form).forumName.value  = tfjForum;
}

var errorDivs = $('tfjROCSubFrm').getElementsByClassName('tfjError');
for (var i = 0; i<errorDivs.length; i++) {
	errorDivs[i].remove();
}

allFormEls = Form.getElements(form);
for(i = 0; i < allFormEls.length; i++) {
    //do something to each form field
    allFormEls[i].value = allFormEls[i].value.strip().stripScripts().stripTags();
    if (allFormEls[i].value == "") {
    		if (allFormEls[i].name == "name") {
    			new Insertion.Before('tfjUserResponseName',' <span id="tfjUserResponseNameError" class="tfjError">&raquo;<\/span>');
    		}
    		if (allFormEls[i].name == "location") {
    			new Insertion.Before('tfjUserResponseLocation',' <span id="tfjUserResponseNameError" class="tfjError">&raquo;<\/span>');
    		}
    		if (allFormEls[i].name == "body") {
    			new Insertion.Before('tfjUserResponseComment',' <span id="tfjUserResponseNameError" class="tfjError">&raquo;<\/span>');
    		}
    	tfjSubmitForm = false;
	}
}

	if (tfjSubmitForm) {

			new Effect.Opacity('tfjROCFrm',
					{
						duration:1.0,
						from:1.0,
						to:0,
						beforeStart:function() {
					  		document.tfjROCSubFrm.submit();
						},
						afterFinish: function(obj)
							{
							Form.reset(form);					      		$('tfjROCFrmComplete').innerHTML = "Thank you for contributing. Comments are moderated by tfj and will not appear on this story until after they have been reviewed and deemed appropriate for posting. Unfortunately, due to the volume of comments we receive, not all comments can be posted.<br><br><a href=\"javascript:void(0);\" onclick=\"tfj_toggleSubmissionForm('tfjROCFrm','tfjROCFrmComplete')\">Post another comment<\/a>";
									new Effect.Opacity('tfjROCFrmComplete',
										{
											duration:1.0,
											from:0,
											to:1.0,
											beforeUpdate:function(obj) {
												$('tfjROCFrm').hide();
												obj.element.show();
											}
										}
									);
							}

					}
				);
	}
}

function tfj_toggleSubmissionForm(show,hide) {

new Effect.Opacity(hide,
					{
						duration:1.0,
						from:1.0,
						to:0,
						afterFinish: function(obj)
							{
								new Effect.Opacity(show,
										{
											duration:1.0,
											from:0,
											to:1.0,
											beforeUpdate:function(obj) {
												$(hide).hide();
												obj.element.show();
											}
										}
									);
							}
					}
				)


}

function tfjShowExtendedComments(el) {
	var block = document.getElementsByClassName('tfjExtended',el.parentNode.parentNode);
	if (block && block.length > 0) {
		tfjToggleUGC(block[0],el);
		el.style.display = "none";
	}
}

function tfjHideExtendedComments(el) {
	var block = el.parentNode.parentNode;
	var blockLinks = block.parentNode.getElementsByTagName('a');
	if (block) {
		tfjToggleUGC(block,el);
			for (var i=0; i < blockLinks.length; i++) {
				blockLinks[i].style.display = "inline";
		}
	}
}

function tfjShowMore(el) {
	var block = document.getElementsByClassName('tfjExtended',el.parentNode.parentNode);
	var initialGraph = el.parentNode.getElementsByTagName('p');
	if (block && block.length > 0) {
el.parentNode.hide();
block[0].show();
	}
}

function tfjShowLess(el) {
	var block = el.parentNode.parentNode;
	var blockLinks = block.parentNode.getElementsByTagName('p');

	block.hide();
	blockLinks[0].show();

}

function tfjToggleUGC(el,lnk) {
	if (tfjLockToggle) {
		return;
	}

	tfjLockToggle = true;
	var tfjToggleClass = (lnk.parentNode.className.indexOf('Closed') > -1) ? true : false;

		Effect.toggle(el,'blind',
		{
			beforeStart:function(obj) {
				try {
					lnk.blur();
				} catch(e) {};
				if (tfjToggleClass) {
				switch(lnk.parentNode.className) {
					case 'tfjOpinionClosed':
						lnk.parentNode.className = 'tfjOpinion';
					break;
					case 'tfjIReportClosed':
						lnk.parentNode.className = 'tfjIReport';
					break;
					case 'tfjBlogsClosed':
						lnk.parentNode.className = 'tfjBlogs';
						Sphere.Widget.search();
					break;
					default:
				}
				}

			},
			afterFinish:function(obj) {
				if (!tfjToggleClass) {
				switch(lnk.parentNode.className) {
					case 'tfjOpinion':
						lnk.parentNode.className = 'tfjOpinionClosed';
					break;
					case 'tfjIReport':
						lnk.parentNode.className = 'tfjIReportClosed';
					break;
					case 'tfjBlogs':
						lnk.parentNode.className = 'tfjBlogsClosed';
					break;
					default:
				}
				}
				tfjLockToggle = false;
			}
		}
	);
}

function tfjToggleNestedContent(el,lnk,num,desc) {
if (tfjLockToggle) {
	return;
}

tfjLockToggle = true;
var tfjLnkTxt = "Last 3 comments only";
		Effect.toggle(el,'blind',
		{
			duration:0.5,
			afterFinish: function() {
				if(!desc) {
					if (lnk.innerHTML == tfjLnkTxt) {
						lnk.innerHTML = "See all " + num + " comments";
					} else {
						lnk.innerHTML = tfjLnkTxt;
					}
				}
				tfjLockToggle = false;
			},
			beforeStart: function() {
				if(desc) {
					$(lnk).style.display = "none";
				}

			}
		}

		);


}


function tfj_displayBlogContent(widgetLoading,widgetContent) {
	if (!$(widgetLoading) || !$(widgetContent)) {
		return;
	}

			Effect.BlindUp(widgetLoading,
				{
					afterFinish:function(obj) {
						$(obj.element.id).remove();
					}
				}
			);
			Effect.BlindDown(widgetContent);
}


var tfjHasOpenPopup = 0;
// this is for opening pop-up windows
function tfj_openPopup( url, name, widgets, openerUrl )
{
	var host = location.hostname;
	if (window == top) { window.top.name = "opener"; }
	var popupWin = window.open( url, name, widgets );
	if(popupWin) {tfjHasOpenPopup = 1;}
	if ( popupWin && popupWin.opener ) {
		if ( openerUrl )
		{
			popupWin.opener.location = openerUrl;
		}
	}
	if ( popupWin) {
		popupWin.focus();
	}
}

function tfjImgSwap( strId, intSwap ) {
	// assumes 2 images: image.gif and image_over.gif
	var imgObj = (typeof(strId) == "object") ? strId.getElementsByTagName('img')[0] : document.getElementById( strId );
	var strTemp = imgObj.src;
	var intStrLength = strTemp.length;
	var intChop, strEnd;

	if ( intSwap ) {
		if (strTemp.indexOf('_over.gif') == -1) {
			intChop = intStrLength - 4;
			strEnd = '_over.gif';
		}
	} else {
		if (strTemp.indexOf('_over.gif') > -1) {
			intChop = intStrLength - 9;
			strEnd = '.gif';
		}
	}

	if (typeof(intChop) != "undefined") {
		strTemp = strTemp.substring( 0, intChop );
	}

	if (typeof(strEnd) != "undefined") {
		imgObj.src = strTemp + strEnd;
	}
}

/*

Flash Detect and Render
=======================

The tfj_FlashObject takes a few required arguments...

	name ......... the id/name of the object/embed
	src .......... the URL of the swf
	width ........ (i think this should be required)
	height ....... (i think this should be required)

...and some optional arguments...

	parameters ... this is a "hash" of keys and values
		{ menu: "true", play: "false", loop: "false" }
		(or set this to null or an empty string to skip)

	flashVars .... this is a hash or a string
		{ cs_url: "/football/nfl/scoreboards/today/" }
		- or -
		"cs_url=/football/nfl/scoreboards/today/"


Sample Usage:
if ( new tfj_FlashDetect().detectVersion( 6 ) ) {

	var tfj_Scoreboard = new tfj_FlashObject( "tfjScoreboard",
		"/.element/img/2.0/swf/nfl_scoreboard.swf",
		420, 85, null, "cs_url=/football/nfl/scoreboards/today/" );

	tfj_Scoreboard.writeHtml();

} else {
	document.write( 'alternate html' );
}

Of course, if you plan to have Flash in lots of places on a page,
it might make more sense to make a global variable for the detection.
You could go as far as creating a session-based cookie...

*/

var VBS_Result = false;

function tfj_FlashDetect() { }

tfj_FlashDetect.prototype.maxVersionToDetect = 8;
tfj_FlashDetect.prototype.minVersionToDetect = 3;

tfj_FlashDetect.prototype.hasPlugin = ( navigator.mimeTypes &&
		navigator.mimeTypes.length &&
		navigator.mimeTypes["application/x-shockwave-flash"] &&
		navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin );

tfj_FlashDetect.prototype.hasActiveX = window.ActiveXObject;

tfj_FlashDetect.prototype.hasWinIE = ( navigator.userAgent &&
		( navigator.userAgent.indexOf( "MSIE" ) != -1 ) &&
		navigator.appVersion &&
		( navigator.appVersion.indexOf( "Win" ) != -1 ) );

tfj_FlashDetect.prototype.getVersion = function () {
	var versionNum = 0;
	var i = 0;

	if ( this.hasActiveX ) {
		var activeXObject = false;
		for ( i = this.maxVersionToDetect; i >= this.minVersionToDetect && !activeXObject; versionNum = ( activeXObject ? i : versionNum ), i-- ) {
			try {
				activeXObject = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash." + i );
			} catch( e ) {
				// do nothing
			}
		}
	} else if ( this.hasWinIE ) {
		VBS_Result = false;
		for ( i = this.maxVersionToDetect; i >= this.minVersionToDetect && !VBS_Result; versionNum = ( VBS_Result ? i : versionNum ), i-- ) {
			execScript( 'on error resume next: VBS_Result = IsObject( CreateObject( "ShockwaveFlash.ShockwaveFlash.' + i + '" ) )', 'VBScript' );
		}
	} else if ( this.hasPlugin ) {
		if ( navigator.plugins && navigator.plugins.length && navigator.plugins["Shockwave Flash"] ) {
			var words = navigator.plugins["Shockwave Flash"].description.split( " " );
			for ( i = 0; i < words.length; ++i ) {
				if ( isNaN( parseInt( words[i] ) ) )
					continue;
				versionNum = words[i];
			}
		}
	}

	return ( versionNum );
}

tfj_FlashDetect.prototype.detectVersion = function ( num ) {
	var isVersionSupported = false;

	if ( ! isNaN( num ) ) {
		isVersionSupported = ( this.getVersion() >= parseInt( num ) );
	}

	return ( isVersionSupported );
}


function tfj_FlashObject( p_name, p_src, p_width, p_height, p_parameters, p_flashVars ) {
	this.m_name			= p_name;
	this.m_src			= p_src;
	this.m_width		= p_width;
	this.m_height		= p_height;
	this.m_flashVars	= p_flashVars;

// constructor
	if ( p_parameters )
	{
		this.setParams( p_parameters );
	}
}

// Declare member properties
tfj_FlashObject.prototype.m_name = '';
tfj_FlashObject.prototype.m_src = '';
tfj_FlashObject.prototype.m_width = '';
tfj_FlashObject.prototype.m_height = '';
tfj_FlashObject.prototype.m_flashVars = '';

tfj_FlashObject.prototype.m_params = {
	menu:		"false",
	quality:	"high",
	allowScriptAccess:		"always",
	wmode:		"transparent"

};

tfj_FlashObject.prototype.setParam = function ( p_name, p_value ) {
	this.m_params[ p_name ] = p_value;
}

tfj_FlashObject.prototype.setParams = function ( p_paramHash ) {
	if ( typeof p_paramHash == "object" ) {
		for ( var param in p_paramHash ) {
			if ( p_paramHash[param] ) {
				this.setParam( param, p_paramHash[param] );
			}
		}
	}
}

tfj_FlashObject.prototype.getParam = function ( p_name ) {
	return ( this.m_params[ p_name ] );
}

tfj_FlashObject.prototype.getParams = function () {
	return ( this.m_params );
}

tfj_FlashObject.prototype.getFlashVarsString = function () {
	var flashVarsString = '';

	if ( typeof this.m_flashVars == "string" ) {
		flashVarsString = this.m_flashVars;
	} else if ( typeof this.m_flashVars == "object" ) {
		for ( var flashVar in this.m_flashVars ) {
			if ( flashVarsString != '' ) {
				flashVarsString += "&";
			}
			flashVarsString += flashVar + "=" + escape( this.m_flashVars[flashVar] );
		}
	}

	return ( flashVarsString );
}

tfj_FlashObject.prototype.getAttributeString = function ( p_attr, p_value ) {
	return ( p_value ? ' ' + p_attr + '="' + p_value + '"' : '' );
}

tfj_FlashObject.prototype.getParamTag = function ( p_name, p_value ) {
	return ( p_value ? '<param name="' + p_name + '" value="' + p_value + '">' : '' );
}

tfj_FlashObject.prototype.getHtml = function () {
	var htmlString = '';
	var eachParam = '';
	var flashUrl = 'http://www.macromedia.com/go/getflashplayer';

// open object
	htmlString += '<object type="application/x-shockwave-flash" \
					classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	htmlString += this.getAttributeString( 'pluginspage', flashUrl );
	htmlString += this.getAttributeString( 'id', this.m_name );
	htmlString += this.getAttributeString( 'data', this.m_src );
	htmlString += this.getAttributeString( 'width', this.m_width );
	htmlString += this.getAttributeString( 'height', this.m_height );
	htmlString += '>';
	htmlString += this.getParamTag( 'movie', this.m_src );
	for ( eachParam in this.getParams() ) {
		htmlString += this.getParamTag( eachParam, this.getParam( eachParam ) );
	}
	htmlString += this.getParamTag( 'flashVars', this.getFlashVarsString() );

// open embed
	htmlString += '<embed type="application/x-shockwave-flash"';
	htmlString += this.getAttributeString( 'pluginspage', flashUrl );
	htmlString += this.getAttributeString( 'name', this.m_name );
	htmlString += this.getAttributeString( 'src', this.m_src );
	htmlString += this.getAttributeString( 'width', this.m_width );
	htmlString += this.getAttributeString( 'height', this.m_height );
	for ( eachParam in this.getParams() ) {
		htmlString += this.getAttributeString( eachParam, this.getParam( eachParam ) );
	}
	htmlString += this.getAttributeString( 'flashVars', this.getFlashVarsString() );
	htmlString += '>';

// close embed
	htmlString += '<\/embed>';

// close object
	htmlString += '<\/object>';

	return ( htmlString );
}

tfj_FlashObject.prototype.writeHtml = function () {
	document.write( this.getHtml() );
}

tfj_FlashObject.prototype.writeMosaicHtml = function (id) {
	document.getElementById(id).innerHTML =  this.getHtml();
}


//   story comments functions
//====================================================== START

var commentsWindow = 25;
var currentPage = 1;
var tfjInitialDisplay = 3;
var nextLink = false;
var loadingComments = false;
var firstTimeNested = true;
var getThisMany = 0;

//gets next set of comments - of length: commentsWindow*currentPage
function tfj_getNextComments(){
	if(loadingComments){ return; }
	loadingComments=true;
	currentPage++;
	getThisMany = commentsWindow * currentPage;
	CSIManager.getInstance().call('http://comments.tfj.com/comments/rss/rssmessages.jspa','full=true&outputType=JSON_BOXED&forumName='+tfjForum+'&threadName='+tfjThread+'&numItems='+getThisMany,'objectid', tfj_loadNextIntoOpinionBox, false, 'tfjComments'+currentPage);
}

//handler for tfj_getNextComments
function tfj_loadNextIntoOpinionBox(obj){
    	var tfj_comment = '';
	hideableComments = '';
	var makeHidden = 'visible';
	for (var xx = 0; xx < tfjInitialDisplay; xx++){
    		var clObject = obj.rss.channel.item[xx];
		hideableComments += tfj_generateACommentDiv(clObject);
    	}
    	for (var xx = ((currentPage-1) * commentsWindow)+tfjInitialDisplay; xx < obj.rss.channel.item.length; xx++) {
		var clObject = obj.rss.channel.item[xx];
		tfj_comment += tfj_generateACommentDiv(clObject);
    	}
        if(obj.rss.channel.item.length < getThisMany || (obj.rss.channel.item.length-((currentPage-1) * commentsWindow))+tfjInitialDisplay < commentsWindow){
		document.getElementById('nextLink').style.visibility = "hidden";
		nextLink = false;
	}
	var nextLinkHtmlVisible = 'visible';
	if(!nextLink){
		nextLinkHtmlVisible='hidden';
	}

	var tfjShowExpandedLnk = $('tfjOpinionContainer').getElementsByClassName('tfjExpandCommentsLnk');
	tfjShowExpandedLnk[0].innerHTML = '<a href="javascript:void(0)" onclick="tfj_ToggleNestedStoryContent(\'tfjOpinionSubContainer\',this, \''+commentsWindow+'\',null);">Last '+tfjInitialDisplay+' comments only<\/a><span id="nextLink" style="visibility:'+nextLinkHtmlVisible+'"> | <a href="javascript:void(0)" onclick="tfj_getNextComments();">Next '+commentsWindow+' comments &raquo;</a></span>';
	loadingComments = false;
	return "<div id='allComments'>"+hideableComments+"<div id='tfjOpinionSubContainer'>"+document.getElementById("tfjOpinionSubContainer").innerHTML+tfj_comment+"</div></div>";
}

//builds a single comment element
function tfj_generateACommentDiv(clObject){
	tfj_comment = '';
        tfj_comment += '                <div class="tfjUGCBox">';
        tfj_comment += '                        <div class="tfjUGCBoxHeader"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/mosaic/base_skins/UGC/b_ugc_TL.gif" alt="" width="4" height="4" /><\/div>';
        tfj_comment += '                        <div class="tfjBoxContent">';
        tfj_comment += '                                <div class="tfjMeta">';
        tfj_comment +=                                  '<span class="tfjContributor">'+clObject['jf:author']+'<\/span><br>';
        tfj_comment += tfjRenderTimeStamp(clObject['pubDate']);
        tfj_comment += '                                <\/div>';
        tfj_comment += '                                <p>';
        tfj_comment += clObject['description'].truncate(300,' ...<a href="javascript:void(0);" onclick="tfjShowMore(this);return false">more<\/a>');
        tfj_comment += '                                <\/p>';

        tfj_comment += '                                <div class="tfjExtended" style="display:none;"><p>';
        tfj_comment += clObject['description'];
        tfj_comment += '                                <a href="javascript:void(0);" onclick="tfjShowLess(this);return false;">less<\/a><\/p><\/div>';


        tfj_comment += '                        <\/div>';
        tfj_comment += '                        <div class="clear"><img src="http://i.cdn.turner.com/tfj/images/1.gif" width="1" height="1" border="0" alt=""></div><div class="tfjUGCBoxFooter"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/mosaic/base_skins/UGC/b_ugc_BL.gif" alt="" width="4" height="4" /><\/div>';
        tfj_comment += '                <\/div>';
	return tfj_comment;
}

//empties the comments
function tfj_clearOutComments(){
	currentPage = 0;
	document.getElementById("tfjOpinionSubContainer").innerHTML='';
}

//shows/hides comments + next link appropraitely
function tfj_ToggleNestedStoryContent(el,lnk,num,desc) {
	if (tfjLockToggle) {
		return;
	}
	tfjLockToggle = true;
	var tfjLnkTxt = "Last 3 comments only";
		Effect.toggle(el,'blind',
		{
			duration:0.5,
			afterFinish: function() {
				if(!desc) {
					if (lnk.innerHTML == tfjLnkTxt) {
						lnk.innerHTML = "Next " + num + " comments &raquo;";
						nextLink = false;
						currentPage = 0;
						tfj_clearOutComments();
						document.getElementById('nextLink').style.visibility = "hidden";
					} else {
						if(!firstTimeNested){
							tfj_getNextComments();
						}
						firstTimeNested = false;
						lnk.innerHTML = tfjLnkTxt;
						nextLink = true;
						document.getElementById('nextLink').style.visibility = "visible";
					}
				}
				tfjLockToggle = false;
			},
			beforeStart: function() {
				if(desc) {
					$(lnk).style.display = "none";
				}

			}
		}

	);
}

//initial load
function tfj_loadReaderOpinion(obj) {

	if (typeof tfjFirstPub != "undefined") {
	    var tfjTimeDiff = tfjCurrTime.getTime() - tfjFirstPub.getTime();
    	var hoursDifference = Math.floor(tfjTimeDiff/1000/60/60);
		if (hoursDifference > 23) {
			tfjCommentsClosed = true;
		}
	}

if (typeof tfjExtendCommenting != "undefined" && tfjExtendCommenting) {
	tfjCommentsClosed = false;
}


if (typeof tfjCommentsClosed != "undefined" && tfjCommentsClosed) {
	if ($('tfjCommentFooter')) {
		$('tfjCommentFooter').remove();
	}
	if ($('tfjROCFrm')) {
		$('tfjROCFrm').remove();
	}
	if ($('tfjROCFrmComplete')) {
		$('tfjROCFrmComplete').innerHTML = "This story is no longer available for comments, though you may read comments that were posted previously. Browse other stories for new opportunities to comment on the latest news.";
		$('tfjROCFrmComplete').show();
	}
}

			var tfj_comment = '';


		if(!obj || !obj.rss || !obj.rss.channel || !obj.rss.channel.item) {
    	tfj_comment += '		<div class="tfjUGCBox">';
    	tfj_comment += '			<div class="tfjUGCBoxHeader"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/mosaic/base_skins/UGC/b_ugc_TL.gif" alt="" width="4" height="4" /><\/div>';
    	tfj_comment += '			<div class="tfjBoxContent">';
    	tfj_comment += '<p style="margin-left:6px;">No comments yet.<\/p>';
    	tfj_comment += '			<\/div>';
    	tfj_comment += '			<div class="clear"><img src="http://i.cdn.turner.com/tfj/images/1.gif" width="1" height="1" border="0" alt=""></div><div class="tfjUGCBoxFooter"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/mosaic/base_skins/UGC/b_ugc_BL.gif" alt="" width="4" height="4" /><\/div>';
    	tfj_comment += '		<\/div>';

			return tfj_comment;
		}


    if (typeof(obj.rss.channel.item.length) == "undefined") {
				var clObject = obj.rss.channel.item;
    	tfj_comment += '		<div id="tfjOpinionSubContainer"><div class="tfjUGCBox">';
    	tfj_comment += '			<div class="tfjUGCBoxHeader"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/mosaic/base_skins/UGC/b_ugc_TL.gif" alt="" width="4" height="4" /><\/div>';
    	tfj_comment += '			<div class="tfjBoxContent">';
    	tfj_comment += '				<div class="tfjMeta">';
    	tfj_comment += 					'<span class="tfjContributor">'+clObject['jf:author']+'<\/span><br>';
    	tfj_comment += tfjRenderTimeStamp(clObject['pubDate']);
    	tfj_comment += '				<\/div>';
    	tfj_comment += '				<p>';
    	tfj_comment += clObject['description'].truncate(300,' ...<a href="javascript:void(0);" onclick="tfjShowMore(this);return false">more<\/a>');
    	tfj_comment += '				<\/p>';

      	tfj_comment += '				<div class="tfjExtended" style="display:none;"><p>';
    	tfj_comment += clObject['description'];
    	tfj_comment += '				<a href="javascript:void(0);" onclick="tfjShowLess(this);return false;">less<\/a><\/p><\/div>';


    	tfj_comment += '			<\/div>';
    	tfj_comment += '			<div class="clear"><img src="http://i.cdn.turner.com/tfj/images/1.gif" width="1" height="1" border="0" alt=""></div><div class="tfjUGCBoxFooter"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/mosaic/base_skins/UGC/b_ugc_BL.gif" alt="" width="4" height="4" /><\/div>';
    	tfj_comment += '		<\/div><\/div>';

		return tfj_comment;

    }



		var tfjShowExpandedCont = $('tfjOpinionContainer').parentNode.getElementsByTagName('a')[0];

		var tfjShowExpandedLnk = $('tfjOpinionContainer').getElementsByClassName('tfjExpandCommentsLnk');


			var numLength = obj.rss.channel.item.length;
			var displayNum = numLength - 1;
			if (numLength > 3) {
				tfjShowExpandedLnk[0].innerHTML = '<a href="javascript:void(0)" onclick="tfj_ToggleNestedStoryContent(\'tfjOpinionSubContainer\',this, \''+numLength+'\',null);">Next '+commentsWindow+' comments &raquo;<\/a> <span id="nextLink" style="visibility:hidden"> | <a href="javascript:void(0)" onclick="tfj_getNextComments()">Next '+commentsWindow+' comments &raquo;</a></span>';
			}
		if (numLength >= 1 && (typeof(tfjReaderOpinions) != "undefined" && tfjReaderOpinions)) {
			tfjToggleUGC('tfjOpinionContainer',tfjShowExpandedCont)
		}

    for (var xx = 0; xx < numLength; xx++) {
				var clObject = obj.rss.channel.item[xx];
				if(xx == 0){
					tfj_comment+='<div id="allComments">';
				}
				if(xx == tfjInitialDisplay)
				{
					tfj_comment+='<div id="tfjOpinionSubContainer" style="display:none;">';
				}

    	tfj_comment += '		<div class="tfjUGCBox">';
    	tfj_comment += '			<div class="tfjUGCBoxHeader"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/mosaic/base_skins/UGC/b_ugc_TL.gif" alt="" width="4" height="4" /><\/div>';
    	tfj_comment += '			<div class="tfjBoxContent">';
    	tfj_comment += '				<div class="tfjMeta">';
    	tfj_comment += 					'<span class="tfjContributor">'+clObject['jf:author']+'<\/span><br>';
    	tfj_comment += tfjRenderTimeStamp(clObject['pubDate']);
    	tfj_comment += '				<\/div>';
    	tfj_comment += '				<p>';
    	tfj_comment += clObject['description'].truncate(300,' ...<a href="javascript:void(0);" onclick="tfjShowMore(this);return false">more<\/a>');
    	tfj_comment += '				<\/p>';

      	tfj_comment += '				<div class="tfjExtended" style="display:none;"><p>';
    	tfj_comment += clObject['description'];
    	tfj_comment += '				<a href="javascript:void(0);" onclick="tfjShowLess(this);return false;">less<\/a><\/p><\/div>';


    	tfj_comment += '			<\/div>';
    	tfj_comment += '			<div class="clear"><img src="http://i.cdn.turner.com/tfj/images/1.gif" width="1" height="1" border="0" alt=""></div><div class="tfjUGCBoxFooter"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/mosaic/base_skins/UGC/b_ugc_BL.gif" alt="" width="4" height="4" /><\/div>';
    	tfj_comment += '		<\/div>';

				if(xx == displayNum)
				{
					tfj_comment+='<\/div></div>';
				}
    }

	return tfj_comment;
}

//   story comments functions
//====================================================== END

/* main page market box
====================================================== */
/* called on focus */
function tfjMbChangeTxtClass( obj ) {
	if(obj.className == 'tfjTxtMBGetQuote') {
		obj.value = '';
		obj.className = 'tfjTxtMBGetQuoteType';
	}
}

/* called on blur */
function tfjMbCheckTxtClass( obj ) {
	if((obj.className == 'tfjTxtMBGetQuoteType') && (obj.value == '')) {
		obj.className = 'tfjTxtMBGetQuote';
		obj.value = 'enter symbol';
	}
}
/* end main page market box
====================================================== */


/* main page more stories [previously 'other news']
===================================================================== */
var tfjMpOnCurPage = 0;
var tfjMpOnNumPages = 5; // default number of pages - can be over-ridden in the page

function tfjMpOnBlur( lnk ) {
	try {
		lnk.blur();
	} catch(e) {};
}

function tfjMpOnJumpTo( intPage, lnk ) {
	tfjMpOnBlur(lnk);
	if(tfjMpOnCurPage != intPage) {
		var fadeOutId = 'tfjOnSects' + tfjMpOnCurPage;
		var fadeInId = 'tfjOnSects' + intPage;
		tfjMpOnTransition( fadeInId, fadeOutId );
		tfjMpOnCurPage = intPage;
		tfjMpOnUpdateBtns();
	}
}

function tfjMpOnPrev(lnk) {
	tfjMpOnBlur(lnk);
	if(tfjMpOnCurPage > 0) {
		var fadeOutId = 'tfjOnSects' + tfjMpOnCurPage;
		var fadeInId = 'tfjOnSects' + (tfjMpOnCurPage - 1);
		tfjMpOnTransition( fadeInId, fadeOutId );
		tfjMpOnCurPage--;
		tfjMpOnUpdateBtns();
	}
}

function tfjMpOnNext(lnk) {
	tfjMpOnBlur(lnk);
	if(tfjMpOnCurPage < (tfjMpOnNumPages-1)) {
		var fadeOutId = 'tfjOnSects' + tfjMpOnCurPage;
		var fadeInId = 'tfjOnSects' + (tfjMpOnCurPage + 1);
		tfjMpOnTransition( fadeInId, fadeOutId );
		tfjMpOnCurPage++;
		tfjMpOnUpdateBtns();
	}
}



function tfjMpOnTransition( fadeInId, fadeOutId ) {
	new Effect.Fade(fadeOutId,
		{ duration: 1.7
		});
	new Effect.Appear(fadeInId);
}


function tfjMpOnUpdateBtns() {
	// left btn
	if(tfjMpOnCurPage > 0) {
		$('tfjMpOnL').style.cursor ='auto';
		$('tfjMpOnL').src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_red_btn.gif';
		$('tfjMpOnL').onmouseover = function() {this.src='http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_red_over_btn.gif';}
		$('tfjMpOnL').onmouseout = function() {this.src='http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_red_btn.gif';}
	}
	else {
		$('tfjMpOnL').style.cursor ='default';
		$('tfjMpOnL').src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_gray_btn.gif';
		$('tfjMpOnL').onmouseover = function() {}
		$('tfjMpOnL').onmouseout = function() {}
	}

	// move the dot
	for(i=0;i<tfjMpOnNumPages;i++) {
		$('tfjMpOnDot'+i).src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_status.gif';
		$('tfjMpOnDot'+i).onmouseover = function() {this.src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_active_status.gif';}
		$('tfjMpOnDot'+i).onmouseout = function() {this.src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_status.gif';}
	}
	$('tfjMpOnDot'+tfjMpOnCurPage).src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_active_status.gif';
	$('tfjMpOnDot'+tfjMpOnCurPage).onmouseover = function() {}
	$('tfjMpOnDot'+tfjMpOnCurPage).onmouseout = function() {}

	// right btn
	if(tfjMpOnCurPage < (tfjMpOnNumPages-1)) {
		$('tfjMpOnR').src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_btn.gif';
		$('tfjMpOnR').onmouseover = function() {this.src='http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_over_btn.gif';}
		$('tfjMpOnR').onmouseout = function() {this.src='http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_btn.gif';}
	}
	else {
		$('tfjMpOnR').src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_gray_btn.gif';
		$('tfjMpOnR').onmouseover = function() {}
		$('tfjMpOnR').onmouseout = function() {}
	}
}

function tfjInitOtherNews() {
	// must use javascript to initially hide or scriptaculous effect won't work
	for(i=0;i<8;i++) { // setting a max possible of 8 pages here
		if($('tfjOnSects' + i)) {
			$('tfjOnSects' + i).style.display = 'none';
		}
	}
	tfjDrawOnButtons();
	$('tfjOnSects0').style.display = 'block';
	$('tfjOtherNews').style.display = 'block';
}

function tfjDrawOnButtons() {
	var str = '';
	str += '<a href="javascript:void(0);" onclick="javascript:tfjMpOnPrev(this);return false;"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_gray_btn.gif" alt="" class="tfjONBtn" border="0" height="19" width="26" id="tfjMpOnL"></a>';
	str += '<a href="javascript:void(0);" onclick="javascript:tfjMpOnJumpTo(0,this);return false;"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_active_status.gif" class="tfjONStatus" alt="" border="0" height="5" width="5" id="tfjMpOnDot0"></a>';
	for(i=1;i<tfjMpOnNumPages;i++) {
		str += '<a href="javascript:void(0);" onclick="javascript:tfjMpOnJumpTo(' + i + ',this);return false;"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_status.gif" onmouseover="this.src=\'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_active_status.gif\'" onmouseout="this.src=\'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_status.gif\'" class="tfjONStatus" alt="" border="0" height="5" width="5" id="tfjMpOnDot'+ i +'"></a>';
	}
	str += '<a href="javascript:void(0);" onclick="javascript:tfjMpOnNext(this);return false;"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_btn.gif" alt="" onmouseover="this.src=\'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_over_btn.gif\'" onmouseout="this.src=\'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_btn.gif\'" class="tfjONBtn" border="0" height="19" width="26" id="tfjMpOnR"></a>';
	$('tfjONBtns').innerHTML = str;
}
/* end main page more stories
===================================================================== */


/* international home page bullet bins
===================================================================== */

var tfjIntlMoreNewsLock = false;
var strIntlMoreBtns1 = '<img src="http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_gray_btn.gif" width="26" height="19" border="0" class="tfjIntlBtnL"><a href="javascript:tfjIntlMoreNewsGoToPage(\'2\');"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_btn.gif" width="26" height="19" border="0" class="tfjIntlBtnR" onmouseover="this.src=\'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_over_btn.gif\'" onmouseout="this.src=\'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_btn.gif\'"></a>';
var strIntlMoreBtns2 = '<a href="javascript:tfjIntlMoreNewsGoToPage(\'1\');"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_red_btn.gif" width="26" height="19" border="0" class="tfjIntlBtnL" onmouseover="this.src=\'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_red_over_btn.gif\'" onmouseout="this.src=\'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_red_btn.gif\'"></a><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_gray_btn.gif" class="tfjIntlBtnR" width="26" height="19" border="0">';

function tfjInitIntlBullets() {
	$('tfjMoreNewsTab1').style.display = "block";
	$('tfjMoreNewsTab2').style.display = "none";
	$('tfjIntlMoreNewsBtns').innerHTML = strIntlMoreBtns1;
	$('tfjIntlMoreNews').style.display = "block";
}

function tfjIntlMoreNewsGoToPage( strPage ) {
	if(!tfjIntlMoreNewsLock){
		var gotopage = eval('strIntlMoreBtns' + strPage);
		$('tfjIntlMoreNewsBtns').innerHTML = gotopage;
		switch(strPage) {
			case '1':
				fadeInId = 'tfjMoreNewsTab' + strPage;
				fadeOutId = 'tfjMoreNewsTab' + '2';
				tfjIntlMoreNewsLock = true;
				tfjMpOnTransition( fadeInId, fadeOutId );
				setTimeout("tfjIntlMoreNewsLock = false;",1700);
				break;
			case '2':
				fadeInId = 'tfjMoreNewsTab' + strPage;
				fadeOutId = 'tfjMoreNewsTab' + '1';
				tfjIntlMoreNewsLock = true;
				tfjMpOnTransition( fadeInId, fadeOutId );
				setTimeout("tfjIntlMoreNewsLock = false;",1700);
				break;
			default:
				break;
		}
	}
}

/* end international home page bullet bins
===================================================================== */


/* search functions
===================================================================== */

var tfjStrInvalidSrchMsg = 'Please enter a valid search term and try again.'+"\n"+'HTML, URLs, and Scripts are not allowed.';

function tfjSearch( frm ) {
	if($('tfjHeadSrchTxt').value != '') {
		if(!tfjVerifySearchString($('tfjHeadSrchTxt').value)) {alert(tfjStrInvalidSrchMsg);}
		else {
			var strSearchLoc = tfjGetSearchLoc();
			strSearchLoc += 'query=' + tfjLeftTrim($('tfjHeadSrchTxt').value);

			strSearchLoc += '&';
			strSearchLoc += 'type=' + $('tfjHeadSrchType').value;
			strSearchLoc += '&';
			strSearchLoc += 'sortBy=date';
			if(location.hostname.indexOf('edition') < 0) {
				strSearchLoc += '&';
				strSearchLoc += 'intl=false';
			} else {
				strSearchLoc += '&';
				strSearchLoc += 'intl=true';
			}
			location.href = strSearchLoc;
		}
	}
	return false;
}

function tfjVerifySearchString( srchTerm ) {
	var htmlRegEx = new RegExp('[\w*|\W*]*<[[\w*|\W*]*|/[\w*|\W*]]>[\w*|\W*]*');

	if(htmlRegEx.exec(srchTerm) || (srchTerm == null) || (tfjLeftTrim(srchTerm).length == 0) || (srchTerm.indexOf(">") >= 0) || (srchTerm.indexOf(";") >= 0) ){
		return false;
	}
	else return true;
}

function tfjGetSearchLoc() {
	var strSearchLoc = 'http://search.tfj.com/search.jsp?'; // default

	if(location.hostname.indexOf('qai') != -1) {
		strSearchLoc = 'http://search.qai.tfj.com/tfjrelaunch/search.jsp?'
	}
	else if(location.hostname.indexOf('beta') != -1) {
		strSearchLoc = 'http://search.tfj.com/search.jsp?'
	}

	return strSearchLoc;
}

function tfjLeftTrim(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	return sString;
}

function tfjFootSearch( frm ) {
	if($('tfjFootSrchTxt').value != '') {
		if(!tfjVerifySearchString($('tfjFootSrchTxt').value)) {alert(tfjStrInvalidSrchMsg);}
		else {

			var strSearchLoc = tfjGetSearchLoc();
			strSearchLoc += 'query=' + tfjLeftTrim($('tfjFootSrchTxt').value);
			strSearchLoc += '&';
			strSearchLoc += 'type=web';
			strSearchLoc += '&';
			strSearchLoc += 'sortBy=date';
			if(location.hostname.indexOf('edition') < 0) {
				strSearchLoc += '&';
				strSearchLoc += 'intl=false';
			} else {
				strSearchLoc += '&';
				strSearchLoc += 'intl=true';
			}
			location.href = strSearchLoc;
		}
	}
	return false;
}

function tfjUpdateSrchType( searchType ) {
	if($('tfjHeadSrchType')) {
		$('tfjHeadSrchType').value = searchType;
	}
	tfjUpdateSrchTypeLnks( searchType );
}

function tfjUpdateSrchTypeLnks( searchType ) {
	if($('tfjHeadSrchTypeArea')) {
		switch(searchType) {
			case 'web':
				$('tfjHeadSrchTypeArea').innerHTML = '<span class="tfjSearchLabel">Web</span> | <a href="javascript:tfjUpdateSrchType(\'news\');">tfj News</a> | <a href="javascript:tfjUpdateSrchType(\'video\');">tfj Videos</a>';
				break;
			case 'news':
				$('tfjHeadSrchTypeArea').innerHTML = '<a href="javascript:tfjUpdateSrchType(\'web\');">Web</a> | <span class="tfjSearchLabel">tfj News</span> | <a href="javascript:tfjUpdateSrchType(\'video\');">tfj Videos</a>';
				break;
			case 'video':
				$('tfjHeadSrchTypeArea').innerHTML = '<a href="javascript:tfjUpdateSrchType(\'web\');">Web</a> | <a href="javascript:tfjUpdateSrchType(\'news\');">tfj News</a> | <span class="tfjSearchLabel">tfj Videos</span>';
				break;
			default:
				break;
		}
	}
}

/* end search functions
===================================================================== */

/* tfj live video popup
===================================================================== */
var tfjVidServer = '';
function tfjLiveVideo( strWhich ) {
	if(!strWhich) {
		strWhich = '1';
	}
	var strVidLoc = tfjVidServer + '/video/live/live.html?stream=stream' + strWhich;
	javascript:tfj_openPopup(strVidLoc,'liveplayer','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=672,height=540')
}
/* end tfj live video popup
===================================================================== */


function tfjVideo(mode, arg, expiration) {
	video_url = '/video/#' + arg;

	if(mode == 'live') { tfjLiveVideo(arg); }
	else if(top.location == self.location) { location.href = video_url; }
	else { vid_win = window.open(video_url, 'vid_win'); }
}


/* main page video box (domestic & intl)
===================================================================== */
var tfjMpVpCurPage = 1;
var tfjMpVpLock = false;
function tfjMpVpBlur( lnk ) {
	try {
		lnk.blur();
	} catch(e) {};
}
/*
 * tfjMpVpNext() and tfjMpVpPrev()
 * are called from previous and next buttons
 */
function tfjMpVpNext( lnk ) {
	tfjMpVpBlur( lnk );
	if((tfjMpVpCurPage < 3)&&(!tfjMpVpLock)) {
		tfjMpVpSlideLeft();
	}
}

function tfjMpVpPrev( lnk ) {
	tfjMpVpBlur( lnk );
	if((tfjMpVpCurPage > 1)&&(!tfjMpVpLock)) {
		tfjMpVpSlideRight();
	}
}

/*
 * tfjMpVpPage( intPage )
 * called from clicking on gray dot icon
 */
function tfjMpVpPage( intPage, lnk ) {
	tfjMpVpBlur( lnk );
	if((tfjMpVpCurPage != intPage)&&(!tfjMpVpLock)) {
		if(tfjMpVpCurPage < intPage) {
			if((intPage - tfjMpVpCurPage) > 1) {
				tfjMpVpSlideDoubleLeft();
			}
			else {
				tfjMpVpSlideLeft();
			}
		}
		else {
			if((tfjMpVpCurPage - intPage) > 1) {
				tfjMpVpSlideDoubleRight();
			}
			else {
				tfjMpVpSlideRight();
			}
		}
	}
}

function tfjLockMpVp( intDur ) {
	var tfjLockDur = intDur * 100;
	tfjMpVpLock = true;
	setTimeout(function() { tfjMpVpLock = false; },tfjLockDur);
}
function tfjMpVpSlideLeft() {
	tfjLockMpVp(3);
	new Effect.MoveBy( 'tfjMpVidCtnt0', 0, -336 , {duration: 0.3} );
	new Effect.MoveBy( 'tfjMpVidCtnt1', 0, -336 , {duration: 0.3} );
	new Effect.MoveBy( 'tfjMpVidCtnt2', 0, -336 , {duration: 0.3} );
	tfjMpVpCurPage++;
	tfjMpVpMoveDot();
	tfjMpVpUpdateBtns();
}

function tfjMpVpSlideDoubleLeft() {
	tfjLockMpVp(6);
	new Effect.MoveBy( 'tfjMpVidCtnt0', 0, -672 , {duration: 0.6} );
	new Effect.MoveBy( 'tfjMpVidCtnt1', 0, -672 , {duration: 0.6} );
	new Effect.MoveBy( 'tfjMpVidCtnt2', 0, -672 , {duration: 0.6} );
	tfjMpVpCurPage++;
	tfjMpVpCurPage++;
	tfjMpVpMoveDot();
	tfjMpVpUpdateBtns();
}

function tfjMpVpSlideRight() {
	tfjLockMpVp(3);
	new Effect.MoveBy( 'tfjMpVidCtnt0', 0, 336 , {duration: 0.3} );
	new Effect.MoveBy( 'tfjMpVidCtnt1', 0, 336 , {duration: 0.3} );
	new Effect.MoveBy( 'tfjMpVidCtnt2', 0, 336 , {duration: 0.3} );
	tfjMpVpCurPage--;
	tfjMpVpMoveDot();
	tfjMpVpUpdateBtns();
}

function tfjMpVpSlideDoubleRight() {
	tfjLockMpVp(6);
	new Effect.MoveBy( 'tfjMpVidCtnt0', 0, 672 , {duration: 0.6} );
	new Effect.MoveBy( 'tfjMpVidCtnt1', 0, 672 , {duration: 0.6} );
	new Effect.MoveBy( 'tfjMpVidCtnt2', 0, 672 , {duration: 0.6} );
	tfjMpVpCurPage--;
	tfjMpVpCurPage--;
	tfjMpVpMoveDot();
	tfjMpVpUpdateBtns();
}

function tfjMpDotMouseOver( id ) {
	$(id).src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_active_status.gif';
}

// image change functions
function tfjMpVpMoveDot() {
	for(i=1;i<4;i++) {
		$('tfjMpVidDot'+i).src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_status.gif';
		$('tfjMpVidDot'+i).onmouseover = function() {this.src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_active_status.gif';}
		$('tfjMpVidDot'+i).onmouseout = function() {this.src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_status.gif';}
	}
	$('tfjMpVidDot'+tfjMpVpCurPage).src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/gray_active_status.gif';
	$('tfjMpVidDot'+tfjMpVpCurPage).onmouseover = function() {}
	$('tfjMpVidDot'+tfjMpVpCurPage).onmouseout = function() {}
}
function tfjMpVpUpdateBtns() {
	if(tfjMpVpCurPage > 1) {
		$('tfjMpVidBtnL').style.cursor ='auto';
		$('tfjMpVidBtnL').src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_red_btn.gif';
		$('tfjMpVidBtnL').onmouseover = function() { this.src='http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_red_over_btn.gif'; }
		$('tfjMpVidBtnL').onmouseout = function() { this.src='http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_red_btn.gif'; }
	}
	else {
		$('tfjMpVidBtnL').style.cursor ='default';
		$('tfjMpVidBtnL').src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/left_gray_btn.gif';
		$('tfjMpVidBtnL').onmouseover = function() {}
		$('tfjMpVidBtnL').onmouseout = function() {}
	}

	if(tfjMpVpCurPage < 3) {
		$('tfjMpVidBtnR').style.cursor ='auto';
		$('tfjMpVidBtnR').src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_btn.gif';
		$('tfjMpVidBtnR').onmouseover = function() {this.src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_over_btn.gif';}
		$('tfjMpVidBtnR').onmouseout = function() {this.src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_red_btn.gif';}
	}
	else {
		$('tfjMpVidBtnR').style.cursor ='default';
		$('tfjMpVidBtnR').src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/content/in_the_news/right_gray_btn.gif';
		$('tfjMpVidBtnR').onmouseover = function() {}
		$('tfjMpVidBtnR').onmouseout = function() {}
	}
}
/* end main page video box
===================================================================== */


/* intl market box
===================================================================== */
function tfjWbMarkets( intWhich ) {
	for(i=1;i<4;i++) {
		if(i==intWhich) {
			$('tfjWbMarkets' + i).style.display = 'block';
			$('tfjWbMarketsTab' + i).className = 'active';
		}
		else {
			$('tfjWbMarkets' + i).style.display = 'none';
			$('tfjWbMarketsTab' + i).className = '';
		}
	}
}
/* end intl market box
===================================================================== */



function tfjMosaicLoadGal( gal, lnk ) {
var tfj_gallery_config = (location.hostname.indexOf('edition.') > -1) ? 'intl' : 'www';
if ( new tfj_FlashDetect().detectVersion( 6 ) ) {
var tfj_Photos = new tfj_FlashObject( "tfjPhotos2", "http://i.cdn.turner.com/tfj/.element/swf/2.0/gallery/image.gallery.swf", 585, 425, null, "galleryUrl="+gal+"&configUrl=http://i.cdn.turner.com/tfj/.element/ssi/"+tfj_gallery_config+"/misc/2.0/omni/config.xml&emailHandler=onEmailClicked&pageType=mosaic&pageURL="+window.location.pathname);
tfj_Photos.writeMosaicHtml('tfjPhotoPlayer');
} else {
tfj_noFlash();
}

	// change the id
	if($('tfjCurGal')) {
		$('tfjCurGal').id = '';
	}
	lnk.parentNode.parentNode.id = 'tfjCurGal';

}

function tfjMosaicSelGalTab( intTab ) {
	// change the tabs
	for(i=1;i<7;i++) {
		if($('tfjPT'+i)) {
			tabObj = $('tfjPT'+i);
			if(i != intTab) {
				tabObj.className = '';
			}
			else {
				tabObj.className = 'tfjPTCurrent';
			}
		}
	}

	// show/hide the sections
	for(i=1;i<7;i++) {
		if($('tfjPPSect'+i)) {
			obj = $('tfjPPSect'+i);
			if(i != intTab) {
				obj.style.display = 'none';
			}
			else {
				obj.style.display = 'block';
			}
		}
	}
}

/* minor topic search */
function tfjUpdateMtSrch(obj){
	obj.value='';
	obj.style.color=(obj.style.color==""?"#000000":"")
}

/* local box main page */
function tfjUpdateTxtElem(obj, strTxt) {
	if(obj.value == strTxt) {
		obj.value='';
		obj.style.color=(obj.style.color==""?"#000":"");
	}
	else if(obj.value == '') {
		obj.value = strTxt;
		obj.style.color=(obj.style.color==""?"#ccc":"");
	}// else user entered something, leave it alone
}

/* breaking news banners
=========================================================================== */
function tfjRenderGenericBanner(object,flashURL,leftColor,rightColor)
{
	if (allCookies['tfjLastClosedBannerId'] == object.id)
	{
		// don't render anything if the banner has been closed.
		return '';
	}

	var myHtml = '<div id="tfjBannerContent"><div id="tfjBannerTopic" class="'+leftColor+'">';

	if (!(object.type == 'Live Breaking News' || object.type == 'Live Developing Story') || !(new tfj_FlashDetect().detectVersion( 8 )))
	{
		myHtml += '<div id="tfjBannerHeader"><div id="tfjBannerHeaderTxt">'+object.title+'<\/div><\/div>';
	}
	else
	{
		leftColor = 'tfjTransparent';// put transparency behind swf files
		myHtml = '<div id="tfjBannerContent"><div id="tfjBannerTopic" class="'+leftColor+'">';
		var tfj_AnimatedBanner = new tfj_FlashObject( "tfjAnimatedBannerTitle", flashURL, 211, 73, null, { bn_title: object.title } );
		myHtml += tfj_AnimatedBanner.getHtml();
	}

	myHtml += '<\/div><div id="tfjBannerBox" class="'+rightColor+'">';
	myHtml += '<div id="tfjBannerBoxContent"><a href="#" onMouseOver="tfjImgSwap(this,1);" onMouseOut="tfjImgSwap(this,0);" onClick="tfj_setCookie(\'tfjLastClosedBannerId\',\''+object.id+'\'); $(\'tfjBannerContainer\').hide(); return true;"><img class="tfjCloseBtn" name="tfjBannerCloseBtn" src="http://i.cdn.turner.com/tfj/.element/img/2.0/content/live_news/banner_'+rightColor.substring(3).toLowerCase()+'_btn.gif" width="14" height="14" alt="" /><\/a>';

	if ((object.type == 'Live Breaking News' || object.type == 'Live Developing Story' || object.type == 'Live Election Coverage') && object.image.length > 0)
	{
		myHtml += '<img class="tfjBannerPhoto" src="'+object.image+'" width="87" height="49" alt="" />';
	}
	
	myHtml += '<div id="tfjBannerHeadline"';
	if (object.size == 'small')
	{
		myHtml += ' class="small"';
	}
	myHtml += '>'+object.content;
	if((object.options) && (object.options != '') && (object.type == 'Breaking News')) {// email link
		myHtml += '<span class="tfjBnEmailLnk"><a href="http://audience.tfj.com/services/tfj/login.do?iref=BNemail&url=http%3A%2F%2Faudience.tfj.com%2Fservices%2Ftfj%2Fregwall%2Fmembercenter.do ">Get Breaking News by e-mail</a></span>';
	}
	myHtml += '<\/div>';
	if (object.pipe != 0 || object.tv != 0)
	{
		myHtml += '<div id="tfjBannerWatchNow">Watch Now: ';
		if (object.tv != 0)
		{
			myHtml += 'on tfj TV';
			if (object.pipe != 0)
			{
				myHtml += ' <span class="tfjGreyTxt">or <\/span>';
			}
		}
		if (object.pipe != 0)
		{
			myHtml += '<a href="javascript:tfjLiveVideo(\''+object.pipe+'\');">Live on tfj.com &raquo;<\/a>';
		}
		myHtml += '<\/div>';
	}

	myHtml += '<\/div><\/div><\/div><div class="tfjPad12Top" style="clear:both;"> <\/div>';

	return myHtml;
}

function tfjRenderDomesticBanner(object){
	var flashURL='http://i.cdn.turner.com/tfj/.element/swf/2.0/breaking_news/bn_dom.swf';
	var leftColor='';
	var rightColor='';
	switch (object.type) {
		case 'Live Breaking News':leftColor='tfjRed';rightColor='tfjBlack';break;
		case 'Breaking News':leftColor='tfjBlack';rightColor='tfjRed';break;
		case 'Live Developing Story':leftColor='tfjYellow';rightColor='tfjBlack';flashURL='http://i.cdn.turner.com/tfj/.element/swf/2.0/breaking_news/bn_dev.swf';break;
		case 'Developing Story':leftColor='tfjBlack';rightColor='tfjYellow';break;
		case 'Watch Now':leftColor='tfjBlue';rightColor='tfjBlue';break;
		case 'Live Election Coverage':leftColor='tfjBlackElex';rightColor='tfjDrkBlue';break;
		default:return '';
	}
	return tfjRenderGenericBanner(object,flashURL,leftColor,rightColor);
}

function tfjRenderInternationalBanner(object){
	var flashURL='http://i.cdn.turner.com/tfj/.element/swf/2.0/breaking_news/bn_int.swf';
	var leftColor='';
	var rightColor='tfjYellow';
	switch (object.type) {
		case 'Live Breaking News':leftColor='tfjYellow';rightColor='tfjBlack';break;
		case 'Breaking News':leftColor='tfjBlack';break;
		case 'Live Developing Story':leftColor='tfjYellow';rightColor='tfjBlack';flashURL='http://i.cdn.turner.com/tfj/.element/swf/2.0/breaking_news/bn_dev.swf';break;
		case 'Developing Story':leftColor='tfjBlack';break;
		case 'Watch Now':leftColor='tfjBlue';rightColor='tfjBlue';break;
		default:return '';
	}
	return tfjRenderGenericBanner(object,flashURL,leftColor,rightColor);
}

/* end breaking news banners
=========================================================================== */


/* global event handlers
=========================================================================== */
function tfjMouseDown(e) {
	if (tfjDropdownOpen) tfjDD.mouseDownBody(e);
	if (tfjOverlayMenuOpen) tfjOverlayMouseDownBody(e);
	return true;
}
/* end global event handlers
=========================================================================== */


/* styled overlay menus
=========================================================================== */
var tfjOverlayOpenId = "";
var tfjOverlayClickedId = "";
var tfjOverlayMenuOpen = false;

// Map menu id's to button classes, for determining later on if the current menu
// is one with non-default behavior.
var tfjOverlayClass = [];


function tfjInitOverlay() {
	document.body.onmousedown = tfjMouseDown;

	// Overlay menus with default behavior
	tfjAddOverlayEvents("tfjOverlayLnk");

	// Add code here for overlay menus with non-default behavior
}


function tfjShowOverlay(menuId) {
	if ($(menuId)) {
		// If the menu is already open, close it
		if ($(menuId).style.display == "block") {
			$(menuId).style.display = "none";
		}
		else {
			$(menuId).style.display = "block";
			tfjOverlayOpenId = menuId;
		    tfjOverlayMenuOpen = true;
			tfjOverlayClickedId = "";
		}
	}

	// Add code here for overlay menus with non-default behavior
}


function tfjHideOverlay(menuId) {
	if ($(menuId)) {
		$(menuId).style.display = "none";
		tfjOverlayOpenId = '';
	    tfjOverlayMenuOpen = false;
	}

	// Add code here for overlay menus with non-default behavior
}


function tfjGetOverlayMenuId(btn) {
	// Get the id parameter from href="javascript:foo('myId')"
	return btn.href.substring(btn.href.indexOf("'") + 1, btn.href.lastIndexOf("'"));
}


function tfjAddOverlayEvents(btnClass) {
	var btnArray = document.getElementsByClassName(btnClass);
	for (var i = 0; i < btnArray.length; i++) {
		// button
		var btn = btnArray[i];
		btn.onmousedown = tfjOverlayMouseDownBtn;

		// menu
		var menuId = tfjGetOverlayMenuId(btn);
		if ($(menuId)) {
			$(menuId).onmousedown = tfjOverlayMouseDownMenu;
		}

		// Store the button class associated with the menu id
	    tfjOverlayClass[menuId] = btnClass;

		// Mac Safari image-rollover bug
		if ((navigator.userAgent.indexOf("Safari") != -1)
		 && (navigator.userAgent.indexOf("Mac") != -1)) {
			// If tfjImgSwap() is called by the onmouseout event
			if (btn.onmouseout && btn.onmouseout.toString().indexOf("tfjImgSwap") != -1) {
				// Make onclick call the onmouseout event handler
				btn.onclick = function onclick() { this.onmouseout(); return true; };
			}
		}
	}
}


function tfjOverlayMouseDownBtn(e) {
	// Get the menu id
	var menuId = tfjGetOverlayMenuId(this);
	tfjOverlayClickedId = menuId;
	return true;
}


function tfjOverlayMouseDownMenu(e) {
	// Get the menu id
	tfjOverlayClickedId = this.id;
	return true;
}


function tfjOverlayMouseDownBody(e) {
	// Close the open overlay menu, unless the mouse is inside the menu
	// or the menu button.
	if (tfjOverlayOpenId != tfjOverlayClickedId) {
		tfjHideOverlay(tfjOverlayOpenId);
	}
	tfjOverlayClickedId = "";
	return true;
}
/* end styled overlay menus
=========================================================================== */


/* styled dropdowns
=========================================================================== */
var tfjDropdownOpen = false;

// tfj dropdown menu (JavaScript object literal)
var tfjDD = {
	curId: "", // id of currently-open dropdown
	ignoreMouseDownBody: false,
	menus: [],

	rowHeight: 17,
	combinedBorderWidth: 20,
	scrollbarWidth: 18,

	minMenuWidth: 105,
	maxMenuWidth: 400,
	defaultMenuWidth: 205,
	defaultRowWidth: 150,
	combinedRowLRPad: 18,
	scrollbarRPad: 12,


	buildDisabledDropdown: function(menuId, buttonWidth, buttonClass, hiddenListSuffix) {
		// default parameters
		if (!buttonWidth) buttonWidth = 140;
		if (!buttonClass) buttonClass = 'tfjDDWireLtg';

		var wrapId = menuId + "_wrap";
		var listId = menuId + "_list" + (hiddenListSuffix ? '_' + hiddenListSuffix : '');

		if ($(wrapId) && $(listId)) {

			// hide the <select>
			$(listId).style.display = "none";

			// Get the displayed value for the first select option
			var listItems = $(listId).options;
			var buttonText = listItems[0].innerHTML;

			var buttonTextLPad = 10;
			var buttonTextRPad = 34;
			var buttonTextWidth = buttonWidth - (buttonTextLPad + buttonTextRPad);

			var leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_ltg_left.gif) 0 0 no-repeat;';
			var rightBgStyle = 'background:url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_ltg_right.gif) 100% 0 no-repeat;';

			switch (buttonClass) {
				case 'tfjDDWire':
					leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_wire_left.gif) 0 0 no-repeat;';
					rightBgStyle = 'background:url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_wire_right.gif) 100% 0 no-repeat;';
					break;
				case 'tfjBlkBgWhtBox':
					leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_blk_left.gif) 0 0 no-repeat;';
					rightBgStyle = 'background:url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_blk_right.gif) 100% 0 no-repeat;';
					break;
			}


			// build content for the button
			var strContent = "\n\n\n\n";
			strContent += '	<div class="tfjDDContainer" style="width:'+buttonWidth+'px;">'+"\n";

			strContent += '		<div class="'+buttonClass+'">'+"\n";
			strContent += '			<div class="tfjDDBtn" onmousedown="return tfjDD.mouseDownBtn(event, \''+menuId+'\');" onclick="return tfjDD.open(\''+menuId+'\')" style="'+rightBgStyle+'">'+"\n";
			strContent += '				<table width="'+buttonWidth+'" border="0" cellspacing="0" cellpadding="0">'+"\n";
			strContent += '					<tr>'+"\n";
			strContent += '						<td width="'+buttonTextLPad+'"><div class="tfjDDBtnLeft" style="'+leftBgStyle+'"></div></td>'+"\n";
			strContent += '						<td width="'+buttonTextWidth+'">'+"\n";
			strContent += '							<div class="tfjDDValueContainer">'+"\n";
			strContent += '								<div id="'+menuId+'_Val" class="tfjDDValue" style="width:'+buttonTextWidth+'px;color:#c5c5c5;">'+buttonText+'</div>'+"\n";
			strContent += '						</td>'+"\n";
			strContent += '						<td width="'+buttonTextRPad+'"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_icon_disabled.gif" alt="" border="0"></td>'+"\n";
			strContent += '					</tr>'+"\n";
			strContent += '				</table>'+"\n";
			strContent += '			</div><!--/tfjDDBtn -->'+"\n\n";
			strContent += '		</div><!--/'+buttonClass+' -->'+"\n\n";

			strContent += '	</div><!--/tfjDDContainer -->'+"\n";
			strContent += "\n\n";

			// draw the new content
			$(wrapId).innerHTML = strContent;

			// reset the list
			$(listId).selectedIndex = 0;

		}//else id of select not found [ abort ]
	},

	buildDropdown: function(menuId, buttonWidth, menuWidth, numVisibleRows, buttonClass, hiddenListSuffix) {
		// default parameters
		if (!buttonWidth) buttonWidth = 140;
		if (!menuWidth) menuWidth = this.defaultMenuWidth;
		if (!numVisibleRows) numVisibleRows = 10;
		if (!buttonClass) buttonClass = 'tfjDDWireLtg';

		if (menuWidth < this.minMenuWidth) menuWidth = this.minMenuWidth;
		if (menuWidth > this.maxMenuWidth) menuWidth = this.maxMenuWidth;

		var wrapId = menuId + "_wrap";
		var listId = menuId + "_list" + (hiddenListSuffix ? '_' + hiddenListSuffix : '');

		this.menus[menuId] = new Array();
		this.menus[menuId].listId = listId;
		this.menus[menuId].updateFirstRow = false;

		if ($(wrapId) && $(listId)) {
			// hide the <select>
			$(listId).style.display = "none";

			var displayedValue = new Array();
			var internalValue = new Array();
			var disabledRow = new Array();

			var listItems = $(listId).options;
			for (var i=0;i<listItems.length;i++) {
				displayedValue[i] = listItems[i].innerHTML;
				internalValue[i] = listItems[i].value;
				disabledRow[i] = listItems[i].disabled;
			}
			var selectedRow = $(listId).selectedIndex;

			// If no row was explicitly selected
			if (selectedRow == 0) {
				// See if the first row matches one of the later rows
				for (i=1;i<displayedValue.length;i++) {
					if (displayedValue[i] == displayedValue[0]) {
						selectedRow = i;
						this.menus[menuId].updateFirstRow = true;
						break;
					}
				}
			}
			var buttonText = displayedValue[selectedRow];
			var numRows = displayedValue.length;

			var buttonTextLPad = 10;
			var buttonTextRPad = 34;
			var buttonTextWidth = buttonWidth - (buttonTextLPad + buttonTextRPad);

			// minus left and right borders
			var fullRowWidth = menuWidth - this.combinedBorderWidth;

			// without scrollbar
			var visibleRowsHeight = numRows * this.rowHeight;
			var rowWidth = fullRowWidth;

			// with scrollbar
			if (numRows > numVisibleRows) {
				visibleRowsHeight = numVisibleRows * this.rowHeight;
				rowWidth -= 10;
			}

			var leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_ltg_left.gif) 0 0 no-repeat;';
			var rightBgStyle = 'background:url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_ltg_right.gif) 100% 0 no-repeat;';

			switch (buttonClass) {
				case 'tfjDDWire':
					leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_wire_left.gif) 0 0 no-repeat;';
					rightBgStyle = 'background:url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_wire_right.gif) 100% 0 no-repeat;';
					break;
				case 'tfjBlkBgWhtBox':
					leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_blk_left.gif) 0 0 no-repeat;';
					rightBgStyle = 'background:url(http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_blk_right.gif) 100% 0 no-repeat;';
					break;
			}


			// build content for the menu
			var strContent = "\n\n\n\n";
			strContent += '	<div class="tfjDDContainer" style="width:'+buttonWidth+'px;">'+"\n";

			strContent += '		<div class="tfjDDBoxContainer">'+"\n";
			strContent += '		<div class="tfjDDBox" id="'+menuId+'" style="width:'+menuWidth+'px;" onmousedown="return tfjDD.mouseDown(event, \''+menuId+'\');">'+"\n";
			strContent += '			<div class="tfjDDBoxHeader"><div class="tfjDDBoxHeaderTL"></div><div class="tfjDDBoxHeaderTR"></div></div>'+"\n";
			strContent += '			<div class="tfjDDBoxContent">'+"\n";

			strContent += '				<div class="tfjDDContent" style="width:'+fullRowWidth+'px;">'+"\n";
			strContent += '					<div class="tfjPad6Top"></div>'+"\n";
			strContent += '					<div class="tfjDDList" style="height:'+visibleRowsHeight+'px; width:'+rowWidth+'px;">'+"\n";
			strContent += '						<ul>'+"\n";

			for (var i=0;i<displayedValue.length;i++) {
				if ((i==0) && (this.menus[menuId].updateFirstRow)) {
					strContent += '						<li id="'+menuId+'_hdnVal"><a href="javascript:tfjDD.select('+i+',\''+this.encodeAttr(displayedValue[i])+'\',\''+this.encodeAttr(internalValue[i])+'\');">'+displayedValue[i]+'</a></li>'+"\n";
				}
				else if (disabledRow[i]) {
					strContent += '						<li class="tfjDDSeparator"><span>'+displayedValue[i]+'</span></li>'+"\n";
				}
				else {
					strContent += '						<li><a href="javascript:tfjDD.select('+i+',\''+this.encodeAttr(displayedValue[i])+'\',\''+this.encodeAttr(internalValue[i])+'\');">'+displayedValue[i]+'</a></li>'+"\n";
				}
			}
			strContent += '						</ul>'+"\n";
			strContent += '					</div>'+"\n";
			strContent += '					<div class="tfjPad8Top"></div>'+"\n";
			strContent += '				</div><!-- /tfjDDContent -->'+"\n";

			strContent += '			</div><!-- /tfjDDBoxContent -->'+"\n";
			strContent += '			<div class="tfjDDBoxFooter"><div class="tfjDDBoxFooterBL"></div><div class="tfjDDBoxFooterBR"></div></div>'+"\n";
			strContent += '		</div><!--/tfjDDBox-->'+"\n";
			strContent += '		</div><!--/tfjDDBoxContainer-->'+"\n";

			strContent += '		<div class="'+buttonClass+'">'+"\n";
			strContent += '			<div class="tfjDDBtn" onmousedown="return tfjDD.mouseDownBtn(event, \''+menuId+'\');" onclick="return tfjDD.open(\''+menuId+'\')" style="'+rightBgStyle+'">'+"\n";
			strContent += '				<table width="'+buttonWidth+'" border="0" cellspacing="0" cellpadding="0">'+"\n";
			strContent += '					<tr>'+"\n";
			strContent += '						<td width="'+buttonTextLPad+'"><div class="tfjDDBtnLeft" style="'+leftBgStyle+'"></div></td>'+"\n";
			strContent += '						<td width="'+buttonTextWidth+'">'+"\n";
			strContent += '							<div class="tfjDDValueContainer">'+"\n";
			strContent += '								<div id="'+menuId+'_Val" class="tfjDDValue" style="width:'+buttonTextWidth+'px;">'+buttonText+'</div>'+"\n";
			strContent += '						</td>'+"\n";
			strContent += '						<td width="'+buttonTextRPad+'"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/global/dropdowns/btn_icon.gif" alt="" border="0"></td>'+"\n";
			strContent += '					</tr>'+"\n";
			strContent += '				</table>'+"\n";
			strContent += '			</div><!--/tfjDDBtn -->'+"\n\n";
			strContent += '		</div><!--/'+buttonClass+' -->'+"\n\n";

			strContent += '	</div><!--/tfjDDContainer -->'+"\n";
			strContent += "\n\n";

			// draw the new content
			$(wrapId).innerHTML = strContent;

			// capture mousedown
			document.body.onmousedown = tfjMouseDown;
		}//else id of select not found [ abort ]
	},

	buildOverlay: function(menuId, menuWidth, numVisibleRows, dx, dy) {
		// default parameters
		if (!menuWidth) menuWidth = this.defaultMenuWidth;
		if (!numVisibleRows) numVisibleRows = 10;

		if (menuWidth < this.minMenuWidth) menuWidth = this.minMenuWidth;
		if (menuWidth > this.maxMenuWidth) menuWidth = this.maxMenuWidth;

		var leftPos = -20;
		var topPos = 1;
		if (dx) leftPos += dx;
		if (dy) topPos += dy;

		var wrapId = menuId + "_wrap";
		var listId = menuId + "_list";
		var titleId = menuId + "_title";

		if ($(wrapId) && $(titleId) && $(listId)) {
			// hide the list
			$(listId).style.display = "none";

			var title = $(titleId).innerHTML;

			// Get the displayed value for each select option
			var listItems = $(listId).getElementsByTagName('li');
			var displayedList = new Array();
			for (var i=0;i<listItems.length;i++) {
				displayedList[i] = listItems[i].innerHTML;
			}

			var numRows = displayedList.length;

			var menuTitleRPad = 60;
			var menuTitleWidth = menuWidth - menuTitleRPad;

			// minus left and right borders
			var fullRowWidth = menuWidth - this.combinedBorderWidth;

			// without scrollbar
			var visibleRowsHeight = numRows * this.rowHeight;
			var rowWidth = menuWidth - this.combinedBorderWidth;

			// with scrollbar
			if (numRows > numVisibleRows) {
				visibleRowsHeight = numVisibleRows * this.rowHeight;
				rowWidth -= 10;
			}


			// build content for the menu
			var strContent = "\n\n\n\n";
			strContent += ' <div class="tfjDDOvrBoxContainer">'+"\n";
			strContent += '		<div class="clear"><img src="http://i.cdn.turner.com/tfj/images/1.gif" width="1" height="1" border="0" alt=""></div>'+"\n";
			strContent += '		<div class="tfjDDOvrBox" id="'+menuId+'" style="width:'+menuWidth+'px;left:'+leftPos+'px; top:'+topPos+'px;" onmousedown="return tfjDD.mouseDown(event, \''+menuId+'\');">'+"\n";
			strContent += '			<div class="tfjDDBoxHeader"><div class="tfjDDBoxHeaderTL"></div><div class="tfjDDBoxHeaderTR"></div></div>'+"\n";
			strContent += '			<div class="tfjDDBoxContent">'+"\n";
			strContent += '				<div class="tfjDDOvrCloseContainer"><div class="tfjDDOvrClose" onclick="tfjDD.close(); return true;"><img src="http://i.tfj.net/tfj/.element/img/2.0/global/dropdowns/overlay_close.png" width="12" height="12" alt="" border="0"></div></div>'+"\n";
			strContent += '				<div class="tfjDDContent" style="width:'+fullRowWidth+'px;">'+"\n";
			strContent += '					<div class="tfjDDOvrTitle" style="width:'+menuTitleWidth+'px;overflow:hidden;">'+title+'</div>'+"\n";
			strContent += '					<div class="tfjDDList" style="height:'+visibleRowsHeight+'px;width:'+rowWidth+'px;">'+"\n";
			strContent += '						<ul>'+"\n";

			for (var i=0;i<displayedList.length;i++) {
				strContent += '					<li>'+displayedList[i]+'</li>'+"\n";
			}
			strContent += '						</ul>'+"\n";
			strContent += '					</div><!-- /tfjDDList -->'+"\n";
			strContent += '					<div class="tfjPad12Top"></div>'+"\n";
			strContent += '				</div><!-- /tfjDDContent -->'+"\n";
			strContent += '			</div><!-- /tfjDDBoxContent -->'+"\n";
			strContent += '			<div class="tfjDDBoxFooter"><div class="tfjDDBoxFooterBL"></div><div class="tfjDDBoxFooterBR"></div></div>'+"\n";
			strContent += '		</div><!--/tfjDDOvrBox-->'+"\n";
			strContent += ' </div><!--/tfjDDOvrBoxContainer-->'+"\n";
			strContent += "\n\n";
			// draw the new content
			$(wrapId).innerHTML = strContent;

			// capture mousedown
			document.body.onmousedown = tfjMouseDown;

		}//else id of select not found [ abort ]
	},


	select: function(index, displayedValue, internalValue) {
		if ($(this.curId)) {
			var menuId = this.curId;

			// close the dropdown
			this.close();

			// change the displayed dropdown value (button text)
			if ($(menuId + '_Val')) {
				$(menuId + '_Val').innerHTML = displayedValue;
			}

			// set the first row of the menu to the current value
			if ((this.menus[menuId].updateFirstRow) && $(menuId + '_hdnVal')) {
				$(menuId+'_hdnVal').innerHTML = '<a href="javascript:tfjDD.select(' + index + ',\'' + this.encodeAttr(displayedValue) + '\',\'' + this.encodeAttr(internalValue) + '\')">' + displayedValue + '</a>';
			}

			var listId = this.menus[menuId].listId;
			if ($(listId)) {
				// if the value has changed
				if ($(listId).selectedIndex != index) {
					// set the index of the selected option for the invisible <select>
					$(listId).selectedIndex = index;

					// If an onchange event handler exists
					if ($(listId).onchange) {
						$(listId).onchange();
					}
				}
			}

			// if a callback function exists
			try {
				var onChoose = eval(menuId + '_OnChoose');
				if (onChoose) {
					onChoose();
				}
			}
			catch(err) {
			}
		}
	},

	open: function(id) {
		if($(id)) {
			// Was the same menu clicked again?
			var sameMenu = (this.curId == id);

			// If a menu is already open
			this.close();

			// If a different menu was clicked
			if (!sameMenu) {
				$(id).style.display = "block";
				this.curId = id;
				tfjDropdownOpen = true;
			}
		}
	},

	close: function() {
		if ($(this.curId)) {
			$(this.curId).style.display = "none";
			this.curId = '';
			tfjDropdownOpen = false;
		}
	},

	encodeAttr: function(str) {
		str=str.replace(/\\/g,'\\\\');
		str=str.replace(/\'/g,'\\\'');
		str=str.replace(/\"/g,'&quot;');
		str=str.replace(/\0/g,'\\0');
		return str;
	},

	mouseDown: function(e, id) {
		this.ignoreMouseDownBody = true;
		return true;
	},

	mouseDownBtn: function(e, id) {
		// True if the same dropdown button was clicked again.
		this.ignoreMouseDownBody = (id && (this.curId == id));
		return true;
	},

	mouseDownBody: function(e) {
		if (!this.ignoreMouseDownBody) {
			this.close();
		}
		this.ignoreMouseDownBody = false;
		return true;
	}
}
/* end styled dropdowns
=========================================================================== */


/* most popular module
========================================================================= */
var tfjMpActiveId = 'tfjMpStory';
var tfjMpLock = false;
var tfjie = false;
function tfjToggleMP(idShow) {

	if (tfjMpActiveId && tfjMpActiveId != idShow) {

		if(!tfjMpLock) {
			tfjMpLock = true;

			if(tfjie) {
				tfjToggleMPIE(idShow);
			}
			else {
				// hide the old
				var elHide = $(tfjMpActiveId);

				Effect.toggle(elHide,'blind',
				{
					duration:0.25,
					beforeStart:function()
					{
						var tfjHideHead = idShow + '-head';
						$(tfjHideHead).className="active";
					}
				}

				);

				// display the new
				var elShow = $(idShow);

				Effect.toggle(elShow,'blind',
				{
					duration:0.25,
					beforeStart:function(obj)
					{
						var tfjShowHead = tfjMpActiveId + '-head';
						$(tfjShowHead).className = "closed";
					},

					afterFinish:function(obj)
					{
						tfjMpActiveId = idShow;
					}
				}
				);
			}// end if tfjie

			// delay the unlock
			setTimeout("tfjMpLock = false;",250);

		}// end if !tfjMpLock

	}// end same id
}

function tfjToggleMPIE(idShow) {

	var elHide = $(tfjMpActiveId);
	var elShow = $(idShow);

	// hide the red header
	var tfjHideHead = idShow + '-head';
	$(tfjHideHead).className="active";

	new Effect.Parallel(
	[
		new Effect.SlideUp(elHide),
		new Effect.SlideDown(elShow)
	], {
		duration: 0.04
	});

	// show the previously active red header
	var tfjShowHead = tfjMpActiveId + '-head';
	$(tfjShowHead).className = "closed";

	// reset the active id
	tfjMpActiveId = idShow;

}

function tfjToggleMPNoSlide(idShow) {

	if (tfjMpActiveId && tfjMpActiveId != idShow) {

		var elHide = $(tfjMpActiveId);
		var tfjHideHead = idShow + '-head';
		$(tfjHideHead).className="active";
		elHide.style.display='none';

		var elShow = $(idShow);
		var tfjShowHead = tfjMpActiveId + '-head';
		$(tfjShowHead).className = "closed";
		elShow.style.display='block';

		tfjMpActiveId = idShow;

	}

}

/* most popular module tab functions */
function tfjMpStories( intWhich ) {
	for(i=1;i<4;i++) {
		if(i==intWhich) {
			$('tfjMpStories' + i).style.display = 'block';
			$('tfjMpStoriesTab' + i).className = 'active';
		}
		else {
			$('tfjMpStories' + i).style.display = 'none';
			$('tfjMpStoriesTab' + i).className = '';
		}
	}
	$('tfjMpStoriesTab'+ intWhich).blur();
}

function tfjMpVideos( intWhich ) {
	for(i=1;i<4;i++) {
		if(i==intWhich) {
			$('tfjMpVideos' + i).style.display = 'block';
			$('tfjMpVideosTab' + i).className = 'active';
		}
		else {
			$('tfjMpVideos' + i).style.display = 'none';
			$('tfjMpVideosTab' + i).className = '';
		}
	}
	$('tfjMpVideosTab'+ intWhich).blur();
}

/* most popular module init function */
function tfjInitMP() {
	$('tfjMpTopic').style.display = 'none';
	$('tfjMpVideo').style.display = 'none';
	$('tfjMostPopMod').style.display = 'block';
}

/* end most popular module
========================================================================= */

/* tfj affiliates (us section)
========================================================================= */
// Preload the button images
var tfjAffiliates_GoImage = new Array;
tfjAffiliates_GoImage["off"] = new Image();
tfjAffiliates_GoImage["off"].src = "http://i.cdn.turner.com/tfj/.element/img/2.0/sect/us/affiliates/go_btn_disabled.gif";
tfjAffiliates_GoImage["on"] = new Image();
tfjAffiliates_GoImage["on"].src = "http://i.cdn.turner.com/tfj/.element/img/2.0/sect/us/affiliates/go_btn.gif";

function tfjAffiliates_SetGoBtn(url) {
	var goButtonId = 'tfjAffiliatesGoBtn';
	if ($(goButtonId)) {
		if (url) {
			$(goButtonId).innerHTML = '<a id="tfjAffiliatesGoLink" href="javascript:void(window.open(\''+url+'\'))"><img src="'+tfjAffiliates_GoImage["on"].src+'" width="29" height="23" border="0" alt=""></a>';
		}
		else {
			$(goButtonId).innerHTML = '<img src="'+tfjAffiliates_GoImage["off"].src+'" width="29" height="23" border="0" alt="">';
		}
	}
}

function tfjAffiliates_SelectRegion(selectObj) {
	var region = selectObj.value.toLowerCase();
		if (region) {
		var mapId = 'tfjAffiliatesMap';
		if ($(mapId)) {
			$(mapId).src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/sect/us/affiliates/affiliates_' + region + '.gif';
		}
		// reset the list
		var affiliatesId = 'tfjDDAffiliatesCity_list_' + region;
		if ($(affiliatesId)) {
			$(affiliatesId).selectedIndex = 0;
		}
		tfjDD.buildDropdown('tfjDDAffiliatesCity', 252, 270, 10, 'tfjDDWire', region);
		tfjAffiliates_SetGoBtn();
	}
	// no region selected
	else {
		var mapId = 'tfjAffiliatesMap';
		if ($(mapId)) {
			$(mapId).src = 'http://i.cdn.turner.com/tfj/.element/img/2.0/sect/us/affiliates/affiliates_default.gif';
		}
		tfjDD.buildDisabledDropdown('tfjDDAffiliatesCity', 252, 'tfjDDWire', 'northeast');
		tfjAffiliates_SetGoBtn();
	}
}

function tfjAffiliates_SelectCity(selectObj) {
	var url = selectObj.value;
	tfjAffiliates_SetGoBtn(url);
}

/* end tfj affiliates (us section)
========================================================================= */

/* cnet product reviews widget
=========================================================================== */
function tfjSearchCnet() {
	switch(document.tsearch.nodeid.value) {
		case "more":
		window.open("http://tfj-cnet.com.com/2001-1_7-0.html?part=tfj-cnet&subj=re&tag=search");
		break;
		case "6500":
		window.open("http://tfj-cnet.com.com/4323-6530_7-6509025.html?part=tfj-cnet&subj=re&tag=search");
		break;
		case "6501":
		window.open("http://tfj-cnet.com.com/4323-6530_7-6509037.html?part=tfj-cnet&subj=re&tag=search");
		break;
		case "3504":
		window.open("http://tfj-cnet.com.com/4323-6525_7-6509098.html?part=tfj-cnet&subj=re&tag=search");
		break;
		case "3000":
		window.open("http://tfj-cnet.com.com/4323-6526_7-6509032.html?part=tfj-cnet&subj=re&tag=search");
		break;
		case "3127":
		window.open("http://tfj-cnet.com.com/4323-6522_7-6509058.html?part=tfj-cnet&subj=re&tag=search");
		break;
		case "6463":
		window.open("http://tfj-cnet.com.com/4323-6531_7-6509125.html?part=tfj-cnet&subj=re&tag=search");
		break;
		case "6450":
		window.open("http://tfj-cnet.com.com/4323-6532_7-6509081.html?part=tfj-cnet&subj=re&tag=search");
		break;
		case "3132":
		window.open("http://tfj-cnet.com.com/4323-6528_7-6509067.html?part=tfj-cnet&subj=re&tag=search");
		break;
		case "3243":
		window.open("http://tfj-cnet.com.com/4323-6523_7-6509031.html?part=tfj-cnet&subj=re&tag=search");
		break;
	}
	return false;
}
/* end cnet product reviews widget
=========================================================================== */

/* partner box output
=========================================================================== */
function tfjPartnerRand_Asort(){ return (Math.round(Math.random())-0.5); }

function tfjPrintPartnerOutput() {
	var tfjPartner_Data = new Array();
	// name, logo, feed location, subscribe link, logo link
	tfjPartner_Data[0] = new Array("Time.com","http://i.cdn.turner.com/tfj/.element/img/2.0/content/partners/time_partner.gif","/.element/ssi/auto/2.0/sect/MAIN/ftpartners/partner.time.html", "/linkto/time.main.html", "/time/?tfj=yes");
	tfjPartner_Data[1] = new Array("EW.com","http://i.cdn.turner.com/tfj/.element/img/2.0/content/partners/entertainment_partner.gif","/.element/ssi/auto/2.0/sect/MAIN/ftpartners/partner.ew.html", "http://subs.timeinc.net/CampaignHandler/ewlinks?source_id=29", "/ew/?tfj=yes");
	tfjPartner_Data[2] = new Array("People.com","http://i.cdn.turner.com/tfj/.element/img/2.0/content/partners/partner_people.gif","/.element/ssi/auto/2.0/sect/MAIN/ftpartners/partner.people.html", "https://subs.timeinc.net/PE/pe_cntl0407.jhtml?experience_id=164491&source_id=5&_requestid=84312", "http://www.people.com/people");
	tfjPartner_Data[3] = new Array("tfjMoney.com","http://i.cdn.turner.com/tfj/.element/img/2.0/content/partners/money_partner.gif","/.element/ssi/auto/2.0/sect/MAIN/ftpartners/partner.money.txt", "http://money.tfj.com/services/bridge/contact.us.html", "/money/index.html?tfj=yes");
	tfjPartner_Data[4] = new Array("tfjSI.com","http://i.cdn.turner.com/tfj/.element/img/2.0/content/partners/si_partner.gif","/.element/ssi/auto/2.0/sect/MAIN/ftpartners/partner.si.txt", "https://subs.timeinc.net/CampaignHandler/si_tfjsi?source_id=19", "/si/?tfj=yes");

	tfjPartner_Data.sort(tfjPartnerRand_Asort);

	for(var i = 0;i < 2;i++) {

		var	temp_partner_html = '<div class="tfjWireBox"><div class="tfjBoxHeader"><div></div></div><div class="tfjBoxContent"><div class="tfjPad8TB12LR"><div class="tfjPartnerTop">';
		if(tfjPartner_Data[i][3] != "") {
			temp_partner_html += '<div class="tfjPartnerSubscribe"><a href="' + tfjPartner_Data[i][3] + '" onmouseover="tfjImgSwap(this,1)" onmouseout="tfjImgSwap(this,0)"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/content/partners/btn_subscribe.gif" width="61" height="17" border="0"></a></div>';
		}
		temp_partner_html += '<div>';
		if(tfjPartner_Data[i][4] != "") {
			temp_partner_html += '<a href="' + tfjPartner_Data[i][4] + '">';
		}
		temp_partner_html += '<img src="' + tfjPartner_Data[i][1] + '" class="tfjPartLogo" border="0" alt="">';
		if(tfjPartner_Data[i][4] != "") {
			temp_partner_html += '</a>';
		}
		temp_partner_html += '</div><div class="clear"></div></div><div id="tfjPartnerInclude_' + i + '">Loading...</div></div></div><div class="tfjBoxFooter"><div></div></div></div>';

		Element.update('randPartner_' + i, temp_partner_html);
		new Ajax.Updater('tfjPartnerInclude_' + i, tfjPartner_Data[i][2], {asynchronous:true, method:'get'});

	}
}

function tfjMpPartnerRotate() {
	var intRandom = Math.floor(Math.random()*2);
	switch(intRandom) {
		case 0:
			$('tfjMpPartnerEW').style.display = "block";
			break;
		case 1:
			$('tfjMpPartnerPeople').style.display = "block";
			break;
		default:
			break;
	}
}
/* end partner box output
=========================================================================== */

/* main page most popular overlay
=========================================================================== */
function tfjShowMoPo() {
	$('tfjOpacity').style.display = "block";
	$('tfjMoPo').style.display = "block";
}

function tfjHideMoPo() {
	$('tfjMoPo').style.display = "none";
	new Effect.Opacity('tfjOpacity', {duration:0.1, from:0.5, to:0.0});

	// reset opacity
	setTimeout("$('tfjOpacity').style.display = \"none\";new Effect.Opacity('tfjOpacity', {duration:0.1, from:0.0, to:0.8});",500)
}

/* partner box omniture tracking
=========================================================================== */
var tfjPSproducts="";
var tfjProducts = new Array();
/* end partner box output
=========================================================================== */

/* set edition js
========================================================================= */
var tfjDomestic_Host = 'www.tfj.com';
var tfjIntl_Host = 'edition.tfj.com';
var tfjUserEd_Pref = allCookies['SelectedEdition'];
var tfjShow_setPref = false;
var tfjUEPHost_Val = location.hostname;
var tfjOn_Dom_Flag;

if(location.hostname.indexOf(tfjDomestic_Host) > -1) { tfjOn_Dom_Flag = 1; }

var tfjSetPrefBox_HTML = '<div id="tfjSettfjEd"><div class="tfjWireSeBox"><div class="tfjWireSeBoxHeader"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/global/set_edition/corner_se_tl.gif" width="4" height="4" alt="" id="tfjSeCnrTL" /></div><div id="tfjBoxSeContent"><a href="javascript:tfjSetPrefBox_Close();"><img class="tfjEditionCloseBtn" src="http://i.cdn.turner.com/tfj/.element/img/2.0/global/set_edition/se_close_btn.gif" width="14" height="14" alt="" /></a><form id="tfjsetPref_Form"><table align="center" class="tfjSetEdition" cellpadding="0" cellspacing="0" border="0"><tr><td class="setEdText"><b>Set your tfj.com Edition</b></td>';

if(tfjOn_Dom_Flag) { tfjSetPrefBox_HTML += '<td class="tfjEditionRadioTD"><input type="radio" id="edition" name="edition" class="tfjEditionRadioBtn" checked="checked" value="www" /></td><td>tfj U.S.</td><td class="tfjEditionRadioTD"><input type="radio" id="edition" name="edition" class="tfjEditionRadioBtn" value="edition" /></td><td>tfj International</td>'; }
else { tfjSetPrefBox_HTML += '<td class="tfjEditionRadioTD"><input type="radio" id="edition" name="edition" class="tfjEditionRadioBtn" checked="checked" value="edition" /></td><td>tfj International</td><td class="tfjEditionRadioTD"><input type="radio" id="edition" name="edition" class="tfjEditionRadioBtn" value="www" /></td><td>tfj U.S.</td>'; }

tfjSetPrefBox_HTML += '<td><a href="javascript:tfjSetEdPref_cooKie();"><img class="tfjEditionBoxBtn" src="http://i.cdn.turner.com/tfj/.element/img/2.0/global/set_edition/se_btn.gif" width="84" height="23" alt="" border="0" /></a></td></tr></table></form></div><div class="tfjWireSeBoxFooter"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/global/set_edition/corner_se_bl.gif" width="4" height="4" alt="" id="tfjSeCnrBL" /></div></div></div>';

if(tfjUserEd_Pref) {
	if(location.hostname == "tfj.com") {
		if(tfjUserEd_Pref == 'www') { location.replace('http://' + tfjDomestic_Host); }
		else{ location.replace('http://' + tfjIntl_Host); }
	}
}
else {
	tfjShow_setPref = true;
}

function tfjSetPrefBox_Close(pref_flag) {
	if (document.getElementById) { document.getElementById('tfjSetEditionContainer').style.display = 'none'; }
	else if (document.all) { document.all['tfjSetEditionContainer'].style.display = 'none'; }
}

function tfjSetEditionBox() {

	Element.update('tfjSetEditionContainer', tfjSetPrefBox_HTML);
	if (document.getElementById) { document.getElementById('tfjSetEditionContainer').style.display = 'block'; }
	else if (document.all) { document.all['tfjSetEditionContainer'].style.display = 'block'; }
	if(!tfjUserEd_Pref) {
		if(location.hostname.indexOf(tfjIntl_Host) > -1) { tfj_setCookie('SelectedEdition', 'edition', 854400, '/', '.tfj.com'); }
		else { tfj_setCookie('SelectedEdition', 'www', 854400, '/', '.tfj.com'); }
	}

}

function tfjSetEdPref_cooKie() {
	form_obj = document.getElementById('tfjsetPref_Form');
	cookie_val = (form_obj.edition[0].checked) ? form_obj.edition[0].value : form_obj.edition[1].value;
	tfj_setCookie('SelectedEdition', cookie_val, 854400, '/', '.tfj.com');
	tfjSetPrefBox_Close(1);
	current_loc = "" + document.location + '';
	if(cookie_val == 'www') {
		if(location.hostname.indexOf(tfjDomestic_Host) < 0) {
			if(location.hostname.indexOf(tfjIntl_Host) > -1) {
				current_loc = current_loc.replace(/^http:\/\/.+\.com/, 'http://' + tfjDomestic_Host);
				location.replace(current_loc);
			}
		}
	}
	else {
		if(location.hostname.indexOf(tfjIntl_Host) < 0) {
			if(location.hostname.indexOf(tfjDomestic_Host) > -1) {
				current_loc = current_loc.replace(/^http:\/\/.+\.com/, 'http://' + tfjIntl_Host);
				location.replace(current_loc);
			}
		}
	}
}

/* end set edition js
========================================================================= */

/* make tfj your home js
========================================================================= */
var tfjHPbkmrk = "http://www.tfj.com";
if(location.hostname == "edition.tfj.com") {
	tfjHPbkmrk = "http://edition.tfj.com";
}

var tfjMakeHPBox_HTML = '<div id="tfjMakeHPBanner"><div class="tfjWireSeBox"><div class="tfjWireSeBoxHeader"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/global/set_edition/corner_se_tl.gif" width="4" height="4" alt="" /></div><div id="tfjBoxSeContent"><a href="javascript:tfjMakeHPBox_Close();"><img class="tfjEditionCloseBtn" src="http://i.cdn.turner.com/tfj/.element/img/2.0/global/set_edition/se_close_btn.gif" width="14" height="14" alt="" /></a><form id="tfjsetPref_Form"><table align="center" class="tfjSetEdition" cellpadding="0" cellspacing="0" border="0"><tr><td class="setEdText"><b>Make tfj Your Home Page</b></td><td><a href="javascript:void(0);" onclick="if(document.all) { this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\''+tfjHPbkmrk+'\');tfjMakeHPBox_Close(); }"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/global/make_hp/set_btn.gif" width="70" height="23" alt="" border="0" class="tfjEditionBoxBtn" /></a></td></tr></table></form></div><div class="tfjWireSeBoxFooter"><img src="http://i.cdn.turner.com/tfj/.element/img/2.0/global/set_edition/corner_se_bl.gif" width="4" height="4" alt="" /></div></div></div>';

function tfjMakeHPBox_Close() {
	if (document.getElementById) { document.getElementById('tfjMakeHPContainer').style.display = 'none'; }
	else if (document.all) { document.all['tfjMakeHPContainer'].style.display = 'none'; }
}

function tfjMakeHPBox() {
	if(document.all) {
		Element.update('tfjMakeHPContainer', tfjMakeHPBox_HTML);
		document.all['tfjMakeHPContainer'].style.display = 'block';
	}
	else {
	tfj_openPopup('/feedback/help/homepage/frameset.2.0.exclude.html','620x364','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,width=620,height=430');
	}

}

/* end make tfj your home js
========================================================================= */

var tfjDocDomain='';
if(location.hostname.indexOf('tfj.com')>0) { tfjDocDomain='tfj.com'; }
if(location.hostname.indexOf('turner.com')>0) { tfjDocDomain='turner.com'; }
if(tfjDocDomain) { document.domain = tfjDocDomain;}
