// File Structure
// BEGIN: Global Variables 
// BEGIN: Global Functions - Display Related
// BEGIN: Global Functions - DOM Related
// BEGIN: Global Functions - Generic Cookie Functions
// BEGIN: Global Functions - Prototype Functions
// BEGIN: Global Functions - Validation Functions
// BEGIN: Global Functions - URL Functions
// BEGIN: Calculator related code
//

// *********************************************************
// BEGIN: Global Variables 
// If you have a variable that you do not want anyone else to un-intentionally reference, declare it below with a "g_" prefix.  This
// prevents someone from accidently assigning a value to a variable like partnerCID w/o realizing the global implications of it.  
// *********************************************************

// default hrblock.com info
//var g_partner_id                    = 0;
//var g_partnerName                   = "hrblock";
//var g_partner_cid                   = "";
//var g_partnerType                   = "normal";
//var g_partnerWelcomeText            = "";

// default taxcut.com info
var g_partner_id                    = 2246;
var g_partnerName                   = "taxcut";
var g_partner_cid                   = "";
var g_partnerType                   = "normal";
var g_partnerWelcomeText            = "";

var g_bUseStaticData                = false;
var g_tunneledPage                  = false;

var g_nvpCount                      = 0;        // number of name value pairs in the current url
var nvp_count                       = 0;        // required for backward compatibility with office locator code only 

var g_bPreLoadProductRunning        = true;
var g_bOffermaticaProductRunning    = false;

// variables valued by web service for otpPartnerId that was ultimately used
var ws_otpPartnerID                 = "-999"; 
var ws_partnerName                  = "-999";  
var ws_partnerCID                   = "-999"; 
var ws_partnerType                  = "-999";  
var ws_partnerWelcomeText           = "";

var wsc_cookie_partnerName          = "";   // values from web service cookie
var wsc_cookie_partnerType          = "";   // values from web service cookie
var wsc_cookie_partnerWelcomeText   = "";   // values from web service cookie
var wsc_partnerCID                  = "";   // values from web service cookie 
var wsc_otpPartnerID                = "";   // values from web service cookie

var g_b_ws_partner_id_different     = false;
var g_bWebServiceWasCalled          = false;
var g_webServiceCallSuccessful      = false;
var g_bWebServiceCallFailed         = false;
var g_webServiceCallTimeout         = false;
var g_bHttpRequestFailed            = false;
var g_product_ws_active             = false;

var g_partner_id_from_cookie        = "";       // the value of otp partner id in the cookie if found
var g_partner_id_from_url           = "";       // the value of otp partner id in the url if found
var g_partner_id_from_offermatica   = "";       // the value of otp partner id in specified by offermatica price test if applicable
var g_partner_id_from_search_engine = "";       // identifies search engine from which organic searchs originated from
var g_partner_id_from_web_service   = "";       // the partner id the web service ultimately used to get information for
var g_partner_id_from_ws_cookie     = "";       // the partner id found in the cookie valued with web service call results

var g_dr_url_info                   =  "";      // dr info in url
var g_dr_cookie_info                =  "";      // dr info currently in digitalriver cookie
var g_dr_ws_info                    =  "";      // dr info returned from web service call

var g_searchEngineTerm              = "";
var g_bReferrerIsSearchEngine       = false;    // set to true if referrer is a search engine

var g_dr_info_to_use                = "";       // digitalriver parm info to use when building digitalriver store links
var g_campaign_id                   = "";       // holds the value found in the CampaignID parm

var g_flashVersion                  = "";

var g_bGetProductInfo               = "";

var g_dr_pgm_info_from_url          = "";
var g_dr_offer_info_from_url        = "";
var g_dr_pgm_info_from_cookie       = "";
var g_dr_offer_info_from_cookie     = "";

var g_query_string_names    = new Array();
var g_query_string_values   = new Array();

var g_curr_query_names      = new Array();       // array of names  in the current url
var g_curr_query_values     = new Array();       // array of values in the current url

var pLearn   = new Array(50);
var pStart   = new Array(50);
var pPPrice  = new Array(50);
var pBPrice  = new Array(50);
var pName    = new Array(50);

for (i = 0; i < 50; i++)
{
    pLearn[i]   = new Array(2);
    pStart[i]   = new Array(2);
    pPPrice[i]  = new Array(2);
    pBPrice[i]  = new Array(2);
    pName[i]    = new Array(2);
}

var g_time_entered      = "";
var g_paidSearch        = 0;

// *********************************************************
// END: Global Variables
// *********************************************************

// several functions require the split query string so the splitQueryString() call
// has been moved inline - 2004/12/28 pintar
try
{
    splitQueryString(location.search);
}
catch (e)
{
     alert("splitQueryString:"+e.description);  
}

g_tunneledPage  = (document.location.pathname.indexOf("/taxes/partner/") != -1) ? true : false;

// *********************************************************
// BEGIN: Global Functions - Display Related
// *********************************************************























function toggle(obj) {
    var el = document.getElementById(obj);
    if ( el.style.display != 'none' ) {
        el.style.display = 'none';
    }
    else {
        el.style.display = '';
    }
}

function WinOpen_(page,w,h) {
    popupWin=open(page,"popup","status=yes,toolbar=no,directories=no,scrollbars=yes,menubar=no,resizable=yes,width=" + w + ",height=" + h);
    popupWin.focus();
}

function closePopUnder()
{
    try
    {       
        window.open("","popunder","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=10,height=10,left=2000,top=2000").close();
    }
    catch(e)
    {
    }
}

function closePopUnder2(windowName)
{
    try
    {       window.open("",windowName,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=10,height=10,left=2000,top=2000").close();
    }
    catch(e)
    {
    }
}

function getFlashVersion()
{
    FLASH_MAX = 9;      // the latest Flash plug-in version or higher
    FLASH_VERSION = 0;  // holds the version of flash this browser has installed

    var agent = navigator.userAgent.toLowerCase();
    if(navigator.plugins != null && navigator.plugins.length > 0)
    { 
        var plugin = navigator.plugins['Shockwave Flash'];
        if(typeof plugin == 'object')
        {
            for(i=3; i<= FLASH_MAX; i++)
            {
                if(plugin.description.indexOf(i+'.') != -1)
                {
                    FLASH_VERSION = i;
                }
            }
        }
    }
    else if(document.all && agent.indexOf('win') != -1 && agent.indexOf('16bit') == -1)
    {
        document.write('<'+'script language="VBScript"'+'> \n');
            document.write('set FlashObj = Nothing \n');
            document.write('on error resume next \n');
            document.write('For i = '+FLASH_MAX+' to 3 step -1 \n');
                document.write('set FlashObj = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n');
                document.write('If (Not(FlashObj is Nothing)) Then \n');
                    document.write('FLASH_VERSION = i \n');
                    document.write('Exit For \n');
                document.write('End If \n');
            document.write('Next \n');
        document.write('<'+'\/script'+'> \n');
    }
    else if(agent.indexOf('webtv/2.5') != -1)
    {
        FLASH_VERSION = 3;
    }
    else if(agent.indexOf('webtv') != -1)
    {
        FLASH_VERSION = 2;
    }
    else
    {
        FLASH_VERSION = -1;
    }

    g_flashVersion  = FLASH_VERSION;

    return FLASH_VERSION;
}

function checkFlash()
{
    var flashVersion = 0;
            if (navigator.plugins != null && navigator.plugins.length > 0) {
                        var flashPlugin = navigator.plugins['Shockwave Flash'];
                        if (typeof flashPlugin == 'object') {
                                    if (flashPlugin.description.indexOf('10.') != -1) flashVersion = 10;
                                    else if (flashPlugin.description.indexOf('9.') != -1) flashVersion = 9;
                                    else if (flashPlugin.description.indexOf('8.') != -1) flashVersion = 8;
                                    else if (flashPlugin.description.indexOf('7.') != -1) flashVersion = 7;
                                    else if (flashPlugin.description.indexOf('6.') != -1) flashVersion = 6;
                                    else if (flashPlugin.description.indexOf('5.') != -1) flashVersion = 5;
                                    else if (flashPlugin.description.indexOf('4.') != -1) flashVersion = 4;
                                    else if (flashPlugin.description.indexOf('3.') != -1) flashVersion = 3;
                        }
                        return flashVersion;
            }
            else {
                        for(var i=10; i>0; i--){
                                    flashVersion = 0;
                                    try{
                                                var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
                                                flashVersion = i;
                                                return flashVersion;
                                    }
                                    catch(e){
                                    }
                        }
            }
}

// *********************************************************
// END: Global Functions - Display Related
// *********************************************************


// *********************************************************
// BEGIN: Global Functions - DOM Related
// *********************************************************

function getAllElements()
{ 
  var all = null;

  if (document.all)
  {
    // we're IE
    var all = document.all;
  }
  else if (document['getElementsByTagName'])
  {
    // we're DOM-aware (Mozilla)
    var all = document.getElementsByTagName("*");
  }

  // if we're not IE or DOM-aware, we'll return null
  return all;
}

function getElementsByAttribute(attr, attrVal)
{   
    var all     = document.all || document.getElementsByTagName('*');
    var arr     = new Array();
    var tempId  = "";

    for(var k=0;k<all.length;k++)
    {
        tempId  = all[k].getAttribute(attr);

        if (tempId != null && tempId.indexOf(attrVal)==0)
        {
            arr[arr.length] = all[k];
        }
    }
    return arr;
}

// *********************************************************
// BEGIN: Global Functions - DOM Related
// *********************************************************


// *********************************************************
// BEGIN: Global Functions - Generic Cookie Functions
// *********************************************************

function getCookie(name)
{
    var search = name + "=";
    if (document.cookie.length > 0)
    {
        // if there are any cookies
        offset = document.cookie.indexOf(search);
        if (offset != -1)
        {   // cookie exists
            offset += search.length;

            // set index of beginning of value
            end = document.cookie.indexOf(";", offset);

            // set index of end of cookie value
            if (end == -1)
            {   end = document.cookie.length;
            }

            return unescape(document.cookie.substring(offset, end));
        }
        else
        {
            return null;
        }
    }
    else
    {
        return null;
    }
}

function getexpirydate(nbrOfDays)
{
    var UTCstring;
    Today       = new Date();
    nomilli     = Date.parse(Today);
    Today.setTime(nomilli+nbrOfDays*24*60*60*1000);
    UTCstring   = Today.toUTCString();
    return UTCstring;
}

function getDomain()
{
    // Returns the current domain w/o the subdomain name.  Called by
    // setCookie() so the same named cookie isn't created for both taxcut.com and WWW.taxcut.com.
    // Return null if we have a domain (like a test server) that isn't constructed like regular domains

    var tempHost    = document.location.hostname;
/*
    var dotLocation = tempHost.lastIndexOf(".",(tempHost.lastIndexOf(".")-1));

    if (countOccurancesOfString(tempHost,".")==3)
    {
        // nothing to do since we handle IP addresses as IP addresses
    }
    else if (dotLocation == -1)
    {
        // host is someting like 'testserver:8080', let browser determine what to use
        tempHost    = null;
    }
    else
    {  
        tempHost    = tempHost.substr(dotLocation);
    }
*/
    var dotCount = 0;

    for (var d=0; d<tempHost.length; d++)
    {
        if (tempHost.substr(d,1)==".")
        {
            dotCount++;
        }
    }

    if (dotCount == 2)
    {
        tempHost = tempHost.substr(tempHost.indexOf("."));  // www.hrblock.com returned as .hrblock.com
    }
    else if (dotCount == 1)
    {
        tempHost = "." + tempHost;  // hrblock.com returned as .hrblock.com
    }
    else if (dotCount == 3)
    {
        tempHost = tempHost;    // ip.ip.ip.ip          returned as ip.ip.ip.ip
                                // cms.kc.hrbock.net    returned as cms.kc.hrbock.net
    }
    else if (dotCount == 0)
    {
        tempHost = null;    // testserver returned as null
    }

    return tempHost;
}

function setCookie(cookieName, cookieValue)
{
    // setCookie(cookiename", "cookievalue", null, "/");
    // cookiename == arg0
    // cookievalue== arg1
    // expdate    == arg2
    // path       == arg3
    // domain     == arg4
    // secure     == arg5

    // always make cookies specific to the domain, like hrblock.com, not www.hrblock.com
    var args    = setCookie.arguments;
    var arglen  = setCookie.arguments.length;

    var expires = (arglen > 2) ? args[2] : null;
    var path    = (arglen > 3) ? args[3] : null;
    //var domain  = (arglen > 4) ? args[4] : null;  // commented out. see below.
    var secure  = (arglen > 5) ? args[5] : false; // true or false not null

    // Call getDomain() so the same named cookie isn't created for both hrblock.com and WWW.hrblock.com.
    // That function returns ".hrblock.com" for "www.hrblock.com", and ".hrblock.com" for "hrblock.com" and
    // null for "testserver:8080", allowing browser to make the determination.
    
    var domain = getDomain();
    

    if(cookieName=="main_cookie")
    {
        if (isTunneledPage())
        {
            cookieValue += "&tpage=1";
        }
    }

    //document.cookie = cookieName + "=" + escape (cookieValue)+
    document.cookie = cookieName + "=" + cookieValue+
    ((expires == null) ? ""         : ("; expires = " + getexpirydate(expires))) +
    ((path    == null) ? ";path=/"  : ("; path=   "   + path))   +
    ((domain  == null) ? ""         : ("; domain=   " + domain)) +
    ((secure  == true) ? "; secure" : "");
}

function deleteCookie( name, path, domain ) {
    if ( getCookie( name ) ) document.cookie = name + '=' +
            ( ( path ) ? ';path=' + path : '') +
            ( ( domain ) ? ';domain=' + domain : '' ) +
            ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

// *********************************************************
// END: Global Functions - Generic Cookie Functions
// *********************************************************


// *********************************************************
// BEGIN: Global Functions - Prototype Functions
// *********************************************************
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}

String.prototype.ltrim = function() {
    return this.replace(/^\s+/,"");
}

String.prototype.rtrim = function() {
    return this.replace(/\s+$/,"");
}
// *********************************************************
// END: Global Functions - Prototype Functions
// *********************************************************


// *********************************************************
// BEGIN: Global Functions - Validation Functions
// *********************************************************

function countOccurancesOfString(stringToSearch, stringToSearchFor)
{
    var stringToSearchLength= stringToSearch.length;
    var numberOccurances    = 0;
    var fromPosition        = 0;

    while(stringToSearch.indexOf(stringToSearchFor, fromPosition) != -1)
    {
        numberOccurances++;
        fromPosition = stringToSearch.indexOf(stringToSearchFor, fromPosition) + (stringToSearchFor.length);
    }
    return numberOccurances;
}

// when calling this function, value stringSpecialCharsAllowed like this "%+-@" in the call
function isNumeric(stringToCheck,  stringSpecialCharsAllowed)
{
   var strValidChars = "0123456789"+stringSpecialCharsAllowed;
   var strChar;
   var bIsValid = true;

   if (stringToCheck.length == 0) return false;

   stringToCheck = stringToCheck.toLowerCase();

    for (i = 0; i < stringToCheck.length; i++)
    {
        strChar = stringToCheck.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            bIsValid = false;
            break;
        }
    }

   return bIsValid;
}

