// homepage content ID
var hpCId = 110979;
var hpData;

// schedule constants
var scdTSfx = "tools/img/scd_thumb.png"; // default location for schow schedule thumbnails
var tzPref = "EST";
var tzCookie = "CNtimezonepref";

// more games rollover path
var mgHvr = "http://i.cdn.turner.com/v5cache/CARTOON/site/Images/i3/call_playnow_100x75.jpg";

// img rollovers
function swapImgSrc (id,path){
	jQuery(id).attr('src',path);
}

// send clickmap tracking to omniture object (ClickMapTracking_globalnav.js)
// passed values are the link position, omniture custom property, and a boolean that switch on (true) or off (false)
// 		the global nav prefix for the link position
function trackLink(id,trackPath) {
	trackPath = jQuery(id).data('trId');
	ClickMapTrackingGlobalNav.sendClickMapTrack(trackPath, 'prop14',false)
}

// do this when the document is fully loaded
jQuery(document).ready(function() {
	if (window.location.hostname.indexOf('staging') > -1) {
		hpDataUrl = "/cnservice/cartoonsvc/content/xml/getContentById.do?contentId=111880&depth=5&filterContentId=112446" + previewFormat;
	} else {
		navdataUrl = "http://www.cartoonnetwork.com/tools/includes/cmagen/navigation.xml";
	}
	jQuery.ajax({
		type: "GET",
		// hpCId defined on line 2
		url: "/cnservice/cartoonsvc/content/xml/getContentById.do?contentId=" + hpCId + "&depth=5" + previewFormat,
		dataType: "xml",
		error: function (request, error) {
			// do this on AJAX error
		},
		success: function(data) {
			hpData = data;

			
			// start the no flash/ipad a-space check 
			if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))  ){
					noFlashASpace();
					noFlashCheckit();
					jQuery("#cnhome").css("width","1200px");	
			} 
			
			// insert the background advert, if  there is one
			var abkLength = jQuery(data).find('Background_Image').text();
			if (abkLength.length > 0) {
				abkString = "background: #ececec url(" + cmaImgBasePath + jQuery(data).find('Background_Image').find('srcUrl').text() + ") center top no-repeat;";
				jQuery('#cnhome .contentWrapper').attr('style',abkString);
				// reduce the width of the swf to show the ad
				jQuery('.aSpace .flashwrapper').css('width',1000);
				jQuery('#cnhome_fo').attr('width',1000);
			}

			// process the featured game data
			// the featured game is always the first game attached to the homepage content ID
			var fgSrc = cmaImgBasePath + jQuery(data).find('FeaturedGame:eq(0)').find('Super_C:first').find('srcUrl').text();
			var fgHvr = cmaImgBasePath + jQuery(data).find('FeaturedGame:eq(0)').find('Super_C_Animated:first').find('srcUrl').text();
			var fgOvr = cmaImgBasePath + jQuery(data).find('FeaturedGame:eq(0)').find('SuperCOverlay:first').find('srcUrl').text();
			var fgAlt = jQuery(data).find('FeaturedGame:eq(0)').attr('contentName');
			var fgLink = jQuery(data).find('FeaturedGame:eq(0)').find('Page_URL:first').text() + "?atclk_hp=hp_b_games_SuperC";
			var fgId = jQuery(data).find('FeaturedGame:eq(0)').attr('contentId');
			var fgShow = jQuery(data).find('FeaturedGame:eq(0)').find('Display_Title:first').text();
			// get the rating stars (../global/data.js)
			var fgRating =  getStars (jQuery(data).find('FeaturedGame:eq(0)').attr('rating_now'),'hps');
			// insert the featrued game
			// bind data and mouseover events for the background rollover effect (../global/data.js)
			// bind a click event for clickmap tracking
			jQuery('div.featuregame .img').attr('id',fgId).data('swaps',{over: fgHvr,out: fgSrc}).addClass('pictures').attr('style','background: url(' + fgSrc + ') center top no-repeat');
			jQuery('<a></a>').attr('href',fgLink).bind('mouseover',function(){
				doHover(fgId,'over');
			}).bind('mouseout', function(){
				doHover(fgId,'out');
			}).appendTo('div.featuregame .img');
			jQuery('<img />').attr({src:fgOvr,width:300,height:165,alt:fgAlt,border:0}).addClass('andj').appendTo('div.featuregame .img a');
			jQuery('div.featuregame .info .title').html(fgShow);
			jQuery('div.featuregame .info .rating').html(fgRating);

			// process and insert the remaining games
			// always use attached games 2-5 and ignore any other games
			i = 1;
			jQuery(data).find('FeaturedGame:gt(0)').each(function(){
				var mgSrc = cmaImgBasePath + jQuery(this).find('game_100x75_image:first').find('srcUrl').text();
				var mgAlt = jQuery(this).attr('contentName');
				var mgLink = jQuery(this).find('Page_URL:first').text() + "?atclk_hp=hp_b_games_c" + i;
				var mgShow = jQuery(this).find('Display_Title:first').text();
				var mgId = jQuery(this).attr('contentId');
				// bind mouseover events for a simple rollover since the hover state uses a static image
				// 		var (mgHvr) for static image defined on line 11
				jQuery('<a></a>').attr('href',mgLink).bind('mouseover',function(){
					jQuery("#" + mgId).attr('src',mgHvr);
				}).bind('mouseout', function(){
					jQuery("#" + mgId).attr('src',mgSrc);
				}).appendTo('div.moregames');
				jQuery('<div></div>').addClass('game').appendTo('div.moregames a:last');
				jQuery('<div></div>').addClass('img').appendTo('div.moregames a:last .game');
				jQuery('<img>').attr({src:mgSrc,width:100,height:75,alt:mgAlt,border:0,name:mgId,id:mgId}).appendTo('div.moregames a:last .game .img');
				jQuery('<div></div>').addClass('show').html(mgShow).appendTo('div.moregames a:last .game');
				i++;
				// breaks the each loop when 4 games have been run (iterator is greater than 4)
				if (i > 4) {
					return false;
				}
			});

			// process and insert the b-space feature cards
			// ignore any cards beyond the first two
			i = 1;
			jQuery(data).find('Homepage_card:lt(2)').each(function(){
				var hcDesc = jQuery(this).find('Description').text();
				var hcCall = jQuery(this).find('CallToAction').text();
				var hcLink = jQuery(this).find('URL').text() + "?atclk_hp=hp_b_checklist_Card" + i;
				var hcTitle = jQuery(this).find('Title').text();
				var hcSrc = cmaImgBasePath + jQuery(this).find('game_100x75:first').find('srcUrl').text();
				jQuery('<a></a>').attr('href',hcLink).appendTo('div.center');
				jQuery('<div></div>').addClass('item').appendTo('div.center a:last');
				jQuery('<div></div>').addClass('img').appendTo('div.center a:last .item');
				jQuery('<img>').attr({src:hcSrc,width:130,height:185,alt:hcTitle,border:0}).appendTo('div.center a:last .item .img');
				jQuery('<div></div>').addClass('blurb').appendTo('div.center a:last .item');
				jQuery('<div></div>').addClass('tease').appendTo('div.center a:last .item .blurb');
				jQuery('<span></span>').html(hcTitle).appendTo('div.center a:last .item .blurb .tease');
				jQuery('<div></div>').addClass('copy').appendTo('div.center a:last .item .blurb');
				jQuery('<span></span>').html(hcDesc).appendTo('div.center a:last .item .blurb .copy');
				jQuery('<div></div>').addClass('call').appendTo('div.center a:last .item .blurb');
				jQuery('<span></span>').html(hcCall).appendTo('div.center a:last .item .blurb .call');
				jQuery('<div></div>').addClass('clr').appendTo('div.center a:last .item');
				if (i == 1) {
					jQuery('<div></div>').addClass('rule').appendTo('div.center');
				}
				i++;
				// breaks the each loop when 2 cards have been run
				if (i > 2) {
					return false;
				}
			});

			// process the video promo data; always use the first instance and ignore any others
			var vpLink = jQuery(data).find('videopromo:first').find('URL:first').text();
			var vpBkSrc = cmaImgBasePath + jQuery(data).find('videopromo:first').find('TEST2:first').find('srcUrl').text();
			var vpTmbSrc = cmaImgBasePath + jQuery(data).find('videopromo:first').find('SneakThumb').find('srcUrl').text();
			// insert video promo; bind data
			// compensate for links that have ? or # characters
			if (vpLink.indexOf('?') < 0) {
				vpSuffix = "?atclk_hp=hp_b_promo_Card";
			} else {
				vpSuffix = "&atclk_hp=hp_b_promo_Card";
			}
			if (vpLink.indexOf('#') > -1) {
				vpOne = vpLink.substring(0,vpLink.indexOf('#'));
				vpTwo = vpLink.substring(vpLink.indexOf('#'),vpLink.length);
				vpLink = vpOne + vpSuffix + vpTwo;
			} else {
				vpLink = vpLink + vpSuffix
			}
			jQuery('<a></a>').attr('href',vpLink).appendTo('div.moduleflex');
			jQuery('<div></div>').css({'background-image':'url(' + vpBkSrc + ')','background-position':'center top','background-repeat':'no-repeat'}).appendTo('div.moduleflex a');
			// if there is a seperate video thumb attached to videopromo node, insert it
			if (jQuery(data).find('videopromo:first').find('SneakThumb').length > 0) {
				jQuery('<img>').attr({'src':vpTmbSrc,'width':120,'height':71,'alt':'','border':0}).appendTo('div.moduleflex a div');
			}

			// process the schedule module
			// uses a seperate data source
			doScheduleArray(data);
		}
	});

	// set up the time zone select menu
	jQuery('div.pull select').change(function(){
		// read the selected value
		jQuery('div.pull select option:selected').each(function(){
			tzPref = jQuery(this).val();
			// put the value in the visible space on the page
			jQuery('div.pull span').html(jQuery(this).text());
		});
		// set/reset the timezone preference cookie if a new selection is made
		setCookie(tzCookie, tzPref, 86400, 'cartoonnetwork.com');
		// redraw the schedule module to match the new selection
		doScheduleArray();
	});

	// homepage-specific alterations to the global footer
	// hide the dotted-line rule
	jQuery('div.footer img:first').attr('src','http://i.cdn.turner.com/toon/tools/img/pixel.gif');
	// insert the network rating
	jQuery('<img>').attr({'src':'/tools/img/legal/rating_tvpg.png','width':36,'height':35,'alt':'','border':0}).css('margin-right','12px').insertAfter('#legalWrapper');
	// change the font color of the privacy policy link
	jQuery('#legalWrapper a:first').addClass('legalSmallFFF').removeClass('legalSmall');
});


