//Variables
//***********************************************************************************************************************************************
var loggedin = false;
var haspreferences = false;
var isPrimary = false;
var firstName = "";
var greeting = "";
var zipCode = "";
var areaCode = "";
var user = "";

//Mail Count
var yhmcount = -1;


var textElementCanUseStyles = (navigator.appVersion.indexOf("MSIE") != -1 || navigator.appVersion.indexOf("4.") == -1);


//Banners
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
//writes a 468x60 banner to the document
function writeBannerRegular(category) {
    var randomNumber = Math.random()*52279;
    document.write("<IFRAME SRC='http://ad.doubleclick.net/adi/comcast.net/;sz=468x60;ord="+randomNumber+"?' name='frame1' width='468' height='60' frameborder='no' border='0' MARGINWIDTH='0' MARGINHEIGHT='0' SCROLLING='no'>");
    document.write("<SCRIPT language='JavaScript1.1' SRC='http://ad.doubleclick.net/adj/comcast.net/;abr=!ie;sz=468x60;ord="+randomNumber+"?'>");
    document.write("</SCRIPT>");
    document.write("</SCRIPT>");
    document.write("<A HREF='http://ad.doubleclick.net/jump/comcast.net/;abr=!ie;sz=468x60;ord="+randomNumber+"?'><IMG SRC='http://ad.doubleclick.net/ad/comcast.net/;abr=!ie;sz=468x60;ord="+randomNumber+"?' border=0 height='60' width='468'></A>");
    document.write("</NOSCRIPT>");
    document.write("</IFRAME>");
}
//writes a 120x600 banner to the document
function writeBannerSkyScraper(category) {
    var minNum = 10000000;
    var maxNum = 99999999;
    var randomNumber = Math.round(Math.random() * (maxNum - minNum)) + minNum;
    var status = ((loggedin) ? "logged" : "anon");
    var term = getParam("query");
    if (is_js < 1.1) {
        document.write('<a href="http://oascentralnx.comcast.net/RealMedia/ads/click_nx.ads/comcast.net/searchresults/1' + randomNumber + '@Right?c=' + status + '&query=' + term + '"><img src="http://oascentralnx.comcast.net/RealMedia/ads/adstream_nx.ads/comcast.net/searchresults/1' + randomNumber + '@Right?c=' + status + '&query=' + term + '"></a>');
    } else {
        document.write('<script 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('</script>');
    }
}

//QueryString Functions
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
/**
 * The following 2 functions return the querystring using javascript.
 * getArgs()
 *     returns the whole querystring as a hashmap object
 * getParam(var parameter)
 *     Convenience function
 *     returns an unecoded value from the querystring based on the parameter
**/
function getArgs() {
    var args = new Object();
    var query = 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
}

//Header Bar Display Functions
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
function displayLoginLogoutButton() {
    if (window.location.href.indexOf("/comcast.html") != -1) {
        return "<img src=\"/images/pixelclear.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" hspace=\"0\" vspace=\"0\">";
    } else if (loggedin) {
	      return "<a href=\"http://www.comcast.net/signout.jsp\"><img src=\"/images/subnav-logout-button.gif\" width=\"49\" height=\"14\" alt=\"\" border=\"0\" hspace=\"0\" vspace=\"0\"></a>";
    } else {
        return "<a href=\"http://www.comcast.net/comcast.html\"><img src=\"/images/subnav-login-button.gif\" width=\"43\" height=\"14\" alt=\"\" border=\"0\" hspace=\"0\" vspace=\"0\"></a>";
    }
}

function displayGreetingYHM() {
    var tmp = "<img alt=\"\" border=\"0\" height=\"1\" src='/images/pixelclear.gif' width=\"1\" />";
    if (loggedin) {
        tmp = getGreeting();
        if (greeting.length >= 1) {
            tmp += ", " + greeting;
        }
        /*
        var ending = "s";
        if (yhmcount == 1) {
            ending = "";
        }
        if (yhmcount != -1) {
            tmp += "&nbsp;&nbsp;<a class=\"whitesmall\" href=\"#\" onclick=\"javascript:window.open('/qry/goto?app=mail', 'Webmail', 'width=800,height=600,location=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes,scrollbars=yes');\">" +
                "You have " + yhmcount + " new message" + ending + "</a>";
        }
        */
    }
    return tmp;
}

function displayEditGreetingButton() {
    var Return = "<img alt=\"\" border=\"0\" height=\"1\" src='/images/pixelclear.gif' width=\"1\" />";
    if (loggedin == true && (location.pathname.indexOf("/home.jsp") == 0 || location.pathname.indexOf("/home.html") == 0 || location.pathname.indexOf("/qry/myhome") == 0) ) {
        Return = "<a href=\"#\" onclick=\"window.open('/providers/greetingProvider/setgreeting.jsp', 'setgreeting', 'width=250,height=110');\"><img alt=\"\" border=\"0\" height=\"13\" src=\"/images/bttn-editgreeting2.gif\" width=\"66\" /></a>";
    }
    return Return;
}

function displayPersonalizeButton() {
    if (loggedin == true && (location.pathname.indexOf("/home.jsp") == 0 || location.pathname.indexOf("/home.html") == 0 || location.pathname.indexOf("/qry/myhome") == 0)) {
        if (actualVersion >= 6) {
            return "<a href=\"javascript:void(0);\" onClick=\"viewPersonalization();\"><img alt=\"\" border=\"0\" height=\"13\" src=\"/images/bttn-layout.gif\" width=\"87\" /></a>";
        } else {
            return "<a href=\"/memberservices/personalize/index.jsp\"><img alt=\"\" border=\"0\" height=\"13\" src=\"/images/bttn-layout.gif\" width=\"87\" /></a>";
        }
    }
    return "<img alt=\"\" border=\"0\" height=\"1\" src=\"/images/pixelclear.gif\" width=\"1\" />";;
}

function viewPersonalization() {
        window.open("/memberservices/personalize/module.jsp","persWinPop","width=730,height=590");
}

function displaySetHomePageButton() {
    var homePageLink = location.protocol + "//" + location.host + "/";
    var Return = "<img alt=\"\" border=\"0\" height=\"1\" src=\"/images/pixelclear.gif\" width=\"1\" />";
    if (loggedin == true && (location.pathname.indexOf("/home.jsp") == 0 || location.pathname.indexOf("/home.html") == 0 || location.pathname.indexOf("/qry/myhome") == 0)) {
        if (is_ie) {
            if (!hp.isHomePage(homePageLink)) {
                Return = "<a href=\"#\" onClick=\"style.behavior='url(#default#homepage)';setHomePage('" + homePageLink + "');\"><img alt=\"\" border=\"0\" height=\"13\" src=\"/images/bttn-homepage.gif\" width=\"133\" /></a>";
            }
        } else if (is_nav) {
            Return = "<a href=\"http://online.comcast.net/help/faq-detail.asp?intFaqID=289\"><img alt=\"\" border=\"0\" height=\"13\" src=\"/images/bttn-homepage.gif\" width=\"133\" /></a>";
        } else {
            //do nothing
        }
    }
    return Return;
}

function getGreeting() {
    var now = new Date();
    var hour = now.getHours();
    var greeting;
    if (hour < 12) {
        greeting = "Good Morning";
    } else if (hour < 17) {
        greeting = "Good Afternoon";
    } else {
        greeting = "Good Evening";
    }

    return greeting;
}

//Module Functions
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
/*Calls
    wideStart(nm, brdr, display);
    wideEnd(brdr, display);
    thinStart(nm, display);
    thinEnd(display);
    customStart(nm, w, brdr, clr, display);
    customEnd(w, brdr, display);
*/
function wideStart(nm, brdr, display) {
    customStart(nm, 371, brdr, null, display);
}
function wideEnd(brdr, display) {
    customEnd(371, brdr, display);
}
function thinStart(nm, display) {
    customStart(nm, 200, "no", null, display);
}
function thinEnd(display) {
    customEnd(200, "no", display);
}
function doubleStart() {
  document.writeln("<tr>");
  document.writeln("  <td class='contentSpace'><img src='/images/pixelclear.gif' width='8' height='1' alt='' border='0' /></td>");
  document.writeln("  <td colspan='3'>");
}
function doubleEnd() {
  document.writeln("  </td>");
  document.writeln("  <td class='contentSpace'><img src='/images/pixelclear.gif' width='8' height='1' alt='' border='0' /></td>");
  document.writeln("</tr>");
}
function customStart(nm, w, brdr, clr, display) {
    document.writeln(customStartReturn(nm, w, brdr, clr, display));
}
function customStartReturn(nm, w, brdr, clr, display) {
    // code to redirect the shopping page
    if (nm=="Amazon") {
        window.location.href="http://shopping.comcast.net";
    }
    // end shopping

    var htmlOut = "";
    nm = nm.toUpperCase();
    w = ((isNaN(w)) ? 200 : parseInt(w));
    clr = (typeof clr == "undefined" || clr == null) ? "#D1DCE2" : clr;
    brdr = (typeof brdr == "undefined" || brdr == null) ? "yes" : brdr;
    display = (typeof display == "undefined" || display == null) ? "yes" : display;
    //tracking
    setModule(nm);
    if (display == "yes" || display == "true") {
        htmlOut =
                "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: " + w + ";\">" +
                "    <tr>" +
                "        <td>" +
                "            <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width: " + w + ";background-color: " + clr + ";\">" +
                "                <tr>" +
                "                    <td align=\"center\" width=\"20\"><img src=\"/images/headerbars/grayDot.gif\" width=\"10\" height=\"10\" /></td>" +
                "                    <td class=\"cBkg\" width=\"" + (w - 20) + "\">" + nm + "</td>" +
                "                </tr>" +
                "            </table>" +
                "        </td>" +
                "    </tr>" +
                "    <tr>" +
                "        <td>" +
                "            <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: " + w + ";\">" +
                "                <tr>";

        if (brdr == "no" || brdr == "false") {
            htmlOut+=
                "                    <td width=\"1\"><img src=\"/images/headerbars/line.gif\" width=\"1\" height=\"6\" border=\"0\" /></td>";
        } else {
            htmlOut+=
                "                    <td bgcolor=\"#D4D6D3\" width=\"1\"><img src=\"/images/headerbars/lineDown.gif\" width=\"1\" height=\"6\" border=\"0\" /></td>";
        }
        htmlOut+=
                "                    <td width=\"" + (w - 75) + "\"><img src=\"/images/headerbars/line.gif\" width=\"" + (w - 75) + "\" height=\"6\" border=\"0\" /></td>" +
                "                    <td width=\"74\" style=\"background-color: " + clr + ";\"><img src=\"/images/headerbars/curve.gif\" width=\"74\" height=\"6\" /></td>" +
                "                </tr>" +
                "            </table>" +
                "        </td>" +
                "    </tr>";
        if (brdr == "no" || brdr == "false") {
            htmlOut+=
                "    <tr><td><img src=\"/images/pixelclear.gif\" width=\"1\" height=\"10\" /></td></tr>" +
                "</table>";
        } else {
            htmlOut+=
                "    <tr>" +
                "        <td>" +
                "            <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: " + w + ";\">" +
                "                <tr>" +
                "                    <td bgcolor=\"#D4D6D3\" width=\"1\"><img src=\"/images/pixelclear.gif\" width=\"1\" height=\"1\" /></td>" +
                "                    <td width=\"" + (w - 2) + "\">" +
                "                        <table border=\"0\" cellpadding=\"10\" cellspacing=\"0\">" +
                "                            <tr>" +
                "                                <td>";
        }
    }
    return htmlOut;
}
function customEnd(w, brdr, display) {
    document.writeln(customEndReturn(w, brdr, display));
}
function customEndReturn(w, brdr, display) {
    var htmlOut = "";
    brdr = (typeof brdr == "undefined" || brdr == null) ? "yes" : brdr;
    display = (typeof display == "undefined" || display == null) ? "yes" : display;
    if (display == "yes" || display == "true") {
        if (brdr == "no" || brdr == "false") {
            htmlOut =
                "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: " + w + ";\">" +
                "    <tr><td height=\"10\"><img src=\"/images/pixelclear.gif\" height=\"10\" /></td></tr>" +
                "</table>";
        } else {
            htmlOut =
                "                                </td>" +
                "                            </tr>" +
                "                        </table>" +
                "                    </td>" +
                "                    <td bgcolor=\"#D4D6D3\" width=\"1\"><img src=\"/images/pixelclear.gif\" width=\"1\" height=\"1\" /></td>" +
                "                </tr>" +
                "            </table>" +
                "        </td>" +
                "    </tr>" +
                "    <tr>" +
                "        <td height=\"1\">" +
                "            <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" c style=\"width: "+w+";\" class=\"cBot\">" +
                "                <tr>" +
                "                    <td bgcolor=\"#D4D6D3\" width=\"16\"><img src=\"/images/pixelclear.gif\" width=\"1\" height=\"1\" border=\"0\" /></td>" +
                "                    <td width=\"" + (w - 32) + "\"><img src=\"/images/pixelclear.gif\" width=\"1\" height=\"1\" border=\"0\" /></td>" +
                "                    <td bgcolor=\"#D4D6D3\" width=\"16\"><img src=\"/images/pixelclear.gif\" width=\"1\" height=\"1\" border=\"0\" /></td>" +
                "                </tr>" +
                "            </table>" +
                "       </td>"+
                "  </tr>" +
                "</table>";
        }
    }
    htmlOut+=
        "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: " + w + ";\">" +
        "    <tr><td height=\"10\"><img src=\"/images/pixelclear.gif\" height=\"10\" /></td></tr>" +
        "</table>";
    return htmlOut;
}
//Search Functions
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
//sets cursor focus to search box on page load
function searchFocus() {
      document.search.query.focus();
//    document.forms[0].elements[2].focus();
}


function writeGoogleBar(cat, fullwidth) {
    var safeSearchCookie = GetCookie("comcastsafesearch");
    if (safeSearchCookie != "off") {
        safeSearchCookie = "on";
    }
    var checkedOption = (getParam("searchChoice") + "") + (getParam("searchCategory") + "");
    fullwidth = (fullwidth == null) ? 0 : fullwidth;

    //widths of all the columns...listed out for no other reason that to easily see them
    existingWidth = 8 + 60 + 240 + 10 + 35 + 10 + /*70 + 10 +*/ 45 + 57;
    //changed 180 to 240 to accomodate wider seach box

    if (fullwidth >= 1) {
        remainingWidth = fullwidth - existingWidth;
    } else {
        //remainingWidth = 164
        remainingWidth = 171
    }

    var searchTarget = "";
    //if (document.location.href.indexOf("qry/websearch") != -1) { searchTarget = "_self"; }
    //else { searchTarget = "googlesearch"; }

    cntCol = 11;
    htmlOut = "<table cellpadding=\"0\" cellspacing=\"0\" height=\"35\" border=\"0\" class=\"googleBar\">" +
              "  <tr>" +
              "    <form name=\"search\" action=\"/qry/websearch\" method=\"get\" target=\"" + searchTarget + "\" onsubmit=\"submitGoogleSearchAction(this);\">" +
              "      <input type=\"hidden\" name=\"cmd\" value=\"qry\">" +
              "      <input type=\"hidden\" name=\"safe\" value=\"" + safeSearchCookie + "\">" +
              "      <td width=\"8\" align=\"center\" class=\"googleText\">&nbsp;</td>" +
              "      <td width=\"240\" class=\"googleText\"><input type=\"text\" name=\"query\" value=\"" + stringReplace(getParam("query"), "+", " ") + "\" class=\"googleTextbox\" /></td>" +
              "      <td width=\"60\" class=\"googleText\" align=\"center\"><input type=\"image\" name=\"go\" src=\"/search/images/searchBttn.jpg\" /></td>";

    if (cat != null && cat.length > 0) {
        htmlOut+= "      <td width=\"10\" class=\"googleText\"><input type=\"radio\" name=\"searchChoice\" value=\"category\" /></td>" +
                  "      <input type=\"hidden\" name=\"searchCategory\" value=\"" + cat.toUpperCase() + "\">" +
                  "      <td width=\"45\" class=\"googleText\"> " + cat + "</td>";
        cntCol += 2;
        remainingWidth -= 55;
    }

    if (cat == null || cat.length == 0 || cat == "Service Center") {
         htmlOut+= "      <td width=\"10\" class=\"googleText\"><input type=\"radio\" name=\"searchChoice\" value=\"site\" /></td>" +
              "           <td width=\"35\" class=\"googleText\"> Site</td>";
        cntCol += 2;
        remainingWidth -= 45;
    }

     if (cat == "Service Center") {
     }
     else {
        htmlOut+= "  <td width=\"10\" class=\"googleText\"><input type=\"radio\" name=\"searchChoice\" value=\"shopping\" /></td>" +
              "      <td width=\"60\" class=\"googleText\"> Shopping</td>";
        cntCol += 2;
        remainingWidth -= 70;
     }

    htmlOut+= "      <td width=\"10\" class=\"googleText\"><input type=\"radio\" name=\"searchChoice\" value=\"google\"" + ((checkedOption != "singingfish") ? " checked=\"true\"" : "" ) + " /></td>" +
              "      <td width=\"45\" class=\"googleText\"> Web&nbsp;By</td>" +
              "      <td width=\"57\" class=\"googleText\"><img src=\"/search/images/googlebarlogo.gif\" alt=\"google\" width=\"52\" height=\"17\" border=\"0\" /></td>";

    if (displaySafeSearchBox()) {
        cntCol++;
        remainingWidth -= 48;
        htmlOut+= "      <td width=\"48\" class=\"googleText\" onMouseover=\"showtip(this, 'Filters explicit adult content.', event);\" onMouseOut=\"hidetip();\"><input type=\"checkbox\" name=\"safeBox\"" + ((safeSearchCookie == "on") ? " checked" : "" ) + " onclick=\"if (document.search.safeBox.checked) {document.search.safe.value='on';} else {document.search.safe.value='off';}\">Safe</td>";
    }

    htmlOut+= "      <td width=\"" + remainingWidth + "\" class=\"googleText\"><img src=\"/images/pixelclear.gif\" width=\"1\" height=\"1\" border=\"0\" /></td>" +
              "    </form>" +
              "  </tr>" +
              "</table>";
    document.writeln(htmlOut);
//  searchFocus();
}
function submitGoogleSearchAction(thisForm) {
    var x = 0;
    var selectedSearch = "";
    var action = "";
    var searchTarget = "";
    for (x = 0 ; x < thisForm.searchChoice.length ; x++) {
        if (thisForm.searchChoice[x].checked) {
            selectedSearch = thisForm.searchChoice[x].value.toLowerCase();
            break;
        }
    }
    if (selectedSearch == "site") {
        action = "/search/siteSearch.jsp";
        searchTarget = "_self";
    } else if (selectedSearch == "singingfish") {
        action = "/qry/sfsearch";
        searchTarget = "_self";
    } else if (selectedSearch == "google") {
        action = "/qry/websearch";
        searchTarget = "_self";
    } else if (selectedSearch == "web") {
        action = "/qry/websearch";
        searchTarget = "_self";
    } else if (selectedSearch == "shopping") {
        action = "http://shopping.comcast.net/xGS-";
        action += stringReplace(document.search.query.value," ","_");
        action += "~NS-1~linkin_id-3053081&CM.src=Search";
        searchTarget = "shoppingsearch";
    } else {
        action = "/search/siteSearch.jsp";
        searchTarget = "_self";
    }
    setSafeSearch(thisForm);
    thisForm.action = action;
    thisForm.target = searchTarget;
    thisForm.submit();
}
function submitGoogleSearchAction2(thisForm) {
//This function is used on siteSearch.jsp
//Same basic concept as submitGoogleSearchAction(thisForm)
//but uses a select box as opposed to radio buttons
    var selectedSearch = thisForm.searchCategory[thisForm.searchCategory.selectedIndex].value.toLowerCase();
    var action = "";
    if (selectedSearch == "all") {
        action = "/search/siteSearch.jsp";
    } else if (selectedSearch == "singingfish") {
        action = "/qry/sfsearch";
    } else if (selectedSearch == "web") {
        action = "/qry/websearch";
    } else {
        action = "/search/siteSearch.jsp";
    }
    setSafeSearch(thisForm);
    thisForm.action = action;
    thisForm.submit();
}
// end 2.1 additions

function displaySafeSearchBox() {
    var result = false;
    var sPath = String(location.pathname).toLowerCase();
    if (sPath.indexOf("/qry/sfsearch") > -1) {
        return true;
    } else if (sPath.indexOf("/qry/websearch") > -1) {
        return true;
    } else {
        return false;
    }
}

function setSafeSearch(theForm) {
    if (typeof(theForm) == "object") {
        var theValue = theForm.safe.value;
        if (theValue == "on" || theValue == "off") {
            setCookie("comcastsafesearch", theValue, 30, "/");
        }
    }
}
//Cookie
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
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 '';
}
//Other
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
function setLeftnavBar(name) {
    var movie = getMovie("leftnav");
    if (typeof(movie) != "undefined") {
        if (movie.PercentLoaded() == 100) {
            movie.SetVariable("_level0.selected", name);
        } else {
            setTimeout("setLeftnavBar('"+name+"');", 100);
        }
    }
}