function isString(valueToCheck)
{
}

// when calling this function, value stringSpecialCharsAllowed like this "%+-+@" in the call
function isAlpha(stringToCheck, stringSpecialCharsAllowed)
{
   var strValidChars = " abcdefghijklmnopqrstuvwxyz"+stringSpecialCharsAllowed;

   var strChar;
   var bIsValid = true;

   if (stringToCheck.length == 0) return false;

   stringToCheck = stringToCheck.toLowerCase();

    for (i = 0; i < stringToCheck.length; i++)
    {
        strChar = stringToCheck.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            bIsValid = false;
            break;
        }
    }

   return bIsValid;
}

// when calling this function, value stringSpecialCharsAllowed like this "=-+@" in the call
function isAlphaNumeric(stringToCheck, stringSpecialCharsAllowed)
{
   var strValidChars = " abcdefghijklmnopqrstuvwxyz0123456789"+stringSpecialCharsAllowed;
   var strChar;
   var bIsValid = true;

   if (stringToCheck.length == 0) return false;

   stringToCheck = stringToCheck.toLowerCase();

    for (i = 0; i < stringToCheck.length; i++)
    {
        strChar = stringToCheck.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            bIsValid = false;
            break;
        }
    }

   return bIsValid;
}

function validateZipCode()
{
    var strZip      = document.getElementById('tfZipCode').value
    var ValidChars  = "0123456789.";
    var returnCode  = true;
    var Char;

    if (strZip == '')
    {
        alert("Please enter a zip code.");
        return false;
    }

    for (i = 0; i < strZip.length; i++)
    {
        Char = strZip.charAt(i);
        if (ValidChars.indexOf(Char) == -1)
        {
            alert("Please enter a valid zip code.");
            return false;
        }
    }

    if (strZip.length != 5)
    {
        alert("Please enter a 5 digit zip code.");
        return false;
    }

    // ***********************************************************************************
    // begin special parms processing
    // ***********************************************************************************
    // parms that need to be passed to office_locator.html can be specified by calling this function as follows:
    // validateZipCode("parms_to_pass:name1=value&name2=value");
    var parmsToPassToLocator = "";
    var bAmpAdded    = 0;

    var argArray;
    var tempStr = "";

    for(var i=0; i<arguments.length; i++)
    {
       argArray = arguments[i].split(":");

       if (argArray[0].toLowerCase()=="parms_to_pass")
       {
            if (bAmpAdded==0)
            {
                parmsToPassToLocator += "&";
                bAmpAdded=1;
            }
            parmsToPassToLocator += argArray[1];
       }
    }
    // end special parms processing

    window.location="/universal/office_locator.html?zip="+strZip+parmsToPassToLocator;

    return false;
}

function validateZipCode2(strZip)
{
    // just validates the zip code w/o forwarding request like validateZipCode() does
    var ValidChars  = "0123456789.";
    var returnCode  = true;
    var Char;

    if (strZip == '')
    {
        alert("Please enter a zip code.");
        return false;
    }

    for (i = 0; i < strZip.length; i++)
    {
        Char = strZip.charAt(i);
        if (ValidChars.indexOf(Char) == -1)
        {
            alert("Please enter a valid zip code.");
            return false;
        }
    }

    if (strZip.length != 5)
    {
        alert("Please enter a 5 digit zip code.");
        return false;
    }

    return true;
}

// *********************************************************
// END: Global Functions - Validation Functions
// *********************************************************


// *********************************************************
// BEGIN: Global Functions - URL Functions
// *********************************************************

// ********************************************
// function splitQueryString(str)
//
// ONLY CALL THIS FUNCTION ONE TIME PER PAGE LOAD!  It values and stores variables that are assumed by other
// code on the page to contain the original values in the search string.  If you need to split any other
// query string, use splitQueryStringLocal() / getQueryValueLocal() instead!
// ********************************************
function splitQueryString(stringToSplit)
{
    // splits stringToSplit query string into array elements

    g_curr_query_names     = new Array();   // array of names  in the current string being split
    g_curr_query_values    = new Array();   // array of values in the current string being split

    if (stringToSplit.substr(0,1)=="?")
    {
        stringToSplit = stringToSplit.substr(1); // remove leading ? if present
    }

    var pairs       = stringToSplit.split("&");
    var argname     = "";
    var value       = "";

    if (pairs[0]==null || pairs[0]=="")
    {
        g_nvpCount      = 0;
    }
    else
    {
        g_nvpCount      = pairs.length;
    }

    for (var i=0; i<g_nvpCount; i++)
    {
        var pos = pairs[i].indexOf('=');

        if (pos >= 0)
        {
            argname = pairs[i].substring(0,pos);
            value   = pairs[i].substring(pos+1);

            g_curr_query_names[g_curr_query_names.length]     = argname;
            g_curr_query_values[g_curr_query_values.length]   = unescape(value);
        }
    }
    nvp_count   = g_nvpCount;   // required for backward compatibility with office locator code only 
}

function getQueryValue(name)
{
    // returns name/value pair value if parsed in splitQueryString() function else returns null
    var value       = null;
    var lowerName   = name.toLowerCase();

    for (var i=0;i<g_curr_query_names.length;i++)
    {
        if (g_curr_query_names[i].toLowerCase()==lowerName)
        {
            value = g_curr_query_values[i];
            break;
        }
    }
    return value;
}

function getAllQueryValues()
{
    var tmpstr = "";
    for (var i=0;i<g_curr_query_names.length;i++)
    {
            tmpstr+= "("+g_curr_query_names[i]+","+g_curr_query_values[i]+")\r\n";
    }
    alert(tmpstr);
}

// *********************************************************
// END: Global Functions - URL Functions
// *********************************************************

function getQV(stringToSplit, valueToGet, operator, delimiter)

{
    // splits stringToSplit query string into array elements then returns the value of the name requested
    // delimiter is generally & or /
    // operator is generally = or .
    // This is because some urls come as ?parm1=value&parm2=value 
    // yet others like DigitalRiver come in as ?parm1.value/parm2.value

    // examples
    //  ?otpPartnerId=12345&productid=31
    //  ?pgm.12345/OfferID.12345/otppartnerid.25222

    if (stringToSplit.substr(0,1)=="?")
    {
        stringToSplit = stringToSplit.substr(1); // remove leading ? if present
    }

    var pairs       = stringToSplit.split(delimiter);
    var argname     = "";
    var value       = "";

    var nvpCount      = pairs.length;

    for (var i=0; i<nvpCount; i++)
    {
        var pos = pairs[i].indexOf(operator);

        if (pos >= 0)
        {
            argname = pairs[i].substring(0,pos);
            value   = pairs[i].substring(pos+1);

            if (argname.toLowerCase()==valueToGet.toLowerCase())
            {
                return value;
            }
        }
    }

    return value;
}

function taxcutLogin(bNewWindow)
{   // only call this function if visitor hasn't selected a tax product yet
    
    var genericLoginLink    = "http://www.hrblock.com/loginRedirect.html?TaxType=OPP&FV=T&HT=F&TaxYear=2007&PartnerID="+g_partner_id;
    if (bNewWindow)
    {
        window.open(genericLoginLink,"","");
    }
    else
    {
        window.location = genericLoginLink;
    }
}

function setPartnerIdToUse()
{
    // sequence of preference when determining partner id to use is:

    // FOR NON-TUNNELED AND TUNNELED PARTNERS
    // partner id from offermatica when running a price test (non-tunneled pages only)
    // partner id in the url
    // partner id in the cookie

    // not that the the web service results will replace g_partner_id if that partner is determined to be invalid or inactive

    if (g_partner_id_from_offermatica != "")
    {
        g_partner_id = g_partner_id_from_offermatica;
    }
    else if (g_partner_id_from_url != "")
    {
        g_partner_id = g_partner_id_from_url;
    }
    else if (g_partner_id_from_cookie != "")
    {
        g_partner_id = g_partner_id_from_cookie;
    }
    else if (g_partner_id_from_search_engine != "")        
    {
        g_partner_id = g_partner_id_from_search_engine;
    }
    else
    {
        // default hrblock.com info
        //g_partner_id = 0;    // hrblock.com default partner id

        // default taxcut.com info
        g_partner_id = 2246; // taxcut.com default partner id
    }







}

function getUrlPartnerId()
{
    var tempId  = "";

    var qs  = window.parent.location.search;

    tempId = getNVPV(qs, 'otpPartnerId', false);

    if ((typeof tempId)=="undefined" || tempId=="" || tempId==null  || tempId=="undefined") 
    {
       tempId = "";
    }

    return tempId;
}
    
function getCookiePartnerId(strCookieName)
{
    // strCookieName == "main_cookie" or "digitalriver"
    tempId = getNVPV("&" + getCookie(strCookieName), 'otpPartnerId', false);

    if ((typeof tempId)=="undefined" || tempId=="" || tempId==null || tempId=="undefined") 
    {
        tempId   = "";
    }

    return tempId;
}

function getOffermaticaPartnerId()
{
    return g_partner_id_from_offermatica;
}

function getCookieElementValue(strCookieName, strElementValueToGet, bCaseSpecific)
{
    tempId = getNVPV("&" + getCookie(strCookieName), strElementValueToGet, bCaseSpecific);

    if ((typeof tempId)=="undefined" || tempId=="" || tempId==null || tempId=="undefined") 
    {
        tempId   = "";
    }

    return tempId;
}

function setDefaultPartnerInfo()
{
    return;

    // *****************************************************************
    // Function not needed since the g_* variables are initialized with default values
    // *****************************************************************
}

function setDefaultProductInfo()
{
    // This functions purpose is to ensure default product information is always available
    
    // This function is called if:
    //
    // 1) The web service was called and it failed OR
    // 2) The page didn't call the web servivce



    // The include file default_product_info_2008.js includes default product names and price.  
    // The Learn More and Start Now information is already available in these arrays elsewhere in this file.
    //
    //      tc_l[]  // taxcut.com learn more links
    //      tc_s[]  // taxcut.com start now links
    //
    //      hrb_l[] // hrblock.com learn more links
    //      hrb_s[] // hrblock.com start now links

    for (var i=0; i<d_pName.length; i++)
    {     

        pBPrice[i][0]=d_pBPrice[i][0];
        pBPrice[i][1]=d_pBPrice[i][1];
        pPPrice[i][0]=d_pPPrice[i][0];
        pPPrice[i][1]=d_pPPrice[i][1];
        pName[i][0]  =d_pName[i][0];
        pName[i][1]  =d_pName[i][1];          
    }
}

