// File Structure
//  Global Variables 
//  Functions - Display
//  Functions - DOM 
//  Functions - Generic Cookie 
//  Functions - Prototype 
//  Functions - Validation 
//  Functions - URL 
//  Functions - Misc
//  Calculator code

// *********************************************************
// BEGIN: Global Variables 
// Having "g_" variables avoids name conflict with other .js files.
// *********************************************************

//default hrblock.com info
var g_partner_id            = 0;
var g_partnerName           = "hrblock";
var g_partner_cid           = "";
var g_partnerType           = "normal";
var g_partnerWelcomeText    = "";
var g_partnerTunneledInd    = "0";

var g_extensionFilingEnabled=false;

//clear the wsc cookie to reduce upstream data in each request
var g_wsc_backup = getCookie('wsc');
setCookie('wsc','');

//executes mboxCreate() if variable is set to true
var g_omatica_home_design      = true;
var g_omatica_office_design    = true;
var g_omatica_online_design    = true;
var g_omatica_software_design  = true;
var g_omatica_taxtips_design   = true;
var g_omatica_competitor_design= false;
var g_omatica_ffa_design       = true;
var g_omatica_cmpgn_design     = true;
var g_omatica_price            = true;
var g_omatica_header           = true;
var g_omatica_footer           = true;

// 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_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 useThisCID                      = "";       // sometimes the CID from web service must be overridden

var g_bPreLoadProductRunning        = true;
var g_bOffermaticaProductRunning    = false;

var g_b_ws_partner_id_different     = false;    // true if web service returns info for a partner other than the one requested
var g_b_ws_call_failed              = 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_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_b_drInfoInUrl                 = false;    // true if digital river info found in url
var g_b_drInfoInCookie              = false;    // true if digital river info found in digitalriver cookie

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 g_time_entered      = "";
var g_paidSearch        = 0;

var g_offermatica_allow = "";

var FLASH_VERSION       = 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);  
}

// pintar 05/07/2009
//g_tunneledPage  = (document.location.pathname.indexOf("/taxes/partner/") != -1) ? true : false;
g_tunneledPage = isTunneledPage();

// *********************************************************
// BEGIN: Functions - Display Related
// *********************************************************
var objDebugWindow;
var bugTxt = "*** START ***<br/>";

bugTxt += "<b>*** INITIAL COOKIE VALUES ***</b><br/>";
bugTxt += "NOTE: If otpPartnerId is in both cookie digitalriver AND main_cookie, it must have the same value:<br/>";
bugTxt += "<font color='red'>getCookie('digitalriver')</font>=='"+getCookie("digitalriver")+"'<br/>";
bugTxt += "<font color='red'>getCookie('main_cookie')</font>=='" +getCookie("main_cookie")+"'<br/>";
bugTxt += "<font color='red'>getCookie('wsc')</font>=='"         +getCookie("wsc")+"'<br/>";    
bugTxt += "<font color='red'>getCookie('hrblockCampaignIDcookie')</font>=='"+getCookie("hrblockCampaignIDcookie")+"'<br/>";   

var bBugWin     = getQueryValue("bugLogic");  // display debug window if bugLogic=true.  remove on production code.
var bBugClicks  = getQueryValue("bugClicks");

if (bBugClicks=="true")
{   bBugClicks = true;
}

if (bBugWin=="true")
{
    bBugWin=true;
    objDebugWindow=window.open("","debugWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=300");    
}
else
{
    bBugWin=false;
}

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 getFlashVersion(){
     return g_sys.checkFlash();
}
function checkFlash(){
    return g_sys.checkFlash();
}

// *********************************************************
// END: Functions - Display Related
// *********************************************************


// *********************************************************
// BEGIN: Functions - DOM Related
// *********************************************************

function getAllElements()
{ 
  var all = null;

  if (document.all)
  {
    // we're IE
    all = document.all;
  }
  else if (document['getElementsByTagName'])
  {
    // we're DOM-aware (Mozilla)
    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: Functions - DOM Related
// *********************************************************


// *********************************************************
// BEGIN: Functions - Generic Cookie Functions
// *********************************************************

function getCookie(name)
{
    //if (bBugWin) bugTxt += "top of getCookie("+name+")<br/>";
    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 hrblock.com and WWW.hrblock.com.
    // Return null if we have a domain (like a test server) that isn't constructed like regular domains

    
    var tempHost    = document.location.hostname;

    /* DO NOT delete::: optimized code

    if (/hrblock\.com/g.test(tempHost)){
    return ".hrblock.com";
    }
    else if(/^\w+$/.test(str)){
        return null;
    }
    else{
        tempHost;
    }

    */


    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 TOP level 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

if (bBugWin) bugTxt += "<font color='red'><b>setCookie('"+cookieName+"','"+cookieValue+"')</b></font>: received "+arglen+" arguments: expires=="+expires+",path=="+path+",secure=="+secure+".<br/>";

    // 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 (bBugWin) bugTxt += "setCookie(): call to getDomain() returned domain as '"+domain+"'.<br/><br/>";

    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 (bBugWin) bugTxt += "<font color='blue'><b>top of deleteCookie("+name+","+path+","+domain+")</b></font> (name,path,domain).<br/>";

    if ( getCookie( name ) ) document.cookie = name + '=' +
            ( ( path ) ? ';path=' + path : '') +
            ( ( domain ) ? ';domain=' + domain : '' ) +
            ';expires=Thu, 01-Jan-1970 00:00:01 GMT';

if (bBugWin) bugTxt += "botom of deleteCookie("+name+","+path+","+domain+") (name,path,domain).<br/>";
}

// *********************************************************
// END: Functions - Generic Cookie Functions
// *********************************************************


// *********************************************************
// BEGIN: TCO Direct Login - Added 08/23/2010
// *********************************************************
function tco_login()
{
	var tmpPid = getCookiePartnerId("main_cookie");
	var tmpCmpgn = getCookieElementValue("hrblockCampaignIDcookie", "CampaignID", false);
    
	processPixelTracking('TCO_LOGIN');	
	/* QA: https://pyqa.hrblock.net/hrblock/DirectLogin/DirectLogin.aspx */
	GB_show('Log In','https://taxes.hrblock.com/hrblock/DirectLogin/directlogin.aspx?PartnerId='+tmpPid+'&CampaignId='+tmpCmpgn,250,364);

}
// *********************************************************
// END: TCO Direct Login
// *********************************************************


// *********************************************************
// BEGIN: Functions - Validation Functions
// *********************************************************

function validateZipCode()
{
    var strZip      = "";
    var ValidChars  = "0123456789.";
    var returnCode  = true;
    var Char;

    try
    {
        strZip = document.getElementById('tfZipCode').value
    }
    catch (e)
    {
        // if no zip code field calls tfZipCode on form, then assume first parameter received is the zip code
        if (arguments.length == 0)
        {
            // no parameters received
            alert("Please provide a zip code.");
            return false;
        }
        else
        {
            strZip  = arguments[0];
        }
    }

    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;
    }

    if (document.location.href.indexOf("/mortgages")!= -1 || (typeof (t1_default) != "undefined" && t1_default.indexOf("mortgage") != -1) )
    {
        if (!confirm(strMortgageExit))
        { 
            return false;
        }
    }

    if ( (document.location.href.indexOf("/bank")!= -1) || (document.location.href.indexOf("/emerald")!= -1) || (typeof (t1_default) != "undefined" && t1_default.indexOf("bank") != -1) )
    {
        if (!confirm(strBankExit))
        { 
            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");
    // validateZipCode("parms_to_pass:CouponID=1");
    // validateZipCode("parms_to_pass:CouponID=1&FC=tax_ind");
 
    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];
       }
    }

    // if on a page that is in the /investments section, always append &FC=fs_ind
    
    if (document.location.pathname.indexOf('/investments') != - 1 && parmsToPassToLocator.indexOf("&FC=fs_ind") == -1)
    {
        parmsToPassToLocator += "&FC=fs_ind";
    }

    // end special parms processing

    window.location="//www.hrblock.com/universal/office_locator.html?zip="+strZip+parmsToPassToLocator;
//window.location="/universal/office_locator.html?zip="+strZip+parmsToPassToLocator;
    return false;
}


function validateAddress(_add){
     if (_add == '')
    {
        alert("Please enter a address.");
        return false;
    }

     if (document.location.href.indexOf("/mortgages")!= -1 || (typeof (t1_default) != "undefined" && t1_default.indexOf("mortgage") != -1) )
    {
        if (!confirm(strMortgageExit))
        { 
            return false;
        }
    }

    if ( (document.location.href.indexOf("/bank")!= -1) || (document.location.href.indexOf("/emerald")!= -1) || (typeof (t1_default) != "undefined" && t1_default.indexOf("bank") != -1) )
    {
        if (!confirm(strBankExit))
        { 
            return false;
        }       
    }

     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];
       }
    }
// if on a page that is in the /investments section, always append &FC=fs_ind
    
    if (document.location.pathname.indexOf('/investments') != - 1 && parmsToPassToLocator.indexOf("&FC=fs_ind") == -1)
    {
        parmsToPassToLocator += "&FC=fs_ind";
    }

     window.location="//www.hrblock.com/universal/office_locator.html?address="+_add+parmsToPassToLocator;
