
// js/browser.js

var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
var is_safari = (navigator.appVersion.indexOf("Safari") > -1);
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));
var is_winXP = ((agt.indexOf("windows nt 5")!=-1));
var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
var is_win32 = (is_win95 || is_winnt || is_win98 || ((is_major >= 4) && (navigator.platform == "Win32")) || (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));
var is_mac    = (agt.indexOf("mac")!=-1);
var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || (agt.indexOf("68000")!=-1)));
var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || (agt.indexOf("powerpc")!=-1)));
var is_macosx = (is_mac && ((agt.indexOf("os x") != -1) || (agt.indexOf("osx") != -1)));
var is_linux = (agt.indexOf("linux") != -1);


// js/main.js

var domain = "";
var sessiondomain = ".comcast.net";
if (document.location.href.indexOf("wwwj") != -1) {
	domain = "http://www.comcast.net";
}
else {
	domain = "http://" + document.domain;
}
var loggedin = false;
var haspreferences = false;
var isPrimary = false;
var firstName = "";
var greeting = "";
var zipCode = "";
var areaCode = "";
var user = "";
var pollPath = "";
var param = "";
var yhmcount = -1; // for backward comp.

if(document.location.pathname == '/games/invasion/setup/') document.location.href = '/gameinvasion/setup/';
if(document.location.pathname == '/games/invasion/sales/') document.location.href = '/gameinvasion/sales/';
if(new String(document.location.pathname).indexOf('/games/invasion/') != -1) document.location.href = '/gameinvasion/';


/**
 *  HEADER TABS
 */

function HdrSearch(title, action, label, fields) {
    this.title  = title;
    this.action = action;
    this.label  = label;
    this.fields = (fields != null) ? fields : [];
}

var headerSearch = {
    currTab:null,
    data:{
        entertainment: new HdrSearch("Entertainment", 'http://sitesearch.comcast.net/', 'Search Entertainment', {'fieldname':'q', 'c':'net', 'cat1':'Entertainment'}),
        finance: new HdrSearch("Finance", 'http://sitesearch.comcast.net/', 'Search Finance', {'fieldname':'q', 'c':'net', 'cat1':'Finance'}),
        games: new HdrSearch("Games", 'http://sitesearch.comcast.net/', 'Search Games', {'fieldname':'q', 'c':'net', 'cat1':'Games'}),
        help: new HdrSearch("Help", 'http://sitesearch.comcast.net/', 'Search Help', {'fieldname':'q', 'c':'net', 'cat1':'Help'}),
        images: new HdrSearch("Images", 'http://www.comcast.net/qry/imagesearch/', 'Search Images', {'fieldname':'query', 'cmd':'qry', 'safe':'on'}),
        //invasion: new HdrSearch("Game Invasion", 'http://sitesearch.comcast.net/', 'Search Game Invasion', {'fieldname':'q', 'c':'net', 'cat1':'Game Invasion'}),
        movies: new HdrSearch("Movies", 'http://sitesearch.comcast.net/', 'Search Movies', {'fieldname':'q', 'c':'net', 'cat1':'Movies'}),
        music: new HdrSearch("Music", 'http://sitesearch.comcast.net/', 'Search Music', {'fieldname':'q', 'c':'net', 'cat1':'Music'}),
        news: new HdrSearch("News", 'http://sitesearch.comcast.net/', 'Search News', {'fieldname':'q', 'c':'net', 'cat1':'News'}),
        //playgames: new HdrSearch("Play Games", 'http://sitesearch.comcast.net/', 'Search Play Games', {'fieldname':'q', 'c':'net', 'cat1':'Play Games'}),
        relationships: new HdrSearch("Relationships", 'http://sitesearch.comcast.net/', 'Search Relationships', {'fieldname':'q', 'c':'net', 'cat1':'Relationships'}),
        shopping: new HdrSearch("Shopping", 'http://shopping.comcast.net/search.php', 'Search Products', {'fieldname':'form_keyword'}),
        sports: new HdrSearch("Sports", 'http://sitesearch.comcast.net/', 'Search Sports', {'fieldname':'q', 'c':'net', 'cat1':'Sports'}),
        tv: new HdrSearch("TV", 'http://sitesearch.comcast.net/', 'Search TV', {'fieldname':'q', 'c':'net', 'cat1':'TV'}),
        video: new HdrSearch("Video", 'http://videosearch.comcast.net/ss-query/videosearch.jsp', 'Search Videos', {'fieldname':'q', 'dr':'1', 'cp':'1'}),
        web: new HdrSearch("Web", 'http://www.comcast.net/qry/websearch/', 'Search the Web', {'fieldname':'query', 'cmd':'qry', 'safe':'on'})
    },
    map:{
        account:{web:2,images:1,video:1,shopping:1,help:1},
        entertainment:{web:2,images:1,video:1,shopping:1,entertainment:1},
        features:{web:2,images:1,video:1,shopping:1},
        finance:{web:2,images:1,video:1,shopping:1,finance:1},
        findit:{web:2,images:1,video:1,shopping:1},
        games:{web:2,images:1,video:1,shopping:1,games:1},
        help:{web:2,images:1,video:1,shopping:1,help:1},
        home:{web:2,images:1,video:1,shopping:1},
        //invasion:{web:2,images:1,video:1,shopping:1,invasion:1},
        movies:{web:2,images:1,video:1,shopping:1,movies:1},
        music:{web:2,images:1,video:1,shopping:1,music:1},
        news:{web:2,images:1,video:1,shopping:1,news:1},
        photocenter:{web:2,images:1,video:1,shopping:1},
        //playgames:{web:2,images:1,video:1,shopping:1,playgames:1},
        pwp:{web:2,images:1,video:1,shopping:1},
        relationships:{web:2,images:1,video:1,shopping:1,relationships:1},
        security:{web:2,images:1,video:1,shopping:1,help:1},
        shopping:{web:1,images:1,video:1,shopping:2},
        sports:{web:2,images:1,video:1,shopping:1,sports:1},
        storage:{web:2,images:1,video:1,shopping:1},
        tv:{web:2,images:1,video:1,shopping:1,tv:1},
        web:{web:2,images:1,video:1,shopping:1},
        images:{web:1,images:2,video:1,shopping:1},
		video:{web:1,images:1,video:2,shopping:1}
    }
}



// script/cookie.js


function setSessionCookie(name, value, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + ";" +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
    document.cookie = curCookie;
}

function setSessionAndFlip(name, value) {
   setSessionCookie(name, value, "/", sessiondomain,false );
   document.location.href = "/";
}


if (document.location.href.indexOf("http://comcast.net") != -1) {
	document.location.href = "http://www.comcast.net";
}

if ((loggedin) && ((document.location.href.indexOf("home.html") != -1) || (document.location.href.indexOf("comcast.html") != -1))) {
	document.location.href = "http://www.comcast.net";
}


/* Global array provides data for tab system */
var tabData = {
    active:[],
    types:{
        dvd:[0,31,66],
        movies:[0,80],
        playgames:[0,87,218]
    }
};

function displayLoginLogoutButton() {
    // Display 'Sign Out'
    if (loggedin) {
        return "<div id=\"t-signout\"><a href=\"" + domain + "/signout.jsp\" title=\"Sign Out\">Sign Out<span id=\"s-signout\" class=\"signin\"></span></a></div>";
    
    // Display 'Sign In'
    } else {
        if ((document.location.href.indexOf("home.html") != -1) || (document.location.href.indexOf("comcast.html") != -1)) {
            return"<div id=\"t-signin\"><a href=\"" + domain + "/signin.jsp\" title=\"Sign In\">Sign In<span id=\"s-signin\" class=\"signin\"></span></a></div>";
        } else {
            return"<div id=\"t-signin\"><a href=\"" + domain + "/signin.jsp" + getRedirectArguments() + "\" title=\"Sign In\">Sign In<span id=\"s-signin\" class=\"signin\"></span></a></div>";
        }
    }
}

function getRedirectArguments() {
    var location = window.location;
    if(new String(location).indexOf('?') == -1) {
        return '?redirectUrl=' + document.location;
    } else {
        var output = '?redirectUrl=' + location.protocol + '//' + location.host + location.pathname;
        var searchStr = location.search.substr(1, location.search.length);
        var search = searchStr.split('&');
        if(search.length) {
            for(i = 0; i < search.length; i++) {
                output += '&redirectArg' + (i + 1) + '=' + search[i];
            }
        }
        
        return output;
    }
}

function setSigninRedirect(linkId) {
    var tmpLink = document.getElementById(linkId);
    if(tmpLink == null) return false;
    tmpLink.href = domain + "/signin.jsp" + getRedirectArguments();
}

function displaySwitchButton() {
	return "<a href=\"" + domain + "/express\" title=\"Switch to the Express View. Requires the Flash 7 plugin.\" onclick=\"setSessionCookie('SESSIONHOME', 'forcedexpress', '/', '" + sessiondomain + "', false);document.location.href='" + domain + "/';return false;\" />Go to Express</a>";
}

function displayGreetingYHM() {
    var tmp = "<span>Welcome, Guest!</span>";
    if (loggedin) {
        tmp = getGreeting();
        if (greeting.length >= 1) {
            tmp += ", " + "<a href=\"" + domain + "/providers/greeting/\" title=\"Modify your greeting name\" class=\"greet\" onclick=\"window.open(this.href, 'greeting', 'scrollbars=no,status=no,location=no,toolbar=no,favorites=no,address=no,menubar=no,resizable=yes,width=335,height=205'); return false;\">" + greeting + "</a>!</span>";
        }
    }
    return tmp;
}

function searchTheWeb(form) {
	var searchTerm = document.getElementById('search-field').value;
	trackBanners(headerSearch.data[headerSearch.currTab].action, headerSearch.currTab);
	if (searchTerm == "") {
		document.location.href = domain + '/search/?tab=' + headerSearch.currTab;
		return false;
	} else {
		return true;
	}
}


function getGreeting() {
    var now = new Date();
    var hour = now.getHours();
    var greeting = "<span>";
    if (hour < 12) {
        greeting += "Good Morning";
    } else if (hour < 17) {
        greeting += "Good Afternoon";
    } else {
        greeting += "Good Evening";
    }

    return greeting;
}


// Used to calculate time elapse in AP articles
// milliseconds in each
var mn = 60000;
var hr = 3600000;
var dy = hr * 6;