function setPricesOnPage()
{
    var arrg_pPPriceElements         = new Array();
    var arrg_pPPriceElementsLength   = 0;

    var productId                    = 0;
    
    arrg_pPPriceElements         = getElementsByAttribute("id", "prodPrice");
    arrg_pPPriceElementsLength   = arrg_pPPriceElements.length;




    for (var x=0; x < arrg_pPPriceElementsLength; x++)
    {
        // get the number (productId) following 'prodPrice'        
        productId   = arrg_pPPriceElements[x].getAttribute("id").substr(9);

        // for every prodPriceXX element, try to find its price in the pPrice[][] array
        for (y=0; y < pPPrice.length && (typeof pPPrice[y][0]!="undefined"); y++)
        {   
            if ( pPPrice[y][0] == productId)
            {

                myObject = arrg_pPPriceElements[x];
                // pPrice[][] == -1 == free
                // pPrice[][] == 0.00 == use base price instead
                // pPrice[][] == n.nn == use this price
                if (pPPrice[y][1] == "-1")
                {
                    myObject.innerHTML="FREE";
                }
                else if (pPPrice[y][1] == "0.00")
                {
                    if (pBPrice[y][1] != "0.00")
                    {
                        myObject.innerHTML="$"+pBPrice[y][1];
                    }
                    else
                    {
                        myObject.innerHTML="";
                    }
                }
                else
                {
                    try
                    {
                        var f_partnerPrice  = parseFloat(pPPrice[y][1]);
                        var f_basePrice     = parseFloat(pBPrice[y][1]);

                        if (f_basePrice > f_partnerPrice)
                        {
                            //myObject.innerHTML="<del>$"+pBPrice[y][1]+"</del>&nbsp;&nbsp;$"+pPPrice[y][1]+" -- f_basePrice=="+f_basePrice+"f_partnerPrice,=="+f_partnerPrice;                    	
                            myObject.innerHTML="<del>$"+pBPrice[y][1]+"</del>&nbsp;$"+pPPrice[y][1]+"&nbsp;";                    	
                        }
                        else
                        {
                            //myObject.innerHTML="$"+pPPrice[y][1]+" -- f_basePrice=="+f_basePrice+"f_partnerPrice,=="+f_partnerPrice;                    	
                            myObject.innerHTML="$"+pPPrice[y][1];                   	
                        }
                    }
                    catch (e)
                    {
                        //alert(e.description);
                    }

                }
            }
        }
    }


}

function getProductInfo(otpId,tunneled_ind)
{   
    // Calls web service to get partner and product info for this partner

    // First check the wsc cookie's partner id.  if it matches the one we were going to call the 
    // web service with, then stub out the web service call and use the partner/product info found in the
    // cookie to value the p[][] array.    
    
    g_bWebServiceWasCalled  = true;
    g_product_ws_active     = true;
    g_webServiceCallTimeout = false; 
    g_bWebServiceCallFailed = true; // this is set to false in webservicecomplete() if the CID has a valid value from web service
    g_bHttpRequestFailed    = false;

    if (checkProductInfoCookie(otpId))
    {
        getWebServiceCookie(); 
        webServiceCallNotNeeded();   // shares much logic with the webServiceCallComplete()
    }
    else
    {
        try
        {
            //callProductPricingWebService(otpId,tunneled_ind); 
              callProductPricingWebService(otpId,"false"); // callProductPricingWebService() sets this to false when complete
            // NOTE: The browser does not wait for the callProductPricingWebService(otpId) call to finish before
            // continuing on with javascript processing!  Therefore, callProductPricingWebService() calls webServiceCallComplete()
            // when it is done so we can control the logic flow.
        }
        catch (error)
        {
            recordExceptionInOmniture("pws","9","getProductInfo()-"+error.description+"-1 js func("+otpId+","+tunneled_ind+")");
            try
            {   
                webServiceCallFailed("getProductInfo()-"+error.description+"- js func("+otpId+","+tunneled_ind+")");
            }
            catch (err)
            {
                recordExceptionInOmniture("pws","9","getProductInfo()-"+err.description+"-3 js func("+otpId+","+tunneled_ind+")");
                err.description;
            }        
        }
    }
}

function webServiceCallNotNeeded()
{
    g_product_ws_active     = false;    // web service no longer active so set boolean

    g_webServiceCallSuccessful  = true;

    // value the web services variables like they would have been had the web service call been made
    ws_partnerName          = wsc_cookie_partnerName;
    ws_partnerType          = wsc_cookie_partnerType;
    ws_partnerWelcomeText   = wsc_cookie_partnerWelcomeText;
    ws_partnerCID           = wsc_partnerCID;    
    ws_otpPartnerID         = wsc_otpPartnerID;

    g_partnerName           = wsc_cookie_partnerName;
    g_partnerType           = wsc_cookie_partnerType;
    g_partnerWelcomeText    = wsc_cookie_partnerWelcomeText;
    g_partner_cid           = wsc_partnerCID;    
    g_partner_id            = wsc_otpPartnerID;
        
    setPricesOnPage();

    processDigitalRiverCookie();

    continueOnloadProcessing();
}

function webServiceCallComplete()
{   


    g_product_ws_active     = false;    // web service no longer active so set boolean


    //    getAllProductInfo(false);


    if (g_bHttpRequestFailed)
    {
        // Set g_webServiceCallSuccessful to let other code on page know the web service failed in the allowed time.
        g_webServiceCallSuccessful  = false;

    }
    else if (g_webServiceCallTimeout)
    {
        g_webServiceCallSuccessful  = false;

    }
    else
    {
        g_webServiceCallSuccessful  = true;


        g_partnerName       = ws_partnerName;
        g_partnerType       = ws_partnerType;
        g_partnerWelcomeText= ws_partnerWelcomeText;
    }

    setPricesOnPage();

    // If the web service ended returning partner and product information for a partner that wasn't the one we asked for, it is
    // because that partner was found to be either invalid or inactive.  In this case, we have already written the main_cookie
    // with the partner id we THOUGHT we were going to use.  If the web service returned a different partner id, we need to overwrite
    // the main_cookie with the partner id returned by the web service!
    g_partner_id_from_web_service   = ws_otpPartnerID;

    if (ws_partnerCID == "no__thanks" || ws_partnerCID == "0")
    {
        ws_partnerCID = "";
    }

    if (ws_partnerCID == "-999")
    {
        g_bWebServiceCallFailed; // the call failed because ws_partnerCID should be 0, no__thanks or some other value than -999
    }



    if (ws_otpPartnerID != g_partner_id)
    {  
        g_b_ws_partner_id_different   = true;



        if (ws_partnerCID == "-999")
        {
            ws_partnerCID = "";
        }

        g_partner_cid   = ws_partnerCID;    
        g_partner_id    = ws_otpPartnerID;

        setCookie("main_cookie", "otpPartnerId="+g_partner_id+"&PartnerId="+g_partner_id, null, "/");
    }




    writeWebServiceCookie();
    
    processDigitalRiverCookie();

    continueOnloadProcessing();
}

function webServiceCallFailed(strReason)
{
    // called by partner_product_client_soap_details.js: callProductPricingWebService() on 500 http response code
    setCookie("main_cookie", "otpPartnerId="+g_partner_id+"&PartnerId="+g_partner_id, null, "/");

    setDefaultPartnerInfo();
    setDefaultProductInfo();

    setPricesOnPage();

    continueOnloadProcessing();
}
















function getProductPrice(requestedProductId)
{
    // This function returns the product price for the requested product.
    // The pPPrice[][] array will always have the correct value, either from 
    // the web servivce call OR from default values if the web service wasn't called or failed.

    for (var i=0; i<pPPrice.length; i++)
    {   
        if (pPPrice[i][0] == requestedProductId)
        {   
            if (pPPrice[i][1] == "-1")
            {
                return "FREE";
            }
            else
            {
                return pPPrice[i][1];
            }
        }
    }
}

function getProductBasePrice(requestedProductId)
{

    // This function returns the base product price for the requested product.
    // The pBPrice[][] array will always have the correct value, either from 
    // the web servivce call OR from default values if the web service wasn't called or failed.

    for (var i=0; i<pBPrice.length; i++)
    {   

        if (pBPrice[i][0] == requestedProductId)
        {   
            if (pBPrice[i][1] == "-1")
            {
                return "FREE";
            }
            else
            {
                return pBPrice[i][1];
            }
        }
    }
}

function getDR_url_info()
{ 
    g_dr_pgm_info_from_url      = getNVPV2(location.search, "pgm",          false, "=", "&");
    g_dr_offer_info_from_url    = getNVPV2(location.search, "OfferID",      false, "=", "&");

    var tempValue   = "";

    if (g_dr_pgm_info_from_url != null && g_dr_pgm_info_from_url != "")
    {
          tempValue = "pgm=" + g_dr_pgm_info_from_url;
          tempValue += (g_dr_offer_info_from_url != null && g_dr_offer_info_from_url != "") ? "&OfferID="+g_dr_offer_info_from_url: "" 
    }

    return tempValue;
}

function getDR_cookie_info()
{
    g_dr_pgm_info_from_cookie   = getNVPV2(getCookie("digitalriver")==null ? "" :getCookie("digitalriver") ,   'pgm',            false, "=", "&"); 
    g_dr_offer_info_from_cookie = getNVPV2(getCookie("digitalriver")==null ? "" :getCookie("digitalriver") ,   'OfferID',        false, "=", "&");

    var tempValue   = "";

    if (g_dr_pgm_info_from_cookie != null && g_dr_pgm_info_from_cookie != "")
    {
        tempValue  = "pgm=" + g_dr_pgm_info_from_cookie;
        tempValue += (g_dr_offer_info_from_cookie != null && g_dr_offer_info_from_cookie != "") ? "&OfferID="+g_dr_offer_info_from_cookie: "";
    }     

    return tempValue;
}

function getDR_ws_info()
{
    var tempValue   = "";

    tempValue = ws_partnerCID;

    return tempValue;
}

function processDigitalRiverCookie()
{
    // This function is called from one of two places:
    //  - onloadProcessing()        if web service not called
    //  - webServiceCallComplete()  if web service was called

    // if the otpPartnerId we determine we should use is different from the otpPartnerId in the digitalriver cookie, the cookie is:
    // - deleted if no pgm or pgm/OfferID info available to us (in url or web service)
    // - deleted if the web service returned a partner id other than the one we requested
    // - replaced with the otpPartnerId and pgm or pgm/OfferID we think we should use

    // if digitalriver cookie already exists but its otpPartnerId != the one we want to use, clear out the digitalriver cookie
    if (g_partner_id != getCookiePartnerId("digitalriver"))
    {
        // wipe out current digitalriver cookie
        tempCookieValue = "";   // since IE has issues deleting/expiring session cookies, just set cookie to ""
        setCookie("digitalriver", "", null, "/");

    }

    // The rules regarding what DR info to write to the digitalriver cookie is as follows where 'DR info' means "pgm=" or "pgm=x&OfferID=x":
    // - the DR info from the web service IF it returned information for a partner other than the one we requested
    // - if present, the DR info in the URL    - UNLESS the otpPartnerId in the url    <> partner id we determine is the correct one to use, in which case we delete the digitalriver cookie
    // - if present, the DR info in the cookie - UNLESS the otpPartnerId in the cookie <> partner id we determine is the correct one to use, in which case we delete the digitalriver cookie 
    // - if present, the DR info from the web service call 

    // Sample name/value pair for digitalriver is ?pgm.123456789/OfferID.1234567, NOT ?pgm=123456789&OfferID=123456789
    // Sample name/value pair for digitalriver is ?pgm.123456789/OfferID.1234567/otpPartnerId=3553, NOT ?pgm=123456789&OfferID=123456789&otpPartnerId=3553
   
    var dr_url_info    =  getDR_url_info();        // dr info in url
    var dr_cookie_info =  getDR_cookie_info();     // dr info in existing digitalriver cookie
    var dr_ws_info     =  getDR_ws_info();         // dr info returned from web service call

    var tempValue   = "";

    if (g_bWebServiceWasCalled && !g_bWebServiceCallFailed && g_b_ws_partner_id_different)
    {
        // If this condition is true, then always use the information from the web service (WS) call result (already assigend to g_partner_cid and g_partner_id) 
        // over any other url or cookie values.
        //
        // If the web service (WS) was called and the requested partner id is what the web service returned, then the DR precedence is URL, then COOKIE, then WS.
        // 
        tempValue = g_partner_cid;

    }
    else if ( (dr_url_info != null && dr_url_info != "") && g_partner_id == getUrlPartnerId() )
    {
        // DR info found in URL and partner id in URL is same as the partner id we determined we need to use
        tempValue = dr_url_info;

    }
    else if ( (dr_cookie_info != null && dr_cookie_info != "" ) && g_partner_id == getCookiePartnerId("digitalriver") )
    {
        // DR info found in COOKIE and partner id in COOKIE is same as the partner id we determined we need to use
        tempValue = dr_cookie_info;

    }
    else if (g_bWebServiceWasCalled)
    {   // (dr_ws_info != null || dr_ws_info != "")
        // take information from the web service if any
        tempValue = dr_ws_info;

    }

    g_partner_cid = tempValue;  // now we know the dr info to use, so set the global variable to hold its value

    if (tempValue != "")
    {
        tempValue = "otppartnerid="+g_partner_id+"&"+tempValue;

        setCookie("digitalriver", tempValue, null, "/");
    }    






}