// window.location="/universal/office_locator.html?address="+_add+parmsToPassToLocator;
     return false;
}


function validateZipCode2(strZip, coupon_value)
{
    // validates the zip code by passing a zipcode value and forwarding to office locator
    //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;
    }
    
    if (document.location.href.indexOf("/mortgages")!= -1 || (typeof (t1_default) != "undefined" && t1_default.indexOf("mortgage") != -1) )
    {
        if (!confirm(strMortgageExit))
        { 
            return false;
        }
    }

    if (document.location.href.indexOf("/bank")!= -1 || (typeof (t1_default) != "undefined" && t1_default.indexOf("bank") != -1) )
    {
        if (!confirm(strBankExit))
        { 
            return false;
        }       
    }
    
    if (coupon_value == '1')
    {
        window.location='//www.hrblock.com/universal/office_locator.html?CouponID=1&zip='+strZip;        
//    window.location='/universal/office_locator.html?CouponID=1&zip='+strZip;        
    }
    else
    {
        window.location='//www.hrblock.com/universal/office_locator.html?zip='+strZip;
// window.location='/universal/office_locator.html?zip='+strZip;
    }
    //return true;
}


function validateOfficeLocatorRequest(zip_form_value, coupon_flag)
{
    var zip_value = zip_form_value;
    var coupon_value = coupon_flag;
    
    if (!validateZipCode2(zip_value, coupon_value))
    {
        return false;
    }

    return true;
}


function findofficebyzip(zip_form_value, coupon_flag)
{
    var zip_value = zip_form_value;
    var coupon_value = coupon_flag;
    
    validateZipCode2(zip_value, coupon_value);
}

//Used by the taxtips articles
function findoffice()
{
    validateOfficeLocatorRequest(document.getElementById('txtzipcode').value);
}
// *********************************************************
// END: Functions - Validation Functions
// *********************************************************


// *********************************************************
// BEGIN: 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
    
if (bBugWin) bugTxt += "<font color='blue'><b>top of splitQueryString("+stringToSplit+")</b></font><br/>";

    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
    }
    
    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;
}

// *********************************************************
// END: Functions - URL Functions
// *********************************************************

// *********************************************************
// BEGIN: Functions - Misc
// *********************************************************
function str_replace(strSource, strReplaceThis, strWithThis) 
{
    var temp = strSource.split(strReplaceThis);
    return temp.join(strWithThis);
}
// needle may be a regular expression
function str_replace_reg(strSource, strReplaceThis, strWithThis) 
{
    var r = new RegExp(strReplaceThis, 'g');
    return strSource.replace(r, strWithThis);
}

function taxcutLogin(bNewWindow)
{   // only call this function if visitor hasn't selected a tax product yet
    
    var genericLoginLink    = "/loginRedirect.html?TaxType=OPP&FV=T&HT=F&TaxYear=2008&PartnerID="+g_partner_id;
    if (bNewWindow)
    {
        window.open(genericLoginLink,"","");
    }
    else
    {
        window.location = genericLoginLink;
    }
}

function setPartnerIdToUse()
{
   g_log.debug("<b>Inside setPartnerIdToUse</b>");

    // 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
    }
    g_log.debug(" setPartnerIdToUse PID to be used "+g_partner_id);
	//window.status="id"+g_partner_id;
}