var months = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var days = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');


// expects date/time in GMT
function getElapsed(dtIn) {
	var now = (new Date()).getTime();
  var dt = makeDate(dtIn);
	var then = dt.getTime();
	var diff = now - then;
  var unit = "";
	if (diff > dy) {
		unit = days[dt.getDay()] + " ";
		unit += months[dt.getMonth()] + " ";
		unit += dt.getDate() + ", ";
		min = dt.getMinutes();
		if (min < 10) {
			min = "0" + min;
		}
		if (dt.getHours() > 12) {
		   unit += (dt.getHours() - 12) + ":" + min + " ";
		   unit += "PM";
		} else {
		   unit += dt.getHours() + ":" + min + " ";
		   unit += "AM";
		}
	} else if (diff > hr) {
		var tm = Math.round(diff/hr);
		var s = (tm > 1) ? "s" : "";
		unit = tm+" hour"+s+" ago";
	} else if (diff > mn) {
		var tm = Math.round(diff/mn);
		var s = (tm > 1) ? "s" : "";
		unit = tm+" minute"+s+" ago";
	}

	return unit;
}

function makeDate(dtIn) {

  var year = dtIn.substr(0,4);
  var month = dtIn.substr(4,2) - 1;
  var day = dtIn.substr(6,2);

  var hour = dtIn.substr(9,2);
  var minute = dtIn.substr(11,2);

  var dt = new Date();
  dt.setUTCFullYear(year);
  dt.setUTCMonth(month);
  dt.setUTCDate(day);
  dt.setUTCHours(hour);
  dt.setUTCMinutes(minute);

	return dt;
}


function getArgs() {
    var args = new Object();
    var query = top.location.search.substring(1);   //get querystring
    var pairs = query.split("&");                   //break on each &
    for(var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=');            //look for name=value
        if (pos == -1) continue;                    //if not found, skip
        var argname = pairs[i].substring(0, pos);   //extract name
        var value = pairs[i].substring(pos+1);      //extract value
        args[argname] = unescape(value);            //store as a property
    }
    return args;                                    //return object
}

function getParam(parameter) {
    var allTheValues = getArgs();                   //get hashmap object
    var theValue = allTheValues[parameter];
    if (typeof theValue == "undefined") {
        theValue = "";
    }
    return theValue;                                //return value
}

function isProduction() {
    var dom = new String(location.hostname);
    if (dom.indexOf("comcast.net") >= 0 || dom.indexOf("attbi.com") >= 0) {
        return true;
    } else {
        return false;
    }
}

function stringReplace(theString, replaceMe, withMe) {
    var rExp;
    var temp = "";
    var newReplaceMe = "";
    for (var x = 0 ; x < replaceMe.length ; x++) {
        temp = replaceMe.substr(x, 1);
        if (
            temp == "$" ||
            temp == "^" ||
            temp == "*" ||
            temp == "(" ||
            temp == ")" ||
            temp == "+" ||
            temp == "?" ||
            temp == "\\"
           ) {
           temp = "\\" + temp;
        }
        newReplaceMe += temp
    }
    rExp = new RegExp(newReplaceMe, "gi");
    results = theString.replace(rExp, withMe);
    return results;
}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
}

function getCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) {
            break;
        }
    }
    return '';
}
function setCookie(name, value, days, path, domain, secure) {
    if (isNaN(days)) {
        days = 1;
    }
    var offset = days * 24 * 60 * 60 * 1000;
    var now = new Date();
    var d;
    if (!isNaN(now.valueOf())) {
        var then = now.valueOf() + offset;
        d = new Date(then);
    } else {
        d = now;
    }
    var curCookie = name + "=" + escape(value) + "; expires=" + d.toGMTString() +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
    document.cookie = curCookie;
}
function getCrumbVal (crumb, offset) {
    var endstr = crumb.indexOf("&", offset);
    if (endstr == -1) {
        endstr = crumb.length;
    }
    var temp = crumb.substring(offset, endstr);
    temp = stringReplace(temp, "+", " ");
    return unescape(temp);
}
function GetCrumb (crumb, name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = crumb.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (crumb.substring(i, j) == arg) {
            return getCrumbVal(crumb,j);
        }
        i = crumb.indexOf("&", i) + 1;
        if (i == 0) {
            break;
        }
    }
    return '';
}

function getFirstFolder() { 
	var path = new String(window.location.pathname);
	var firstFolder = path.split("/");
	return firstFolder[1];
}

function getChannelName() {
    var tmpPageID = getFirstFolder();
    var folderSplit = new String(window.location.pathname).split('/');
    var isResultsPage = (tmpPageID == 'qry');
    
    if(isResultsPage) {
    	tmpPageID = 'search/?tab=web';
        //tmpPageID = folderSplit[2];
    } /*else if(tmpPageID == 'games') {
        tmpPageID = (folderSplit[2] != null && folderSplit[2]) ? folderSplit[2] : tmpPageID;
    }*/
    
    // Handle alternate domains
    var domainData = new String(location.hostname).split('.');
    if(domainData[0] == 'acctmgt') {
        tmpPageID = 'account';
    } else if(domainData[0] == 'shopping' || (new String(window.location.pathname).indexOf('pricegrabber') != -1)) {
        tmpPageID = 'shopping';
    }
    return tmpPageID;
}


var minNum = 10000000;
var maxNum = 99999999;
var randomNumber = Math.round(Math.random() * (maxNum - minNum)) + minNum;
var status = ((loggedin) ? "logged" : "anon");
var term = getParam("query");
var pagename = getFirstFolder();

function writeBannerSkyScraper(category) {
	document.write('<scr' + 'ipt language="JavaScript1.1" src="http://oascentral.comcast.net/RealMedia/ads/adstream_jx.ads/comcast.net/searchresults/1' + randomNumber + '@Right?c=' + status + '&query=' + term + '">');
	document.write('</scr' + 'ipt>');
}

function writeSkyBan(position) {
    var placement = "";
    if ((pagename == "comcast.html") || (pagename == "home.html") || (pagename == "explore.html")) { pagename = "home"; }
    if (position == "navbar") {
    	placement = "Left";
    }
    else {
    	placement = "Right";
    }
    if ((document.getElementById('comcastnet').className.indexOf('lite') == -1)) {
		if ((position == "navbar" && loggedin) || (position == "assistant" && !loggedin)) {
			document.write('<div id="assistant-sky"><div id="assistant-sky-iframe"><h3></h3>');
			document.write('<iframe width="120" height="600" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" src="http://oascentral.comcast.net/RealMedia/ads/adstream_sx.cgi/comcast.net/' + pagename + '/1' + randomNumber + '@' + placement + '?c=' + status + '&query=' + term + '"></iframe>');
			document.write("</div></div>");
		}
	}
}

function navTracking() {
	if(document.getElementById != null) {
    var navBox = document.getElementById('nav');
    if(navBox != null) {
        var navAnchors = navBox.getElementsByTagName('a');
        for(i=0; i < navAnchors.length; i++) {
            if(navAnchors[i].className == 'menu') continue;
            var href = new String(navAnchors[i].href);
            if(href.indexOf('javascript:') != -1) continue;
            navAnchors[i].href += ((href.indexOf('?') != -1) ? '&' : '?') + "CM.src=Navigation";
        }    
    }
}
}

var chnlPath = ""; 
if (document.location.href.indexOf("invasion") != -1) {
	chnlPath = "games";
}
else if (document.location.href.indexOf("playgames") != -1) {
	chnlPath = "gamesplay";
}
else if ((pagename == "comcast.html") || (pagename == "home.html") || (pagename == "explore.html")) { 
	chnlPath = "home"; 
}
else {
	chnlPath = getFirstFolder();
}

// Writes links in the Search subnav bar
function searchQry(type) {
	if (type != "videosearch") {
		document.location.href = "/qry/" + type + "?query=" + getParam('query');
	}
	else {
		document.location.href = "http://videosearch.comcast.net/ss-query/videosearch.jsp?q=" + getParam('query');
	}
}

function submitAskComcast(frm) {
    if(frm.q.value == '') return false;
    var defaultFeatures = 'scrollbars=no,status=no,location=no,toolbar=no,favorites=no,address=no,menubar=no,resizable=yes';
    var askFeatures     = defaultFeatures + ',width=500,height=435';
    var tmpQuery        = new String(frm.q.value).split(' ');
    var tmpQueryStr     = frm.action + '?q=' + tmpQuery.join('+');
    window.open(tmpQueryStr, "ask", askFeatures);
    return false;
}

// Provides an accessible, standards-compliant method of handling popup windows that also degrades gracefully in the absense of JavaScript
function externalLinks() {

	// detect modern, DOM-compliant browsers
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");

	for (var i=0; i< anchors.length; i++) {
		var anchor = anchors[i];

		// window chrome features
		var defaultFeatures = 'scrollbars=no,status=no,location=no,toolbar=no,favorites=no,address=no,menubar=no,resizable=yes';
		var comicFeatures = defaultFeatures + ',width=650,height=320';
		var fanFeatures = defaultFeatures + ',width=560,height=625';
		var slideshowFeatures = defaultFeatures + ',width=560,height=625';
		var askFeatures = defaultFeatures + ',width=500,height=435';
		var newWinMsg = ". This link will open in a new window.";
		var fanMsg = ". This link will open in a new window.";
		var ssMsg = "View a photo slideshow starting with this picture. This link will open in a new window.";

		// test for anchors that contain hyperlinks, exclude named page anchors
		//if (!anchor.getAttribute("href")) return;

		// test for anchors that contain the REL attribute
		if (anchor.getAttribute("rel")) {

			// for links that should open a fully-chromed, full-sized browser window
			//if (anchor.getAttribute("rel") == "external") {
			if (anchor.getAttribute("rel").indexOf("external") != -1) {
				//anchor.title += newWinMsg;
				anchor.target = "_blank";
			}

			// for links that should open with specific chrome features and preset sizes
			if (anchor.getAttribute("rel").indexOf("popup") != -1) {
				anchor.onclick = function() {
					var anchorFeat = (this.href.indexOf("Comic") != -1 || this.href.indexOf("comic") != -1) ? comicFeatures : defaultFeatures;
					window.open(this.href, this.rel, anchorFeat);
					return false;
				}
			}

			// for links to Fan videos
			if (anchor.getAttribute("rel") == "fan") {
				//anchor.title += fanMsg;
				anchor.onclick = function() {
					window.open(this.href, "fan", fanFeatures);
					return false;
				}
			}

			// for links to Ask Comcast
			if (anchor.getAttribute("rel") == "ask") {
				//anchor.title += newWinMsg;
				anchor.onclick = function() {
					window.open(this.href, "ask", askFeatures);
					return false;
				}
			}

			// for links to AP Photo Slideshow
			/*if (anchor.getAttribute("rel") == "slideshow") {
				//anchor.title += ssMsg;
				anchor.onclick = function() {
					window.open(this.href, "slideshow", slideshowFeatures);
					return false;
				}
			}*/

			// symbol lookup
			if (anchor.getAttribute("rel").indexOf("symbollookup") != -1) {
				anchor.onclick = function() {
                    var tmpURL       = this.href;
                    var tmpSymbolObj = document.getElementById('searchfor');
                    if(tmpSymbolObj != null) tmpURL += "?searchfor=" + tmpSymbolObj.value;
                    window.open(tmpURL, this.rel, askFeatures);
					return false;
				}
			}

			// used for links in leftnav
			if (anchor.className && anchor.className.indexOf("channel") != -1) {
				anchor.onclick = function() {
					subnav(this.getAttribute("rel"), this);
					return false;
				}
			}

			// used for closing popup window and loading document in the opener
			if (anchor.getAttribute("rel") == "opener") {
				anchor.onclick = function() {
					opener.document.location.href = this.getAttribute("href");
					self.close();
					return false;
				}
			}

			}
	}
}