// ***********************************************
// onloadProcessing()
// ***********************************************
function onloadProcessing()
{   
    // By the time we get here, any offermatica calls that might have changed the partner
    // id (and thus the product pricing) will have executed and called offermaticaPartnerSelect().
    


    g_partner_id_from_search_engine = getSearchEnginePartnerId();
    g_partner_id_from_url           = getUrlPartnerId();
    g_partner_id_from_cookie        = getCookiePartnerId("main_cookie");
    g_partner_id_from_offermatica   = getOffermaticaPartnerId();

    setPartnerIdToUse();

    processMainCookie();
   




    // check if CampaignID should be written to a cookie
    campaignIdCheck();          // check if CampaignID should be written to a cookie

    // ********************************************************************
    // If g_bGetProductInfo is true if getElementsByAttribute() finds at least one element 
    // with an id that begins with prodPrice, as in <span id="prodPrice31"></span> 
    // then call the product web service
    // ********************************************************************


    // dynamic partner and product info not available until post-hrblock.com launch
    if (g_bGetProductInfo || (getElementsByAttribute("id", "prodPrice").length > 0) || (document.location.pathname.indexOf('/taxes/partner/index.jsp') != - 1) )
    {       



        // NOTE: Javascript processing continues on without waiting for the asynchronous web service call in getProductInfo() to finish.  If you want
        // code to execute AFTER the web service call is complete, put the code in function webServiceCallComplete().
        getProductInfo(g_partner_id,g_tunneledPage);       // get information about products assigned to this partner
        // NOTE: Javascript processing continues on without waiting for the asynchronous web service call in getProductInfo() to finish.  If you want
        // code to execute AFTER the web service call is complete, put the code in function webServiceCallComplete().
    }
    else
    {
        processDigitalRiverCookie();
        continueOnloadProcessing();
    }
}

function continueOnloadProcessing()
{
    // if no web service calls on page: this is called directly by onloadProcessing()
    // if web services calls were done: this is called by webServiceCallComplete()

    if ( (typeof is_homepage) !='undefined' && (is_homepage) )
    {
        try
        {
            updatePriceValuesInFlash(); 
        }
        catch (e)
        {
            //
        }
    }

    try
    {   
        specialOnloadProcessing();  // this function can be defined by anyone requiring a special function 
                                    // to run after the document has loaded, like Ajay needed for Omniture
    }
    catch (e)
    {
        // specialOnloadProcessing() is not required to appear on the page so intercept this error
    }
/*
    if (getCookiePartnerId("digitalriver") != "" && (getCookiePartnerId("digitalriver") != getCookiePartnerId("main_cookie")) )
    {
        alert("Condition: The dr value '"+getCookiePartnerId("digitalriver")+"' <> main_cookie value '"+getCookiePartnerId("main_cookie"));
    }
*/

    if (getQueryValue("testExceptionLogging")=="true")
    {
        recordExceptionInOmniture("ocs","0","Exception logging is working.");
    }
}






// ***********************************************
// offermaticaPartnerSelect()
// ***********************************************
function offermaticaPartnerSelect(om_partner_id)
{
    g_partner_id_from_offermatica = om_partner_id;

}

function getNVPvalue(strURL, strParmName, bCaseSpecific)
{
    return getNVPV(strURL, strParmName, bCaseSpecific);
}

// ****************
// similar to getNVPV2(strURL, strParmName, bCaseSpecific, operator, delimiter) below
// ****************
function getNVPV(strURL, strParmName, bCaseSpecific)
{   
    // Description: returns value of a name/value pair in the passed URL string
    // Usage: getNVPV(url, 'ADCAMPAIGN', '1');
    //
    // Parameters:
    //   strURL: url to extract the name/value pair from
    //   strParmName: name part of name/value pair
    //   bCaseSpecific: when searching for name, use case passed to function. 1==true; 0==false
    //
    // Returns:
    //  the value of the nvp if found and "" if not found

    if (bCaseSpecific)
    { 
    }
    else
    {
        strParmName = strParmName.toLowerCase();
        strURL      = strURL.toLowerCase();
    }

    var strChar = "";

    if (strURL.indexOf("?"+strParmName+"=") != -1)
    {   strChar = "?";
    }
    else if (strURL.indexOf("&"+strParmName+"=") != -1)
    {   strChar = "&";
    }
    else
    {   return "";
    }

    var strTemp1 = strURL.substring(strURL.indexOf(strChar+strParmName+"=")+strParmName.length+2, strURL.length);

    if (strTemp1.indexOf("&", 0) == -1)
    {   return strTemp1;
    }
    else
    {   return strTemp1.substring(0, strTemp1.indexOf("&"));
    }
}

// ****************
// similar to getNVPV(strURL, strParmName, bCaseSpecific) above
// ****************
function getNVPV2(strURL, strParmName, bCaseSpecific, operator, delimiter)
{   
    // Description: returns value of a name/value pair in the passed URL string
    // Usage: getNVPV2(url, 'otpPartnerId', '1', '=', '&');
    // Usage: getNVPV2(url, 'OfferID', '1', '.', '/');
    // Usage: getNVPV2(url, 'pgm', '1', '.', '/');
    //
    // Parameters:
    //   strURL: url to extract the name/value pair from
    //   strParmName: name part of name/value pair
    //   bCaseSpecific: when searching for name, use case passed to function. 1==true; 0==false
    //
    // Returns:
    //  the value of the nvp if found and "" if not found

    if (bCaseSpecific)
    { 
    }
    else
    {
        strParmName = strParmName.toLowerCase();
        strURL      = strURL.toLowerCase();
    }

    var strChar = "";

    if (strURL.indexOf("?"+strParmName+operator) != -1)
    {   strChar = "?";
    }
    else if (strURL.indexOf(delimiter+strParmName+operator) != -1)
    {   strChar = delimiter;
    }
    else
    {   return "";
    }

    var strTemp1 = strURL.substring(strURL.indexOf(strChar+strParmName+operator)+strParmName.length+2, strURL.length);

    if (strTemp1.indexOf(delimiter, 0) == -1)
    {   return strTemp1;
    }
    else
    {   return strTemp1.substring(0, strTemp1.indexOf(delimiter));
    }
}

function getSearchTerm()
{
    // If possible, get the search term passed to us from certain search engines.  This term can be
    // used for various purposes across the site

    // determine if referrer is available
    // determine if referrer is a search engine
    // extract search term from appropriate name/value pair
    
    var referrer_query = "";

    if (document.referrer != null)
    {   // referrer information is available
        if (document.referrer.indexOf("?") != -1)
        {   // referrer sent a query string in url
            referrer_query = document.referrer.substr(document.referrer.indexOf("?")); 
        }
    }   
    else
    {
        return;
    }

    if ((document.referrer.indexOf('google.com') > -1) )
    {
        g_bReferrerIsSearchEngine = true;
        g_searchEngineTerm    =  referrer_query=="" ? "" : getNVPV(referrer_query, 'q', false); 
    } 
    else if ((document.referrer.indexOf('yahoo.com') > -1)) 
    {
        g_bReferrerIsSearchEngine = true;
        g_searchEngineTerm    = referrer_query=="" ? "" : getNVPV(referrer_query, 'p', false); 
    } 
    else if ((document.referrer.indexOf('msn.com') > -1)) 
    {
        g_bReferrerIsSearchEngine = true;
        g_searchEngineTerm    = referrer_query=="" ? "" : getNVPV(referrer_query, 'q', false);                
    } 
    else if ((document.referrer.indexOf('aol.com') > -1)) 
    {
        g_bReferrerIsSearchEngine = true;
        g_searchEngineTerm    = referrer_query=="" ? "" : getNVPV(referrer_query, 'query', false); 

        if (g_searchEngineTerm=="")
        {
            g_searchEngineTerm    = referrer_query=="userQuery-nfd" ? "" : getNVPV(referrer_query, 'userQuery', false); 
        }               
    } 
    else if ((document.referrer.indexOf('netscape.com') > -1)) 
    {
        g_bReferrerIsSearchEngine = true;
        g_searchEngineTerm    = referrer_query=="" ? "" : getNVPV(referrer_query, 'query', false); 

        if (g_searchEngineTerm=="")
        {
            g_searchEngineTerm    = referrer_query=="userQuery-nfd" ? "" : getNVPV(referrer_query, 'userQuery', false); 
        }                
    } 
    else if ((document.referrer.indexOf('ask.com') > -1)) 
    {
        g_bReferrerIsSearchEngine = true;
        g_searchEngineTerm    = referrer_query=="" ? "" : getNVPV(referrer_query, 'q', false);

        if (g_searchEngineTerm=="")
        {
            g_searchEngineTerm    = referrer_query=="" ? "" : getNVPV(referrer_query, 'ask', false); 
        }
    }  

    if (g_bReferrerIsSearchEngine && g_searchEngineTerm=="")
    {
        g_searchEngineTerm="search_term_not_available";
    }
}

function getSearchEnginePartnerId()
{
    // if (no partner id passed in url and no partner id in cookie) AND
    //   if (not from paid search) AND
    //      if (from search engine) THEN
    //          write appropriate partner id assigned to that search engine to the cookie
    //          so it gets passed along to otp

    var searchPID   = "";
    var srchsim     = "";

    // this line allows us to simulate search engine referrals
    srchsim = getQueryValue("srchsim");    

    if (document.referrer != null)
    {
        getSearchTerm();
    }
    else
    {
        // can't get referrer so return null for search engine partner id
        return null;
    }

    // check if visitor came from paid search

    if ( (g_bReferrerIsSearchEngine && location.search.indexOf('omnisource=') != -1) || ((srchsim != "") && location.search.indexOf('omnisource=') != -1) )
    {
        g_paidSearch = 1; // g_paidSearch value is referenced in the omniture code
    }

    if (g_paidSearch!="1")
    {
        // if we came from a search engine (but not paid search),  write that search engine partner id to the cookie
        if ( (document.referrer != null) || (srchsim != "") )
        {
            if ((document.referrer.indexOf('google.com') > -1)          || (srchsim=="google") )
            {
                //searchPID   =  2054;    // hrblock.com
                searchPID   =  2260;    // taxcut.com
            } 
            else if ((document.referrer.indexOf('yahoo.com') > -1)      || (srchsim=="yahoo") ) 
            {
                //searchPID   =  2055;    // hrblock.com
                searchPID   =  2259;    // taxcut.com
            } 
            else if ((document.referrer.indexOf('msn.com') > -1)        || (srchsim=="msn") ) 
            {
                //searchPID   =  2056;    // hrblock.com
                searchPID   =  2258;    // taxcut.com
            } 
            else if ((document.referrer.indexOf('aol.com') > -1)        || (srchsim=="aol") ) 
            {
                //searchPID   =  2057;    // hrblock.com
                searchPID   =  2263;    // taxcut.com
            } 
            else if ((document.referrer.indexOf('netscape.com') > -1)   || (srchsim=="netscape") ) 
            {
                //searchPID   =  2058;    // hrblock.com
                searchPID   =  2261;    // taxcut.com
            } 
            else if ((document.referrer.indexOf('ask.com') > -1)  || (srchsim=="ask") ) 
            {
                //searchPID   =  2059;    // hrblock.com
                searchPID   =  2262;    // taxcut.com
            } 
        }
    }   

    return searchPID;
}

function campaignIdCheck() 
{
    g_campaign_id      = getQueryValue('CampaignID');

    if(g_campaign_id != null) 
    {
        setCookie('hrblockCampaignIDcookie', 'CampaignID=' + g_campaign_id, null, "/");
    }
}

function getCookieInfoForSignon()
{
   taxType  = getQueryValue("TaxType");

    if (taxType == null)
    {   // if no TaxType specified then assume opp for unavailable check below
        taxType = "opp";   // default to opp if TaxType nvp not specified
    }
   
   document.signon.PartnerID.value      = g_partner_id;
   document.signon.time_entered.value   = g_time_entered;      
   
   setCookie("OTPCookie", taxType, 365, "/", ".hrblock.com");
}

function isTunneledPage()
{
    if (document.location.href.indexOf("/taxes/partner/") == -1)
    {   
        return false
    }
    else
    {
        return true;
    }
}