// pre-process the schedule data
var scdArray = new Array();
function doScheduleArray(){
	
	// Quick addon to populate the date at the end
	var sch_n_cal = tday;
	jQuery("#sch_n_cal_sub").append('<p id="sch_ncal_sub_date">' + tdate + '</p><p id="sch_ncal_sub_day">' + sch_n_cal.substr(0,3) + '</p>');
	
	// clear any old data out of the array by setting it's length
	//		necessary for redraw if a new timezone is selected
	scdArray.length = 0;
	// check for a timezone preference cookie
	if (document.cookie.lastIndexOf(tzCookie) > -1) {
		tzPref = readCookie(tzCookie);
	}
	// default value for timezone offset
	var timeOffset = 0;
	switch (tzPref) {
		// eastern
		case 'EST':
			jQuery('div.pull span').html('EASTERN');
			timeOffset = 0;
			break;
		// central
		case 'CST':
			jQuery('div.pull span').html('CENTRAL');
			timeOffset = -1;
			break;
		// mountain
		case 'MST':
			jQuery('div.pull span').html('MOUNTAIN');
			timeOffset = -2;
			break;
		// pacific
		case 'PST':
			jQuery('div.pull span').html('PACIFIC');
			timeOffset = 0;
			break;
		// hawaii; does not observe daylight savings, so two possible offsets
		case 'HST':
			jQuery('div.pull span').html('HAWAII');
			if (serverTime.indexOf('EDT') > -1) {
				timeOffset = -5;
			} else {
				timeOffset = -6;
			}
			break;
	}
	jQuery.ajax({
		// tdate is defined in parseTime.js
		type: "GET",
		url: "/cnschedule/xmlServices/" + tdate + ".EST.xml",
		dataType: "xml",
		error: function (request, error) {
			// do this on AJAX error
		},
		success: function(data) {
			var i = 0;
			// process data from every show node and insert data from the relevant nodes 
			//		into an array (scdTimeAry) for further processing
			jQuery(data).find('show').each(function(){
				if ((jQuery(this).attr('blockName') != "AdultSwim")) {
					scdTitle = jQuery(this).attr('title');
					scdPath = jQuery(this).attr('path');
					if (scdPath == "") {
						scdPath = "/schedule/index.html";
					}
					scdTimeAry = jQuery(this).attr('time').split(':');
					scdTime = parseInt(scdTimeAry[0]) + timeOffset + ":" + scdTimeAry[1];
					scdArray[i] = {show:scdTitle,url:scdPath,time:scdTime};
					i++;
				}
			});
			// next step, draw the schedule module based on the data in the array
			fillScheduleMod();
		}
	});
}