function getUrlPartnerId()
{
    if (bBugWin) bugTxt += "<font color='blue'><b>top of getUrlPartnerId()</b></font><br/>";

    var tempId  = "";

    var qs  = window.parent.location.search;

    tempId = getNVPV(qs, 'otpPartnerId', false);

    if ((typeof tempId)=="undefined" || tempId=="" || tempId==null  || tempId=="undefined") 
    {
       tempId = "";
    }
    if (bBugWin) bugTxt += "getUrlPartnerId() returning '"+tempId+"'</b></font><br/>";

    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()
{
    if (bBugWin) bugTxt += "<font color='blue'><b>top of getOffermaticaPartnerId()</b></font><br/>";
    if (bBugWin) bugTxt += "getOffermaticaPartnerId() returning '"+g_partner_id_from_offermatica+"'<br/>";
    return g_partner_id_from_offermatica;
}

// added on 1/14/2009 (ajay)
// set a given cookie element with new value
// The cookie element name is CaSe SeNsItIvE.
function setCookieElementValue(strCookieName, strElementNameToSet, strElementValueToSet)
{
    var tmpcookieval=getCookie(strCookieName);
    //alert('tmpcookieval::'+tmpcookieval+'::setCookieElementValue in cookie'+strCookieName);
    if (tmpcookieval!='' && tmpcookieval!=null)
    {
        var NVPVarr = tmpcookieval.split("&");
        var finalcookiestr=''
        for (var i=0;i< NVPVarr.length; i++ )
        {
          var tmparr=NVPVarr[i].split("="); 
          if ( (tmparr[0] != null) && (tmparr[0] == strElementNameToSet))
          {
              finalcookiestr+=strElementNameToSet+'='+strElementValueToSet+'&';
          }
          else
          {
              finalcookiestr+=NVPVarr[i]+'&';
          }
        }
        if (finalcookiestr!='')
        {
           finalcookiestr=finalcookiestr.substring(0,finalcookiestr.length-1);
        }
        setCookie(strCookieName,finalcookiestr, null, "/");
    if (bBugWin) bugTxt += "setCookieElementValue("+strCookieName+","+strElementNameToSet+","+strElementValueToSet+") set cookie "+strCookieName+" to "+finalcookiestr+"<br/>";
    }
}

function getCookieElementValue(strCookieName, strElementValueToGet, bCaseSpecific)
{
    tempId = getNVPV("&" + getCookie(strCookieName), strElementValueToGet, bCaseSpecific);

    if ((typeof tempId)=="undefined" || tempId=="" || tempId==null || tempId=="undefined") 
    {
        tempId   = "";
    }

    return tempId;
}

function productIdValid(productId)
{
    try
    {
        if (g_hrb_partner_product.getProductId(productId).length)
        {   // no action needed
        }
    }
    catch (e)
    {   
        return false;
    }
    return true;
}

function setPricesOnPage()
{
    g_log.debug('<b>Inside setPricesOnPage</b>');
    var arrg_pPPriceElements         = new Array();
    var arrg_pPPriceElementsLength   = 0;

    var fontPre = "";
    var fontPost = "";

    var productId                    = 0;
    
    arrg_pPPriceElements         = getElementsByAttribute("id", "prodPrice");
    arrg_pPPriceElementsLength   = arrg_pPPriceElements.length;

    
    // for every prodPriceXX element on the page, find its price in the g_hrb_partner_product._partner_product.prodList object
    for (var x=0; x < arrg_pPPriceElementsLength; x++)
    {
        // get the number (productId) following 'prodPrice'        
        productId   = arrg_pPPriceElements[x].getAttribute("id").substr(9);

        if (productIdValid(productId))
        {            
            myObject = arrg_pPPriceElements[x];
         
            // Price Color is purple if dynamic product retrieval fails
            // If this is a TCO product, use purple pricing if g_hrb_partner_product.getStatusTC0()==0
            // If this is a TCS product, use purple pricing if g_hrb_partner_product.getStatusTCS()==0

            fontPre     = "";
            fontPost    = "";

            if (g_hrb_partner_product.getProductPlatform(productId).toLowerCase()=="s")
            {   // product is TCS
                if (g_hrb_partner_product.getStatusTCS()==0)
                {
                    fontPre = "<span style='color:#7D007D;'>";
                    fontPost= "</span>";
                }
            }
            else
            {   // product is TCO
                if (g_hrb_partner_product.getStatusTCO()==0)
                {
                    fontPre = "<span style='color:#7D007D;'>";
                    fontPost= "</span>";
                }
            }
            var _bpr=g_hrb_partner_product.getProductBasePrice(productId);
            var _ppr=g_hrb_partner_product.getProductPartnerPrice(productId);
            g_log.debug("setPricesOnPage: productID:"+productId+" bpr:"+_bpr+" ppr:"+_ppr);
            // _ppr == -1    == free
            // _ppr == 0.00  == use base price instead
            // _ppr == n.nn  == use this price

            if (_ppr == "-1")
            {
                myObject.innerHTML=fontPre+"FREE"+fontPost;
            }
            else if (_ppr == "0.00")
            {
                if (_bpr != "0.00")
                {
                    myObject.innerHTML=fontPre+"$"+_bpr+fontPost;
                }
                else
                {
                    myObject.innerHTML="";
                }
            }
            else
            {
                try
                {   
                    var f_partnerPrice  = parseFloat(_ppr);
                    var f_basePrice     = parseFloat(_bpr);

                  
                    if (f_basePrice > f_partnerPrice)
                    {
                        //myObject.innerHTML="<del>$"+_bpr+"</del>&nbsp;&nbsp;$"+_ppr+" -- f_basePrice=="+f_basePrice+"f_partnerPrice,=="+f_partnerPrice;                     
                        if (parent.document.location.href.indexOf("/compare_online_product.html") != -1)
                        {   
                            //product comparison page does NOT get strikethrough due to space limitations 
                            myObject.innerHTML="$"+_ppr;                                 
                        }
                        else
                        {
                            // if the current innerHTML of this span tag has a space, then put a line break between the base and discounted pricing
                            if (myObject.innerHTML.toLowerCase() == "&nbsp;")
                            {   
                                myObject.innerHTML="<del>$"+_bpr+"</del><br/>$"+_ppr+"&nbsp;";  
                            }
                            else
                            {
                                myObject.innerHTML="<del>$"+_bpr+"</del>&nbsp;$"+_ppr+"&nbsp;";  
                            }
                        }                                                
                    }
                    else
                    {
                        //myObject.innerHTML="$"+_ppr+" -- f_basePrice=="+f_basePrice+"f_partnerPrice,=="+f_partnerPrice;                      
                        if (!g_tunneledPage && g_partner_id == 0)
                        {
                            // Some A/B tests require the price NOT be split over two lines.  The presense of &nbsp;&nbsp; singals that.
                            var breakCode = "&nbsp;&nbsp;";
                            
                            if (myObject.innerHTML.toLowerCase() != "&nbsp;&nbsp;")
                            {
                                breakCode   = "<br/>";
                            }

                           /* if (productId==30)
                            {    
                                 myObject.innerHTML="<del>$29.95</del>"+breakCode+fontPre+"$"+_ppr+fontPost;                                        
                            }
                            else if (productId==32)
                            {   
                                 myObject.innerHTML="<del>$49.95</del>"+breakCode+fontPre+"$"+_ppr+fontPost; 
                            }*/
                           // else
                            //{                                     
                                 myObject.innerHTML=fontPre+"$"+_ppr+fontPost;   
                            //}                                
                        }
                        else
                        {
                            myObject.innerHTML=fontPre+"$"+_ppr+fontPost; 
                        }
                    }
                }
                catch (e)
                {
                    //alert(e.description);
                }
            }
        }
        else{
        g_log.debug('setPricesOnPage product id '+productId+' is invalid ');

        g_log.error('E27');
        }
    }
}

function webServiceCallSuccess()
{
    // called from partner_product_details_soap_client.js after successful ajax call
    g_log.debug('<b>Inside webServiceCallSuccess</b>');
  
    // If partner is tunneled and we are not on a tunneled page,  forward this request to the tunneled index page for the partner.
    // If partner is non-tunneled and we are non on a non-tunneled page, forward this request to the UHP.
    // alert("webServiceCallSuccess(): g_hrb_partner_product.getPartnerTunnel() == "+g_hrb_partner_product.getPartnerTunnel()+" and g_tunneledPage=="+g_tunneledPage);
    if (g_hrb_partner_product.getPartnerTunnel() == 1 && !g_tunneledPage && document.location.pathname.indexOf("/popup") == -1)
    {   // Tunneled partner GENERALLY cannot be displayed on an unitunneled pages. There are some un-tunneled pages they
        // CAN access, such as  /taxes/products/online/popups/state_fees.html.
        g_log.debug("webServiceCallSuccess(): sending tunneled partner "+g_hrb_partner_product.getPartnerOtpPartnerId()+" to /taxes/partner/index.jsp?otpPartnerId="+g_hrb_partner_product.getPartnerOtpPartnerId());
        document.location = "/taxes/partner/index.jsp?otpPartnerId="+g_hrb_partner_product.getPartnerOtpPartnerId();
        return;
    }
    else if (g_hrb_partner_product.getPartnerTunnel() == 0 && g_tunneledPage)
    {   // Un-tunneled partners cannot be displayed on tunneled pages
        g_log.debug("webServiceCallSuccess(): sending un-tunneled partner "+g_hrb_partner_product.getPartnerOtpPartnerId()+" to /index.html?otpPartnerId="+g_hrb_partner_product.getPartnerOtpPartnerId());
        document.location = "/index.html?otpPartnerId="+g_hrb_partner_product.getPartnerOtpPartnerId();
        return;
    }
    else
    {
        // no action needed
    }

    g_partnerName       = g_hrb_partner_product.getPartnerName();
    g_partnerType       = g_hrb_partner_product.getPartnerType();
    g_partnerWelcomeText= g_hrb_partner_product.getPartnerWelcome();
    g_partnerTunneledInd= g_hrb_partner_product.getPartnerTunnel();
    
    // If server call returned partner/product info for a partner that wasn't the one we asked for, that partner was either invalid or inactive.  
    // Since we have already written the main_cookie with the partner id we THOUGHT we were going to use, we must overwrite it with the 
    // partner id returned by the server call.

    useThisCID = g_hrb_partner_product.getPartnerCID();
    
    if (useThisCID == "no__thanks" || useThisCID == "0" || useThisCID == "na")
    {
        useThisCID = "";
    }

    if (g_hrb_partner_product.getPartnerOtpPartnerId() != g_partner_id)
    {  
        g_b_ws_partner_id_different = true;
        
        g_partner_cid   = useThisCID;    
        g_partner_id    = g_hrb_partner_product.getPartnerOtpPartnerId();

        setCookie("main_cookie", "otpPartnerId="+g_partner_id+"&PartnerId="+g_partner_id, null, "/");
    }

    processDigitalRiverCookie();

    callsoftwarepricing(getCookieElementValue("digitalriver", "offerid", false),getCookieElementValue("digitalriver", "pgm", false));
}

function remoteDataProcessComplete()
{
    g_log.debug('<b>Inside remoteDataProcessComplete</b>');
    writeWebServiceCookie();
    setPricesOnPage();
    continueOnloadProcessing();
}

function webServiceCallNotNeeded()
{
    g_log.debug('<b>Inside webServiceCallNotNeeded</b>');

    g_partnerName           = g_hrb_partner_product.getPartnerName();
    g_partnerType           = g_hrb_partner_product.getPartnerType();
    g_partnerWelcomeText    = g_hrb_partner_product.getPartnerWelcome();
    g_partnerTunneledInd    = g_hrb_partner_product.getPartnerTunnel();
    g_partner_cid           = g_hrb_partner_product.getPartnerCID(); 
    g_partner_id            = g_hrb_partner_product.getPartnerOtpPartnerId(); 

    // The reason this re-direct code is required is that if you go to a non-tunneled page w partner 0, changet it to a
    // tunneled partner id and hit enter, then hit the back button, you are on a non-tunneled page with a tunneled partner
    // id in the wsc cookie.  So best bet is to double check the tunneled indicator in the wsc cookie and ensure
    // you are where you should be.
    // alert("webServiceCallNotNeeded(): g_hrb_partner_product.getPartnerTunnel() == "+g_hrb_partner_product.getPartnerTunnel()+" and g_tunneledPage=="+g_tunneledPage);
    if (g_partnerTunneledInd == 1 && !g_tunneledPage && document.location.pathname.indexOf("/popup") == -1)
    {   // Tunneled partner GENERALLY cannot be displayed on an un-tunneled pages. There are some un-tunneled pages they
        // CAN access, such as  /taxes/products/online/popups/state_fees.html.
        g_log.debug("webServiceCallNotNeeded(): sending tunneled partner "+g_partner_id+" to /taxes/partner/index.jsp?otpPartnerId="+g_partner_id);
        document.location = "/taxes/partner/index.jsp?otpPartnerId="+g_partner_id;
        return;
    }
    else if (g_partnerTunneledInd == 0 && g_tunneledPage)
    {   // Un-tunneled partners cannot be displayed on tunneled pages
        g_log.debug("webServiceCallNotNeeded(): sending un-tunneled partner "+g_partner_id+" to /index.html?otpPartnerId="+g_partner_id);
        document.location = "/index.html?otpPartnerId="+g_partner_id;
        return;
    }
    else
    {
        // no action needed
    }

    setPricesOnPage();
    continueOnloadProcessing();
}

function webServiceCallFailed(strReason)
{
    // ************************************************* TBD: **********************************************************************
    // This fuction has been replace with partnerJSONFailed(errorcode)
    // *********************************************************************************************************************************
    g_log.debug('<b>Inside webServiceCallFailed </b>strReason'+strReason);
    g_b_ws_call_failed  = true;
   // 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, "/");
    //setCookie("wsc", "", null, "/");
    // TBD:
    setCookie("digitalriver", "", null, "/");
    g_log.debug("webServiceCallFailed(strReason):"+getCookieElementValue("digitalriver", "offerid", false)+","+getCookieElementValue("digitalriver", "pgm", false));
    callsoftwarepricing(getCookieElementValue("digitalriver", "offerid", false),getCookieElementValue("digitalriver", "pgm", false)); 
    setPricesOnPage();      
}

function getAllProductInfo(bAlert)
{
    bugTxt += "<font color='blue'><b>top of getAllProductInfo()</b></font>.<br/><br/><span style='font-size: 8pt;'>";

    var prodListSize = g_hrb_partner_product._partner_product.prodList.length;
    var prod;
    var tstr  = "";
    var pid;

    for (var i=0; i<prodListSize; i++)
    {   
        prod = g_hrb_partner_product.getProductInfo(prodList[i].getProductId());
        pid  = prod.getProductId();
        tstr+= "product id=="+pid+",BasePrice=="+prod.getProductBasePrice(pid)+",PartnerPrice=="+prod.getProductPartnerPrice(pid)+",Name=="+prod.getProductName(pid)+",StartNow=="+prod.getProductStartNow(pid)+",LearnMore=="+prod.getProductLearnMore(pid)+"<br/>";
    }
    bugTxt += tstr+"</span><br/>";
}


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 != "") && (g_dr_offer_info_from_url != null && g_dr_offer_info_from_url != "") )
    { // both PGM and OFFERID are in the URL
      tempValue = "pgm=" + g_dr_pgm_info_from_url + "&OfferID="+g_dr_offer_info_from_url;
    }
    else if (g_dr_pgm_info_from_url != null && g_dr_pgm_info_from_url != "")
    {   // only PGM is in the url
        tempValue = "pgm=" + g_dr_pgm_info_from_url;
    }
    else if (g_dr_offer_info_from_url != null && g_dr_offer_info_from_url != "")
    {   // only OFFERID is in the url
        tempValue = "OfferID=" + g_dr_offer_info_from_url;
    }

    g_b_drInfoInUrl = false;

    if (tempValue != "")
    {
        g_b_drInfoInUrl = true;
    }

    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 != "") && (g_dr_offer_info_from_cookie != null && g_dr_offer_info_from_cookie != "") )
    { // both PGM and OFFERID are in the cookie "digitalriver"
        tempValue = "pgm=" + g_dr_pgm_info_from_cookie + "&OfferID="+g_dr_offer_info_from_cookie;
    }
    else if (g_dr_pgm_info_from_cookie != null && g_dr_pgm_info_from_cookie != "")
    {   // only PGM is in the cookie "digitalriver"
        tempValue = "pgm=" + g_dr_pgm_info_from_cookie;
    }
    else if (g_dr_offer_info_from_cookie != null && g_dr_offer_info_from_cookie != "")
    {   // only OFFERID is in the cookie "digitalriver"
        tempValue = "OfferID=" + g_dr_offer_info_from_cookie;
    }    

    g_b_drInfoInCookie = false;

    if (tempValue != "")
    {
        g_b_drInfoInCookie = true;
    }

    return tempValue;
}