function showFlash() {
    var movie = getMovie("topnav");
    if (typeof(movie) != "undefined") {
        if (movie.PercentLoaded() == 100) {
             movie.SetVariable("_level0.showflash", "true");
        } else {
            setTimeout("showFlash();", 100);
        }
    }
}

function getMovie(name) {

    if (window[name]) {
        return window[name];
    }
    return document[name];
}

usrZipCode = "";
function getZipCode() {
    return usrZipCode;
}

function setZipCode(zipcode) {
    usrZipCode = zipcode;
}

function getFirstName() {
    return usrFirstName;
}

usrFirstName = "";
function setFirstName(firstname) {
    usrFirstName = firstname;
}

function getUserName() {
    return usrName;
}

usrName = "";
function setUserName(username) {
    usrName = username;
}

/**
 * This function writes out a text element dependent on the browser version
 */
function writeTextElement(name, size, value, cssclass) {
  document.write('<input type="text" name="'+name+'" size="'+size+'" ');
  if (value != null) {
    document.write(' value="'+value+'" ');
  }
  if (cssclass != null) {
    document.write(' class="'+cssclass+'" ');
  }
  if (textElementCanUseStyles) {
    document.write(' style="width:'+(size * 10)+'px;" ');
  }
  document.write(' />');
}

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 updateBrowser(pathToUpgradePage) {
    //redirects user to upgrade page if pathToUpgradePage is set
    //returns true or false if pathToUpgradePage is not set
    var update = false;
    if (is_nav || is_ie || is_opera) {
        //Check Revisions
        if (is_nav6up || is_ie5up || is_opera) {
            //good
        } else {
            //bad
            update = true;
        }
    } else {
        //default to portal for other browsers
        //mozilla check coming later
    }
    if (update) {
        if ((typeof pathToUpgradePage == "undefined") || pathToUpgradePage.length == 0 ){
            return update;
        } else {
            window.location = pathToUpgradePage;
        }
    }
    return update;
}