// draw/redraw the schedule module
function fillScheduleMod() {
	// empty any previous content out of the div
	jQuery('div.scheduleMod .items').html('');
	// scdArray.length equals the number of non-Adult Swim values in the array
	//		step back 4 to get the last 4 prime time shows
	sStart = scdArray.length - 4;
	j = 1; // iterator used to identify the each schedule item for it's click map name
	for (i = sStart; i < scdArray.length; i++) {
		thumbSrc = scdArray[i].url;
		// handle the thumbnail for any node with an undefined site association
		if (thumbSrc == "/schedule/index.html") {
			tempStr = scdArray[i].show.toUpperCase();
			if (tempStr == "MOVIE:") {
				scdArray[i].show = "MOVIE";
				thumbSrc = "/tools/img/home/scdthumbs/movie.png";
			} else if (tempStr == "SPECIAL:") {
				scdArray[i].show = "SPECIAL PRESENTATION";
				thumbSrc = "/tools/img/home/scdthumbs/default.png";
			} else {
				thumbSrc = "/tools/img/home/scdthumbs/default.png";
			}
		} else {
			thumbSubStr = thumbSrc.substring(0,thumbSrc.indexOf('index.html'));
			// concatenate show path with thumbnails suffix (scdTSfx) defined on line 5
			thumbSrc = thumbSubStr + scdTSfx;
		}
		tempNums = scdArray[i].time;
		numAr = new Array();
		numAr = tempNums.split(' ');
		tlStr = "?atclk_hp=hp_c_schedule_Card" + j;
		j++;
		// bind a click event and data for the click map
		jQuery('<a></a>').attr('href',scdArray[i].url + tlStr).appendTo('div.scheduleMod .items');
		jQuery('<div></div>').addClass('item').appendTo('div.scheduleMod .items a:last');
		jQuery('<div></div>').addClass('top').appendTo('div.scheduleMod .items a:last .item');
		jQuery('<div></div>').addClass('img').appendTo('div.scheduleMod .items a:last .item .top');
		jQuery('<img>').attr({src:thumbSrc,width:40,height:40,border:0,alt:scdArray[i].show}).appendTo('div.scheduleMod .items a:last .item .top .img');
		jQuery('<div></div>').addClass('time').html(numAr[0]).appendTo('div.scheduleMod .items a:last .item .top');
		jQuery('<div></div>').addClass('meridian').html('P').appendTo('div.scheduleMod .items a:last .item .top');
		jQuery('<div></div>').addClass('clr').appendTo('div.scheduleMod .items a:last .item .top');
		jQuery('<div></div>').addClass('btm').html(scdArray[i].show).appendTo('div.scheduleMod .items a:last .item');
		if (i < scdArray.length -1) {
			jQuery('<div></div>').addClass('vrule').appendTo('div.scheduleMod .items');
		}
	}
}