// Hides and shows submenus and highlights appropriate button
function subnav(menuName, buttonName) {

// detect modern, DOM-compliant browsers
if (!document.getElementById) return;

	var menuName = document.getElementById(menuName);

	if (menuName.style.display == "none") {
		menuName.style.display = "";
		//if (buttonName.className.indexOf("selected") == -1) {
			buttonName.className = stringReplace(buttonName.className, "menu", "menu-s");
		//}
	}

	else {
		menuName.style.display = "none";
		//if (buttonName.className.indexOf("selected") == -1) {
			buttonName.className = stringReplace(buttonName.className, "menu-s", "menu");
		//}
	}
}

// Writes channel label next to Comcast logo
function writeLogo() {
	document.write('<h2><a href="/' + getChannelName() + '">' + getChannelName() + '</a></h2>');
}

// Writes HTML navbar IFRAME for third parties
function writeNav() {
	document.write('<iframe src="http://www.comcast.net/includes/layout/inav.html" id="navframe" frameborder="0" scrolling="no"><\/iframe>');
}

function writeNavBody() {
	if (parent.document.location.href.indexOf("finance.comcast.net") != -1) {
		if (parent.document.location.href.indexOf("/rich/us_markets") != -1) {
			document.write('<body id="comcastnet" class="finance markets rich standard">');
		}
		else {
			document.write('<body id="comcastnet" class="finance main rich standard">');
		}
	}
}



/**
 *  HEADER TABS
 */

var isSearchResultsPage = null;
function writeHeaderSearchTabs(tmpID) {
	if (is_ie && is_mac) { } else {
	var tmpPageID = tmpID != null ? tmpID : getChannelName();
    
    if(headerSearch.map[tmpPageID] == null) tmpPageID = 'home';
    var tabOrder = headerSearch.map[tmpPageID];
    
    document.write('<ul>');
    for(tabName in tabOrder) {
        if(headerSearch.data[tabName] == null) continue;
        var isDefault = (isSearchResultsPage != null) ? (tabName == tmpPageID) : (tabOrder[tabName] == 2);
        writeHeaderTab(tabName, isDefault);
    }
    document.write('</ul>');
    handleHeaderTabClick();
    //document.getElementById('search-field').focus();
    
    }
}

function writeHeaderTab(tabName, isDefault) {
    if(isDefault) headerSearch.currTab = tabName;
    var tmpID    = 'searchtab-' + tabName;
    var tmpClass = isDefault ? 'selectedtab' : '';
    var tmpTitle = headerSearch.data[tabName].title;
    var output = "<li id='" + tmpID + "'>"
        + "<a onclick=\"handleHeaderTabClick('" 
        + tabName + "');\" class='" + tmpClass + "'>" + tmpTitle + "</a></li>";
    document.write(output);
}


function handleHeaderTabClick(tabName) {
    var searchForm = document.getElementById('search-form');
    
    var isInitEvent = false;
    
    // Initial set
    if(tabName == null) {
        var tabName = headerSearch.currTab;
        isInitEvent = true;
    } else if(headerSearch.currTab == tabName) {
        return false;
    } else {
        document.getElementById('search-field').focus();
    }
    var oldTab = document.getElementById('searchtab-' + headerSearch.currTab).firstChild;
    oldTab.className = '';
    var newTab = document.getElementById('searchtab-' + tabName).firstChild;
    newTab.className = 'selectedtab';
    
    // If initializing and web is not default tab, remove hidden fields
    if(isInitEvent && tabName != 'web') {
        for(fieldName in headerSearch.data.web.fields) {
            var tmpObj = document.getElementById(fieldName);
            if(tmpObj != null) tmpObj.parentNode.removeChild(tmpObj);
        }
    }
    
    // Remove old hidden fields
    for(fieldName in headerSearch.data[headerSearch.currTab].fields) {
        var tmpObj = document.getElementById(fieldName);
        if(tmpObj != null) tmpObj.parentNode.removeChild(tmpObj);
    }
    headerSearch.currTab = tabName;
    
    var searchFieldName = 'query';
    
    // Add new hidden fields
    for(fieldName in headerSearch.data[tabName].fields) {
        var fieldValue = headerSearch.data[tabName].fields[fieldName];
        /* Change query field name */
        if(fieldName == 'fieldname') {
            searchFieldName = fieldValue;
            continue;
        }
        
        var tmpObj = document.getElementById(fieldName);
        if(tmpObj != null) {
            tmpObj.value = fieldValue;
        } else {
            if(is_ie) {
                var tmpString = '<input type="hidden" name="' + fieldName + '" id="' + fieldName + '" value="' + fieldValue + '"/>';
                var tmpObj = document.createElement(tmpString);
            } else {
                var tmpObj = document.createElement('input');
                tmpObj.id    = fieldName;
                tmpObj.name  = fieldName;
                tmpObj.type  = 'hidden';
                tmpObj.value = fieldValue;
            }
            searchForm.appendChild(tmpObj);
        }
    }
    document.getElementById('search-field').name = searchFieldName;
    searchForm.action     = headerSearch.data[tabName].action;
    document.getElementById('search-label').innerHTML = headerSearch.data[tabName].label + ':';
    
    if(isInitEvent || isSearchResultsPage == null || document.getElementById('search-field').value == "") return false;
    searchForm.submit();
}





/**
 *  BEGIN NEW EMAIL ICON CODE
 */

/* Contains data for getting number of unread emails */
var emailQuery = {
    ref:{
        frame:null,
        frameDoc:null
    },
    request:null,
    url: "/qry/yhm.js?rand=" + randomNumber
}



/**
 *  Returns XMLHttpRequest ('AJAX') object (if supported)
 */
function getAjaxRequestObj() {
    if(window != null && window.XMLHttpRequest != null) {
        return new XMLHttpRequest();
    } else if(window != null && window.ActiveXObject != null && !is_mac) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        return null;
    }
}


/**
 *  Executed when email icon is rendered
 */
function writeEmailIcon() {
	if(!loggedin || !hasRightVersion) return false;
	
    emailQuery.request = getAjaxRequestObj();
    if(emailQuery.request == null) {
        initEmailFrameRequest();
        return false;
    }
	
    emailQuery.request.onreadystatechange = function() {
        if(emailQuery.request.readyState != 4) return false;
        if(emailQuery.request.responseXML == null) return false;
        var requestData = emailQuery.request.responseXML;
        var status = new String(getElementTextNS('', 'status', requestData, 0)).toLowerCase();
        if(status != 'success') return false;
        var messageCount = parseInt(getElementTextNS('', 'newmail', requestData, 0));
        if(messageCount && messageCount != "0") document.getElementById('email-icon').innerHTML = '<span>' + messageCount + '</span>';
        //if(!messageCount) messageCount = '';
        //document.getElementById('email-icon').innerHTML = '<span>' + messageCount + '</span>';
    };
    
    var tmp = emailQuery.request.open("GET", emailQuery.url, true);
    emailQuery.request.send(null);
}



/**
 *  Attempt to retrieve and display # emails for browsers lacking AJAX support
 */
function initEmailFrameRequest() {    
    var tmpFrame = document.createElement('iframe');
    tmpFrame.setAttribute('id', 'email-icon-frame');
    tmpFrame.setAttribute('name', 'email-icon-frame');
    tmpFrame.style.border    = '0px';
    tmpFrame.style.height    = '0px';
    tmpFrame.style.width     = '0px';
    tmpFrame.src = emailQuery.url;
    
    emailQuery.ref.frame = document.getElementById('email-icon').appendChild(tmpFrame);
    
    if(emailQuery.ref.frame.contentDocument) { // For NS6
        emailQuery.ref.frameDoc = emailQuery.ref.frame.contentDocument; 
    } else if(emailQuery.ref.frame.contentWindow) { // For IE5.5 and IE6
        emailQuery.ref.frameDoc = emailQuery.ref.frame.contentWindow.document;
    } else if(emailQuery.ref.frame.document) { // For IE5
        emailQuery.ref.frameDoc = emailQuery.ref.frame.document;
    }
}


/**
 *  XML file processing utility function
 */
function getElementTextNS(prefix, local, parentElem, index) {
    var result = '';
    if(prefix && isIE) {
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    } else {
        var tmpTags = parentElem.getElementsByTagName(local);
        result = tmpTags[index];
    }
    if(result) {
        if (result.childNodes.length > 1) {
            return result.childNodes[1].nodeValue;
        } else {
            return result.firstChild.nodeValue;    		
        }
    } else {
        return null;
    }
}



/**
 *  END NEW EMAIL ICON CODE 
 */