// does a userAgent detect for Windows XP and displays copy and download links for those users only
function security_intro() {
if (!is_win2k && is_winXP) {

	xp_intro =  "<div class=\"blacksmall\"><b><span style=\"color: #991D20;\">NOTE:</span>&nbsp; Before installing Security Manager:</b><br />";
	xp_intro += "<ol style=\"margin-top: 5px; margin-bottom: 0px;\"><li>Uninstall any existing firewall on your PC, for example, McAfee Personal Firewall.</li>";
	xp_intro += "<li>Make sure your system meets the minimum system requirements (below) for successful installation and operation of Security Manager.</li></ol></div>";
	document.write(xp_intro);
	}

else {
	other_intro = "<div class=\"blacksmall\" style=\"color: #991D20;\">We're sorry, but your PC does not meet the minimum requirements for Security Manager.<br />Support for other operating systems is coming soon. Please check back periodically.</div>";
	document.write(other_intro);
	}	
}

function security_features() {
if (!is_win2k && is_winXP) {
	
	xp_features = "<div class=\"blacksmall\"><a href=\"http://media.comcast.net/anon.comcastonline/onleng/downloads/securitymgr.exe\" class=\"bluesmallbold2\">Download</a> Comcast Security Manager today and discover all the Internet has to offer without worrying about exposure to inappropriate content, hackers, threats to your privacy and annoying pop-up advertisements.  Comcast Security Manager provides one easy-to-use solution for installing and managing the following security features:</div>";
	document.write(xp_features);
	}
	
else {
	other_features = "<div class=\"blacksmall\">Download Comcast Security Manager today and discover all the Internet has to offer without worrying about exposure to inappropriate content, hackers, threats to your privacy and annoying pop-up advertisements. Comcast Security Manager provides one easy-to-use solution for installing and managing the following security features:</div>";
	document.write(other_features);
	}
}