// ***************************** no flash check it

function noFlashCheckit(){
	var foo1 = jQuery(hpData).find("Promo_160x240").find("URL").text();
	var foo2 = jQuery(hpData).find("Promo_160x240").find("srcUrl").text();
	jQuery("#checkitzone").append('<div id="nfaCheckIt"><a href="' + foo1 + '"><img src="' + cmaImgBasePath + foo2 + '"></a></div>');
	
}

// ***************************** all the no flash aspace stuff

var nfaT;
var cCount = 0;
var nfaC = 1;
var nfaTime = 6400;
var nfaFadeTime = 1000;
function noFlashASpace(){
	
	jQuery("#flash_content").append('<div id="nfaWrap"><div id="nfaCards"></div><div id="nfaNavWrap"><div id="nfaNav"></div></div></div>');

		jQuery(hpData).find("a_space_slate").each(function () {
			
			// actual card population	
			cCount ++;
			if (cCount == 1) {
			jQuery("#nfaCards").append('<div id="nfaC' + cCount +'"><a href="' + jQuery(this).find("ClickUrl_master").text() + '"><img src="'+ cmaImgBasePath + jQuery(this).find("Backup_Image").find("srcUrl").text() + '"></a></div>');
			} else {
		
			jQuery("#nfaCards").append('<div id="nfaC' + cCount +'" style="display:none;"><a href="' + jQuery(this).find("ClickUrl_master").text() + '"><img src="'+ cmaImgBasePath + jQuery(this).find("Backup_Image").find("srcUrl").text() + '"></a></div>');	
			}
			
			// navigation population
			if (cCount == 1) {
			jQuery("#nfaNav").append('<div id="nfaN' + cCount +'" onClick="aNav('+ cCount +')" class="nfaCellActive nfaCell"><img src="/tools/img/noflash/frontFrame.png" class="frameMask"><img src="'+ cmaImgBasePath + jQuery(this).find("Thumb").find("srcUrl").text()+'"><p>'+ jQuery(this).find("About_text").text()+'</p></div>');
			} else {
			jQuery("#nfaNav").append('<div id="nfaN' + cCount +'" onClick="aNav('+ cCount +')" class="nfaCell"><img src="/tools/img/noflash/frontFrame.png" class="frameMask"><img src="'+ cmaImgBasePath + jQuery(this).find("Thumb").find("srcUrl").text()+'"><p>'+ jQuery(this).find("About_text").text()+'</p></div>');
			}
			

			if (cCount == jQuery(hpData).find("a_space_slate").length ) {
				jQuery("#nfaNav").append('<div class="nfaClear"></div>');
					
			}
			
		});

	// start the auto cycle	
	nfaT = setTimeout( "nfaCycle()" , nfaTime);
}

