
// 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 = "http://www.comcast.net";
var sessiondomain = ".comcast.net";
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.



/**
 *  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://stage.comcast.commerce.atomz.com/exec/', 'Search Entertainment', {'fieldname':'q', 'c':'net', 'cat1':'Entertainment'}),
        finance: new HdrSearch("Finance", 'http://stage.comcast.commerce.atomz.com/exec/', 'Search Finance', {'fieldname':'q', 'c':'net', 'cat1':'Finance'}),
        games: new HdrSearch("Games", 'http://stage.comcast.commerce.atomz.com/exec/', 'Search Games', {'fieldname':'q', 'c':'net', 'cat1':'Games'}),
        help: new HdrSearch("Help", 'http://stage.comcast.commerce.atomz.com/exec/', '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://stage.comcast.commerce.atomz.com/exec/', 'Search Game Invasion', {'fieldname':'q', 'c':'net', 'cat1':'Game Invasion'}),
        movies: new HdrSearch("Moves", 'http://stage.comcast.commerce.atomz.com/exec/', 'Search Movies', {'fieldname':'q', 'c':'net', 'cat1':'Movies'}),
        music: new HdrSearch("Music", 'http://stage.comcast.commerce.atomz.com/exec/', 'Search Music', {'fieldname':'q', 'c':'net', 'cat1':'Music'}),
        news: new HdrSearch("News", 'http://stage.comcast.commerce.atomz.com/exec/', 'Search News', {'fieldname':'q', 'c':'net', 'cat1':'News'}),
        //playgames: new HdrSearch("Play Games", 'http://stage.comcast.commerce.atomz.com/exec/', 'Search Play Games', {'fieldname':'q', 'c':'net', 'cat1':'Play Games'}),
        relationships: new HdrSearch("Relationships", 'http://stage.comcast.commerce.atomz.com/exec/', '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://stage.comcast.commerce.atomz.com/exec/', 'Search Sports', {'fieldname':'q', 'c':'net', 'cat1':'Sports'}),
        tv: new HdrSearch("TV", 'http://stage.comcast.commerce.atomz.com/exec/', '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;
	if ((searchTerm == "search the web") || (searchTerm == "")) {
		var redirectTarget = 'http://www.comcast.net/search';
		if(headerSearch.currTab == 'images' || headerSearch.currTab == 'video' || headerSearch.currTab == 'shopping' || headerSearch.currTab == 'news') {
		    redirectTarget += '/' + headerSearch.currTab;
		}
		document.location.href = redirectTarget;
		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 = 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('window.open') != -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 = "/search/videosearch.html?query=" + 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="/' + getFirstFolder() + '">' + getFirstFolder() + '</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">');
		}
	}
}



var isSearchResultsPage = null;
function writeHeaderSearchTabs(tmpID) {
	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>');
    
    if(is_ie && is_mac) {
        setTimeout('handleHeaderTabClick();', 200);
    } else {
        handleHeaderTabClick();
    }
}

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:{
        html:domain + "/query/email/auth.html?rand=" + randomNumber,
        xml:domain + "/query/email/auth.xml?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 = '';
        document.getElementById('email-icon').innerHTML = ' ' + messageCount;
    };
    
    var tmp = emailQuery.request.open("GET", emailQuery.url.xml, 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.html;
    
    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() {
	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="/signin.jsp"><img src="http://media3.comcast.net/images/global/teaser.jpg" alt="Sign in to: create and send multimedia photo shows; send free video emails to your friends and family; watch thousands of free videos from music to movie trailers to news; customize scores stock and bookmarks." /></a></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);
		writeSkyBan("assistant");
	}
	else if ((hasRightVersion) && ((!isInNetwork) && (!loggedin))) {
		document.write(stub);
		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 {
        	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=yes,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=500,height=435");
	}
	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();
	//document.getElementById("search-field").focus();
	//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');
}


/**************************************
 *
 *  '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();