function security_download() {
if (!is_win2k && is_winXP) {
customStart("Download", "200");

	xp_download =  "<div class=\"blacksmall\"><b>Comcast Security Manager</b><br />";
	xp_download += "Discover a safer Internet.<br /><br />";
	xp_download += "<a href=\"http://media.comcast.net/anon.comcastonline/onleng/downloads/securitymgr.exe\" class=\"bluesmallbold2\">Download it now!</a></div>";
	document.write(xp_download);
	
customEnd("200");
}

else { }	
}


//Create Tooltip
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
//pass the element you want to 'tooltip' and the msg
//onMouseOver="showtip(this, 'I am a tooltip.');" onMouseOut="hidetip();"
function showtip(current, msg, theEvent) {
    var elml = current;
    var elm = document.getElementById("tooltip");
    var x = 0;
    var y = 0;
    if (theEvent != '') {
        x = theEvent.x;
        y = theEvent.y;
    } else {
        x = elml.offsetTop + elml.offsetHeight + 4;
        y = elml.offsetLeft + 10;
    }
    elm.innerText = msg;
    elm.style.left = parseInt(x);
    elm.style.top = parseInt(y);
    elm.style.visibility = "visible";
}
function hidetip() {
    var elm = document.getElementById("tooltip");
    elm.style.visibility = "hidden";
}
document.write("<div id=\"tooltip\" style=\"position:absolute;visibility:hidden;border:1px solid black;font-size:12px;layer-background-color:lightyellow;background-color:lightyellow;padding:1px\"></div>");

//Util Functions
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
function isProduction() {
    var domain = new String(location.hostname);
    if (domain.indexOf("comcast.net") >= 0 || domain.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
} // Ends the "trim" function
//Validation
//***********************************************************************************************************************************************
//***********************************************************************************************************************************************
function validateZipCode(zip) {
    if (!zip || zip.length == 0) {
        alert("You must provide your five digit zip code");
        return false;
    }
    if (!isNaN(zip) && zip.length == 5) {
        return true;
    }
    if ((zip.length == 10) && !isNaN(zip.substring(0,5)) && !isNaN(zip.substring(6,10)) && zip.substring(5,6) == '-') {
        return true;
    }
    alert("Please enter a valid zip code.");
    return false;
}