// Writes Assistant sidebar when authenticated. When Flash is disabled, nothing shows. When JavaScript is disabled, nothing shows.
function writeAssistant() {
	if (document.getElementById("comcastnet").className.indexOf("lite") == -1) {
	var pop = '<div id="assistant-pop"><a href="#" onclick="popAssistant(); return false;" title="Launch the Popup Assistant. This link will open in a new window."><span>Comcast Assistant</span></a></div>';
	var modify = '<div id="assistant-modify"><div><a href="#"><span>Modify Assistant</span></a></div></div>';
	var skip = '<div class="skip"><a href="#a-assistant">Skip this Flash Movie</a></div>';
	var anchor = '<a name="a-assistant"></a><div class="skip"><a href="#a-pagetop">Back to Top</a><br /></div>';
	var faux = '<div id="assistant-faux"><a href="/signin.jsp" title="Access the Comcast Assistant by signing in to Comcast.net"><span>Comcast Assistant</span></a></div>';
	var stub = '<div id="assistant-teaser"><a href="http://www.comcast.net/security/mcafee/?cm.src=VirusScanAssistantPromo"><img src="/images/global/teaser.jpg" alt="Comcast High-Speed Internet includes: McAfee Virus Protection. Free Download." /></a></div>';
	var stubFrame = '<div id="assistant-teaser"><iframe src="/providers/assistant/teaser/index.html" scrolling="no" frameborder="0" width="200" height="300"></iframe></div>';
	var queryStr = "?is=common/assistant";
		queryStr += "&un="+user;
		
	//document.write('<div id="assistant">');
	//document.write(banner);
	
    if ((hasRightVersion) && (loggedin)) {
   		document.write(pop);
		document.write(skip);
		document.write('<div id="assistant-flash">');
       	writeFlash("assistantFlash","/Canvas.swf"+queryStr,200,1900,"#19314B");
       	document.write('</div>');
		document.write(anchor);
	}
	else if ((hasRightVersion) && (isInNetwork)) {
		document.write(pop);
		//document.write(modify);
		//document.write(faux);
		//document.write(stub);
		document.write(stubFrame);
		writeSkyBan("assistant");
	}
	else if ((hasRightVersion) && ((!isInNetwork) && (!loggedin))) {
		//document.write(stub);
		document.write(stubFrame);
		writeSkyBan("assistant");
	}
	
	//document.write('</div>');
}
}

function writePopupAssistant() {
    if ((hasRightVersion) && (loggedin)) {
	    self.focus();
        var queryStr = "?is=common/assistant";
        queryStr += "&un="+user;
        var winH = 600;
        if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
            winH = window.innerHeight;
        } else if( document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ) { //IE 6+ in 'standards compliant mode'
            winH = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible
            winH = document.body.clientHeight;
        }
        writeFlash("assistantFlash","/Canvas.swf"+queryStr,200,1300,"#19314B");
	} else {
	    self.close();
	}
}

function popAssistant() {
	if ((hasRightVersion) && (loggedin)) {
		var h = (eval((screen.height) - 100));
		window.open('/providers/assistant/popup.html','popup_assistant','scrollbars=yes,status=no,location=no,toolbar=no,favorites=no,address=no,menubar=no,resizable=yes,width=220,height=' + h + ',top=10,left=10');
	}
	else {
		document.location.href = "/signin.jsp?redirectUrl=" + document.location;
	}
}

function writeCover(path) {
	if (hasRightVersion) {
		var queryStr="?channel="+path+"&";
		var h = 246;
		if (loggedin||isInNetwork) {
			queryStr += "isLoggedIn=true"; 
				h = 466;
		}
		document.write('<div id="cover">');
		writeFlash("coverFlash","/swf/classic/cover/CoverSA.swf"+queryStr,592,h);
		document.write('</div>');
		}
}

function writePoll(path) {
/*    if (hasRightVersion) {
    
    	if (document.location.href.indexOf("playgames") != -1) {
    		path = "classic/poll/gamesplay";
    	}
    	
    	var queryStr = "?is="+path;
        if (loggedin) {
            queryStr += "&un="+user;
        }
        document.write('<div class="module wide">');
    	document.write('<h3 id="h-poll">Poll</h3>');
    	document.write('<div class="skip"><a href="#a-poll">Skip this Flash Movie</a><br /></div>');
        writeFlash("pollFlash","/Canvas.swf"+queryStr,180,250);
        document.write('<a name="a-poll"></a>');
        document.write('</div>');
        document.write('<div class="module-divider"></div>');
	}*/
}

function writeScores(showOnly, tabId) {
    if ((hasRightVersion) && (document.location.href.indexOf("golf") == -1)) {
    	document.write('<div class="module wide scores">');
    	document.write('<h3 id="h-scores">Scoreboard</h3>');
        document.write('<div class="skip"><a href="#a-scores">Skip this Flash Movie</a><br /></div>');
        // only display NFL scores in NFL channel
        if (document.location.href.indexOf("nfl") != -1) {
        	writeFlash("scoresFlash","/swf/common/module/scores/scores.swf?backgroundColor=FFFFFF&islgin="+loggedin + "&showOnly=true&tabId=nfl",200,420);
        }
        else if (document.location.href.indexOf("nhl") != -1) {
        	writeFlash("scoresFlash","/swf/common/module/scores/scores.swf?backgroundColor=FFFFFF&islgin="+loggedin + "&showOnly=true&tabId=nhl",200,420);
		}
        else {
        	writeFlash("scoresFlash","/swf/common/module/scores/scores.swf?backgroundColor=FFFFFF&islgin="+loggedin,200,420);
        }
		/*if (!showOnly) {
			writeFlash("scoresFlash","/swf/common/module/scores/scores.swf?backgroundColor=FFFFFF&islgin="+loggedin,200,420);
		} else {
			writeFlash("scoresFlash","/swf/common/module/scores/scores.swf?backgroundColor=FFFFFF&islgin="+loggedin + "&showOnly=true&tabId=" + tabId,200,420);
		}*/
        document.write('<a name="a-scores"></a>');
        document.write('</div>');
        document.write('<div class="module-divider"></div>');
    }
}