function processMainCookie()
{
    var qs      = "";
    var tempQS  = "";

    qs  = location.search;
    qs  = unescape(qs);

    if (g_partner_id_from_offermatica != "" && g_partner_id_from_offermatica != null)
    {
        // write cookie using offermatica id and tag on partnerid for otp
        setCookie("main_cookie","otpPartnerId="+g_partner_id+"&PartnerId="+g_partner_id, null, "/");
    }
    else if (g_partner_id_from_url != "" && g_partner_id_from_url != null)
    {
        if (g_partner_id_from_url == g_partner_id_from_cookie)
        {
            // url id == cookie id so do not re-write the cookie otherwise other parms in the cookie would be lost
        }
        else
        {        
            // url id != cookie id so write cookie using current query string and tag on partnerid for otp
            if (qs.indexOf("?")!=-1) 
            {
                qs = qs.slice(qs.indexOf("?")+1);
            }
            tempQS      = qs.toLowerCase();     // allows search for parm otppartnerid to be case indifferent
            iBeginPos   = tempQS.indexOf("otppartnerid");
            qs = qs.substring(0,iBeginPos)+"otpPartnerId="+qs.substring(iBeginPos+13,qs.length);
            setCookie("main_cookie", qs+"&PartnerID="+g_partner_id, null, "/");            
        }
    }
    else if (g_partner_id_from_cookie != "" && g_partner_id_from_cookie != null)
    {
        // do nothing
    }
    else if (g_partner_id_from_search_engine != "" && g_partner_id_from_search_engine != null)
    {
        // is this an organic, non-paid search engine referral
        setCookie("main_cookie", "otpPartnerId="+g_partner_id+"&PartnerId="+g_partner_id_from_search_engine+"&srchTerm="+g_searchEngineTerm, null, "/");
    }
    else
    {
        // no partner id specified in url/cookie or can be inferred, so use default parnter id for this domain + current query string 
        if (qs.indexOf("?")!=-1) 
        {
            qs = qs.slice(qs.indexOf("?")+1);
        }
        setCookie("main_cookie", qs+"&otpPartnerId="+g_partner_id+"&PartnerID="+g_partner_id, null, "/");  
    }
}

function showDownPage()
{        
    var otpWin;

    if (otpWin = window.open(sysprop_returnUser_maint_url,"otpstatus","width=560,height=280,scrollbars=yes"))
    {
    }
    else
    {
        alert(sysprop_returnUser_maint_msg);
    }
}

function FindAction(Entity)
{
    // this function is called by the taxcut online login section in the header

    getCookieInfoForSignon();

    if (Entity == 'Register' )
    {
        SubmitValidation();
        return true;
    }
    else if (Entity == 'ForgotPassword' )
    {
        window.location = 'ForgotPassword.aspx?BackPage=Login&'
                }
    else if (Entity == 'Update' )
    {
        window.location = 'Login.aspx?Target=UpdateUserInformation&taxtype=OTP&PartnerID='
    }
    else if (Entity == 'Policy' )
    {
        openCTWindow('SecurityPolicy','/universal/privacy.html','status,resizable,width=' + parseInt(Math.min(screen.availWidth,800)) + ',height=' + parseInt(Math.min(screen.availHeight,600)-25) + ',left=0,top=0,screenX=0,screenY=0,scrollbars=1');
    }
    else if (Entity == 'Login' )
    {
        return true;
    }

} //end FindAction()

function doTaxes()
{   //document.location="/taxes/doing_my_taxes/";
        document.location="/taxes/products/product.jsp?productId=31";
}

function doExtension()
{   //document.location="/taxes/doing_my_taxes/products/extension.html";
        document.location="/taxes/products/product.jsp?productId=69";
}    

function otpLogin() 
{
    if(document.getElementById('txtusername').value != '' && document.getElementById('txtpassword').value != '') {
        if ( (typeof sysprop_showPopUnder) !='undefined' && sysprop_showPopUnder==1 ) {
            try {
                window.open('','popunderotp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=10,height=10,left=2000,top=2000').close();
            } catch(e) { }
        }
        if ( (typeof sysprop_otpStatus)!='undefined' && (sysprop_otpStatus==1 || sysprop_otpStatus==2)) {
            showDownPage();
            return false;
        } else {
            FindAction('Login');
        }
    }
}

function loadinparent(url)
{
    top.location.href = url;
}

// **********************************************************************************
// BEGIN: Calculator related code
// **********************************************************************************

var calcURLS =new Array();
var omnivariable =new Array();
calcURLS[0]='';
calcURLS[1]='';
//DeductionFind (aka Occupational Planner)
calcURLS[2]='/taxes/tax_tips/tax_planning/jobdeduction_finder.html';
//2006 AMT Calculator
//calcURLS[3]='/taxes/tools/2006_amtcalc/frameset.jsp';
//changed to 2007
calcURLS[3]='http://www.hrblock.com/calcs/calculators2007/amtestimator2007/frameset.jsp'
omnivariable[3]='AMT_'
//2006 Withholding
calcURLS[4]='http://www.hrblock.com/calcs/calculators2007/whcalc2007/main.jsp';
//2006 Savers Credit Calculator
//calcURLS[5]='/taxes/tools/2006_saverscalc/frameset.jsp';
//changed to 2007
calcURLS[5]='http://www.hrblock.com/calcs/calculators2007/savers2007/frameset.jsp';
omnivariable[5]='savers_2007_'
//Checklist Tool
calcURLS[6]='/taxes/tax_tips/tax_planning/tax_checklist.html';
omnivariable[6]='checklist_'
//Rate Tables
calcURLS[7]='/taxes/tax_calculators/rate_tables/filing_status.html';
omnivariable[7]='ratetables_status'
//Advice JSP pages
calcURLS[8]='/learning/advice/advice_generator/osadviceoptions.jsp';
//2006 DayCare Calculator
//calcURLS[9]='/taxes/tools/2006_daycarecalc/frameset.jsp';
//changed to 2007
calcURLS[9]='http://www.hrblock.com/calcs/calculators2007/daycare2007/frameset.jsp';
omnivariable[9]='daycare_2007_'
//2006 Education Tax Benefit Calculator
//calcURLS[10]='/taxes/tools/2006_educalc/frameset.jsp';
//2007 Education Tax Benefit Calculator
calcURLS[10]='http://www.hrblock.com/calcs/calculators2007/eduestimator2007/frameset.jsp';
omnivariable[10]='edutax_2007_'
//2006 Self-employment Calculator
//calcURLS[11]='/taxes/tools/2006_secalc/frameset.jsp';
//2007 Self-employment Calculator
calcURLS[11]='http://www.hrblock.com/calcs/calculators2007/seestimator2007/frameset.jsp';
omnivariable[11]='selfemp_2007_'
//2005 Tax Estimator
calcURLS[12]='/taxes/tools/2005_taxcalc/frameset.jsp';
//2005 DayCare Calculator
calcURLS[13]='http://www.hrblock.com/taxes/tools/2005_daycarecalc/frameset.jsp';
//2005 AMT Calculator
calcURLS[14]='/taxes/tools/2005_amtcalc/frameset_2.jsp';
//2005 Educaton Tax Benefit Calculator
calcURLS[15]='/taxes/tools/2005_educalc/frameset.jsp';
//2005 Savers Credit Calculator
calcURLS[16]='/taxes/tools/2005_saverscalc/frameset.jsp';
//2005 Self-employment Calculator
calcURLS[17]='/taxes/tools/2005_SEcalc/new_frameset.jsp';
//2005 Self-employment Calculator
calcURLS[18]='http://www.hrblock.com/calcs/calculators2007/taxestimator2007/frameset.jsp';
omnivariable[18]='Tax_Est2007_';
var omniName="";
function showCalcs(indx,referlink)
{
 var calcLinks =new Array('none','taxest','dedfind','amt','with')
if( indx==5 || indx==9 || indx==10 || indx==11)
            {
                         WinOpen_(calcURLS[indx],875,500)
            }
else if( indx==6 || indx==7)
            {
                 var tmpURL=document.location.pathname;
                         document.location=calcURLS[indx]
            }
else if(indx==1 || indx==2 || indx==4 || indx==18 || indx==3)
{
            var tmpURL=document.location.pathname;
            if (tmpURL.indexOf('tax_tips/index.html')>0)
            {
                displayCalc(indx,referlink);
                //trackWebAnalytics();
            }
            else
            {
                document.location='/tax_tips/index.html?calcIndx='+indx+'&referlink='+referlink;
            }
}
else
 document.location="/tax_tips/index.html?calcIndx="+indx
}

// specifically for calculators as the start button should open this in a new window

function staticProductStartNowNewWin(requestedProductId)
{ 
    // Read the main_cookie to retrieve (if available) the otpPartnerId and other parms
    // that may have been passed into inital visit to hrblock.com.  
    
    // if no cookie value is found, use otpPartnerId=0
    
    var cookieValue = getCookie("main_cookie");    
    
    // Sometimes we pass additional name/value pairs to start now links which
    // need to be appended to the target start now link. 
    // Add additional parms to this method following one of these two methods:
    // staticPageStartNow(31,"&newparm1=newvalue1","&newparm2=newvalue2");
    // staticPageStartNow(31,"&newparm1=newvalue1&newparm2=newvalue2");
    
    var additionalParms = "";
    
    var args    = staticProductStartNowNewWin.arguments;
    var argsLen = staticProductStartNowNewWin.arguments.length;
            
    for(var i=0; i<argsLen; i++) 
    {       
        if (args[i].toString().charAt(0)=="&")
        { 
            additionalParms = args[i];
        }
    }
    
    var parms = cookieValue + additionalParms;        

    window.open(hrb_s[requestedProductId] + parms,'productwin','left=20,top=20,width=900,height=500,toolbar=1,resizable=1');
}
// **********************************************************************************
// END: Calculator related code
// **********************************************************************************


function bookmark()
{
  if (window.sidebar) 
  { 
      // Mozilla Firefox Bookmark		
      window.sidebar.addPanel(document.title, location.href,"");	
  } 
  else if( window.external ) 
  { 
        // IE Favorite		
      window.external.AddFavorite( location.href, document.title); 
  }
  else 
  {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) or CTRL-D (Safari) to bookmark");
  }
}

function emailtaxtips()
{
    var tax_tip_email_path = "//www.hrblock.com/taxtip/email_tax_tips.jsp";
	WinOpen_(tax_tip_email_path, 580, 500);
}


// **************************************************************************
// BEGIN: The tc_s[] and tc_l[] variable definitions below for use on TAXCUT.COM
// **************************************************************************
var tc_s  = new Array(); // holds start now link info
var tc_l  = new Array(); // holds learn more link info

// *******************************************************************************************
//TAXCUT.COM 'START NOW' links for 2006-2007 - Use these AFTER 11/30/2007 at 11:59pm when tco products launch
// *******************************************************************************************
// ONLINE and OFFICE
tc_s[30] = "http://www.hrblock.com/loginRedirect.html?TaxType=TCL&FV=T&HT=F&TaxYear=2007";            // tco basic
tc_s[31] = "/taxes/online/index.html?";                                                               // tco parent
tc_s[32] = "http://www.hrblock.com/loginRedirect.html?TaxType=OPP&FV=T&HT=F&TaxYear=2007";            // tco premium
tc_s[33] = "http://www.hrblock.com/loginRedirect.html?TaxType=SIG&FV=T&HT=F&TaxYear=2007";            // tco signature
tc_s[44] = "http://www.hrblock.com/loginRedirect.html?TaxType=TCL&FV=T&HT=F&Target=ATA&TaxYear=2007"; // tco ata
tc_s[46] = "http://www.hrblock.com/loginRedirect.html?TaxType=TCL&FV=T&HT=F&OtpExt=1&TaxYear=2007";   // extension  
tc_s[62] = "http://www.hrblock.com/loginRedirect.html?TaxType=PTS&FV=T&HT=F&TaxYear=2007&";           // office online office default
tc_s[69] = "http://www.hrblock.com/loginRedirect.html?TaxType=TCL&FV=T&HT=F&OtpExt=1&TaxYear=2007";   // tco extension
tc_s[80] = "http://www.hrblock.com/loginRedirect.html?TaxType=OPS&FV=T&HT=F&TaxYear=2007";            // tco premium + state
tc_s[84] = "https://tangotax.hrblock.com/tango.html?";                                                // tango
tc_s[188]= "http://www.hrblock.com/loginRedirect.html?TaxType=TCL&FV=T&HT=F&OtpExt=1&TaxYear=2007";   // extension  
tc_s[197]= "https://www.deductionpro.com/dpro/Welcome.jsp";                                           // deductionpro online

// *******
// TAXCUT.COM 'START NOW' links - SOFTWARE 
// The productID is received from the function getDigitalRiverProductId(product, format, platform)
// *******
tc_s[34] = "http://shop.taxcut.com/store/taxcut/DisplayHomePage";              // tcs parent
tc_s[35] = "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs basic
tc_s[36] = "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs premium + state + efile
tc_s[37] = "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs premium + state
tc_s[38] = "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs home and business
tc_s[39] = "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs state
tc_s[40] = "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs deduction pro
tc_s[78] = "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs file an extension
tc_s[81] = "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs premium
tc_s[82] = "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs willpower
tc_s[83] = "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs home and business attorney
tc_s[195]= "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs real estate attorney
tc_s[196]= "http://shop.taxcut.com/store/taxcut/AddItemToRequisition/productID=";   // tcs business attorney
// *******************************************************************************************
// TAXCUT.COM 'LEARN MORE' 
// *******************************************************************************************