function getDR_ws_info()
{
    // Returns CID info from the web service call.  Note!  The useThisCID value may be different 
    // from what was really returned from the w/s call, so do not directly us w/s call value.
    return useThisCID;
}

function processDigitalRiverCookie()
{
    g_log.debug('<b>Inside processDigitalRiverCookie</b>');
    // This function is called from one of three places:
    //  - onloadProcessing()        if web service not called
    //  - webServiceCallSuccess()  if web service was called
    //  - webServiceCallNotNeeded() if  we found the wsc cookie already had the info we needed

    // 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, "/");
        g_log.debug('processDigitalRiverCookie : g_partner_id:'+g_partner_id+' != getCookiePartnerId:'+getCookiePartnerId("digitalriver"));
     }

    // The rules regarding what DR info to write to the digitalriver cookie is as follows:
    // - the DR info from the web service IF it returned information for a partner other than the one we requested
    // - the DR info in the URL    - UNLESS the otpPartnerId in the digitalriver cookie <> partner id we determine is the correct one to use
    // - the DR info in the cookie - UNLESS the otpPartnerId in the digitalriver cookie <> partner id we determine is the correct one to use
    // - the DR info returned from the partner web service call if any 

    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_b_ws_partner_id_different)
    {
        // Web service successful but returned a different partner id than was requested.  Use information from the web service (WS) over url or cookie values.
        tempValue = g_partner_cid;
        g_log.debug('processDigitalRiverCookie: use DR info from url :'+tempValue);

    }
    else if ( g_b_drInfoInUrl && (g_partner_id == getCookiePartnerId("digitalriver") || !g_b_drInfoInCookie) )
    {
        // DR info found in URL AND (partner id in DR COOKIE is same as partner id we determined we need to use OR 
        // the digitalriver cookie is empty), write dr url info to digitalriver cookie
        tempValue = dr_url_info;
        g_log.debug('processDigitalRiverCookie: use DR info from url :'+tempValue);

    }
    else if ( g_b_drInfoInCookie && (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.  Sounds
        // redundant, but if we don't value tempValue here, then g_partner_cid wouldn't be correctly valued below!
        tempValue = dr_cookie_info;
        g_log.debug('processDigitalRiverCookie: use DR info from COOKIE :'+tempValue);
    }
    else if (dr_ws_info != null && dr_ws_info != "" && dr_ws_info != 0)
    {   
        // take information from the web service if any
       tempValue = dr_ws_info;
       g_log.debug('processDigitalRiverCookie: use DR info from ws call:'+tempValue);
        
    }
    else{
        tempValue = ""; // if unable to determine what DR info to use, use ""
    }

    g_partner_cid = tempValue;  // now we know the dr info to use, so set the global variable to hold it
    if (g_b_ws_call_failed) 
    {
        tempValue = ""; 
    }

    if (tempValue != ""){
        tempValue = "otppartnerid="+g_partner_id+"&"+tempValue;
    }  
    
    setCookie("digitalriver", tempValue, null, "/");    
    g_log.debug('processDigitalRiverCookie :: main cookie:'+getCookie("main_cookie")+' DR cookie:'+getCookie("digitalriver"));
   
}

function isDRUrlAndCookieDifferent()
{
    // Returns true if DR info in url is different from what is currently in the digitalriver cookie.
    // If yes, then this flags a condition that we must get call the software product info servlet
    var url_pgm      = getNVPV2(location.search, "pgm",          false, "=", "&");
    var url_offer    = getNVPV2(location.search, "OfferID",      false, "=", "&");

    var cookie_pgm   = getNVPV2(getCookie("digitalriver")==null ? "" :getCookie("digitalriver") ,   'pgm',      false, "=", "&"); 
    var cookie_offer = getNVPV2(getCookie("digitalriver")==null ? "" :getCookie("digitalriver") ,   'OfferID',  false, "=", "&");

    // generally, pgm and offerid are NOT going to be in the url, just on the first page visited
    if (url_pgm != "" || url_offer != "")
    {   //alert("isDRUrlAndCookieDifferent(): url_pgm=="+url_pgm+" and url_offer=="+url_offer);
        if (url_pgm == cookie_pgm && url_offer == cookie_offer)
        {
            // DR info in url and cookie are the same
            return false;
        }
        else
        {   // DR info in url and cookie are the different.  This triggers a call to get updated partner/product info.
            return true;
        }
    }
}

// ***********************************************
// 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().
    
	// reset the cookie value from the backup variable
	setCookie('wsc',g_wsc_backup);

    g_log.debug('<b>Inside onloadProcessing</b>');

    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();

    g_log.debug("<table border=1 bordercolor='#EEEEEE' cellspacing=0 style='font-family:Verdana;font-size:11px;'><tr> <th>partner id Source</th><th>value</th><th>priority</th></tr><tr> <td>g_partner_id_from_offermatica</td><td>&nbsp;"+g_partner_id_from_offermatica+"</td><td>1</td></tr><tr> <td>g_partner_id_from_url</td><td> "+g_partner_id_from_url+"</td><td>2</td></tr><tr> <td>g_partner_id_from_cookie</td><td> "+g_partner_id_from_cookie+"</td><td>3</td></tr><tr> <td>g_partner_id_from_search_engine</td><td> "+g_partner_id_from_search_engine+"</td><td>4</td></tr></table>");

    setPartnerIdToUse();
    processMainCookie();
    // check if CampaignID should be written to a cookie
    campaignIdCheck();

    // ********************************************************************
    // 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
    // ********************************************************************
    g_log.debug(" onloadProcessing: price span tags:<b>"+getElementsByAttribute("id", "prodPrice").length+"</b>");

    // 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) || document.location.href.indexOf("search2.h")!= -1 || document.location.href.indexOf("atomzdev.")!= -1)
    var bDomainOkForCall    = true;
    // To avoid cross-domain call errors in the xmlHttpRequest, add non hrblock.com sites, including subdomains, in this if statement
    if (document.location.href.indexOf("search2.h")!= -1)
    {
        bDomainOkForCall = false;
    }
    if (bDomainOkForCall && (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 webServiceCallSuccess().
        getPartnerProduct(g_partner_id,g_tunneledPage);       // get partner & product information
    }
    else
    { g_log.debug(" onloadProcessing():going directly to continueOnloadProcessing");
        continueOnloadProcessing();
    }
}

function continueOnloadProcessing()
{
    g_log.debug('<b>Inside continueOnloadProcessing</b>');
    // if no web service calls on page: this is called directly by onloadProcessing()
    // if web services calls were done: this is called by webServiceCallSuccess()

    if ( (typeof is_homepage) !='undefined' && (is_homepage) )
    {
        try{
            updatePriceValuesInFlash(); 
        }
        catch (e){}
    }

    //hightlight taxtips links
    updateTaxTipsArticleLink();
    if ( document.location.pathname.indexOf("/taxes/products/software/back_editions") != -1 )
    {
        try{
             g_log.debug(" continueOnloadProcessing():BACK EDITION page");
            getSoftwareProductsInfo(); 
        }
        catch (e) {
            g_log.error('E26');
        }
    }

    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){
        g_log.debug('No specialOnloadProcessing is found ');
    }

    try{  
            //run pixel processing only for block domains
            var _env =g_sys.checkEnv();
                if (_env=='PROD' || _env=="QA" || _env=="DEV"){
                        processPixelTracking();

                }
    }
    catch (e){
        g_log.debug('Problem calling processPixelTracking().');
    }

if (bBugWin) bugTxt += "<br/>continueOnloadProcessing(): *** ALL PROCESSING COMPLETE.  BELOW ARE FINAL VALUES USED. ***<br/>";