function writeFlashHome() {
		var usrname= GetCrumb(myportal, "em");
		document.write('<div id="flashhome-wrapper">');
		document.write('<div id="flashhome">');
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="592" height="2000" id="site" align="middle">');
		document.write('  <param name="allowScriptAccess" value="sameDomain" />');
		document.write('  <param name="movie" value="Canvas.swf" />');
		document.write('  <param name="FlashVars" value="is=classic&loggedin=true&ion=true&un='+usrname+'" />');
		document.write('  <param name="quality" value="high" />');
		document.write('  <param name="menu" value="false" />');
		document.write('  <param name="salign" value="lt" />');
		document.write('  <param name="bgcolor" value="#EBEDEF" />');
		document.write('  <embed src="Canvas.swf" quality="high" FlashVars="is=classic&loggedin=true&ion=true&un='+usrname+'" salign="lt" bgcolor="#19314B" width="592" height="2000" name="site" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
		document.write('</div></div>');
		//document.write('<iframe id="page" name="page" src="page.html?section=0&content=0&name=HOME - Comcast.net" noresize="noresize" width="400" height="0" frameborder="0" scrolling="no"><\/iframe>');
}

var sessionHomeCookie=GetCookie("SESSIONHOME");



function writeExpress() {
	var queryStr = new String(window.location.search);
	queryStr = queryStr.substr(1);
	if (queryStr.length > 0) queryStr += "&";
	queryStr += "un="+GetCrumb(myportal, "em")+"&";
	queryStr += "&is=express&";
	queryStr += "ion="+isInNetwork+"&";
	queryStr += stamp;
	
	var w = "100%";
	if (isIE) w = "995";
	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+w+'" height="2000" id="site" align="middle">');
	document.write('  <param name="allowScriptAccess" value="sameDomain" />');
	document.write('  <param name="movie" value="Canvas.swf" />');
	document.write('  <param name="FlashVars" value="'+queryStr+'" />');
	document.write('  <param name="quality" value="high" />');
	document.write('  <param name="menu" value="false" />');
	document.write('  <param name="salign" value="lt" />');
	document.write('  <param name="bgcolor" value="#19314B" />');
	document.write('  <embed src="Canvas.swf" quality="high" FlashVars="'+queryStr+'" salign="lt" bgcolor="#19314B" width="'+w+'" height="2000" name="site" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('<\/object>');
	document.write('<iframe id="page" name="page" src="page.html?section=0&content=0&name=HOME - Comcast.net" noresize="noresize" width="400" height="0" frameborder="0" scrolling="no"><\/iframe>');
}

function metaBypass() {
	if ((sessionHomeCookie == "express") || (sessionHomeCookie == "forcedexpress")) {
	} 
	else { 
		if (loggedin) {
			document.write('<meta http-equiv="refresh" content="5; URL=/explore.html" />');
		}
		else {
			
		}
	}
}

function writeEmbeddedFan() {
}


function viewTheFan(source) {
}

function hideTheFan() {
	var vlyr = document.getElementById("fanLayer");
	vlyr.style.left = -2500;
	vlyr.style.display = "none";
}

function popTheFan(vid,conf) {
	window.open("/providers/fan/popup.html?"+vid+"&config="+conf,'thefan',"width=560,height=625");
}

function hideStatusMsg() {
	document.getElementById("statusmsg").style.display = "none";
}













/*
 * Tab Initialization
 */
function initTabs() {
	if (document.getElementsByTagName) {
    var tmpTags = document.getElementsByTagName('dl');
    // Loop through all 'dl' tags, look for 'tab-set' class

    for(i = 0; i < tmpTags.length; i++) {
        if(!tmpTags[i].className || tmpTags[i].className != 'tab-set') continue;
        var tabSetType  = new String(tmpTags[i].id).split('-')[2];
        var tabSetID    = new String(tmpTags[i].id).split('-')[3];
        var tabSplitID  = new String(tmpTags[i].id).split('-');
        var tabSetWidth = (tabSplitID[4] != null) ? tabSplitID[4] : 160;
        tabData.active[tabSetID] = {tabRefs:[],contentRefs:[],currTab:null,type:tabSetType};
        
        var tmpDate = new Date();
        var dotw = tmpDate.getDay();
        var isWeekend = (dotw == 0 || dotw > 4);
        var selectSecondTab = ((tabSetID == 'intheaters') && isWeekend);
        
        var tabCount  = 0;
        var tabOffset = 0;
        var tabToActivate  = null;
        for(var o = 0; o < tmpTags[i].childNodes.length; o++) {
            if(tmpTags[i].childNodes[o].nodeType == 1) {
                var tagType = new String(tmpTags[i].childNodes[o].nodeName).toLowerCase();
                if(tagType == 'dt') {
                    tabData.active[tabSetID].tabRefs[tabCount] = tmpTags[i].childNodes[o];
                    
                    // Determine tab to be selected
                    if((selectSecondTab && tabCount == 1) || tabToActivate == null) {
                        tabToActivate = tmpTags[i].childNodes[o];
                    }
                    
                    var currOffset = tabData.types[tabSetType][tabCount];
                    var nextOffset = (tabData.types[tabSetType][tabCount+1] != null) ? tabData.types[tabSetType][tabCount+1] : null;
                    var currWidth  = (nextOffset != null ? nextOffset : tabSetWidth) - currOffset;
                    tabOffset     += tabData.types[tabSetType][tabCount];

                    tmpTags[i].childNodes[o].id = 'tab-set-hdr-' + tabSetID + '-' + tabCount;
                    tmpTags[i].childNodes[o].style.backgroundImage = "url(http://media3.comcast.net/images/headings/tabs-" + tabSetType + ".gif)";
                    tmpTags[i].childNodes[o].style.backgroundPosition = '-' + currOffset + 'px 0px';
                    tmpTags[i].childNodes[o].style.marginLeft = (currOffset + 'px');
                    tmpTags[i].childNodes[o].style.width = (currWidth + 'px');
                    tmpTags[i].childNodes[o].onclick = function() { activateTab(this); };

                } else if(tagType == 'dd') {
                    tabData.active[tabSetID].contentRefs[tabCount] = tmpTags[i].childNodes[o];
                    if(!tabCount++) tmpTags[i].childNodes[o].style.visiblity = 'visible';
                }

            } else {
                lastTag = null;
            }

        }
        if(tabToActivate != null) activateTab(tabToActivate);
    }
    }
}


/*
 * Tab activation
 */
function activateTab(tabObj) {
    var idData      = new String(tabObj.id).split('-');
    var tabSetID    = idData[3];
    var tabSetType  = tabData.active[tabSetID].type;
    var clickTabID  = idData[4];

    // Clear active tab
    if(tabData.active[tabSetID].currTab != null) {
        var currTabID  = tabData.active[tabSetID].currTab;
        var currOffset = tabData.types[tabSetType][currTabID];
        tabData.active[tabSetID].tabRefs[currTabID].style.backgroundPosition = '-' + currOffset + 'px 0px';
        tabData.active[tabSetID].contentRefs[currTabID].style.display = 'none';
    }

    // Activate new tab
    var clickOffset = tabData.types[tabSetType][clickTabID];
    tabData.active[tabSetID].tabRefs[clickTabID].style.backgroundPosition = '-' + clickOffset + 'px -18px';
    tabData.active[tabSetID].contentRefs[clickTabID].style.display = 'block';

    tabData.active[tabSetID].currTab = clickTabID;
}


var myportal = "";
myportal = GetCookie("MYPORTAL");
if (myportal != '') {
	user = GetCrumb(myportal, "em");
	if (user != '') {
		loggedin = true;
	}
	greeting = GetCrumb(myportal, "gt");
	zipCode  = GetCrumb(myportal, "zip");
	areaCode = GetCrumb(myportal, "npa");
	isPrimary = (GetCrumb(myportal, "ipr") == 'y')?true:false;
	var p = GetCrumb(myportal, "p");
	if (p != '') haspreferences = true;
}

function getZipCode() {
    return zipCode;
}


function fanPopup(url) {
	if (hasRightVersion) { 
		window.open(url, "thefan", "scrollbars=no,status=no,location=no,toolbar=no,favorites=no,address=no,menubar=no,resizable=yes,width=560,height=625");
	}
	else {
		document.location.href = "/flashUpgrade.html";
	}
}

function nhlPopup(game) {
	var url = (loggedin || isInNetwork) ? domain + "/sports/nhl/player/index.jsp?gameType=game" + game : "/signin.jsp?redirectUrl=" + escape(domain + "/sports/nhl/player/index.jsp?gameType=game" + game + "&redirected=true");
	var win = (loggedin || isInNetwork) ? "width=730,height=688" : "width=789,height=706";
	window.open(url, game, "scrollbars=no,status=yes,statusbar=yes,location=no,toolbar=no,favorites=no,address=no,menubar=no,resizable=yes," + win);
}

function askPopup(url) {
	if (hasRightVersion) { 
		window.open(url, "askcomcast", "scrollbars=no,status=no,location=no,toolbar=no,favorites=no,address=no,menubar=no,resizable=yes,width=520,height=482");
	}
	else {
		document.location.href = "/flashUpgrade.html";
	}
}

function askPopupF(url) {
	if (hasRightVersion) { 
		window.open(url, "askcomcast", "scrollbars=no,status=no,location=no,toolbar=no,favorites=no,address=no,menubar=no,resizable=yes,width=520,height=482");
	}
	else {
		document.location.href = "/flashUpgrade.html";
	}
}

function slidePopup(url) {
	window.open(url, "slideshow", "scrollbars=auto,status=no,location=no,toolbar=no,favorites=no,address=no,menubar=no,resizable=yes,width=600,height=650");
}

function slideClose(url) {
	opener.document.location.href = url;
	self.close();
	return false;
}

function pageLoad() {
	externalLinks();
	if(typeof(initTabs) != 'undefined') initTabs();
	
	if(document.location.hash != null && document.location.hash != '') return;
	
	/* Initialize search box */
	if(document.getElementById('search-field') == null) return;
	var usernameField = document.getElementById('user');
	if(usernameField == null) {
	    setTimeout("document.getElementById('search-field').focus();", 1);
	} else {
	   setTimeout("document.getElementById('user').focus();", 1);
	}
	
	document.onkeydown = function(evt) {
	   var evt = (evt != null) ? evt : ((event != null) ? event : null);
	   if(!evt) return;
	   if(evt.altKey || evt.ctrlKey) return; // Modifier keys active
	   
	   var target = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	   if(target == null) return;
	   
	   var nodeName  = (target.nodeName != null) ? new String(target.nodeName).toLowerCase() : '';
	   var typeValue = (target.type != null) ? new String(target.type).toLowerCase() : '';
	   
	   /* Header Search box */
	   if(target.id != null && target.id == 'search-field') {
            var keyCode = parseInt(evt.keyCode);
            if(keyCode == 13) return; // Enter/Return
            if(keyCode == 38 || keyCode == 40 || keyCode == 33 || keyCode == 34) { // Up/down arrows, Page up/down
                //target.blur(); 
                setTimeout("document.getElementById('search-field').blur();", 1);
            }
	   /* Other text/textarea */
	   } else if((nodeName == 'input' && (typeValue == 'text' || typeValue == 'password')) || nodeName == 'textarea') {
	       return;
	   
	   /* Other nodes/document body */
	   } else {
	       if(evt.keyCode == null) return;
	       var searchNode = document.getElementById("search-field");
	       if(evt.keyCode > 47 && evt.keyCode < 112) {
	           var keyValue = String.fromCharCode(evt.keyCode)[evt.shiftKey ? 'toUpperCase' : 'toLowerCase']();
	           if(!is_safari) searchNode.value += keyValue;
	           setTimeout("document.getElementById('search-field').focus();", 1);
	       }
	   }
	}
	
	//alert("page loaded");
}

/*
 * URL Randomizer
 *
 * Returns original URL with a random integer appended as an argument, prevents caching
 */
function randomizeURL(url) {
    return url + ((url.indexOf('?') != -1) ? '&random=' : '?random=') + Math.floor(Math.random() * 999999);
}



function disneyConnection(url) {
var title = "Welcome to Disney Connection!";
var myname = "disneyConnectionAuth"; 
var width = "800"; 
var height = "500"; 
var winl = (screen.width - width) / 2;
var wint = (screen.height - height) / 2;
features = 'toolbar=yes,height='+height+',width='+width+',top='+wint+',left='+winl+',scrollbars=yes,';

if(self.SymRealWinOpen) {
	window.open=SymRealWinOpen; 
} 
 
	var uri = '/kids/';
	var referrer = "";
	var extra = "";
	var internal = false;
	if (uri.indexOf(".exlink") == -1) {
		if (internal) {
			uri += ".inlink";
		} else {
		uri += ".exlink";
		}
	}
	setTitle(title);
	DCS = new Object();
	DCS.dcsuri = uri;
	DCS.dcspro = window.location.protocol;
	DCS.dcssip = window.location.hostname;
	var dCurrent = new Date();
	DCS.dcsdat = dCurrent.getTime();
	
	if (referrer.length == 0) {
		referrer = window.location.href;
	}
	
	DCS.dcsref = referrer;
	var query = getTitle() + dcsDCS() + extra + ((url.length > 0) ? "&CM.url=" + url : "");
	dcsTrack(query);
	
	if (url.length > 0) {
		if (internal) {
			window.location = url;
		} else {
			width = castInt(width);
			height = castInt(height);
			var params = "";
				if (width > 0) {
					params += (params != null && params.length > 0) ? "," : "";
					params += "width=" + width;
				}
				if (height > 0) {
					params += (params != null && params.length > 0) ? "," : "";
					params += "height=" + height;
				}
				if (features != null && features.length > 0) {
					params += (params != null && params.length > 0) ? "," : "";
					params += features;
				}
			window.open(url, "tracking", params);
			}
		}
}


window.onload = pageLoad;


// To preload images in javascript
function cacheImage(tmpSrc) {
    var tmpImg = new Image();
    tmpImg.src = tmpSrc;
    return tmpImg;
}


function appendBreadcrumbList(crumbs) {
    if (document.getElementById('breadcrumb2')) {
        for (x=0; x<crumbs.length; x++) {
            appendBreadcrumb(crumbs[x]);
        }
    }
}


function appendBreadcrumb(crumbObj) {
    if (typeof(crumbObj) != 'object'
      || crumbObj.text == null
      || crumbObj.href == null) return false;
    
    // Identify last dd tag in breadcrumb
    var breadBox = document.getElementById('breadcrumb');
    var breadLoaf = breadBox.getElementsByTagName('dd')[0];
    var newLink = '&#160;<span>&gt;</span>&#160' +'<a href="' + crumbObj.href + '">' + crumbObj.text + '</a>';
    breadLoaf.innerHTML += newLink;
}


function removeFaqCrumbs() {
    if (document.getElementById('breadcrumb2')) {
        var refContent = document.getElementById('content');
        var topModule = refContent.getElementsByTagName('div')[0];
        var breadBox = topModule.getElementsByTagName('h4')[0];
        var crumbs = breadBox.getElementsByTagName('a');
        
        // Ignore first crumb ('FAQ')
        var crumbReturn = [];
        for(x=0; x<crumbs.length; x++) {
            var rawLink = new String(crumbs[x].href);
            if(rawLink.indexOf('.com/') == -1) {
                var outLink = rawLink;
            } else {
                var outLink = rawLink.substr(rawLink.indexOf('.com/') + 4);
            }
            
            crumbReturn[crumbReturn.length] = {text:crumbs[x].innerHTML, href:outLink};
        }
        
        breadBox.style.display = 'none';
        breadBox.style.visibility = 'hidden';
        return crumbReturn;
    }
}

function photoPopup() {
var width='533';
if(width != null && width.length != 0) width = parseInt(width) + 32;
else width = 600;

var height='400';
if(height != null && height.length != 0) height = parseInt(height) + 148;
else height = 700;

window.open(''.concat('/data/home/photopopup.html?random=',Math.random()), 'Photo', 'width=' + width + ',height=' + height + ',hotkeys=no,status=no,resizable=yes,scrollbars=no');
}

/******** start page scrolling *********/
function ScrollProps() {
    this.begin;
    this.end;
    this.start;
    this.change;
    this.dur = 1000;
}

var xScroll = new ScrollProps();
var yScroll = new ScrollProps();
var psintv;

function easeOut(t, b, c, d) {
    return -c *(t/=d)*(t-2) + b;
}

function pageScroll() {
    var elapsed = (new Date()).getTime() - yScroll.start;
    //alert(elapsed+" : "+yScroll.dur);
    if (elapsed < yScroll.dur) {
        scrollTo(
            easeOut(elapsed, xScroll.begin, xScroll.change, xScroll.dur),
            easeOut(elapsed, yScroll.begin, yScroll.change, yScroll.dur)
        );
    } else {
        scrollTo(xScroll.end,yScroll.end);
        clearInterval(psintv);
    }
}

function jumpTo(x,y) {
    yScroll.begin = getWindowYOffset();
    yScroll.end = y;
    yScroll.start = (new Date()).getTime();
    yScroll.change = yScroll.end - yScroll.begin;

    xScroll.begin = getWindowXOffset();
    xScroll.end = x;
    xScroll.start = yScroll.start;
    xScroll.change = xScroll.end - xScroll.begin;

    clearInterval(psintv);
    psintv = setInterval("pageScroll()",10);
    //alert(getWindowXOffset()+" : "+getWindowYOffset());
}

var d = document;
var checkObj = d.all ? (d.getElementById?3:2) : (d.getElementById?4:(d.layers?1:0));

function getWindowXOffset(){
    if(checkObj == 2 || checkObj == 3){
        if (document.documentElement && document.documentElement.scrollTop) {
            return document.documentElement.scrollLeft;
        } else {
            return d.body.scrollLeft;
        }
    }else if(checkObj == 1 || checkObj == 4){
        return window.pageXOffset;
    }
}

function getWindowYOffset(){
    if(checkObj == 2 || checkObj == 3){
        if (document.documentElement && document.documentElement.scrollTop) {
            return document.documentElement.scrollTop;
        } else {
            return document.body.scrollTop;
        }
    } else if(checkObj == 1 || checkObj == 4){
        return window.pageYOffset;
    }
}
/******** end page scrolling *********/




/**************************************
 *
 *  'js/flash_detection.js' FUNCTIONS & VARIABLES
 *
 *************************************/


var flash2Installed = false;    // boolean. true if flash 2 is installed
var flash3Installed = false;    // boolean. true if flash 3 is installed
var flash4Installed = false;    // boolean. true if flash 4 is installed
var flash5Installed = false;    // boolean. true if flash 5 is installed
var flash6Installed = false;    // boolean. true if flash 6 is installed
var flash7Installed = false;    // boolean. true if flash 7 is installed
var flash8Installed = false;    // boolean. true if flash 8 is installed
var flash9Installed = false;    // boolean. true if flash 9 is installed
var maxVersion = 9;             // highest version we can actually detect
var actualVersion = 0;          // version the user really has
var requiredVersion = 7;        // version the user needs to view site (max 9, min 2)
var hasRightVersion = false;    // boolean. true if it's safe to embed the flash movie in the page
var jsVersion = 1.0;            // the version of javascript supported

// Check the browser...we're looking for ie/win, but not aol
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; // true if we're on windows

// This is a js1.1 code block, so make note that js1.1 is supported.
jsVersion = 1.1;

// Write vbscript detection on ie win. IE on Windows doesn't support regular
// JavaScript plugins array detection.
if(isIE && isWin) {
    document.write('<SCR' + 'IPT LANGUAGE="VBScript"\> \n');
    document.write('on error resume next \n');
    document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
    document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
    document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
    document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
    document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
    document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
    document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
    document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
    document.write('<\/SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

function detectFlash() {
    // If navigator.plugins exists...
    if (navigator.plugins) {
        // ...then check for flash 2 or flash 3+.
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
          var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
          var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
          var flashVersion = parseInt(flashDescription.substring(16));

          flash2Installed = flashVersion == 2;
          flash3Installed = flashVersion == 3;
          flash4Installed = flashVersion == 4;
          flash5Installed = flashVersion == 5;
          flash6Installed = flashVersion == 6;
          flash7Installed = flashVersion == 7;
          flash8Installed = flashVersion == 8;
          flash9Installed = flashVersion >= 9;
        }
    }

    for (var i = 2; i <= maxVersion; i++) {
        if (eval("flash" + i + "Installed") == true) actualVersion = i;
    }

    if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 4;

    if (actualVersion < requiredVersion) {
        /*if (document.location.href == "http://www.comcast.net/") {
        	document.location.href = "/flashUpgrade.html";
        }*/
	} else {
        hasRightVersion = true;
    }
}


function writeFlash(name, file, width, height, bgcolor, wmode) {
    bgcolor = (bgcolor==null) ? "#FFFFFF" : bgcolor;
    wmode = (wmode==null) ? "opaque" : wmode;
    document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' id='"+name+"' width='"+width+"' height='"+height+"'>");
    document.write('  <param name="allowScriptAccess" value="sameDomain" />');
    document.write("  <param name='movie' value='"+file+"'>");
    document.write("  <param name='wmode' value='"+wmode+"'>");
    document.write("  <param name='quality' value='high'>");
    document.write("  <param name='bgcolor' value='" + bgcolor + "'>");
    document.write("  <param name='menu' value='false'>");
    document.write("  <embed src='"+file+"' bgcolor='"+bgcolor+"' name='"+name+"' width='"+width+"' height='"+height+"' wmode='"+wmode+"' quality='high' menu='false' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>");
    document.write("</object>");
}


var flashcookie = GetCookie("FPO");
var clientprefs = GetCookie("CLIENTPREFS");

if (clientprefs != "") {
	var flashVersion = GetCrumb(clientprefs, "fpo");
	var upgradeMsg = GetCrumb(clientprefs, "umsg");
}


function upgrade() {
	var upgradeMessage = '';
	var flashTitle = 'Visit our Upgrade page to download the Macromedia Flash 7 player.';
	var browserTitle = 'Visit our Upgrade page to download a new web browser.';
	
	var upgrade1 = '<div id="upgradebar"><p>';
	var upgrade2 = ' <span id="upgrade-close"><a href="#" onclick="hideUpgrade()" title="Do not show me this message again.">Do not show me this message again.</a></span>';
	var upgrade3 = '</p></div>';

    if ((upgradeMsg != "off") || (flashcookie == null)) {
        if ((!document.getElementById) && (!hasRightVersion)) {
            upgradeMessage = 'We recommend that you upgrade your <a href="/browserUpgrade.html" title="' + browserTitle + '">Web browser</a> and <a href="/flashUpgrade.html" title="' + flashTitle + '">Macromedia Flash</a> to view the full experience of Comcast.net.';
        } else if ((!hasRightVersion) && (document.getElementById)) {
            upgradeMessage = 'We recommend that you upgrade to the latest version of <a href="/flashUpgrade.html" title="' + flashTitle + '">Macromedia Flash</a> to view the full experience of Comcast.net.';
            document.getElementById("breadcrumb").style.top = "130px";
        } else if (!document.getElementById) {
            upgradeMessage = 'We recommend that you upgrade your <a href="/browserUpgrade.html" title="' + browserTitle + '">Web browser</a> to view the full experience of Comcast.net.';
        } else {
            upgrade1 = "";
            upgradeMessage = "";
            upgrade2 = "";
            upgrade3 = "";
        }
        
        document.write(upgrade1 + upgradeMessage);
        if (document.getElementById) document.write(upgrade2);
        document.write(upgrade3);
	}
}


function hideUpgrade() {
	document.getElementById("upgradebar").style.display = "none";
	document.getElementById("breadcrumb").style.top = "110px";
	
	var prefString = "fpo=" + flashVersion + "&umsg=off";
	setCookie("CLIENTPREFS", prefString, 360, "/");
}


function setOverride(ver) {
	var prefString = "fpo=" + ver + "&umsg=" + upgradeMsg;
	setCookie("CLIENTPREFS", prefString, 360, "/");
	window.location.replace("/");
}

detectFlash();




/**************************************
 *
 *  'js/checkNetwork.js' FUNCTIONS
 *
 *************************************/

if (document.location.href.indexOf('www.comcast.net') != -1) {
	var _networkDebug = false;
	var triedsettingcookie = false;
	var isInNetwork = false;
	var hasIsInNetworkCookieSet = false;
	var networkCookie = GetCookie("ISINNETWORK");
	
	if (networkCookie != '') {
		var isInNetworkCheck = GetCrumb(networkCookie, "network");
		isInNetwork = (isInNetworkCheck == 'comcast') || (networkCookie == "comcast");
		if (_networkDebug) {
			alert("isInNetworkCheck=" + isInNetworkCheck);
		}
		hasIsInNetworkCookieSet = true;
	}
	
	if (_networkDebug) {
		alert("isInNetwork=" + isInNetwork + ",hasIsInNetworkCookieSet=" + hasIsInNetworkCookieSet+ ",networkCookie=" + networkCookie);
	}
	
if (!hasIsInNetworkCookieSet) {
		var urlSearch = location.search.substr(1);
		var parms = urlSearch.split("&");
		for(idx = 0; idx < parms.length; idx++) {
	        var parm = parms[idx].split("=");
		if (parm[0] == "cookieattempt" && parm[1] == "1") {
			triedsettingcookie = true;
			break;
			} 
		}
	if (!triedsettingcookie){  
		if (parms == "")
		{
		window.location="/CheckIsInNetwork?redirectUrl="+document.URL+"?cookieattempt=1";
		}
		else
		{
		var encodedurl = document.URL.replace("&","%26");
		window.location="/CheckIsInNetwork?redirectUrl="+encodedurl+"%26cookieattempt=1";
		}
	}
}
}


/**************************************
 *
 *  'js/wt_lib.js' FUNCTIONS & VARIABLES
 *
 *************************************/

var dcsTesting = false;
if (dcsTesting && isProduction()) {
    //insurance in case it is true in production
    dcsTesting = false;
}
var dcsHTML = 0;
var dcsPOLL = 1;
var dcsEXPLORE = 2;
var dcsEXPRESS = 3;
var dcsLITE = 4;

var dcsDomain = "ssdc.comcast.net";

var dcsURI = "";
var dcsTitle = "";
var dcsHeadlines = "";
var dcsModules = "";
var dcsBanners = "";
var dcsRef = "";

/* Images Array */
var gImages = new Array;
var gIndex = 0;

/* Objects to hold the meta data */
                                //This is what they appear to hold
var DCS = new Object();			//holds browser url information
var WT = new Object();			//holds user information, screen size, date, browser type, etc...
var COMCAST = new Object();		//all tags not included in the other groups






/**************************************
 *
 *  'SET' FUNCTIONS
 *
 *************************************/

function dcsClearValues() {
    dcsID = "";
    dcsURI = "";
    dcsTitle = "";
    dcsModules = "";
    dcsBanners = "";
    dcsRef = "";
    dcsSIP = window.location.hostname;
}
function setModule(name) {
    if (dcsModules.length == 0) {
        dcsModules = name
    } else {
        dcsModules += ";" + name;
    }
}
function setHeadlines(name) {
    if (dcsHeadlines.length == 0) {
        dcsHeadlines = name
    } else {
        dcsHeadlines += ";" + name;
    }
}
function setBanner(name) {
    if (dcsBanners.length == 0) {
        dcsBanners = name
    } else {
        dcsBanners += ";" + name;
    }
}
function addBanner(name) {
    setBanner(name);
}
function setTitle(title) {
    if (typeof title == "undefined" || title == null) {
        title = "";
    }
    dcsTitle = title;
}
function setURI(uri) {
    if (typeof uri == "undefined" || uri == null) {
        uri = "";
    }
    dcsURI = uri;
}
function setReferrer(ref) {
    if (typeof ref == "undefined" || ref == null) {
        ref = "";
    }
    dcsRef = ref;
}




/**************************************
 *
 *  'GET' FUNCTIONS
 *
 *************************************/


function getID(type) {
    var id = "dcskz8vvr00000c9f3oy3ybgs_3d5h"; //use as default if nothing else found
    if (isProduction()) {
        switch (type) {
            case dcsPOLL:
                id = "dcs7bjhh110000oyioyaka1kl_7j9u";
                break;
            case dcsHTML:
                id = "dcskz8vvr00000c9f3oy3ybgs_3d5h";
                break;
            case dcsEXPLORE:
                id = "dcs8ir0f010000oyioyaka1kl_8j7n";
                break;
            case dcsEXPRESS:
                id = "dcsc5owwq00000kv5xgto5tru_4j8e";
                break;
            case dcsLITE:
                id = "dcsigvpg110000oyioyaka1kl_7j7v";
                break;
        }
    } else {
        id = "dcscah7h110000oyioyaka1kl_7j8d";
    }
    return id;
}
function getModule() {
    return append("CM.mn", dcsModules);
}
function getHeadlines() {
    return append("CM.hl", dcsHeadlines);
}
function getBanner() {
    return append("WT.ad", dcsBanners);
}
function getTitle() {
    return append("WT.ti", dcsTitle);
}
function getURI() {
    return append("dcsuri", dcsURI);
}
function getSIP() {
    return append("dcssip", dcsSIP);
}
function getFlashVersion() {
    return append("CM.flashver", actualVersion);
}
function getReferrer() {
    if (dcsRef.length > 0) {
        return append("dcsref", dcsRef);
    } else {
        if ((window.document.referrer != "") && (window.document.referrer != "-")) {
            return append("dcsref", new String(window.document.referrer));
        }
    }
    return "";
}



/**************************************
 *
 *  'DCS' (?) Methods
 *
 *************************************/

function append(name, value) {
    //appends a name value pair to the querystring
    if (typeof value == "undefined" || value == null) {
        value = "";
    } else {
        value += "";
    }
    if (value.length > 0) {
        return "&" + name + "=" + escape(value);
    } else {
        return "";
    }
}
function dcsComcast() {
    var query = "";
    for (name in COMCAST) {
        if (COMCAST[name]) {
            query += append(name, COMCAST[name]);
        }
    }
    return query;
}
function dcsDCS() {
    var query = "";
    for (name in DCS) {
        if (DCS[name]) {
            if (name == "dcsuri") {
                var str = DCS[name];
                var subStr = "/qry/myhome";
                var index = str.indexOf(subStr);
                if (index >= 0) {
                    index += subStr.length;
                    DCS[name] = str.substring(0, index);
                }
            }
            query += append(name, DCS[name]);
        }
    }
    return query;
}
function dcsWT() {
    var query = "";
    for (name in WT) {
        if (WT[name]) {
            query += append("WT." + name, WT[name]);
        }
    }
    return query;
}
function dcsTag() {
    var query = "";
    query += dcsComcast();
    query += dcsDCS();
    query += dcsWT();
    query += getModule() + getBanner() + getHeadlines() + getFlashVersion();
    dcsTrack(query);
}
function dcsCreateImage(dcsSrc) {
    //final call to write the image
    //when image loads the page is tracked
    if (dcsTesting) {
        displayInWindow(dcsSrc);
    } else {
        if (document.images) {
            gImages[gIndex] = new Image;
            gImages[gIndex].src = dcsSrc;
            gIndex++;
        } else{
            document.write("<img alt=\"\" border=\"0\" height=\"1\" name=\"DCSIMG\" src=\"" + dcsSrc + "\" width=\"1\">");
        }
    }
}
function dcsTrack(query, type) {
    /*if (typeof type == "undefined") {
        type = dcsHTML;
    }
    var path = "http" + (window.location.protocol.indexOf('https:') == 0 ? "s" : "") + "://" + dcsDomain + "/" + getID(type) + "/dcs.gif?";
    if (query.indexOf("&") == 0) {
        query = query.substring(1);
    }
    path += query;
    if (path.length > 2040 && navigator.userAgent.indexOf('MSIE') >= 0) {
        path = path.substring(0, 2040) + "&WT.tu=1";
    }
    dcsCreateImage(path);
    dcsClearValues();*/	//clear all values when finished to prepare for other calls
}
//Fill Variables
//************************************************************************************************************************************
function dcsVar() {
    //creates the main objects with some generic information
    //stuff can be added here or removed
    var dCurrent = new Date();
    WT.tz = dCurrent.getTimezoneOffset() / 60 * -1;
    WT.bh = dCurrent.getHours();
    WT.ul = navigator.appName == "Netscape" ? navigator.language : navigator.userLanguage;
    if (typeof(screen) == "object") {
        WT.cd = screen.colorDepth;
        WT.sr = screen.width + "x" + screen.height;
    }
    if (typeof(navigator.javaEnabled()) == "boolean") {
        WT.jo = navigator.javaEnabled() ? "Yes" : "No";
    }
    WT.ti = document.title;
    WT.js = "Yes";
    if (typeof(gVersion) != "undefined") {
        WT.jv = gVersion;
    }
    DCS.dcsuri = window.location.pathname;
    DCS.dcsqry = window.location.search;
    if ((window.document.referrer != "") && (window.document.referrer != "-")) {
        if (!(navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) < 4)) {
            DCS.dcsref = window.document.referrer;
        }
    }
    DCS.dcssip = window.location.hostname;
    DCS.dcsdat = dCurrent.getTime();
}
function dcsMeta() {
    //loops through meta tags and records them in the objects
    var myDocumentElements;
    if (document.all) {
        myDocumentElements = document.all.tags("meta");
    } else if (document.documentElement) {
        myDocumentElements = document.getElementsByTagName("meta");
    }
    if (typeof(myDocumentElements) != "undefined") {
        for (var i = 0 ; i < myDocumentElements.length ; i++) {
            myMeta = myDocumentElements.item(i);
            if (myMeta.name) {
                if (myMeta.name.indexOf("WT.") == 0) {
                    WT[myMeta.name.substring(3)] = myMeta.content;
                } else if (myMeta.name.indexOf("DCS.") == 0) {
                    DCS[myMeta.name.substring(4)] = myMeta.content;
                } else {
                    //added as a catch all for all meta tags to be tagged
                    COMCAST[myMeta.name] = myMeta.content;
                }
            }
        }
    }
}


/**************************************
 *
 *  GENERAL UTILITY FUNCTIONS
 *
 *************************************/

function castBoolean(param) {
    if (typeof param != "boolean") {
        param = castString(param).toLowerCase();
        if (param.length == 0 || param == "true" || param == "1") {
            param = true;
        } else {
            param = false;
        }
    }
    return param;
}

function castString(param) {
    if (typeof param == "undefined" || param == null) {
        param = "";
    } else if (typeof param != "string") {
        param += "";
    }
    return param;
}

function castInt(param) {
    if (isNaN(param)) {
        param = -1;
    } else {
        param = parseInt(param, 10);
    }
    return param;
}

function displayInWindow(str) {
    if (dcsTesting) {
        var win = window.open("", "", "height=400,width=400,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
        win.document.writeln("<html><head><title>Tracking Testing</title></head><body><textarea style=\"height:375px;width:375px;\">" + str + "</textarea></body></html>");
    }
}

function displayArguments() {
    if (dcsTesting) {
        var message = "";
        for (var x = 0 ; x < arguments.length ; x++) {
            if (arguments[x].length > 0) {
                message += x + ": " + arguments[x] + "\n";
            }
        }
        if (message.length > 0) {
            displayInWindow("Parameters:<br />" + message);
        }
    }
}

function wtParseParamString(query) {
    var args = new Object();
    var pairs = query.split("&");					//break on each &
    for (var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=');			//look for name=value
        if (pos == -1) continue;					//if not found, skip
        var argname = pairs[i].substring(0, pos);	//extract name
        var value = pairs[i].substring(pos+1);		//extract value
        args[argname] = unescape(value);			//store as a property
    }
    return args;									//return object
}

function wtGetParam(query, parameter) {
    var values = wtParseParamString(query);			//get hashmap object
    var theValue = castString(values[parameter]);
    return theValue;								//return value
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function getElementsByClassName(oElm, strTagName, strClassName){
    /* From: http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ */
    var arrElements = (strTagName == "*" && document.all)? document.all : 
    oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}
Array.prototype.push = ArrayPush;
function ArrayPush(value){
    this[this.length] = value;
}



//
// These two functions create navigational select boxes from any select box with the class of "select-box-nav"
//
function selectBoxNavInitialization() {
    var theSelects = getElementsByClassName(document, "select", "select-box-nav");
    for (var i=0; i<theSelects.length; i++) {
        eval('theSelects[i].onchange = function () { selectBoxNavExec(theSelects['+i+']); }');
    }
}
addLoadEvent(selectBoxNavInitialization);

function selectBoxNavExec(theSelect) {
    destination = theSelect.options[theSelect.selectedIndex].value;
    if (destination) location.href = destination;
}
        







/**************************************
 *
 *  NAVIGATION TRACKING FUNCTIONS
 *
 *************************************/


/* Call Tracking - banner */
function trackBanners(uri, name, referrer, url, newWindow, extra) {
    uri = castString(uri);
    name = castString(name);
    referrer = castString(referrer);
    url = castString(url);
    extra = castString(extra);
    newWindow = castBoolean(newWindow);
    if (uri.indexOf(".banner") == -1) {
        uri += ".banner";
    }
    if (name.length == 0) {
        name = "UnknownName";
    }
    DCS = new Object();
    DCS.dcsuri = uri;
    DCS.dcspro = window.location.protocol;
    DCS.dcssip = window.location.hostname;
    var dCurrent = new Date();
    DCS.dcsdat = dCurrent.getTime();
    if (referrer.length == 0) {
        referrer = window.location.href;
    }
    DCS.dcsref = referrer;
    var query = append("WT.ac", name) + dcsDCS() + extra;
    dcsTrack(query);
    if (url.length > 0) {
        if (newWindow) {
            window.open(url, "tracking");
        } else {
            window.location = url;
        }
    }
}
	
/* Call Tracking - external link */
function trkLink(uri, title, referrer, url, extra, internal, width, height, features) {
    uri = castString(uri);
    title = castString(title);
    referrer = castString(referrer);
    url = castString(url);
    extra = castString(extra);
    features = castString(features);
    internal = castBoolean(internal);
    if (uri.indexOf(".exlink") == -1) {
        if (internal) {
            uri += ".inlink";
        } else {
            uri += ".exlink";
        }
    }
    setTitle(title);
    DCS = new Object();
    DCS.dcsuri = uri;
    DCS.dcspro = window.location.protocol;
    DCS.dcssip = window.location.hostname;
    var dCurrent = new Date();
    DCS.dcsdat = dCurrent.getTime();
    if (referrer.length == 0) {
        referrer = window.location.href;
    }
    DCS.dcsref = referrer;
    var query = getTitle() + dcsDCS() + extra + ((url.length > 0) ? "&CM.url=" + url : "");
    dcsTrack(query);
    if (url.length > 0) {
        if (internal) {
            window.location = url;
        } else {
            width = castInt(width);
            height = castInt(height);
            var params = "";
            if (width > 0) {
                params += (params != null && params.length > 0) ? "," : "";
                params += "width=" + width;
            }
            if (height > 0) {
                params += (params != null && params.length > 0) ? "," : "";
                params += "height=" + height;
            }
            if (features != null && features.length > 0) {
                params += (params != null && params.length > 0) ? "," : "";
                params += features;
            }
            window.open(url, "tracking", params);
        }
    }
}
	
function trkExLink(uri, title, referrer, url, extra) {
    //deprecated.  made a more general function
    trkLink(uri, title, referrer, url, extra, false);
}

function linkTracking(name, redirect, windowName, params) {
    //deprecated.  old code
    trkLink(name, "Old Tracking", "", redirect, "", false);
}

function trackExternalLink(uri, title, referrer, url, extra) {
    //deprecated.  function name too long for flash.
    trkLink(uri, title, referrer, url, extra, false);
}
	
/* Call Tracking - Poll */
function trackPoll(uri, value) {
    uri = castString(uri);
    value = castString(value);
    setURI(uri);
    setTitle("Comcast Polls");
    var query = getURI() + getTitle() + "&" + value;
    dcsTrack(query, dcsPOLL);
}
	
/* Call Tracking - new Portal */
function trackPortal(params) {
    var query = "";
    query += dcsComcast();
    query += dcsDCS();
    query += dcsWT();
    query += getModule() + getBanner() + getHeadlines() + getFlashVersion();
    params = castString(params);
    params = unescape(params);
    params = query + params;
    if (params.indexOf("CM.site=explore") > -1) {
        dcsTrack(params, dcsEXPLORE);
    } else if (params.indexOf("CM.site=express") > -1) {
        dcsTrack(params, dcsEXPRESS);
    } else if (params.indexOf("CM.site=lite") > -1) {
        dcsTrack(params, dcsLITE);
    } else {
        dcsTrack(params);
    }
}

function trackPortalLink(params, url, trgt) {
    var query = "";
    query += dcsComcast();
    query += dcsDCS();
    query += dcsWT();
    query += getModule() + getBanner() + getHeadlines() + getFlashVersion();
    params = castString(params);
    params = unescape(params);
    params = query + params;
    url = castString(url);
    url = unescape(url);
    trgt = castString(trgt);
    trgt = unescape(trgt);
    if (params.indexOf("CM.site=explore") > -1) {
        dcsTrack(params, dcsEXPLORE);
    } else if (params.indexOf("CM.site=express") > -1) {
        dcsTrack(params, dcsEXPRESS);
    } else if (params.indexOf("CM.site=lite") > -1) {
        dcsTrack(params, dcsLITE);
    } else {
        dcsTrack(params);
    }
    window.open(url, trgt);
}
	
/* Call Tracking - Top Nav */
function pTopNav(params) {
    //tracks a cover external link
    //character saver function for the cover
    var uri = "/topnav.swf";
    var referrer = wtGetParam(params, "r");
    var theLink = wtGetParam(params, "l");
    var extra = wtGetParam(params, "e");
    extra = stringReplace(extra, ";;;", "&") + "&CM.gc=" + wtGetParam(params, "i");
    if (extra.indexOf("&sw=1") > -1) {
        extra = stringReplace(extra, "&sw=1", "");
        trkLink(uri, "", referrer, theLink, extra, true);
    } else {
        var width = wtGetParam(params, "w");
        var height = wtGetParam(params, "h");
        var features = wtGetParam(params, "f");
        extra = stringReplace(extra, "&sw=0", "");
        trkLink(uri, "", referrer, theLink, extra, false, width, height, features);
    }
}
	
/* Call Tracking - Cover */
function pCoverL(params) {
    params = castString(params);
    //tracks a cover external link
    //character saver function for the cover
    var uri = wtGetParam(params, "u");
    var title = wtGetParam(params, "t");
    var referrer = wtGetParam(params, "r");
    var theLink = wtGetParam(params, "l");
    var extra = wtGetParam(params, "e");
    extra = unescape(extra);		
    extra = stringReplace(extra, ";;;", "&");
    if (extra.indexOf("&sw=1") > -1) {
        extra = stringReplace(extra, "&sw=1", "");
        trkLink(uri, title, referrer, theLink, extra, true);
    } else {
        extra = stringReplace(extra, "&sw=0", "");
        trkLink(uri, title, referrer, theLink, extra, false);
    }
}
function pCover(params) {
    params = castString(params);
    //character saver function for the cover
    var uri = wtGetParam(params, "u");
    var title = wtGetParam(params, "t");
    var referrer = wtGetParam(params, "r");
    var extra = wtGetParam(params, "e");
    extra = unescape(extra);
    extra = stringReplace(extra, ";;;", "&");
    trackFlash(uri, title, referrer, extra);
}

/* Call Tracking - the Fan */
function pFan(params) {
    var trackingSection = wtGetParam(params, "ts");
    var uri = trackingSection + "/fan" + wtGetParam(params, "u") + ".swf";
    var title = wtGetParam(params, "t");
    var referrer = "/fan" + wtGetParam(params, "r") + ".swf";
    var extra = wtGetParam(params, "e");
    extra = stringReplace(extra, ";;;", "&");
    trackFlash(uri, title, referrer, extra);
}

function pFanL(params) {
    var trackingSection = wtGetParam(params, "ts");
    var uri = trackingSection + "/fan" + wtGetParam(params, "u") + ".swf";
    var title = wtGetParam(params, "t");
    var referrer = "/fan" + wtGetParam(params, "r") + ".swf";
    var theLink = wtGetParam(params, "l");
    var extra = wtGetParam(params, "e");
    extra = stringReplace(extra, ";;;", "&");
    trkLink(uri, title, referrer, theLink, extra, false);
}
	
/* Call Tracking - Flash */
function trackFlash(uri, title, referrer, extra) {
    uri = castString(uri);
    title = castString(title);
    referrer = castString(referrer);
    extra = castString(extra);
    setTitle(title);
    DCS = new Object();
    DCS.dcsuri = uri;
    DCS.dcspro = window.location.protocol;
    DCS.dcssip = window.location.hostname;
    var dCurrent = new Date();
    DCS.dcsdat = dCurrent.getTime();
    if (referrer.length == 0) referrer = window.location.href;
    DCS.dcsref = referrer;
    var query = getTitle() + dcsDCS() + extra;
    dcsTrack(query);
}
dcsVar();
dcsMeta();