// OFFICE
tc_l[62] = "/taxes/online/online_office.html?";         // office online office default

// ONLINE
tc_l[30] = "/taxes/online/basic.html?";                 // tco basic
tc_l[31] = "/taxes/online/index.html?";                 // tco parent
tc_l[32] = "/taxes/online/premium.html?";               // tco premium
tc_l[33] = "/taxes/online/signature.html?";             // tco signature
tc_l[44] = "/taxes/online/ask_a_tax_advisor.html?";     // tco ata
tc_l[69] = "/taxes/extensions.html?";                   // tco extension
tc_l[80] = "/taxes/online/premium_bundle.html?";        // tco premium + state
tc_l[84] = "http://www.hrblock.com/tango/index.html?";           // tango
tc_l[197]= "https://www.deductionpro.com/dpro/Welcome.jsp"; // deductionpro online

// SOFTWARE
tc_l[34] = "http://shop.taxcut.com/store/taxcut/DisplayHomePage"; // tcs parent
tc_l[35] = "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=NA";        // tcs 
tc_l[36] = "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=104758400";  // tcs premium + state + efile
tc_l[37] = "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=104757000";  // tcs premium + state
tc_l[38] = "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=104758800";  // tcs home and business
tc_l[39] = "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=81714000";  // tcs state
tc_l[40] = "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=82180500";  // tcs deduction pro
tc_l[78] = "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=NA";        // tcs file an extension
tc_l[81] = "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=104741300";  // tcs premium
tc_l[82] = "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=107118900";  // tcs willpower
tc_l[83] = "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=107118600";  // tcs home and business attorney
tc_l[195]= "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=107118000";  // tcs real estate attorney
tc_l[196]= "http://shop.taxcut.com/store/taxcut/DisplayProductDetailsPage/productID=107118100";  // tcs business attorney

// **************************************************************************
// End: The tc_s[] and tc_l[] variable definitions above for use on TAXCUT.COM
// **************************************************************************


// **************************************************************************
// BEGIN: The hrb_s[] and hrb_l[] variable definitions below for use on HRBLOCK.COM's header_init_hrblock_2008.js
// If the web service isn't called or fails, these hrb_s[] and hrb_l[] values are used instead of pStart[][[] and pLearn[][].
// **************************************************************************
var hrb_s = new Array();  // holds start now link info
var hrb_l = new Array();  // holds learn more link info

// *******************************************************************************************
// HRBLOCK.COM 'START NOW' links for 2006-2007 - Use these AFTER 11/30/2007 at 11:59pm when hrblock.com launches
// *******************************************************************************************
// ONLINE and OFFICE
hrb_s[30] = "/loginRedirect.html?TaxType=TCL&FV=T&HT=F&TaxYear=2007&";            // tco basic
hrb_s[31] = "/product.jsp?productId=31&";                                         // tco split page
hrb_s[32] = "/loginRedirect.html?TaxType=OPP&FV=T&HT=F&TaxYear=2007&";            // tco premium
hrb_s[33] = "/loginRedirect.html?TaxType=SIG&FV=T&HT=F&TaxYear=2007&";            // tco signature
hrb_s[44] = "/loginRedirect.html?TaxType=TCL&FV=T&HT=F&Target=ATA&TaxYear=2007&"; // tco ata
hrb_s[46] = "/loginRedirect.html?TaxType=TCL&FV=T&HT=F&OtpExt=1&TaxYear=2007&";   // extension   
hrb_s[62] = "/loginRedirect.html?TaxType=PTS&FV=T&HT=F&TaxYear=2007&";            // tco online office
hrb_s[64] = "/product.jsp?productId=64&";                                         // tco online services split
hrb_s[65] = "/universal/office_locator.html?";                                    // tco office locator
hrb_s[69] = "/loginRedirect.html?TaxType=TCL&HT=F&FV=F&OtpExt=1&TaxYear=2007&";   // tco extension
hrb_s[80] = "/loginRedirect.html?TaxType=OPS&FV=T&HT=F&TaxYear=2007&";            // tco premium + state
hrb_s[84] = "https://tangotax.hrblock.com/tango.html";                            // tango
hrb_s[85] = "/loginRedirect.html?TaxType=OTP&FV=T&HT=F&TaxYear=2007&";            // tco FFA
hrb_s[197]= "https://www.deductionpro.com/dpro/Welcome.jsp";                      // deductionpro online

// *******
// HRBLOCK.COM 'START NOW' links - SOFTWARE
// These links don't go directly to digital river but instead get processed by /taxes/product/product.jsp which
// evaluates the tcfmt ["dl","cd"] and tcpf ["pc","mac"] to determine which productID to use in the DR link.  This is 
// required because if a page doesn't call the web service, the DR pgm and OfferID information will only be known by a
// call to product.jsp.
// ******* 
hrb_s[34] = "product.jsp?productId=34&";    // tcs split page
hrb_s[35] = "product.jsp?productId=35&";    // tcs basic
hrb_s[36] = "product.jsp?productId=36&";    // tcs premium + state + efile
hrb_s[37] = "product.jsp?productId=37&";    // tcs premium + state
hrb_s[38] = "product.jsp?productId=38&";    // tcs home and business
hrb_s[39] = "product.jsp?productId=39&";    // tcs state
hrb_s[40] = "product.jsp?productId=40&";    // tcs deduction pro
hrb_s[78] = "product.jsp?productId=78&";    // tcs extension
hrb_s[81] = "product.jsp?productId=81&";    // tcs premium
hrb_s[82] = "product.jsp?productId=82&";    // tcs willpower
hrb_s[83] = "product.jsp?productId=83&";    // tcs home and business attorney
hrb_s[195]= "product.jsp?productId=195&";   // tcs real estate attorney
hrb_s[196]= "product.jsp?productId=196&";   // tcs business attorney

// *******
// HRBLOCK.COM 'LEARN MORE' links - OFFICE and ONLINE
// *******
hrb_l[30] = "product.jsp?productId=30&";    // tco basic
hrb_l[31] = "product.jsp?productId=31&";    // tco split page
hrb_l[32] = "product.jsp?productId=32&";    // tco premium
hrb_l[33] = "product.jsp?productId=33&";    // tco signature
hrb_l[44] = "product.jsp?productId=44&";    // tco ata
hrb_l[46] = "product.jsp?productId=46&";    // extension
hrb_l[62] = "product.jsp?productId=62&";    // tco online office
hrb_l[64] = "product.jsp?productId=64&";    // tco online services split
hrb_l[65] = "product.jsp?productId=65&";    // tco office locator
hrb_l[69] = "product.jsp?productId=69&";    // tco extension
hrb_l[80] = "product.jsp?productId=80&";    // tco premium + state
hrb_l[84] = "/tango/index.html?";           // tango
hrb_l[85] = "product.jsp?productId=85&";    // tco FFA
hrb_l[197]= "https://www.deductionpro.com/dpro/Welcome.jsp";    // deductionpro online

// *******
// HRBLOCK.COM 'LEARN MORE' links - SOFTWARE
// *******
hrb_l[34] = "product.jsp?productId=34&tclm=1&";     // tcs split page
hrb_l[35] = "product.jsp?productId=35&tclm=1&";     // tcs basic
hrb_l[36] = "product.jsp?productId=36&tclm=1&";     // tcs premium + state + efile
hrb_l[37] = "product.jsp?productId=37&tclm=1&";     // tcs premium + state
hrb_l[38] = "product.jsp?productId=38&tclm=1&";     // tcs home and business
hrb_l[39] = "product.jsp?productId=39&tclm=1&";     // tcs state
hrb_l[40] = "product.jsp?productId=40&tclm=1&";     // tcs deduction pro
hrb_l[78] = "product.jsp?productId=78&tclm=1&";     // tcs extension
hrb_l[81] = "product.jsp?productId=81&tclm=1&";     // tcs premium
hrb_l[82] = "product.jsp?productId=82&tclm=1&";     // tcs willpower
hrb_l[83] = "product.jsp?productId=83&tclm=1&";     // tcs home and business attorney
hrb_l[195]= "product.jsp?productId=195&tclm=1&";    // tcs real estate attorney
hrb_l[196]= "product.jsp?productId=196&tclm=1&";    // tcs business attorney

// **************************************************************************
// END: The hrb_s[] and hrb_l[] variable definitions above for use on HRBLOCK.COM.com's header_init_hrblock_2008.js
// **************************************************************************


// ********
// This function accepts the parameters
//  site           ALWAYS REQUIRED. Valid values are 'hrblock' or 'taxcut'.
//  linkname       Optional: Used for omniture reporting
//  &              Optional: A parm starting with "&" will be appended to the destURL
//
// sample usage:
//  productLearnMore(35, "site:taxcut");
//  productLearnMore(35, "site:hrblock", "linkname:uniqueId"); 
//  productLearnMore(35, "site:hrblock", "linkname:uniqueId", "&customname=customvalue&a=b&name=value"); 
//  
// certain situations require calling the function this way where sid=1 is hrblock and sid=2 is taxcut
// productLearnMore(35, sid)
// ********
function productLearnMore(requestedProductId)
{
    var siteName        = "";
    var destURL         = "";
    var uniqueId        = "";   // Valued from optional parm. Sent to webAnalytics() call to uniquely identify which object on page was clicked
    var args            = arguments;
    var argsLen         = arguments.length;
  
    // determine which "learn more" function should be called
    for (var x=0; x<argsLen; x++ )
    {
        if ((''+arguments[x]).indexOf("site:") != -1)
        {
            siteName    = arguments[x].substr(5).toLowerCase();

            if (siteName != "hrblock" && siteName != "taxcut")
            {
                alert("invalid site '"+siteName+"' to productLearnMore()");
            }
        }

        if ((''+arguments[x]).indexOf("linkname:") != -1)
        {
            // if found, append that value to the webAnalytics() call in the linkname: parm.
            // var uniqueId   = the value part of the parm 'linkname:value'      
            uniqueId    = arguments[x].substr(9);
        }

    }

try
{
	if (getQueryValue("bugClicks")=="true")
	{
        var bugMsg  = "";
        bugMsg += "productLearnMore(";

        var bAddComma  = false;

        var args            = arguments;
        var argsLen         = arguments.length;

        for (var x=0; x<argsLen; x++ )
        {
            if (bAddComma)
            {
                bugMsg += ",";
            }
            bugMsg += arguments[x];            
            bAddComma  = true;
        }

        bugMsg += ")";
        alert(bugMsg);
	}
}
catch (e)
{
}

    if (arguments[1]==1)
    {
        siteName = "hrblock";
    }
    else if (arguments[1]==2)
    {
        siteName = "taxcut";
    }

    if (siteName=="")
    {
        if (location.host.indexOf("taxcut.com") != -1)
        {
            siteName    = "taxcut";
        }
        else
        {
            siteName    = "hrblock";
        }
    }

    if (siteName=="hrblock" && ( (location.host.indexOf("taxcut.com") != -1) || (location.host.indexOf("msitep") != -1) || (location.host.indexOf("k4te") != -1)  )  )
    {
        //destURL += "//www.hrblock.com";
    }

    if (siteName == "hrblock")
    {
        // certain flash objects pass additional name/value pair to this function which
        // need to be appended to the target learn more link.  start at 2nd argument
        // since first arg is always the product id - pintar    
        var additionalParms = "";
    
        var args    = productLearnMore.arguments;
        var argsLen = productLearnMore.arguments.length;
    
        for(var i=0; i<argsLen; i++) 
        {                   
            if (args[i].toString().charAt(0)=="&")
            { 
                additionalParms = args[i];
                // alert("tagging on "+additionalParms);
            }
        }

        //  If web service call wasn't made or fails, populate pLearn[][] from hard coded values in hrb_l[]
        if ((typeof pLearn[0][0])=="undefined" || pLearn[0][0] == null || pLearn[0][0] == "")
        {   
            //alert("pLearn[0][0]=="+pLearn[0][0]+" and wsc cookie is "+getCookie("wsc")+". Trying to populate form cookie.");

            // The pLearn[][] array would not have been populated if this page didn't trigger a call
            // to the web service (by the presence of a prodPriceXX element, etc).  This valid condition
            // means we have to try to value the product info from the cookie, then if there still isn't
            // product info, use static info instead.

            // try to value the pLearn[][] from the cookie then try again
            getWebServiceCookie();

            if ((typeof pLearn[0][0])=="undefined" || pLearn[0][0] == null || pLearn[0][0] == "")
            {
                // unable to value from cookie so use static data
                g_bUseStaticData  = true;
            }
            else
            {
                //alert("using pLearn[][] data from web service cookie");
            }
        }

        // g_bUseStaticData will only be false here if we were unable to populate the pLearn[][] array directly from
        // the web service call or from the web service cookie

        var bTargetPageIsJSP   = false;
        
        if (g_bUseStaticData && (hrb_l[requestedProductId].indexOf(".jsp") != -1))
        {
            bTargetPageIsJSP  = true;
        }
        else 
        {
            for (x=0; x < 50; x++)
            {
                if (pLearn[x][0] == requestedProductId && (pLearn[x][1].indexOf(".jsp") != -1))
                {
                    bTargetPageIsJSP  = true;
                    break;
                }
            }
        }

        //if (g_tunneledPage && (hrb_l[requestedProductId].indexOf(".jsp") != -1) )
        if (bTargetPageIsJSP)
        {
            if (g_tunneledPage)
            { 
                destURL = "/taxes/partner/";
            }
            else
            {
                destURL = "/taxes/products/";
            }
        }

        var bFound  = false;
    
        if (g_bUseStaticData)
        {
            //alert("Using static learn more link '"+hrb_l[requestedProductId]+"'");
            //destURL    += hrb_l[requestedProductId] + additionalParms + getCookie("main_cookie");
            destURL    += hrb_l[requestedProductId] + additionalParms;
            //alert("static destURL=='"+destURL+"'");
            bFound  = true;
        }
        else
        {   
            for (x=0; x < 50; x++)
            {
                if (pLearn[x][0] == requestedProductId)
                {
                    destURL += pLearn[x][1]+additionalParms;
                    bFound  = true;
                    break;
                }
            }
        }

        if (bFound)
        {
        }
        else
        {
            //alert("Product '"+requestedProductId+"' not assigned to partner '"+g_partner_id+"'");
            //return;
        }
    }
    else if (siteName == "taxcut")
    {
        destURL = tc_l[requestedProductId];

        // if destination is digital river then append the digitalriver cookie contents
        if (tc_l[requestedProductId].indexOf("shop.taxcut.com") != -1)
        {
            destURL += "&" + getCookie("digitalriver");
        }
        else
        {
             destURL += "&" + getCookie("main_cookie");
        }

    }

    var pageNameToUse   = ((typeof omni_pagename)!="undefined" && omni_pagename != "") ? omni_pagename : "";

    var newanchor = document.createElement("a");

    newanchor.setAttribute('href',  document.location.href);        

    try
    {




        // remove any & characters from pageNameToUse and uniqueId otherwise webAnalytics() will not properly parse the paraemters when these are used in prop6 and eVar11

        pageNameToUse   = pageNameToUse.replace(/&/g, "^");
        uniqueId        = uniqueId.replace(/&/g, "^");
        webAnalytics(newanchor, 'trackvars:prop6='+pageNameToUse+"-"+requestedProductId+"-"+uniqueId+'&eVar11='+pageNameToUse+"-"+requestedProductId+"-"+uniqueId+'&', 'trackevents:' ,'linkname:'+pageNameToUse+"-"+requestedProductId+"-"+uniqueId, 'type:o');    	        
    }
    catch (e)
    {
       //alert("productLearnMore("+requestedProductId+"): error calling webAnalytics:"+e.description);  
    }

    if (requestedProductId == 84)
    {
        window.top.location= "http://www.hrblock.com/tango/index.html?otpPartnerId=2246";
        return;
    }

    if (requestedProductId == 197)
    {
        window.open("https://www.deductionpro.com/dpro/Welcome.jsp","dedpro","");
        return;
    }
/*
    if (hrb_l[requestedProductId].indexOf("&tclm=1") != -1)
    {
		//window.top.location = destURL+"&tclm=1";    // specify (.top.) window.top.location for tunneled office locator page

        window.open(destURL+"&tclm=1","DigitalRiverStore","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=500,left=10,top=10");
    }    
    else
    {
        //destURL += "&otpPartnerId=" + getCookieElementValue("main_cookie", "otpPartnerId", false); 

        window.top.location = destURL;              // specify (.top.)  window.top.location for tunneled office locator page
    }
*/
    window.location = destURL;
}