if (bBugWin)
{
    bugTxt += "g_nvpCount      =='"+g_nvpCount+"' [valued by splitQueryString()]<br/><br/>";

    bugTxt += "<b>*** GLOBAL PARTNER DATA ***</b><br/>";
    bugTxt += "g_partner_id=='"         +g_partner_id +"'<br/>";
    bugTxt += "g_partnerName=='"        +g_partnerName+"'<br/>";
    bugTxt += "g_partner_cid=='"        +g_partner_cid+"'<br/>";
    bugTxt += "g_partnerType=='"        +g_partnerType+"'<br/>";
    bugTxt += "g_partnerTunneledInd=='" +g_partnerTunneledInd+"'<br/>";
    bugTxt += "g_partnerWelcomeText=='" +g_partnerWelcomeText+"'<br/><br/>";

    bugTxt += "<b>*** DATA FROM WEB SERVICE CALL / WSC COOKIE ***</b><br/>";
    bugTxt += "partner ID is '"        +g_hrb_partner_product.getPartnerOtpPartnerId()+"'<br/>";
    bugTxt += "partner Name is '"      +g_hrb_partner_product.getPartnerName() +"'<br/>";
    bugTxt += "partner CID is '"       +g_hrb_partner_product.getPartnerCID()  +"'<br/>";
    bugTxt += "partner Type is '"      +g_hrb_partner_product.getPartnerType() +"'<br/>";
    bugTxt += "partner Tunneled is '"  +g_hrb_partner_product.getPartnerTunnel() +"'<br/>";
    bugTxt += "partner Welcome is '"   +g_hrb_partner_product.getPartnerWelcome()+"'<br/><br/>";

    bugTxt += "<b>*** PARTNER ID SOURCES/VALUES ***</b><br/>";
    bugTxt += "g_partner_id_from_cookie        =='"+g_partner_id_from_cookie+"'<br/>";
    bugTxt += "g_partner_id_from_url           =='"+g_partner_id_from_url+"'<br/>";
    bugTxt += "g_partner_id_from_offermatica   =='"+g_partner_id_from_offermatica+"'<br/>";
    bugTxt += "g_partner_id_from_search_engine =='"+g_partner_id_from_search_engine+"'<br/>";

    bugTxt += "<b>*** INFORMATION ABOUT THE WEB SERVICE CALL ***</b><br/>";
    bugTxt += "<b>Ignore these values if web service call was skipped.</b><br/>";

    // use a try/catch here because the http_request object may not exist
    try
    {
        bugTxt += "http_request.status=="+http_request.status+"<br/>";
    }
    catch (e)
    {
        //
    }

    bugTxt += "<b>*** SEARCH ENGINE DATA ***</b><br/>";
    bugTxt += "g_searchEngineTerm       =='"+g_searchEngineTerm+"'<br/>";
    bugTxt += "g_bReferrerIsSearchEngine=='"+g_bReferrerIsSearchEngine+"'<br/><br/>";

    bugTxt += "<b>*** CAMPAIGN DATA ***</b><br/>";
    bugTxt += "g_campaign_id   =='"+g_campaign_id+"'<br/><br/>";

    bugTxt += "<b>*** DIGITAL RIVER DATA ***</b><br/>";
    bugTxt += "g_dr_info_to_use=='"     +g_dr_info_to_use+"'  [Currently never valued]<br/>";
    bugTxt += "getDR_url_info()   =='"  +getDR_url_info()+"'<br/>";
    bugTxt += "getDR_ws_info()    =='"  +getDR_ws_info()+"'<br/>";
    bugTxt += "getDR_cookie_info()=='"  +getDR_cookie_info()+"'<br/><br/>";

            
    bugTxt += "<b>*** COOKIE VALUES ***</b><br/>";
    bugTxt += "NOTE: If otpPartnerId is in both cookie digitalriver AND main_cookie, it must have the same value:<br/>";
    bugTxt += "<font color='red'>getCookie('digitalriver')</font>=='"+getCookie("digitalriver")+"'<br/>";
    bugTxt += "<font color='red'>getCookie('main_cookie')</font>=='" +getCookie("main_cookie")+"'<br/>";
    bugTxt += "<font color='red'>getCookie('wsc')</font>=='"         +getCookie("wsc")+"'<br/>";    
    bugTxt += "<font color='red'>getCookie('hrblockCampaignIDcookie')</font>=='"+getCookie("hrblockCampaignIDcookie")+"'<br/>";   
   
    writeDebugWindow();
}
/*
    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.");
    }
}

function writeDebugWindow()
{
    objDebugWindow.document.write(bugTxt+"<br/>*** END***");
}

// ***********************************************
// offermaticaPartnerSelect()
// ***********************************************
function offermaticaPartnerSelect(om_partner_id)
{
    if (bBugWin) bugTxt += "<font color='purple'><b>top of offermaticaPartnerSelect("+om_partner_id+")</b></font> [This function is only called by content being served from Offermatica.]<br/>";
    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 (strURL==null || strURL=="")
    {
        return "";
    }

    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 (strURL==null || strURL=="")
    {
        return "";
    }

    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('bing.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)
    {
        if (g_searchEngineTerm=="") 
        {
            g_searchEngineTerm="search_term_not_available";
        }
        else
        {
            try
            {                
                document.getElementById('tt_searchText').focus();
                g_searchEngineTerm=unescape(g_searchEngineTerm);
                if (g_searchEngineTerm.indexOf("+")==0)
                {   // some srch engines have a leading + in the search term, remove it.
                    g_searchEngineTerm=g_searchEngineTerm.substr(1);
                }
                g_searchEngineTerm=g_searchEngineTerm.replace(/\+/g, " ");    
                document.getElementById('tt_searchText').value=g_searchEngineTerm;                
            }
            catch (e)
            {   
                // noop
            }
        }
    }
}

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
    if (bBugWin) bugTxt += "<font color='blue'><b>top of getSearchEnginePartnerId()</b></font><br/>";

    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
        if (bBugWin) bugTxt += "getSearchEnginePartnerId() returning '"+searchPID+"' since no referrer found.<br/>";
        return searchPID;
    }

    // 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('bing.com') > -1)        || (srchsim=="bing") ) 
            {
                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
            } 
        }
    }   
    if (bBugWin) bugTxt += "getSearchEnginePartnerId() returning '"+searchPID+"'. document.referrer=='"+document.referrer+"'<br/>";
    return searchPID;
}

function campaignIdCheck() 
{
    g_campaign_id      = getQueryValue('CampaignID');

    if (bBugWin) bugTxt += "<font color='blue'><b>top of campaignIdCheck(): CampaignID in url is '"+g_campaign_id+"'.</b></font><br/>";

    if(g_campaign_id != null) 
    {
        setCookie('hrblockCampaignIDcookie', 'CampaignID=' + g_campaign_id, null, "/");
        if (bBugWin) bugTxt += "campaignIdCheck(): cookie 'hrblockCampaignIDcookie' set to 'CampaignID="+g_campaign_id+"'.<br/>";
    }
    else
    {
        if (bBugWin) bugTxt += "campaignIdCheck(): do not write cookie 'hrblockCampaignIDcookie' since it wasn't in the url.<br/>";
    }
}

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;      
}

function isTunneledPage()
{
    if (document.location.pathname.indexOf("/taxes/partner/") != - 1 && document.location.pathname.indexOf('.jsp') != - 1)
    {   
        return true;
    }
    else
    {
        return false;
    }
}

function processMainCookie()
{
    g_log.debug('<b>Inside processMainCookie</b>');
    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

        g_log.debug("processMainCookie(): writing partner id '"+g_partner_id_from_offermatica+"' assigned by offermatica. Call setCookie('main_cookie','otpPartnerId="+g_partner_id+"&PartnerId="+g_partner_id+"')<br/>");
        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
           g_log.debug("processMainCookie(): no need to write/re-write main_cookie since g_partner_id_from_url["+g_partner_id_from_url+"] == g_partner_id_from_cookie["+g_partner_id_from_cookie+"].  Re-writing would delete site-visit parm values anyway.<br/>");
        }
        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);
            g_log.debug("processMainCookie(): g_partner_id_from_url["+g_partner_id_from_url+"] != g_partner_id_from_cookie["+g_partner_id_from_cookie+"] so write g_partner_id["+g_partner_id+"] to the cookie.<br/>");
            setCookie("main_cookie", qs+"&PartnerID="+g_partner_id, null, "/");  
        }
    }
    else if (g_partner_id_from_cookie != "" && g_partner_id_from_cookie != null)
    {
        // do nothing
        g_log.debug("processMainCookie(): g_partner_id_from_cookie["+g_partner_id_from_cookie+"] is not == '' and not == null, so don't write main_cookie.<br/>");
    }
    else if (g_partner_id_from_search_engine != "" && g_partner_id_from_search_engine != null)
    {
        // is this an organic, non-paid search engine referral
        g_log.debug("processMainCookie(): g_partner_id_from_search_engine["+g_partner_id_from_search_engine+"] valued so write it to main_cookie.<br/>");
        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 partner id for this domain + current query string 
        if (qs.indexOf("?")!=-1) 
        {
            qs = qs.slice(qs.indexOf("?")+1);
        }
         g_log.debug("processMainCookie(): no partner id available from anywhere so use default partner id for this domain + current query string.<br/>");
        setCookie("main_cookie", qs+"&otpPartnerId="+g_partner_id+"&PartnerID="+g_partner_id, null, "/");  
    }
}

function FindAction(Entity)
{
    // this function is called by the TCO 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]='/calcs/calculators2007/amtestimator2007/frameset.jsp'
omnivariable[3]='AMT_'
//2006 Withholding
//calcURLS[4]='/taxes/tools/2006_whcalc/frameset.jsp';
//2008 withholding
calcURLS[4]='/calcs/calculators2008/whcalc2008/frameset.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]='/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)
{

        if (indx==18)
        {
            document.location="/taxes/tax_calculators/index.html";
        }
        else
        {

            var tmpURL=document.location.pathname;
            if (tmpURL.indexOf('/taxes/tax_calculators/index.html')>0)
            {
                displayCalc(indx,referlink);
                //trackWebAnalytics();
            }
            else
            {
                document.location="/taxes/tax_calculators/index.html?calcIndx="+indx+'&referlink='+referlink;
            }
        }
}
else
 document.location="/taxes/tax_calculators/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
    
if (bBugWin) bugTxt += "staticProductStartNowNewWin("+requestedProductId+") calling getCookie('main_cookie')<br/>";
    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 = "/taxes/tax_tips/email_taxtips.html?taxtip_id="+g_tax_tip_id;
    //WinOpen_(tax_tip_email_path, 580, 500);
    var popup=open(tax_tip_email_path,"popup","status=yes,toolbar=no,directories=no,scrollbars=no,menubar=no,resizable=no,width=585,height=530");
    popup.focus();
}

// ********
// This function accepts the parameters
//  site           Required: Valid value is currently just 'hrblock'.
//  linkname       Optional: Used for omniture reporting
//  &              Optional: A parm starting with "&" will be appended to the destURL
//
// sample usage:
//  productLearnMore(34, "site:hrblock");
//  productLearnMore(34, "site:hrblock", "linkname:uniqueId"); 
//
//  There are two ways to have this pass along additional parameters to the destination page:
//  productLearnMore(34, "site:hrblock", "linkname:uniqueId", "&customname=customvalue&a=b&name=value"); 
//  productLearnMore(34, "site:hrblock", "linkname:unqiueId", "parms:&customname=customvalue&a=b&name=value");
// ********
function productLearnMore(requestedProductId)
{ 
    if (requestedProductId == 84)
    {
        window.top.location="/tango/index.html";
        return;
    }

    if (requestedProductId == 197)
    {
        window.open("https://www.deductionpro.com/dpro/Welcome.jsp","dedpro","");
        return;
    }

    var siteName        = "";
    var destURL         = "";
    var destDomain      = "";
    var uniqueId        = "";   // Valued from optional parm. Sent to webAnalytics() call to uniquely identify which object on page was clicked
    var bTargetPageIsJSP= false;
    var passParms       = "";

    // 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            = 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")
            {
                //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);
        }

        if ((''+arguments[x]).indexOf("parms:") != -1)
        {
            // if found, append that value to the webAnalytics() call in the linkname: parm.
            // var uniqueId   = the value part of the parm 'linkname:value'      
            additionalParms    = arguments[x].substr(6);
            if (additionalParms.indexOf("&") != 0)
            {
                additionalParms = "&" + additionalParms;
                alert('additionalParms '+additionalParms)
            }
        }
    }

    if (siteName=="")
    {   // Domains other than hrblock.com not currently supported
        siteName    = "hrblock";
    }

    if (siteName == "hrblock")
    {
        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];
            }
        }

        if (productIdValid(requestedProductId))
        {
            if (g_hrb_partner_product.getProductLearnMore(requestedProductId).indexOf("product.jsp") != -1)
            {
                bTargetPageIsJSP  = true;
            }
        }
        else
        {
            // It could be that the current page didn't create the g_hrb_partner_product object since it
            // wasn't flagged as having products or doesn't have any elements with id like "prodPriceXXXXX" on it.
            // In this case just go to "/taxes/products/"+requestedProductId+".html"
            
            document.location = "/taxes/products/"+requestedProductId+".html";
            return;
        }
      
        //destURL = g_hrb_partner_product.getProductLearnMore(requestedProductId)+additionalParms;
        
        if (g_tunneledPage)
        {   
            //destURL = "/taxes/partner/" + destURL;
            destURL = "/taxes/partner/product.jsp?productId=" + requestedProductId;
        }
        else
        {   
            destURL = "/taxes/products/" + requestedProductId + ".html";
        }

        if (additionalParms != "")
        {
            if (destURL.indexOf("?") == -1)
            {
                destURL += "?" + additionalParms;
            }
            else
            {
                destURL += additionalParms;
            }

            //alert('final URL '+destURL)
        }

        if (getQueryValue("bBugClicks")=="true")
        {   
            alert(" bTargetPageIsJSP=="+bTargetPageIsJSP+"\r destURL=="+destURL);
        }
    }
    else if (siteName == "taxcut" || siteName == "external")
    {
        // Domains other than hrblock.com not currently supported
        // destURL = g_hrb_partner_product.getProductLearnMore(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 & characters from pageNameToUse and uniqueId otherwise webAnalytics() will not properly parse the parameters 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');                        
        var prop6_eVar11 = getProductPlatform(requestedProductId)+"-"+requestedProductId+"-"+getProductName(requestedProductId)+"-"+pageNameToUse+"-"+uniqueId;
        webAnalytics(newanchor, "trackvars:prop6="+prop6_eVar11+"&eVar11="+prop6_eVar11+"&", "trackevents:" ,"linkname:"+pageNameToUse+"-"+requestedProductId+"-"+uniqueId, "type:o");                
    }
    catch (e)
    {
       //alert("productLearnMore("+requestedProductId+"): error calling webAnalytics:"+e.description);  
    }

    //destURL += "&otpPartnerId=" + getCookieElementValue("main_cookie", "otpPartnerId", false); 

    if (getQueryValue("bBugClicks")=="true")
    {   
        alert("going to '"+destURL+"'\rsiteName=="+siteName+"\rpageNameToUse=="+pageNameToUse+"\rbFound=="+bFound+"\rbTargetPageIsJSP=="+bTargetPageIsJSP+"\rrequestedProductId=="+requestedProductId+"\rhrb_s["+requestedProductId+"]=="+hrb_s[requestedProductId]);
    }
    window.top.location = destDomain + destURL; // specify (.top.)  window.top.location for tunneled office locator page
}

// ********
// This function can take additional parameters:
//  site           Required: Valid value is currently just 'hrblock'.
//  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'
//  
// ********
function productStartNow(requestedProductId)
{ 
    if (requestedProductId == 84)
    {
        return openTango(); // special tango code
    }
    
    if (requestedProductId == 197)
    {
        window.open("https://www.deductionpro.com/dpro/Welcome.jsp","dedpro","");
        return;
    }

    var siteName        = "";
    var destURL         = "";
    var destDomain      = "";
    var bSoftware       = false;
    var sku;

    var bTargetPageIsJSP    = false;
    var bTargetPageIsLogin  = 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    = "";

    if (requestedProductId==46)
    {   // send old extension product to new extension product
        requestedProductId = 188;
    }

    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")
            {
                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);
        }
        if ((''+arguments[x]).indexOf("sku:") != -1)
        {
            sku    = arguments[x].substr(4);
        }    
    }

    if (siteName=="")
    {   // Domains other than hrblock.com not currently supported
        siteName    = "hrblock";
    }

    if (g_hrb_partner_product.getProductPlatform(requestedProductId).toLowerCase() == "s" )
    {
        destDomain  = "http://shop.taxcut.com";
        destURL     = "/store/taxcut/en_US/AddItemToRequisition/productID."+sku+'?'+getCookie("digitalriver");
        bSoftware   = true;
        g_log.debug("productStartNow()....s.k=="+g_hrb_partner_product.getProductSKU(requestedProductId));
    }

    if (siteName == "hrblock")
    {   
        if (!bSoftware)
        {
            destURL = g_hrb_partner_product.getProductStartNow(requestedProductId);

            if (destURL.indexOf("product.jsp") != -1)
            {
                bTargetPageIsJSP    = true;
            }  
            else if (destURL.indexOf("loginRedirect.html") != -1)
            {
                bTargetPageIsLogin  = true;
            }


            if (!bTargetPageIsLogin)
            {   
                if (g_tunneledPage)
                {   
                    destURL = "/taxes/partner/" + destURL;
                }
                else
                {   
                    destURL = "/taxes/products/"+requestedProductId+".html";
                }
            }
        }
        else
        {
            // no action
        }

        if (getQueryValue("bBugClicks")=="true")
        {   
            alert(" bTargetPageIsJSP=="+bTargetPageIsJSP+"\r destURL=="+destURL);
        }
    }    
    else if (siteName == "taxcut" || siteName == "external")
    {
        // Domains other than hrblock.com not currently supported.
        // 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, "^");
        var prop5_eVar10 = getProductPlatform(requestedProductId)+"-"+requestedProductId+"-"+getProductName(requestedProductId)+"-"+pageNameToUse+"-"+uniqueId;
      //webAnalytics(newanchor, 'trackvars:prop5='+pageNameToUse+"-"+requestedProductId+"-"+uniqueId+'&eVar10='+pageNameToUse+"-"+requestedProductId+"-"+uniqueId+'&', 'trackevents:event14' ,'linkname:'+pageNameToUse+"-"+requestedProductId+"-"+uniqueId, 'type:o');
        webAnalytics(newanchor, "trackvars:prop5="+prop5_eVar10+"&eVar10="+prop5_eVar10+"&", "trackevents:event14" ,"linkname:"+pageNameToUse+"-"+requestedProductId+"-"+uniqueId, "type:o");
    }
    catch (e)
    {
       //alert("productLearnMore("+requestedProductId+"): error calling webAnalytics:"+e.description);  
    }

    if (destURL.indexOf("loginRedirect.html") != -1)
    {   
        destURL += "&" + getCookie("main_cookie");
    }

    if (getQueryValue("bBugClicks")=="true")
    {   
        alert("going to '"+destURL+"'\rsiteName=="+siteName+"\rpageNameToUse=="+pageNameToUse+"\rbFound=="+bFound+"\rbTargetPageIsJSP=="+bTargetPageIsJSP+"\rrequestedProductId=="+requestedProductId+"\rhrb_s["+requestedProductId+"]=="+hrb_s[requestedProductId]);
    }

    window.top.location = destDomain + destURL;  // need window.top.location for tunneled office locator page
}

// **************************************************************************************
// returns tco, tcs or off sourced from d_pName[][] array
// **************************************************************************************
function getProductPlatform(requestedProductId)
{
    if (productIdValid(requestedProductId))
    {
        if (g_hrb_partner_product.getProductPlatform(requestedProductId).toLowerCase() == "o")
        {
            return "tco";    // online
        }
        else if (g_hrb_partner_product.getProductPlatform(requestedProductId).toLowerCase() == "r")
        {
            return "off";    // office
        }
        else if (g_hrb_partner_product.getProductPlatform(requestedProductId).toLowerCase() == "s")
        {
            return "tcs";    // software
        }
        else
        {
            return "nfd";    // not found (nfd)
        }
    }
    else
    {
        return "nfd";
    }
}

// **************************************************************************************
// returns tco, tcs or off sourced from d_pName[][] array
// **************************************************************************************
function getProductName(requestedProductId)
{
    if (productIdValid(requestedProductId)){
        return g_hrb_partner_product.getProductOmnitureName(requestedProductId);
    }
    else{
        return "nfd";
    }
}

// *********************************************************
// END: TCS and TCO link code
// *********************************************************


// *********************************************************
// BEGIN: Web Service Cookie Code
// *********************************************************

function getWebServiceCookie(partnerID)
{
    var cValue = unescape(getCookie("wsc"));
        g_log.debug("Inside getWebServiceCookie("+partnerID+")  Cookie value "+cValue); 

    if (cValue != null && cValue != "null" && cValue != false && cValue != "")
    {
		try
		{       
			if (!g_hrb_partner_product.setPartnerProduct(cValue,true))
			{
				// this would happen if parsing failed
				return false;
			}
			// these values used in webServiceCallNotNeeded() to value global variables


			if ((g_hrb_partner_product.getPartnerOtpPartnerId() != partnerID))
			{   g_log.debug("getWebServiceCookie(): URL PID and wsc COOKIE PID are different!  Get updated product info.");
				// The partner id in the cookie isn't the one we want.
				// By returning false, will call the partner information from the server.
				return false;
			}
			else if (isDRUrlAndCookieDifferent())
			{   g_log.debug("getWebServiceCookie(): DR in both URL and COOKIE but different!  Get updated product info.");
				// The partner id in URL and cooke match but URL DigitalRiver info is different from digitalriver cookie
				// By returning false, will call the partner information from the server.
				return false;
			}
			else
			{   // The partner id in the cookie is the correct one, so no need to call the server
				// to get partner/product info since it's already in the cookie.
				g_log.debug("getWebServiceCookie(): No partner or digital river info changed, so no web service call needed.");
				return true;
			}
			
		}
		catch (e)
		{
			g_log.debug(":getWebServiceCookie("+partnerID+"):"+e.message);
		}
    }   

    // The cookie doesn't exist so get the partner information from the server.
    return false;
}

function getWebServiceCookie_OLD(partnerID)
{
    var cValue = unescape(getCookie("wsc"));
        g_log.debug("<b>Inside getWebServiceCookie</b>("+partnerID+")  Cookie value "+cValue); 

    if (cValue != null && cValue != "null" && cValue != false && cValue != "")
    {
        g_hrb_partner_product.setPartnerProduct(cValue,true);
        // these values used in webServiceCallNotNeeded() to value global variables

        if (g_hrb_partner_product.getPartnerOtpPartnerId() != partnerID)
        {
            // The partner id in the cookie isn't the one we want, so returning false will
            // cause us to get the correct partner information from the server.
            return false;
        }
        else
        {   // The partner id in the cookie is the correct one, so no need to call the server
            // to get partner/product info since it's already in the cookie.
            return true;
        }
    }   

    // The cookie doesn't exist so get the partner information from the server.
    return false;
}

function writeWebServiceCookie() 
{   
    g_log.debug('<b>Inside writeWebServiceCookie </b>');
    // This function is called after a successful call to the server for partner/product information.

    var wsinfo  = g_hrb_partner_product.getCompressedStr();
    g_log.debug(' writeWebServiceCookie : wsinfo:'+wsinfo);

    // ****************************** TBD: COMPLETE THIS SECTION!! ********************************
    // 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 domain cookie constraints imposed by browsers.
   
    setCookie("wsc",wsinfo, null, "/");
}

// *********************************************************
// 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;
}

// *********************************************************
// 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: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			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.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

// example calls
// onclick="omnitureOnClick('navLocation:h',  'navName:logo');"
// onclick="omnitureOnClick('navLocation:hpn','navName:taxes');"
// onclick="omnitureOnClick('navLocation:fpn','navName:customer_support');"
// onclick="omnitureOnClick('navLocation:f',  'navName:site_map');"
// onclick="omnitureOnClick('navLocation:b',  'navName:selectCompany', 'pageName:override_current_omni_pagename');"

function omnitureOnClick()
{
    if (typeof(s_hrb) != "undefined")
    {

        var tempPageName= "";
        var origPageName= s_hrb.pageName;
        
        var navLocation = "unknown";
        var navName     = "unknown";        
        
        var additionalTrackVars = "";
        
        var args        = arguments;
        var argsLen     = arguments.length;    

        for (var x=0; x<argsLen; x++)
        {
            if ((''+arguments[x]).indexOf("navLocation:") != -1)
            {
                navLocation    = arguments[x].substr(12).toLowerCase().replace(/&/g, "^");
            }
            else if ((''+arguments[x]).indexOf("navName:") != -1)
            {
                navName    = arguments[x].substr(8).toLowerCase();
                navName    = navName.replace(/&amp;/g, "and");
                navName    = navName.replace(/&nbsp;/g, " ");
                navName    = navName.replace(/&/g, " and ");
                
                // remove common html markup that may be in the anchor that called this function
                navName    = navName.replace(/<br>/g, "");
                navName    = navName.replace(/<br \/>/g, "");            
                navName    = navName.replace(/<b>/g, "");
                navName    = navName.replace(/<\/b>/g, "");
                navName    = navName.replace(/<sup>/g, "");
                navName    = navName.replace(/<\/sup>/g, "");
            }    
            else if ((''+arguments[x]).indexOf("pageName:") != -1)
            {
                tempPageName = arguments[x].substr(9).toLowerCase().replace(/&/g, "^");
                if (tempPageName != "undefined")
                {   
                    s_hrb.pageName = tempPageName;
                }
            }
            else if ((''+arguments[x]).indexOf("trackvars:") != -1)
            {
                additionalTrackVars = arguments[x].substr(10);
                if (additionalTrackVars.length > 0)
                {
                    additionalTrackVars += "&"; 
                }
            }
        }
            
        var newanchor = document.createElement("a");

        newanchor.setAttribute('href',  document.location.href); 
		document.body.appendChild(newanchor);

        var bOmniPageNameResolved    = false;

        if ( (typeof omni_pagename)=="undefined" || omni_pagename=="" || omni_pagename==null  || omni_pagename=="undefined")
        {
            // IF you click on a nav item BEFORE the page has finished loading, then omni_pagename will not be defined because
            // it is the omniture_std.html file included at the very bottom of the page that defines this variable.  In those
            // cases, the try/catch blocks below will handle the resulting javascript errors.

            // track the domain of the page that isn't setting omni_pagename
            omni_pagename = document.location.hostname;

            // is this is a page on hrblock.com domain?
            if ( (omni_pagename.indexOf("hrblock.com") != -1) || (omni_pagename.indexOf("handrblock.com") != -1) || (omni_pagename.indexOf("hrbtax.com") != -1) || (omni_pagename.indexOf("hrbtrade.com") != -1)  )
            {
                // is this is a internal search page?
                if (  (omni_pagename.indexOf("search2.") != -1) || (omni_pagename.indexOf("ahp.") != -1) || (omni_pagename.indexOf("taxpro.") != -1) || (omni_pagename.indexOf("jobs.") != -1) )
                {
                    // if hrblock.com, and internal search or not ocs owned, just use document.location.hostname for omni_pagename 
                    bOmniPageNameResolved = true;
                }
                else if (document.location.pathname.indexOf(".jsp") != -1) 
                {
                    // if a jsp page, try to identify the jsp application that is not valuing pagename
                    omni_pagename += "/application";
                    
                    if (document.location.pathname.indexOf("/taxes/fast_facts/") != -1)
                    {
                        omni_pagename += "/tax_faq";
                    }
                    else
                    {
                        omni_pagename += "/unknown/"+document.location.pathname;
                    }
                }
            }
            else
            {
                bOmniPageNameResolved   = true;
            }

            if (bOmniPageNameResolved)
            {
                // no action needed
            }
            else
            {
                try
                {
                    recordExceptionInOmniture("ocs-nopagename","9","using "+omni_pagename+"/nav/"+navLocation+"/"+navName);
                }
                catch (e)
                {
                    // alert("omnitureOnClick(): error calling recordExceptionInOmniture:"+e.description);  
                }
                
            }
        }

        try
        {
            webAnalytics(newanchor, "trackvars:eVar48="+omni_pagename+"/nav/"+navLocation+"/"+navName+"&"+additionalTrackVars, "trackevents:" ,"linkname:"+"/nav/"+navLocation+"/"+navName, "type:o");                
        }
        catch (e)
        {
            // alert("omnitureOnClick(): error calling webAnalytics:"+e.description);  
        }
        
        //s_hrb.pageName = origPageName;
    }
    else
    {
        // omniture has not loaded before onclick was processed
        // so evaluating s_hrb would have cause javascript error
    }
}        

//load the software processing JS for the product learn more in online pages
if ( document.location.pathname.indexOf('product.jsp') != - 1)
{
    document.write('<script type=\"text\/javascript\" src=\"\/includes\/js\/soft_product_processing.js\"><\/script>');
}

function hasValue(v)
{
    // returns true if this variable is defined and has a non empty value
    if (typeof v!='undefined' && v!=null && v!='')
    {
        return true;
    }
    return false;
}

// *********************************************************
// allow_offermatica_test()
// Checks to see if an offermatica test can be run or not by 
// checking if an otpPartnerId exists in the url or in the cookie.
// *********************************************************
function allow_offermatica_test()
{
    if (bBugWin) bugTxt += "<font color='blue'><b>top of allow_offermatica_test()</b></font><br/>";

    var pid_from_cookie = getCookiePartnerId("main_cookie");    
    var pid_from_url    = getUrlPartnerId();
    var pid_to_use;

    if (hasValue(pid_from_url))
    {
        pid_to_use = pid_from_url;
    }
    else if (hasValue(pid_from_cookie))
    {
        pid_to_use = pid_from_cookie;
    }
    else 
    {
        pid_to_use = 0; // tbd: 1) organic search engine partner id and 2) 2631 returned from partner info servlet call
    }
    
    if (bBugWin) bugTxt += "allow_offermatica_test(): getCookiePartnerId('main_cookie')=='"+pid_from_cookie+"'<br/>";
    if (bBugWin) bugTxt += "allow_offermatica_test(): getUrlPartnerId()=='"+pid_from_url+"'<br/>";
    if (bBugWin) bugTxt += "allow_offermatica_test(): pid_to_use=='"+pid_to_use+"'<br/>";
    
    var offermatica_pids = new Array("","0","180",
                                     "3346","3347","3348","3349","3350","3351","3352","3353","3401","3405", /* UHP Image Test */
                                     "3407","3408","3409","3410","3411","3412","3413",  /* 1040EZ Test */
                                     "3416","3417","3418","3419","3420","3421", /* DIY Main Online Test */
                                     "3511","3512","3513","3514","3515","3516","3517",  /* Organic Search - UHP */
                                     "3523","3524","3525","3526","3527","3528","3529","3530",   /* FFA Top Section Design */
                                     "3548","3549","3550","3551","3552","3553","3554","3555",   /* Paid Search - UHP */
                                     "3536","3537","3538","3539","3540","3541",     /* Paid Search - Office */
                                     "3542","3543","3544","3545","3546","3547",     /* Paid Search - DIY */
                                     "3602","3603","3604","3605","3606",    /* Organic Search - UHP - Round 2 */
                                     "3571","3572","3573",   /* Lineup - UHP */
                                     "3574","3575","3576",   /* Lineup - DIY */
                                     "3567","3568","3569","3570","3569","3558","3559","3560","3561","3562","3563","3564","3565","3566",  /* Banner Ad - Retail */
                                     "3607","3608","3610","3611", 	/* BoB Online Price Test */
									 "3402","3403","3404", /* Basic Online Price Test */
									 "3724","3725","3726");	/* UHP */
                                       
    g_offermatica_allow = "0";

    for (var i=0;i<offermatica_pids.length;i++)
    {       
        if (offermatica_pids[i] == pid_to_use)
        {
            g_offermatica_allow = "1";            
            break;
        }
    }
}