// this is the auto cycle function
function nfaCycle(){
	
	
		jQuery(".nfaCellActive").removeClass("nfaCellActive");
		jQuery("#nfaC" + nfaC + "").fadeOut(nfaFadeTime + 200);
		if (nfaC == cCount) {
		nfaC = 1;
		} else {
		nfaC++;
		}
		jQuery("#nfaN" + nfaC + "").addClass("nfaCellActive");	
		jQuery("#nfaC" + nfaC + "").fadeIn(nfaFadeTime);
	

	//reset the timer	
	nfaT = setTimeout( "nfaCycle()", nfaTime);
}

// clickin one of the buttons
function aNav(foo) {
	clearTimeout(nfaT);
	
		jQuery(".nfaCellActive").removeClass("nfaCellActive");
		jQuery("#nfaC" + nfaC + "").fadeOut(nfaFadeTime + 200);
		nfaC = foo;
		jQuery("#nfaN" + nfaC + "").addClass("nfaCellActive");
		jQuery("#nfaC" + nfaC + "").fadeIn(nfaFadeTime);
	nfaT = setTimeout( "nfaCycle()", nfaTime);
	
	
}
/* replaced with a JSP-generated SSI
function doHPLists(data){
	l1Hdr = jQuery(data).find('FooterLists:eq(0)').find('ListHeader').text();
	l1Link = jQuery(data).find('FooterLists:eq(0)').find('ListURL').text();
	l1LTxt = jQuery(data).find('FooterLists:eq(0)').find('LinkTxt').text();
	jQuery('<div></div>').addClass('hdr').appendTo('div.listone');
	jQuery('<div></div>').addClass('title').html(l1Hdr).appendTo('div.listone .hdr');
	if (l1Link != "") {
		jQuery('<div></div>').addClass('alllink').appendTo('div.listone .hdr');
		jQuery('<a></a>').data('trId','hp_c_footerlist_q1_allink').attr('href',l1Link).html(l1LTxt + ' &raquo;').bind('click', function(){
			trackLink(this,tlStr);
		}).appendTo('div.listone .hdr .alllink');
		jQuery('<div></div>').addClass('clr').appendTo('div.listone .hdr');
	}
	jQuery('<div></div>').addClass('col').appendTo('div.listone');
	jQuery('<div></div>').addClass('col').appendTo('div.listone');
	jQuery('<div></div>').addClass('clr').appendTo('div.listone');
	i = 1;	
	jQuery(data).find('FooterLists:eq(0)').find('ListItem:lt(6)').each(function(){
		thisTxt = "&raquo; " + jQuery(this).find('Text').text() + "<br />";
		thisLnk = jQuery(this).find('URL').text();
		tlStr = "hp_c_footerlist_q1_link" + i;
		if (i <= 3) {
			jQuery('<a></a>').data('trId',tlStr).attr('href',thisLnk).html(thisTxt).bind('click', function(){
				trackLink(this,tlStr);
			}).appendTo('div.listone .col:first');
		} else {
			jQuery('<a></a>').attr('href',thisLnk).html(thisTxt).bind('click', function(){
				trackLink(this,tlStr);
			}).appendTo('div.listone .col:last');
		}
		i++;
	});
	l2Hdr = jQuery(data).find('FooterLists:eq(1)').find('ListHeader').text();
	l2Link = jQuery(data).find('FooterLists:eq(1)').find('ListURL').text();
	l2LTxt = jQuery(data).find('FooterLists:eq(1)').find('LinkTxt').text();
	jQuery('<div></div>').addClass('hdr').appendTo('div.listtwo');
	jQuery('<div></div>').addClass('title').html(l2Hdr).appendTo('div.listtwo .hdr');
	if (l1Link != "") {
		jQuery('<div></div>').addClass('alllink').appendTo('div.listtwo .hdr');
		jQuery('<a></a>').data('trId','hp_c_footerlist_q2_allink').attr('href',l2Link).html(l2LTxt + ' &raquo;').bind('click', function(){
			trackLink(this,tlStr);
		}).appendTo('div.listtwo .hdr .alllink');
		jQuery('<div></div>').addClass('clr').appendTo('div.listtwo .hdr');
	}
	jQuery('<div></div>').addClass('col').appendTo('div.listtwo');
	jQuery('<div></div>').addClass('col').appendTo('div.listtwo');
	jQuery('<div></div>').addClass('clr').appendTo('div.listtwo');
	i = 1;
	jQuery(data).find('FooterLists:eq(1)').find('ListItem:lt(6)').each(function(){
		thisTxt = "&raquo; " + jQuery(this).find('Text').text() + "<br />";
		thisLnk = jQuery(this).find('URL').text();
		tlStr = "hp_c_footerlist_q2_link" + i;
		if (i <= 3) {
			jQuery('<a></a>').data('trId',tlStr).attr('href',thisLnk).html(thisTxt).bind('click', function(){
				trackLink(this,tlStr);
			}).appendTo('div.listtwo .col:first');
		} else {
			jQuery('<a></a>').data('trId',tlStr).attr('href',thisLnk).html(thisTxt).bind('click', function(){
				trackLink(this,tlStr);
			}).appendTo('div.listtwo .col:last');
		}
		i++;
	});
	l3Hdr = jQuery(data).find('FooterLists:eq(2)').find('ListHeader').text();
	l3Link = jQuery(data).find('FooterLists:eq(2)').find('ListURL').text();
	l3LTxt = jQuery(data).find('FooterLists:eq(2)').find('ListTxt').text();
	jQuery('<div></div>').addClass('hdr').appendTo('div.listthree');
	jQuery('<div></div>').addClass('title').html(l3Hdr).appendTo('div.listthree .hdr');
	jQuery('<div></div>').addClass('col').appendTo('div.listthree');
	jQuery('<div></div>').addClass('clr').appendTo('div.listthree');
	i = 1;
	jQuery(data).find('FooterLists:eq(2)').find('ListItem:lt(3)').each(function(){
		thisTxt = "&raquo; " + jQuery(this).find('Text').text() + "<br />";
		thisLnk = jQuery(this).find('URL').text();
		tlStr = "hp_c_footerlist_q3_link" + i;
		jQuery('<a></a>').data('trId',tlStr).attr('href',thisLnk).html(thisTxt).bind('click', function(){
			trackLink(this,tlStr);
		}).appendTo('div.listthree .col');
		i++
	});
	l4Hdr = jQuery(data).find('FooterLists:eq(3)').find('ListHeader').text();
	l4Link = jQuery(data).find('FooterLists:eq(3)').find('ListURL').text();
	l4LTxt = jQuery(data).find('FooterLists:eq(3)').find('ListTxt').text();
	jQuery('<div></div>').addClass('hdr').appendTo('div.listfour');
	jQuery('<div></div>').addClass('title').html(l4Hdr).appendTo('div.listfour .hdr');
	jQuery('<div></div>').addClass('col').appendTo('div.listfour');
	jQuery('<div></div>').addClass('clr').appendTo('div.listfour');
	i = 1;
	jQuery(data).find('FooterLists:eq(3)').find('ListItem:lt(3)').each(function(){
		tlStr = "hp_c_footerlist_q4_link" + i;
		thisTxt = "&raquo; " + jQuery(this).find('Text').text() + "<br />";
		thisLnk = jQuery(this).find('URL').text();
		jQuery('<a></a>').data('trId',tlStr).attr('href',thisLnk).html(thisTxt).bind('click', function(){
			trackLink(this,tlStr);
		}).appendTo('div.listfour .col');
		i++
	});
	l5Hdr = jQuery(data).find('FooterLists:eq(4)').find('ListHeader').text();
	l5Link = jQuery(data).find('FooterLists:eq(4)').find('ListURL').text();
	l5LTxt = jQuery(data).find('FooterLists:eq(4)').find('ListTxt').text();
	jQuery('<div></div>').addClass('hdr').appendTo('div.listfive');
	jQuery('<div></div>').addClass('clr').appendTo('div.listfive');
	jQuery('<div></div>').addClass('title').html(l5Hdr).appendTo('div.listfive .hdr');
	jQuery('<div></div>').addClass('col').appendTo('div.listfive');
	i = 1;
	jQuery(data).find('FooterLists:eq(4)').find('ListItem:lt(10)').each(function(){
		tlStr = "hp_c_footerlist_q5_link" + i;
		thisTxt = "&raquo; " + jQuery(this).find('Text').text() + "<br />";
		thisLnk = jQuery(this).find('URL').text();
		jQuery('<a></a>').data('trId',tlStr).attr('href',thisLnk).html(thisTxt).bind('click', function(){
			trackLink(this,tlStr);
		}).appendTo('div.listfive .col');
	});
}
*/