// ********
// This function can take additional parameters:
//  site           ALWAYS REQUIRED: Valid values are 'hrblock' or 'taxcut'.
//  format         Required for software products.  Valid values are "dl" or "cd".
//  platform       Required for software products.  Valid values are "pc" or mac".
//  linkname       Optional: Used for omniture reporting.
//
// sample usage:
//  productStartNow(35, "format:cd", "platform:pc", "site:taxcut");  // software products required 'format','platform', and 'site'
//  productStartNow(32, "site:taxcut")                               // non-software products only require 'site'
//
// sample usage: receiving a uniqueId to send to webAnalytics()
//  productStartNow(35, "site:hrblock", "format:dl", "platform:mac", "linkname:unique"); // software products required 'format','platform', and 'site'
//  productStartNow(32, "site:taxcut", "linkname:uniqueId")                              // non-software products only require 'site'
//  
// certain situations require calling the function this way where sid=1 is hrblock and sid=2 is taxcut
// productStartNow(35, sid)
// ********
function productStartNow(requestedProductId)
{ 
//    alert("productStartNow("+requestedProductId+")");
    var siteName        = "";
    var destURL         = "";
    var bSoftware       = false;
    var uniqueId        = "";   // Valued from optional parm. Sent to webAnalytics() call to uniquely identify which object on page was clicked
    var tcs_format      = "";
    var tcs_platform    = "";
    var digitalRiverProductId   = "";

    var args    = arguments;
    var argsLen = arguments.length;

    // process additional parameters we may have received
    for (var x=0; x<argsLen; x++ )
    {
        if ((''+arguments[x]).indexOf("format:") != -1)
        {
            tcs_format      = arguments[x].substr(7).toLowerCase();
            if (tcs_format != "dl" && tcs_format != "cd")
            {
                alert("invalid format value '"+tcs_format+"' to productStartNow()");
            }
        }
        if ((''+arguments[x]).indexOf("platform:") != -1)
        {
            tcs_platform    = arguments[x].substr(9).toLowerCase();
            if (tcs_platform != "pc" && tcs_platform != "mac")
            {
                alert("invalid platform value '"+platform+"' to productStartNow()");
            }
        }
        if ((''+arguments[x]).indexOf("site:") != -1)
        {
            siteName        = arguments[x].substr(5).toLowerCase();
            if (siteName != "hrblock" && siteName != "taxcut")
            {
                alert("invalid site value '"+siteName+"' to productStartNow()");
            }
        }
        if ((''+arguments[x]).indexOf("linkname:") != -1)
        {
            // if found, append that value to the webAnalytics() call in the linkname: parm.
            // var uniqueId   = the value part of the parm 'linkname:value'      
            uniqueId    = arguments[x].substr(9);
        }
    }

try
{
	if (getQueryValue("bugClicks")=="true")
	{
        var bugMsg  = "";
        bugMsg += "productStartNow(";

        var bAddComma  = false;

        var args            = arguments;
        var argsLen         = arguments.length;

        for (var x=0; x<argsLen; x++ )
        {
            if (bAddComma)
            {
                bugMsg += ",";
            }
            bugMsg += arguments[x];            
            bAddComma  = true;
        }

        bugMsg += ")";
        alert(bugMsg);
	}
}
catch (e)
{
}

    if (arguments[1]==1)
    {
        siteName = "hrblock";
    }
    else if (arguments[1]==2)
    {
        siteName = "taxcut";
    }

    if (siteName=="")
    {
        if (location.host.indexOf("taxcut.com") != -1)
        {
            siteName    = "taxcut";
        }
        else
        {
            siteName    = "hrblock";
        }
    }

    if (siteName=="hrblock" && ( (location.host.indexOf("taxcut.com") != -1) || (location.host.indexOf("msitep") != -1) || (location.host.indexOf("k4te") != -1)  )  )
    {
        destURL += "//www.hrblock.com";
    }

    // if destination is digital river ("shop.taxcut.com" in destURL)
    //    append the digitalriver cookie 
    //    append correct digitalRiverProductId based on tcfmt (format == dl or cd) and tcpf (platform == mac or pc) parms
    // else start now is for a TCO product
    //    append the main_cookie

    if (tcs_format != "" || tcs_platform != "")
    {
        bSoftware   = true;
        digitalRiverProductId   = getDigitalRiverProductId(requestedProductId, tcs_format, tcs_platform);
    }

    if (siteName == "hrblock")
    {   
        //  If web service call isn't made or fails, use values from these hard coded array values hrb_l[]
        if ((typeof pLearn[0][0])=="undefined" || pLearn[0][0] == null || pLearn[0][0] == "")
        {   
            //alert("pLearn[0][0]=="+pLearn[0][0]+" and wsc cookie is "+getCookie("wsc")+". Trying to populate form cookie.");

            // The pLearn[][] array would not have been populated if this page didn't trigger a call
            // to the web service (by the presence of a prodPriceXX element, etc).  This valid condition
            // means we have to try to value the product info from the cookie, then if there still isn't
            // product info, use static info instead.

            // try to value the pLearn[][] from the cookie then try again
            getWebServiceCookie();

            if ((typeof pLearn[0][0])=="undefined" || pLearn[0][0] == null || pLearn[0][0] == "")
            {
                // unable to value from cookie so use static data
                g_bUseStaticData  = true;
            }
            else
            {
                //alert("using pStart[][] data from web service cookie");
            }
        }

        // g_bUseStaticData will only be false here if we were unable to populate the pStart[][] array directly from
        // the web service call or from the web service cookie

        var bTargetPageIsJSP   = false;

        if (g_bUseStaticData && (hrb_s[requestedProductId].indexOf(".jsp") != -1))
        {
            bTargetPageIsJSP  = true;
        }
        else 
        {
            for (x=0; x < 50; x++)
            {   //alert("looking for match on "+requestedProductId+":  pStart["+x+"][0] =="+pStart[x][0]+", pStart["+x+"][1] =="+pStart[x][1]);
                if (pStart[x][0] == requestedProductId && (pStart[x][1].indexOf(".jsp") != -1))
                {   
                    bTargetPageIsJSP  = true;
                    break;
                }
            }
        }
//alert("bTargetPageIsJSP="+bTargetPageIsJSP+", g_bUseStaticData="+g_bUseStaticData);
        //if (g_tunneledPage && (hrb_s[requestedProductId].indexOf(".jsp") != -1) )
        if (bTargetPageIsJSP)
        {
            if (g_tunneledPage)
            { 
                destURL = "/taxes/partner/";
            }
            else
            {
                destURL = "/taxes/products/";
            }
        }


        var bFound  = false;

        if (g_bUseStaticData)
        {   
            // use hard coded start now link data on this page
            destURL += hrb_s[requestedProductId];
            bFound  = true;
        }
        else
        {   
            // use the start now link data populated from the web service call
            for (x=0; x < 50; x++)
            {   
                if (pStart[x][0] == requestedProductId)
                {   
                    destURL    += pStart[x][1]; 
                    bFound  = true;
                    break;
                }
            }

            if (bFound)
            {
            }
            else
            {
                //alert("Product '"+requestedProductId+"' not assigned to partner "+g_partner_id);
                //return;
            }
        }

        if (bSoftware)
        {
            // the tcfmt and tcpf parms tell product.jsp which digital river urls to use
            destURL += "&" + getCookie("digitalriver"); // partner "pgm" and "OfferID" info in this cookie will override value than default info product.jsp would have used
            destURL += "&tcfmt="+tcs_format+"&tcpf="+tcs_platform;
        }
    }
    else if (siteName == "taxcut")
    {
        if (bSoftware)
        {
            // software 'add to cart'.  append value from digitalriver cookie.  It may have information such as OfferID, pgm, etc.
            destURL += tc_s[requestedProductId] + digitalRiverProductId + "&" + getCookie("digitalriver");
        }
        else
        {
            // online or office 'start now'.  append value from main_cookie cookie.  
            destURL += tc_s[requestedProductId] + "&" + getCookie("main_cookie");
        }
    }



    var pageNameToUse   = ((typeof omni_pagename)!="undefined" && omni_pagename != "") ? omni_pagename : "";

    var newanchor = document.createElement("a");

    newanchor.setAttribute('href', document.location.href);

    try
    {
        // remove any & characters from pageNameToUse and uniqueId otherwise webAnalytics() will not properly parse the paraemters when these are used in prop6 and eVar11
        pageNameToUse   = pageNameToUse.replace(/&/g, "^");
        uniqueId        = uniqueId.replace(/&/g, "^");
        webAnalytics(newanchor, 'trackvars:prop5='+pageNameToUse+"-"+requestedProductId+"-"+uniqueId+'&eVar10='+pageNameToUse+"-"+requestedProductId+"-"+uniqueId+'&', 'trackevents:event14' ,'linkname:'+pageNameToUse+"-"+requestedProductId+"-"+uniqueId, 'type:o');
    }
    catch (e)
    {
       //alert("productLearnMore("+requestedProductId+"): error calling webAnalytics:"+e.description);  
    }

    if (getQueryValue("bugClicks")=="true")
    {
        alert("going to '"+destURL+"'");
    }

    if (requestedProductId == 84)
    {
        // special tango code
        return openTango();
    }

    if (requestedProductId == 197)
    {
        window.open("https://www.deductionpro.com/dpro/Welcome.jsp","dedpro","");
        return;
    }

    if (destURL.indexOf("loginRedirect.html") != -1)
    {   
        destURL += "&" + getCookie("main_cookie");
    }    

    window.top.location = destURL;  // need window.top.location for tunneled office locator page
}