// *********************************************************
// END allow_offermatica_test()
// *********************************************************
// *********************************************************
// callOffermatica(clicksrc)
// Passes the mbox onclick name for links and buttons to 
// register within offermatica.
// *********************************************************
function callOffermatica(clicksrc)
{
    var defaultImageURL = document.location.protocol + '//www.hrblock.com/images/pixel.gif';
    var clickedMboxName = clicksrc;  

    clickRequestUrl = document.location.protocol + '//mbox9e.offermatica.com/m2/hrblock/' + 'ubox/image?mbox=' + clickedMboxName + 
                     '&mboxSession=' +  mboxFactoryDefault.getSessionId().getId() + '&mboxPC=' + 
                     mboxFactoryDefault.getPCId().getId() + '&mboxXDomain=disabled&mboxDefault=' + escape(defaultImageURL) + 
                     '&profile.productClicked=home_office' + '&t=' + (new Date()).getTime();   

    (new Image()).src = clickRequestUrl;   

    return;
}
// *********************************************************
// END callOffermatica(clicksrc)
// *********************************************************
//used by software pages
function updateProductVariation(pid,variation,obj)
{   
    document.getElementById(pid+'_variation').value=variation;
}

/* function to hightlight taxtips article links*/
function updateTaxTipsArticleLink(){
    var page_nav_tax_tip =getElementsByAttribute("id", "page_nav_tax_tip");
    var  title = unescape(getQueryValue('ttiptitle'));
     for (var k=0;k<page_nav_tax_tip.length;k++){
        var tax_tip_items = page_nav_tax_tip[k].getElementsByTagName("li");
        
        for (var i=0;i<tax_tip_items.length;i++){
            var tax_tip_item = "";
            var tmpHref=tax_tip_items[i].childNodes[0].href;
            title = title.trim();
            var indx = tmpHref.indexOf("ttiptitle");
            tax_tip_item = (unescape(tmpHref.substring(indx+10))).trim();
            if(tax_tip_item == title){
                tax_tip_items[i].childNodes[0].style.color = "white";
                tax_tip_items[i].style.background = "#7DC242";
                break;
            }
        }
    }
}

function handleNonClickable(e){
    var obj =null;
    var ypos=0;
    if (window.event){
        obj=event.srcElement;
        ypos=(event.clientY + document.documentElement.scrollTop  )  ;
    }
    else {
    obj=e.target;
    ypos =e.pageY ;      
    }
    var objTagNm= obj.tagName;
    if ((objTagNm.toLowerCase())=='input' ||  (objTagNm.toLowerCase())=='a'  || (objTagNm.toLowerCase())=='select' ){
       return;
    }
    if (obj.onclick!= undefined && obj.onclick!=null&& obj.onclick!=''){
       return;
    }
    if (typeof obj.parentNode !='undefined'){
        if (obj.parentNode.tagName=='A' ){
           return;
        }
        else if (obj.parentNode.onclick!= undefined && obj.parentNode.onclick!=null && obj.parentNode.onclick!=''){
            return false;
        }
    }
    var navname='';
    var navloc='NONClK';
    if(obj.tagName=='IMG'){
        var tmpimgName=obj.src;
        if ( typeof tmpimgName!='undefined' && tmpimgName!=null && tmpimgName!=''){
        tmpimgName=tmpimgName.substring(tmpimgName.lastIndexOf('/')+1,tmpimgName.length)
        }
        navname+='im|'+tmpimgName;
    }
    else if ((typeof obj.style!='undefined')&& obj.style.backgroundImage!=''){
        var tmpimgName=obj.style.backgroundImage;
        if ( typeof tmpimgName!='undefined' && tmpimgName!=null && tmpimgName!=''){
        tmpimgName=tmpimgName.substring(tmpimgName.lastIndexOf('/')+1,tmpimgName.length)
        }
        navname+='im|'+tmpimgName;
    }
    else if ((typeof obj.id!='undefined') && obj.id!=''){
        navname+='id|'+obj.id;
    }
    else if ((typeof obj.className!='undefined') && obj.className!='' ){
        navname+='cl|'+obj.className;
    }

    if(obj.tagName=='BODY'){
       navname+='black_area';
    }
    if (ypos > 135 && ypos <635){
     navloc+='/BODY';
    }
    else if (ypos < 135){
     navloc+='/HEAD';
    }
    else{
     navloc+='/FOOT';
    }
    omnitureOnClick('navLocation:'+navloc,'navName:'+navname);
}