// **************************************************************************************
// calls to this function must already validate that 'format' and 'platform' are valid
// **************************************************************************************
function getDigitalRiverProductId(requestedProductId, format, platform)
{
    // when changing this code, also update similar code in product.jsp
    var id;

          switch (requestedProductId)
          {
           case 34: 
                // tcs split / homepage
                // there is no product id for a home page
           case 35:
               // tcs basic
                id   = "NA";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                { id = "NA";
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    { id = "NA";
                    }
                    else if (platform=="mac")
                    { id = "NA";
                    }
                }
              break;
            case 36:
                // tcs premium + state + efile
                id   = "104758400";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                {   id = "104758700";
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    {   id = "104758500";
                    }
                    else if (platform=="mac")
                    {   id = "104758600";
                    }
                }
                break;
            case 37:
                // tcs premium + state
                id   = "104757000";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                { id = "104758300";
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    { id = "104758100";
                    }
                    else if (platform=="mac")
                    { id = "104758200";
                    }
                }
                break;
            case 38: 
                // tcs home and business
                id   = "104758800";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                {   id = "104759000";
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    {   id = "104758900";
                    }
                    //else if (platform=="mac")
                    //{   id = "XXXXXXXX";  there is no mac product for 38
                    //}
                }
                break;
            case 39:
                // tcs state
                id   = "81714000";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                {   id = "81714000";
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    {   id = "81714000";
                    }
                    else if (platform=="mac")
                    {   id = "81714000";
                    }
                }
                break;
            case 40:
                // deduction pro
                id   = "82180500";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                {   id = "82227600";
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    {   id = "82227400";
                    }
                    else if (platform=="mac")
                    {   id = "82227500";
                    }
                }
                break;
            case 78:
                // tcs extension
                id   = "XXXXXXXX";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                {   id = "XXXXXXXX";
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    {   id = "XXXXXXXX";
                    }
                    else if (platform=="mac")
                    {   id = "XXXXXXXX";
                    }
                }
                break;
            case 81:
                // tcs premium
                id   = "104741300";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                {   id = "104758000";
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    {   id = "104757800";
                    }
                    else if (platform=="mac")
                    {   id = "104757900";
                    }
                }
                break;
            case 82:
                // tcs willpower
                id   = "107118900";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                {   id = "107119100";
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    {   id = "107119000";
                    }
                    //else if (platform=="mac")
                    //{   id = "XXXXXXXX";   there is no mac product for 82
                    //}
                }
                break;
            case 83:
                // tcs home and business attorney
                id   = "107118600";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                {   id = "107118700";
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    {   id = "107118800";
                    }
                    //else if (platform=="mac")
                    //{   id = "XXXXXXXX";   there is no mac product for 83
                    //}
                }
                break;
            case 195:
                // tcs real estate attorney
                id   = "107118000";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                {   // id = "XXXXXXXX";   there is no cd for 195
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    {   id = "107118000";    // this product has no variations so it just has one id
                    }
                    //else if (platform=="mac")
                    //{   // id = "XXXXXXXX";   there is no cd for 195
                    //}
                }
                break;
            case 196:
                // tcs business attorney
                id   = "107118100";   // ID related to 'product detail' page on DR is default

                if (format=="cd")
                {   // id = "XXXXXXXX";   there is no cd for 196
                }
                else if (format=="dl")
                { 
                    if (platform=="pc")
                    {   id = "107118100";    // this product has no variations so it just has one id
                    }
                    //else if (platform=="mac")
                    //{   // id = "XXXXXXXX";   there is no cd for 196
                    //}
                }
                break;
            default:
              break;            
            }

    return id;
}

// *********************************************************
// END: TCS and TCO link code
// *********************************************************


// *********************************************************
// BEGIN: Web Service Cookie Code
// *********************************************************

function checkProductInfoCookie(iPartnerId)
{

    var g_partner_id_from_ws_cookie = getCookieElementValue("wsc", "pid", false);



    if (g_partner_id_from_ws_cookie=="")
    {
        g_partner_id_from_ws_cookie=null;
    }

    if (g_partner_id_from_ws_cookie == iPartnerId)
    {

        return true;
     }
    else
    {

        return false;
    }
}

function getWebServiceCookie()
{
    var prodid;

    pcount                          = getCookieElementValue("wsc", "pc", true);

    // these values used in webServiceCallNotNeeded() to value global variables
    wsc_cookie_partnerName          = unescape(getCookieElementValue("wsc", "pn",      true));
    wsc_cookie_partnerType          = unescape(getCookieElementValue("wsc", "pt",      true));
    wsc_cookie_partnerWelcomeText   = unescape(getCookieElementValue("wsc", "pwt",     true));
    wsc_partnerCID                  = uncompressProductInfo(getCookieElementValue("wsc", "pcid",    true), 'name');

    wsc_otpPartnerID                = getCookieElementValue("wsc", "pid", true);
    
    for (x=0; x<pcount; x++)
    {
        prodid      = getCookieElementValue("wsc", "i"+x, true);

        pName[x][0]  = prodid;
        pBPrice[x][0]= prodid;
        pStart[x][0] = prodid;
        pLearn[x][0] = prodid;
        pPPrice[x][0]= prodid;

        pName[x][1]   = uncompressProductInfo(getCookieElementValue("wsc", "n"+x, true),'name');

        pBPrice[x][1] = uncompressProductInfo(getCookieElementValue("wsc", "b"+x, true),'price');
        pStart[x][1]  = uncompressProductInfo(getCookieElementValue("wsc", "s"+x, true),'start');
        pLearn[x][1]  = uncompressProductInfo(getCookieElementValue("wsc", "l"+x, true),'learn');
        pPPrice[x][1] = uncompressProductInfo(getCookieElementValue("wsc", "p"+x, true),'price');
    }
















    return true;
}

function writeWebServiceCookie() 
{

    var wsinfo  = "";

    wsinfo += "&pn="    + escape(ws_partnerName);    
    wsinfo += "&pt="    + escape(ws_partnerType);  
    wsinfo += "&pwt="   + escape(ws_partnerWelcomeText);    
    wsinfo += "&pcid="  + compressProductInfo(ws_partnerCID,        'name');  

    wsinfo += "&pid="   + ws_otpPartnerID;    

    for (x=0; x <pName.length; x++)  
    {
        if ((typeof pName[x][0])=="undefined")
        {
            break;
        }
        wsinfo+="&i"+x+"="+pName[x][0];                                 // write product id

        wsinfo+="&n"+x+"="+compressProductInfo(pName[x][1],   'name');  // write product name
        wsinfo+="&b"+x+"="+compressProductInfo(pBPrice[x][1], 'price'); // write base price
        wsinfo+="&s"+x+"="+compressProductInfo(pStart[x][1],  'start'); // write start now link
        wsinfo+="&l"+x+"="+compressProductInfo(pLearn[x][1],  'learn'); // write learn more link
        wsinfo+="&p"+x+"="+compressProductInfo(pPPrice[x][1], 'price'); // write partner price
    }

    wsinfo += "&pc="+x;

    // First get the current size of document.cookie.  If its size, plus the size of wsinfo, exceeds 4096 bytes, do NOT write the
    // cookie as it will likely fail due to domina cookie constraints imposed by browsers.

    var currentWscCookie = getCookie("wsc");

    if (currentWscCookie != null)
    {
        currentWscCookieLength  = currentWscCookie.length;
    }
    else
    {
        currentWscCookieLength  = 0;
    }

    var currentDomainCookieSize = document.cookie.length;

    var newDomainCookieSize = currentDomainCookieSize - currentWscCookieLength + wsinfo.length + 3; // 3 bytes for the cookie name "wsc"


    if (newDomainCookieSize < 4000) 
    { 
        setCookie("wsc",wsinfo, null, "/");
    }
    else
    {

    }

}

function compressProductInfo(sToCompress, sType) 
{
  if (sType=='price')
  {
    sToCompress =   sToCompress.replace(/0.00/gi, "^y");
    sToCompress =   sToCompress.replace(/9.95/gi, "^z");
  }
  else if (sType=='start' || sType=='learn' || sType=='name')
  {
    sToCompress =   sToCompress.replace(/&/gi, "^a");
    sToCompress =   sToCompress.replace(/TaxYear=20/gi, "^b");
    sToCompress =   sToCompress.replace(/TaxType=/gi, "^c");
    sToCompress =   sToCompress.replace(/Target=/gi, "^d");
    sToCompress =   sToCompress.replace(/\/loginRedirect.html/gi, "^e");
    sToCompress =   sToCompress.replace(/product.jsp/gi, "^f");
    sToCompress =   sToCompress.replace(/\/universal\/office_locator.html/gi, "^g");
    sToCompress =   sToCompress.replace(/office/gi, "^h");

    sToCompress =   sToCompress.replace(/productId=/gi, "^1");
    sToCompress =   sToCompress.replace(/otpPartnerId=/gi, "^2");
    sToCompress =   sToCompress.replace(/&FV=T&HT=F/gi, "^3");
    sToCompress =   sToCompress.replace(/state/gi, "^4");
    sToCompress =   sToCompress.replace(/taxcut/gi, "^5");
    sToCompress =   sToCompress.replace(/premium/gi, "^6");
    sToCompress =   sToCompress.replace(/software/gi, "^7");
    sToCompress =   sToCompress.replace(/online/gi, "^8");
    sToCompress =   sToCompress.replace(/\/taxes\/doing_my_taxes\/products\/popup\/otp_compare_popup.html/gi, "^9");
  }

  return sToCompress;
}

function uncompressProductInfo(sToUncompress, sType) 
{
  if (sType=='price')
  {
    sToUncompress = sToUncompress.replace(/\^y/g,  "0.00");
    sToUncompress = sToUncompress.replace(/\^z/g,  "9.95");
  }
  else if (sType=='start' || sType=='learn' || sType=='name')
  {
    sToUncompress = sToUncompress.replace(/\^a/g,  "&");
    sToUncompress = sToUncompress.replace(/\^b/g, "TaxYear=20");
    sToUncompress = sToUncompress.replace(/\^c/g, "TaxType=");
    sToUncompress = sToUncompress.replace(/\^d/g, "Target=");
    sToUncompress = sToUncompress.replace(/\^e/g,  "/loginRedirect.html");
    sToUncompress = sToUncompress.replace(/\^f/g,  "product.jsp");
    sToUncompress = sToUncompress.replace(/\^g/g,  "/universal/office_locator.html");
    sToUncompress = sToUncompress.replace(/\^h/g,  "office");

    sToUncompress = sToUncompress.replace(/\^1/g,  "productId=");
    sToUncompress = sToUncompress.replace(/\^2/g,  "otpPartnerId=");
    sToUncompress = sToUncompress.replace(/\^3/g,  "&FV=T&HT=F");
    sToUncompress = sToUncompress.replace(/\^4/g,  "State");
    sToUncompress = sToUncompress.replace(/\^5/g,  "taxcut");
    sToUncompress = sToUncompress.replace(/\^6/g,  "premium");
    sToUncompress = sToUncompress.replace(/\^7/g,  "software");
    sToUncompress = sToUncompress.replace(/\^8/g,  "online");
    sToUncompress = sToUncompress.replace(/\^9/g,  "/taxes/doing_my_taxes/products/popup/otp_compare_popup.html");
  }

  return sToUncompress;
}

// *********************************************************
// END: Web Service Cookie Code
// *********************************************************

//function to escape tax tips url
function createTaxTipsUrl(sPath, sTaxTipTitle)
{
    var titleQuery = "?ttiptitle=";
    var sUrl = sPath + titleQuery + escape(sTaxTipTitle);
    document.location = sUrl;
}


// *********************************************************
// BEGIN: Tango Product Code
// *********************************************************
function MM_preloadImages() 
{ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() 
{ //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) 
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openTango()
{
    var w = window.screen['availWidth']?window.screen.availWidth:window.screen.width;
    var h = window.screen ['availHeight']?window.screen.availHeight:window.screen.height;
    var dw = w<1024?w:1024;
    var dh = h<2048?h:2048;
    dw = dw-12;
    dh = dh-30;
    var x = (w-dw-12)/2; 
    var y = (h-dh-30)/2;      
    var tgw = window.open("https://tangotax.hrblock.com/tango.html","_blank","status=no, location=no, toolbar=no, menubar=no, width="+dw+", height="+dh+", left="+x+", top="+y+", resizable=yes");         
    return tgw==null;
}

//MM_preloadImages('https://tangotax.hrblock.com/tangotax/images/sneakpeak_on.gif');
//MM_preloadImages('//tgopqaapp01/tangotax/images/sneakpeak_on.gif');

// *********************************************************
// END: Tango Product Code
// *********************************************************

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
