
//------------------------------------------------------------------------------
// Copyright 2007 Intuit Inc. All rights reserved. Unauthorized reproduction is
// a violation of applicable law. This material contains certain confidential or
// proprietary information and trade secrets of Intuit Inc.
//------------------------------------------------------------------------------
/**
      @file

      Provide help functionalities to help content file.
        
*//****************************************************************\

	Coded by Peter Harris, June 2003.
	Adapted for QB U.S. by Celia Luk and Jeff Taggart, 2006
   ============================================================
		JavaScript Toolkit for HTML Help
   ------------------------------------------------------------
   This toolkit contains routines for the following features:
	== User Feedback interface.
		- makeFeedbackAndHelpSupportLink( divObj )
	== Wrapper functions for JS callable lib
	  - CheckCondition(condition)
	  - ShowTopic(helpitemid)
	  - SearchTopics(searchQuery)
	  - qbcommand(command)
	  - QBURL(url)
	  - GetQBValue(key)
	== Boiler-plate
	 - makeProAdvisorLink()
	 - makeCommunityLink()
   ------------------------------------------------------------
   _____________________ Version History ______________________
   Version 3.00 - Feb 27, 2006
   - Clean up unncessary code
   - Modify Feedback functions not to get Feedback URL from ACE
   - Remove connections between this JS and QB, instead using HelpSystem's JS calliable lib
    Version 2.30 - June 23, 2006
	 - Add Feedback functions for user comments. Previously this was handled by Feedback.CHM
	 - Redefine Conditional text operators to be more "user friendly"
	 - Make functions IE7 compatible
	 - Remove "popup" functions. Popups will not be used in QB2007
	 - General cleanup to remove obsolete global variables and functions
	Version 2.20 - Feb 9, 2006
	 - Create boiler-plate for pro-advisor and community
	 - Add static expando
  	Version 2.10 - August 28, 2003
	 - Create a multi-capacitant environment where the script can link to files whether from Perforce, from CHM, or from /updates.
	Version 2.07 - July 17, 2003
	 - Reformat all links to explicitly include the CHM file, if there is one. Fixes broken expando and popup links.
	Version 2.06 - July 10, 2003
	 - Hide <H?> title and <H4>Related Topics</H4> when in an expando window.
	Version 2.05 - July 9, 2003
	 - Made SKU.js an override to ActiveX detection; added <detectsku> tag for showing detected info.
	Version 2.04 - June 12, 2003
	 - Added automatic lightning bolt to irefs linking to "http://"
	Version 2.03 - June 10, 2003
	 - Added multisectional, radio button based expando tag <a multiexpando="basename">.
	Version 2.02 - June 9, 2003
	 - Extended Strata (and Flavours) handling:
		- All codes now in arrays QUICKBOOKS_ALLSTRATA, QUICKBOOKS_STRATAWITHFLAVOUR and QUICKBOOKS_ALLFLAVOURS
		- Added (+) operator; i.e. PRO+ = PRO, PREMIER, ENTERPRISE
		- Added (-) operator; i.e. PRO- = LITE, BASIC, PRO
		- Added (:) operator; i.e. PREMIER: = PREMIER but only with no Flavour
		- Added NOT() operator; i.e. skus="NOT(ENTERPRISE,CONTRACTOR)" = anything that isn't QBES or CONTRACTOR
	 - Added automatic tooltips for expando sections. Requires <html xmlns:qb> header tag.
	Version 2.01 - June 3, 2003
	 - Added new Flavors: PROFESSIONAL, WHOLESALE, RETAIL.
	 - Added text mods "2TEXT" and "ORDINAL" for working with numbers.
	 - Added rollovers for expando graphic.
	 - Added support for multiple expando graphics (use attribute icon="", e.g. <a expando icon="green">).
	Version 2.0 - June 2003
	 - Taking what we learned in v.1, this is a complete
	   rewrite, with lots of new and wonderful stuff.
	   For information about previous versions, check
	   qbw.js from Gecko/Godzilla.

\****************************************************************/
// The following variable contains the hardcoded date of the build
// of the CHM. The reason for this that the ".lastModified" property
// doesn't work inside HTMLHelp and we need to submit this for VOC data
// from inside HTML Help (embedded browser) for the 'yes'/'no' feedback.
// We should find an automated workaround for this manual fix, to avoid
// constant updating of this value. -MTK 2-20-2003

PACKAGE_DATE	= "6,22,2007";

// Code added by C.Clabourne 9/18/2007
//----- Define "apex" to be the topmost frame that doesn't throw a zone error -----\\
//----- Use it to replace "top" everywhere (specifically, Expando global tracking -----\\
var apex = window.self;
var tempObj = window.self;
while (tempObj) {
	apex = tempObj;
	tempObj = tempObj.parent;
	try {
		var tmp = tempObj.name;
	}
	catch (e) {
		tempObj = null;
	}
	if (apex == tempObj) {		// You've reached "top." without a zone crash. Stop looping.
		tempObj = null;
	}	
}

// ------------------------------------------------------------ \\
// ---  DEFINE THE FILE-LINK PREFIXES FOR THIS ENVIRONMENT  --- \\
// ------------------------------------------------------------ \\

IS_EXPANDO_FRAME = ( window.name.indexOf("_expando_") > -1 );

PATH_PREFIX_IMAGES = "../../Shared/Images/Common/";
PATH_PREFIX_BEHAVIORS = "../../Shared/JavaScript/";
// ------------------------------------------------------------ \\


ICON_PRINTER		= PATH_PREFIX_IMAGES + "icon_printer.gif";
ICON_FEEDBACK		= PATH_PREFIX_IMAGES + "icon_feedback_email.gif";
ICON_LIGHTNING		= PATH_PREFIX_IMAGES + "icon_lightningbolt.gif";
ICON_PDF			= PATH_PREFIX_IMAGES + "icon_pdf.gif";
ICON_HELP_FEEDBACK	= PATH_PREFIX_IMAGES + "icon_help_feedback.gif";
ICON_HELP_SUPPORT	= PATH_PREFIX_IMAGES + "icon_help_support.gif";
ICON_FEEDBACK_YES = PATH_PREFIX_IMAGES + "feedback_yes.gif";
ICON_FEEDBACK_NO = PATH_PREFIX_IMAGES + "feedback_no.gif";

/*
// ------------------------------------------------------------ \\
// ---      DISABLE THE "RIGHT-CLICK" MENU IN THE HELP      --- \\
// ------------------------------------------------------------ \\

document.onmousedown = rightclick;
// this only works because it provides an alternate window (the alert box) for the mouseup to trigger in.
// it would be better to intercept and stop the onmouseup event instead, but I can't do it yet.
function rightclick(e) {
  if (event.button == 2) {
//	alert("Right-click disabled");
//	event.returnValue = false;
//	event.cancelBubble = true;
	return false;
  }
}
*/

// ------------------------------------------------------------ \\
// ---  INCLUDE STYLE SHEET BEHAVIORS WITH RELATIVE PATHS   --- \\
// ------------------------------------------------------------ \\
var txt = "";
txt += "<style>\n";
txt += "qb\\:tooltip { behavior: url(" + PATH_PREFIX_BEHAVIORS + "tooltip.htc); }\n";
txt += ".stripes { behavior: url(" + PATH_PREFIX_BEHAVIORS + "stripes.htc); margin-bottom: 0em; margin-top: 1em; }\n";
txt += "</style>";
document.writeln(txt);


// ------------------------------------------------------------ \\
// ----- DEFINE ALL TEXT RESOURCES HERE (FOR TRANSLATION) ----- \\
// ------------------------------------------------------------ \\
TEXT = new Array();
TEXT["expando_tooltip"] =		"Expand/Collapse Text";
TEXT["expando_multi_tooltip"] =		"Display details";
TEXT["expando_loading"] =		" Loading, please wait . . . ";
TEXT["feedback_ratetopic"] =		"Tell us how we can improve QuickBooks.";
TEXT["helpsupport_linktext"] =		"More help resources";
TEXT["printericontext"] =			"Print Topic";
TEXT["tooltip_expando"] =			"Expand/Collapse Text";
TEXT["tooltip_multiexpando"] =		"Display details";
TEXT["pro_advisor_text"] = 			"You could also ask your accountant for assistance. If you don't have an accountant, Intuit can help you ";
TEXT["community_text_1"] = 			"If you don't see your problem listed above, check the";
TEXT["community_text_2"] = 			"QuickBooks Community site for";

var parentContentDivObj = null;

// ============================================================ \\
// =====           CONDITIONAL & VARIABLE TEXT            ===== \\
// ============================================================ \\

function doStartup() {
	// QBW050264 - switch the calls of tagScanner() and expando_doStartup(), so that
	// the conditional text will be evaluated before resize and bring up the expando frame
	tagScanner();
	expando_doStartup();
	updateScrollbar();
}

function tagScanner() {
	// ----- first off, let's find the _expando_ parent frame ----- \\
	// ----- might not be _top, but first above "_expando_"s  ----- \\
	var iTargetObj = self;
	while ( iTargetObj.name.indexOf("_expando_") >= 0 ) {
		iTargetObj = iTargetObj.parent;
	}
	var iTarget = iTargetObj.name;
	if (iTargetObj == top || iTarget == "") {
		iTarget = "_top";
	}
	if (iTargetObj == self) {
		iTarget = "";
	}

	// -----  This function scans through every HTML DOM node in the file.   ----- \\
	// -----  NB: HTML attributes are case-sensitive! 'Name' is not 'name'.  ----- \\

	var at_body = "";
	// <H4>Related Topics</H4> was changed to <p class="seealso">See Also</p>
	var at_relatedtopics = "";
	// Let's not show "See Also" links in expando topics
    var at_seealso = "";
  // Do not show "To do this task"
  var at_todotask = "";
    
  allElements = document.getElementsByTagName("*");
  
  // ----- accomodate IE 5.5 ----- \\
	if ( allElements.length == 0 ) { allElements = document.all; }
	// ----------------------------- //
	
	for (var i=0; i<allElements.length; i++) {
		nodeObj = allElements[i];
		tNode = nodeObj.nodeName.toUpperCase();

		if (tNode.substring(0,1) != "#") {
			// ----- Only check if not XML object ----- \\
			// QBW052635 - Nov 09, 2007 Support conditional expando, we do not evaluate
			// the condition if class="expando" coz expando will evaluate it
			if (nodeObj.className.toLowerCase() != "expando") {
  			tSKUs = "";
  			tSKUs = nodeObj.getAttribute("skus");
  			tService = "";
  			tService = nodeObj.getAttribute("service");
  			tPref = "";
  			tPref = nodeObj.getAttribute("pref");
  			if (tSKUs || tService || tPref) {
  				// ----- make this item conditional ----- \\
  				if ( validateSKUs(tSKUs) && validatePrefOrService(tService) && validatePrefOrService(tPref)) {
  					nodeObj.style.display = (tNode=="SPAN" || tNode=="A") ? "inline" : "block";
  				} else {
  					nodeObj.style.display = "none";
  				}
  			}
  			// end FLAVOR conditional
  		}
  		}

		if ( tNode == "A" ) {
			linkObj = nodeObj;

			if (iTarget) {
				if ( !(linkObj.target) ) {
					linkObj.target = iTarget;
				}
			}

			// ----- implement expando text links here ----- \\
			var tDivID = "";
			tDivID = nodeObj.getAttribute("expando");
      if (tDivID != null) {
				makeExpandoLink( linkObj, tDivID );
			}

			// ----- implement radio button expando text links here ----- \\
			var tDivID = "";
			tDivID = nodeObj.getAttribute("multiexpando");
			if ( tDivID ) {
				makeMultiExpandoLink( linkObj, tDivID );
			}

		}

		if (nodeObj.id.toLowerCase() == "help_feedback_link") {
			// ----- Add the help feedback link to the bottom of the topic ----- \\
			if ( !IS_EXPANDO_FRAME ) {
				//makeFeedbackAndHelpSupportLink( nodeObj , 1);
			}
		}

		if (nodeObj.id.toLowerCase() == "help_feedback_link_noresources") {
			// ----- Add the help feedback link to the bottom of the topic ----- \\
			if ( !IS_EXPANDO_FRAME ) {
				//makeFeedbackAndHelpSupportLink( nodeObj, 0 );
			}
		}
		
		if (nodeObj.id.toLowerCase() == "pro_advisor_link") {
			// ----- Add the help feedback link to the bottom of the topic ----- \\
			if ( !IS_EXPANDO_FRAME ) {
				makeProAdvisorLink( nodeObj);
			}
		}
		
		if (nodeObj.id.toLowerCase() == "community_link") {
			// ----- Add the help feedback link to the bottom of the topic ----- \\
			if ( !IS_EXPANDO_FRAME ) {
				makeCommunityLink(nodeObj);
			}
		}


		// -----  Hide certain segments in the case of expando frames  ----- \\
		if (IS_EXPANDO_FRAME) {
			// ----- hide the first content tag after the body if it's an <H#> tag. ----- \\
			if ( at_body == "AT" && nodeObj.innerHTML ) {
				at_body = "PAST";
				var divId = nodeObj.getAttribute("id");
				if (tNode == "DIV" && divId.toUpperCase() == "HELP_HEADER") {
					nodeObj.style.display = "none";
				}
			}

			if ( !at_body && tNode == "BODY" ) {
				at_body = "AT";
			}

			
			// -- hide any <p class="seealso">See Also</p> blocks along with any list items -- 
			var sSeealso ="";
			if ( !at_seealso && tNode == "P" ) {
				if ( nodeObj.attributes["class"] ) { sSeealso = nodeObj.attributes["class"].value.toUpperCase(); }
				if ( sSeealso == "SEEALSO" ) { at_seealso = "AT"; }
			}
		
			if ( at_seealso == "AT" ) {
				if ( tNode == "P" ) {
					nodeObj.style.display = "none";
				}
				if ( tNode == "OL" || tNode == "UL" ) {
					nodeObj.style.display = "none";
				}
				if ( tNode != "P" && tNode != "OL" && tNode != "UL" ) {
					at_seealso = "";
				}
			}
			
			// -- QBW042126 07/25/06 cluk - hide any <span class="task">To do this task</span>
			var sTodotask ="";
			if ( !at_todotask && tNode == "SPAN" ) {
				if ( nodeObj.attributes["class"] ) { sTodotask = nodeObj.attributes["class"].value.toUpperCase(); }
          if ( sTodotask == "TASK" ) { at_todotask = "AT"; }
			}
		
			if ( at_todotask == "AT" ) {
				if ( tNode == "SPAN" ) {
					nodeObj.style.display = "none";
				}
				else {
					at_todotask = "";
				}
			}
		}
	}
}

function validateSKUs ( source ) {

  if (source == null || string_trim(source).length <=0) return true;
  
	var tTokens = source.split(",");
	
	var tList = new Array();
	for (var j=0; j < tTokens.length; j++) {
	  /* trim the conditionId and check if the condition is valid*/
		conditionId = string_trim(tTokens[j]);
		if (checkCondition(conditionId) == true) {
      return true;
    }
  }
  return false;
}

function validatePrefOrService ( source ) {

  if (source == null || string_trim(source).length <=0) return true;
	var tTokens = source.split("+");
	
	var tList = new Array();
	for (var j=0; j < tTokens.length; j++) {
	  /* trim the conditionId and check if the condition is valid*/
		conditionId = string_trim(tTokens[j]);
		if (checkCondition(conditionId) == false) {
      return false;
    }
  }
  return true;
}

// ============================================================ \\
// =====                Utility functions                  ===== \\
// ============================================================ \\
function string_trim ( str ) {
	str = str.replace( /^\s*/ , "" );
	str = str.replace( /\s*$/ , "" );
	return str;
}

// ------------------------------------------------------------ \\
// ============================================================ \\
// =====                EXPANDO SECTIONS                  ===== \\
// ============================================================ \\
// ------------------------------------------------------------ \\
// -----     INSERT CODE FOR EXPANDO AND MULTIEXPANDO     ----- \\

// ------------------------------------------------------------------- \\
// -----        DEFINE ALL CONSTANTS AND NECESSARY OBJECTS       ----- \\

EXPANDO_GRAPHICS = new createExpandoGraphicsObject( "green", "white" );

if (!apex.GLOBALFRAMES)	{ apex.GLOBALFRAMES = new createGlobalFramesObject(); }

var EXPANDO_MULTILINKS = new Array();

// ------------------------------------------------------------------- \\

function createExpandoGraphicsObject() {
	if (arguments.length == 0) return;

	this.Colorlist = new Array();
	this.Color = new Array();
	this.Icon = new Array();

	for (var i=0; i<arguments.length; i++) {
		var couleur = arguments[i];
		this.Colorlist[i] = couleur;
		this.Icon[i] = new createExpandoButtonObject(couleur);
		this.Color[couleur.toLowerCase()] = this.Icon[i];
	}

	// Make first colour the default
	this.Default = arguments[0];
}

function createExpandoButtonObject ( couleur ) {
	this.Name = couleur;
	this.Open = new Image();	this.Open.src = 	PATH_PREFIX_IMAGES + "button_expand_" + couleur + "_open_lo.gif";
	this.Close = new Image();	this.Close.src =	PATH_PREFIX_IMAGES + "button_expand_" + couleur + "_close_lo.gif";
	this.OpenOver = new Image();	this.OpenOver.src =	PATH_PREFIX_IMAGES + "button_expand_" + couleur + "_open_hi.gif";
	this.CloseOver = new Image();	this.CloseOver.src =	PATH_PREFIX_IMAGES + "button_expand_" + couleur + "_close_hi.gif";
}

function createGlobalFramesObject() {
	this.Expandos = 0;
	this.Expando = new Array();
	this.ExpandoPadding = "0px";
	this.ExpandoMargin = "2px";
	this.Popups = 0;
	this.Popup = new Array();
}

function createExpandoFrameObject ( divObj, filename ) {
	this.FrameName = expando_getFrameName( apex.GLOBALFRAMES.Expandos++ );
	this.File = filename;
	this.DivObj = divObj;
	this.IFrameObj = null;
	this.Loading = false;
	this.Loaded = false;
}


// ------------------------------------------------------------------- \\
// -----            "ON-LOAD" AND "ON-CHILD-LOAD" CODE           ----- \\

function expando_doStartup() {
	if (parent && parent != self) {
		document.body.style.margin = apex.GLOBALFRAMES.ExpandoMargin;
		document.body.style.padding = apex.GLOBALFRAMES.ExpandoPadding;
	}

	if (parent && parent != self && parent.expando_childLoaded ) {
		parent.expando_childLoaded( self.name );
	}

	if (!parent || parent == self) {
		// ----- Only the top window gets resized by humans
		//window.onresize = expando_onresizeBrowser;
		window.onresize = onResize;
	} else {
		window.onresize = expando_onresizeFrame;
	}
}


function expando_childLoaded ( frameName ) {
	if ( frameName ) {
		var framething = apex.GLOBALFRAMES.Expando[frameName];
		var divObj = framething.DivObj;
		window.clearTimeout(divObj.externalWatchID);

		expando_resizeExternalChildFrame( frameName );
		framething.Loading = false;
		framething.Loaded = true;

		if (divObj.firstChild.nodeName == "#text") {
			// ----- "Loading" message; remove
			divObj.removeChild( divObj.firstChild );
		}
	}
}


function expando_isAllLoaded() {
	for ( var n=1; n <= apex.GLOBALFRAMES.Expandos; n++ ) {
		var framenom = expando_getFrameName(n);
		var framething = apex.GLOBALFRAMES.Expando[framenom];
		if (framething && framething.Loading) {
			return false;
		}
	}
	return true;
}


// ------------------------------------------------------------------- \\
// -----              TURN LINKS INTO EXPANDO LINKS              ----- \\

function makeExpandoLink ( linkObj, divID ) {
	var tDivObj = expando_findExpandoDiv( linkObj, divID );

	// QBW052635 - Nov 09, 2007 Support conditional expando
	if (tDivObj == null) {
    // disable the display of the <a> tag if <div> tag is not found or fail during 
    // condtion evaluation
    linkObj.style.display = "none";
  }
  
	// -----  If there's no valid target zone for this link,       ----- \\
	// -----  then we don't activate the href, and it's just text. ----- \\
	if (tDivObj) {

		// ----- is there a specific icon= being asked for? ----- \\
		var tMyIcon = linkObj.getAttribute( "icon" );
		if ( !tMyIcon || !EXPANDO_GRAPHICS.Color[tMyIcon] ) {
			tMyIcon = EXPANDO_GRAPHICS.Default;
		}
		if (tMyIcon) tMyIcon = tMyIcon.toLowerCase();

		// ----- does it default to open or closed, and is it static? ----- \\
		var tStartOpen = false;
		var tStaticExpando = false;
		var tSwitch = linkObj.getAttribute( "type" );		// ----- XHTML, strict
		if (tSwitch)
		{
  		if ( tSwitch.toLowerCase() == "open" ) {
  			tStartOpen = true;
  		}
  		if ( tSwitch.toLowerCase() == "static" ) {
  			tStaticExpando = true;
  		}
  	}

		// ----- set up custom attributes for Anchor and DIV ----- \\
		linkObj.divObj = tDivObj;
		linkObj.startOpen = (tStartOpen || tStaticExpando);
		linkObj.iconColor = tMyIcon;
		linkObj.unloadedFileList = new Array();

		linkObj.divObj.linkObj = linkObj;
		linkObj.divObj.startOpen = (tStartOpen || tStaticExpando);
		linkObj.divObj.external = false;


		// ----- prepare the DIV ----- \\
		if ( !expando_divPrep( tDivObj ) ) {
			return;
		}


		// ----- avoid IE 5.5 redraw bug when sections are auto-open ----- \\
		if ( tStartOpen && tDivObj.ie55 ) {
			return;
		}

		if (tStaticExpando)   // Static Expando - cluk
		{
			// remove the border width of the expando
			tDivObj.style.borderWidth = 0;
		}

		if (!tStaticExpando) {
			// ----- add open/close graphic to link and set color ----- \\
			var imgObj = document.createElement("IMG");
			var iconObj = EXPANDO_GRAPHICS.Color[linkObj.iconColor];
			imgObj.src = (tStartOpen) ? iconObj.Close.src : iconObj.Open.src;
			// crop if too large (= graphic is missing, usually)
			if (imgObj.width > 16 || imgObj.width == 0) { imgObj.width = 12; imgObj.height = 12; }
			imgObj.border = 0;
			imgObj.style.marginRight = 4;
			imgObj.style.marginLeft = 4;
			imgObj.style.marginBottom = 1;
			imgObj.style.marginTop = 2;
			//linkObj.insertBefore( imgObj, linkObj.firstChild );   // put expando icon in front of text
			linkObj.appendChild(imgObj);  // put expando icon  behind text
			linkObj.style.color = "#000099";

			// ----- activate the link ----- \\
			//linkObj.href = "javascript:nothing()"; //C.Clabourne - Setting the href blows up Knova
			linkObj.onclick = expandoText;
			linkObj.onmouseover = expandoMouseOver;
			linkObj.onmouseout = expandoMouseOut;
		}
	}
}

function makeMultiExpandoLink ( linkObj, divBaseID ) {
	// ----- works like radio buttons do: if the generic divBaseID = "block", then
	// ----- each actual <DIV ID=""> would be "block(1)", "block(2)", etc.
	// ----- multiExpandos require an explicit ID in the DIV; no anonymous blocks.

	if (!(window.EXPANDO_MULTILINKS[divBaseID])) { EXPANDO_MULTILINKS[divBaseID] = 0; }
	var tID = ++EXPANDO_MULTILINKS[divBaseID];

	var tDivObj = document.getElementById( divBaseID+"("+tID+")" );

	// -----  If there's no valid target zone for this link,       ----- \\
	// -----  then we don't activate the href, and it's just text. ----- \\
	if (tDivObj) {

		// ----- does it default to open or closed? ----- \\
		var tStartOpen = false;
		if ( linkObj.getAttribute("open") != null ) {		// ----- HTML, transitional
			tStartOpen = true;
		}
		var tSwitch = linkObj.getAttribute( "type" );		// ----- XHTML, strict
		if ( tSwitch.toLowerCase() == "open" ) {
			tStartOpen = true;
		}

		// ----- set up custom attributes for Anchor and DIV ----- \\
		linkObj.divObj = tDivObj;
		linkObj.startOpen = tStartOpen;
		linkObj.unloadedFileList = new Array();
		linkObj.divBase = divBaseID;
		linkObj.divIndex = tID;

		linkObj.divObj.linkObj = linkObj;
		linkObj.divObj.startOpen = tStartOpen;
		linkObj.divObj.external = false;


		// ----- prepare the DIV ----- \\
		if ( !expando_divPrep( tDivObj ) ) {
			return;
		}

		// ----- add radio button to link and set color ----- \\
		var rkoObj = document.createElement("INPUT");
		rkoObj.type = "radio";
		rkoObj.name = divBaseID;
		rkoObj.id = "_"+divBaseID+"_"+tID;
		linkObj.insertBefore( rkoObj, linkObj.firstChild );
		linkObj.style.color = "#000099";

		// ----- activate the link ----- \\
		//linkObj.href = "javascript:nothing()"; //C.Clabourne - Setting the href blows up Knova
		linkObj.onclick = multiExpandoText;
	}
}

function makeIncludoBlock( divObj ) {
	divObj.startOpen = true;
	expando_divPrep ( divObj );
}

// ------------------------------------------------------------------- \\

function expando_divPrep ( divObj ) {

	tFile = divObj.getAttribute("file");
	if (tFile) {
		// ----- need to set up an iframe container for the external file ----- \\
		if ( !expando_createExternalFrame( divObj, tFile ) ) {
			// ----- failure; hide DIV (in case it's visible now)
			divObj.style.display = "none";
			return false;
		}

		if ( divObj.startOpen ) {
			if ( !expando_attachToDisplayParent( divObj ) ) {
				// ----- there was no hidden parent to attach to, ergo ----- \\
				// ----- this segment is currently displayed; load it! ----- \\
				expando_loadExternalFiles( divObj );
				trackExpandoUsage( "AUTO", divObj.externalFile );
			}
		}

		divObj.external = true;
	}

	if ( divObj.startOpen ) {
		// ----- Start this expando block open ----- \\
		divObj.style.display = (divObj.nodeName == "SPAN") ? "inline" : "block";
	} else {
		divObj.style.display = "none";
	}

	return true;
}

function expando_findExpandoDiv ( anchorTag, divID ) {
	// ----- If there's a "divID", then find that DIV ID. Otherwise,  ----- \\
	// ----- search forward in the DOM for the next valid target tag. ----- \\
	// ----- Valid:  DIV/SPAN tag or LI tag with "expando" class      ----- \\
	var divTag = null;

	if (divID) {
		divTag = document.getElementById(divID);
	} else {
		var tgs = document.getElementsByTagName("*");
		// ----- accomodate IE 5.5 ----- \\
		if ( tgs.length == 0 ) {
			if ( document.all ) {
				tgs = document.all;
			}
		}
		// ----------------------------- //
		var postAnchor = false;
		for ( var j=0; j<tgs.length; j++ ) {
			var thisObj = tgs[j];
			if (!postAnchor) {
				if (thisObj == anchorTag) {
					postAnchor = true;
				}
			} else {
				if ( (thisObj.tagName == "DIV" || thisObj.tagName == "SPAN" || thisObj.tagName == "LI") &&
				     (thisObj.className.toLowerCase() == "expando" ||
				      thisObj.className.toLowerCase().substring(0,8) == "expando_") ) {
          // QBW052635 - Nov 09, 2007 Support conditional expando
    			var tSKUs = thisObj.getAttribute("skus");
    			var tService = thisObj.getAttribute("service");
    			var tPref = thisObj.getAttribute("pref");
    			if ( validateSKUs(tSKUs) && validatePrefOrService(tService) && validatePrefOrService(tPref)) {
					   divTag = thisObj;
					   break;
					}
				} else{
				  // QBW052635 - if seeing a <A> tag, we want to stop looking for expando div tag;
				  // otherwise, it will mess up other following expandos
				  if (thisObj.tagName == "A") {
            divTag = null;
            break;
          }
        }
			}
		}
	}

	return divTag;
}


// ------------------------------------------------------------------- \\
// -----       "ONCLICK" OPERATING CODE FOR EXPANDO EVENTS       ----- \\


function expandoText(e) {
	if (!e) var e = window.event;

	var anchor = expando_getAnchorObject(e);

	if (anchor == null) return;

	var iconColor = anchor.iconColor;
	var divObj = anchor.divObj;
	var subList = anchor.unloadedFileList;


	if (divObj) {

		if ( ( divObj.externalFile && !divObj.externalLoaded ) || anchor.unloadedFileList.length > 0 ) {
			// ----- need to load external files ----- \\
			expando_loadExternalFiles( divObj );
		}

		// ----- Find the open/close image in the link, if there is one  ----- \\
		tPicObj = "";
		for ( j=0; j < anchor.childNodes.length; j++ ) {
			if (anchor.childNodes[j].tagName == "IMG") {
				var tAnchor = unescape(anchor.childNodes[j].src);
				if ( ( tAnchor == unescape(EXPANDO_GRAPHICS.Color[iconColor].Open.src) )
				  || ( tAnchor == unescape(EXPANDO_GRAPHICS.Color[iconColor].Close.src) )
				  || ( tAnchor == unescape(EXPANDO_GRAPHICS.Color[iconColor].OpenOver.src) )
				  || ( tAnchor == unescape(EXPANDO_GRAPHICS.Color[iconColor].CloseOver.src) )
				) {
					tPicObj = anchor.childNodes[j];
					break;
				}
			}
		}
		// ----- Use the .style.display property to determine open/closed status    ----- \\
		// ----- It must be set explicitly by the setup code; it defaults to blank. ----- \\
		tShowMode = (divObj.nodeName == "SPAN") ? "inline" : "block";
		if (divObj.style.display == "none") {
			divObj.style.display = tShowMode;
			if (tPicObj) {
				tPicObj.src = EXPANDO_GRAPHICS.Color[iconColor].Close.src;
			}
		} else if (divObj.style.display == tShowMode) {
			divObj.style.display = "none";
			if (tPicObj) {
				tPicObj.src = EXPANDO_GRAPHICS.Color[iconColor].Open.src;
			}
		}

		// ----- need to roll up existing parental expandos.
		expando_nestedFramesResize ( divObj );
	}
}


function multiExpandoText(e) {
	if (!e) var e = window.event;

	var anchor = expando_getAnchorObject(e);

	if (anchor == null) return;

	var tDivBase = anchor.divBase;
	var tDivIndex = anchor.divIndex;

	// ----- change the state of every DIV in the radio button array
	for (var i=1; i <= EXPANDO_MULTILINKS[tDivBase]; i++) {
		var tRadioButton = document.getElementById( "_"+tDivBase+"_" + i );

		var uniqueDivID = tDivBase + "(" + i + ")";
		var tDivObj = document.getElementById(uniqueDivID);

		if (i == tDivIndex) {
			// ----- currently clicked radio button, do actions here ----- \\
			tRadioButton.checked = true;

			if ( ( tDivObj.externalFile && !tDivObj.externalLoaded ) || anchor.unloadedFileList.length > 0 ) {
				// ----- need to load external files ----- \\
				expando_loadExternalFiles( tDivObj );
			}

			// ----- this is the selected DIV (or SPAN); make visible ----- \\
			var tShowMode = (tDivObj.nodeName == "SPAN") ? "inline" : "block";
			tDivObj.style.display = tShowMode;
		} else {
			// ----- clean up other, non-active radio buttons ----- \\
			tRadioButton.checked = false;
			tDivObj.style.display = "none";
		}

		// ----- need to resize parent frames, if any ----- \\
		expando_nestedFramesResize( tDivObj );
	}
}


function expandoMouseOver(e) {
	if (!e) var e = window.event;

	var anchor = expando_getAnchorObject(e);

	if (anchor == null) return;

	var iconColor = anchor.iconColor;

	// ----- Find the open/close image in the link, if there is one  ----- \\
	tPicObj = "";
	for ( j=0; j < anchor.childNodes.length; j++ ) {
		var imgObj = anchor.childNodes[j];
		if (imgObj.tagName == "IMG") {
			if ( unescape(imgObj.src) == unescape(EXPANDO_GRAPHICS.Color[iconColor].Open.src) ) {
				imgObj.src = EXPANDO_GRAPHICS.Color[iconColor].OpenOver.src;
				break;
			}
			if ( unescape(imgObj.src) == unescape(EXPANDO_GRAPHICS.Color[iconColor].Close.src) ) {
				imgObj.src = EXPANDO_GRAPHICS.Color[iconColor].CloseOver.src;
				break;
			}
		}
	}
}


function expandoMouseOut(e) {
	if (!e) var e = window.event;

	var anchor = expando_getAnchorObject(e);

	if (anchor == null) return;

	var iconColor = anchor.iconColor;

	// ----- Find the open/close image in the link, if there is one  ----- \\
	tPicObj = "";
	for (j=0; j < anchor.childNodes.length; j++ ) {
		var imgObj = anchor.childNodes[j];
		if (imgObj.tagName == "IMG") {
			if ( unescape(imgObj.src) == unescape(EXPANDO_GRAPHICS.Color[iconColor].OpenOver.src) ) {
				imgObj.src = EXPANDO_GRAPHICS.Color[iconColor].Open.src;
				break;
			}
			if ( unescape(imgObj.src) == unescape(EXPANDO_GRAPHICS.Color[iconColor].CloseOver.src) ) {
				imgObj.src = EXPANDO_GRAPHICS.Color[iconColor].Close.src;
				break;
			}
		}
	}
}


function expando_getAnchorObject ( e ) {
	var anchor = null;

	if (e.target) {			// Mozilla
		anchor = e.target;
	}
	if (e.srcElement ) {		// IE
		anchor = e.srcElement;
	}
	if (anchor.nodeType == 3) {	// defeat Safari bug
		anchor = anchor.parentNode;
	}

	// ----- the srcElement could be a subtag of <A> (e.g. an image); ----- \\
	// ----- crawl up the DOM until you reach the actual <A> tag.     ----- \\
	while ( (anchor != null) && (anchor.tagName != "A") ) {
		anchor = anchor.parentNode;
	}
	if (anchor.tagName != "A") { anchor = null; }

	return anchor;
}


// ------------------------------------------------------------------- \\
// -----      CREATE AND MANAGE "EXTERNAL" FILES AS EXPANDOS     ----- \\


function expando_createExternalFrame( divObj, tFile ) {
	// ----- There's an external file referenced by the DIV.   ----- \\
	// ----- Create and size an IFRAME for the included file.  ----- \\
	tFile = tFile.replace(/\\/g, "/");

	// ----- fail to create the expando link if it's a         ----- \\
	// ----- cyclical file reference.                          ----- \\
	if ( !expando_checkCyclical( tFile ) ) {
		return false;
	}

	// ---- store info we need later in global "frames" object  ---- \\
	var tFrmObj = new createExpandoFrameObject( divObj, tFile );
	apex.GLOBALFRAMES.Expando[tFrmObj.FrameName] = tFrmObj;


	// ----- erase current contents of DIV ----- \\
	while ( divObj.lastChild ) {
		divObj.removeChild(divObj.lastChild);
	}

	// ----- insert the "Loading..." warning ----- \\
	var tt = document.createTextNode( TEXT["expando_loading"] );
	divObj.appendChild(tt);


	// ----- Note: a link to the <iframe> node is not the same ----- \\
	// ----- as a link to the frame window; which is to say    ----- \\
	// ----- divObj.all(0) != document.frames(tIFName).        ----- \\
	// ----- Which is why the iframe needs both name and ID.   ----- \\

	// ----- create IFRAME object ----- \\
	var iframeObj = document.createElement("IFRAME");
	iframeObj.name = tFrmObj.FrameName;
	iframeObj.id = tFrmObj.FrameName;

	iframeObj.scrolling = "auto";
	iframeObj.style.position = "absolute";
	iframeObj.style.width = 64;
	iframeObj.style.height = 64;
	iframeObj.style.top = -10000;
	iframeObj.style.left = -10000;
	iframeObj.style.display = "block";
	iframeObj.style.border = "0px";		// Mozilla
	iframeObj.frameBorder = 0;		// IE

	divObj.appendChild(iframeObj);

	// ----- add some custom attributes to the DIV ----- \\
	divObj.externalFile = tFile;
	divObj.externalLoaded = false;
	divObj.externalFrame = iframeObj;

	apex.GLOBALFRAMES.Expando[tFrmObj.FrameName].IFrameObj = iframeObj;

	return true;
}


function expando_loadExternalFiles ( divObj ) {

	if ( !divObj.externalLoaded ) {
		var tIFrameName = divObj.externalFrame.name;

		if (!window.frames[tIFrameName].name) { window.frames[tIFrameName].name = tIFrameName; }
		
		apex.GLOBALFRAMES.Expando[tIFrameName].Loading = true;
		apex.GLOBALFRAMES.Expando[tIFrameName].Loaded = false;
		window.frames[tIFrameName].location.replace( divObj.externalFile );
		divObj.externalLoaded = true;

		trackExpandoUsage( "XPANDO", divObj.externalFile );

		// ----- set up a timer watch to see if it's loaded. Useful for non-Help   ----- \\
		// ----- target files; proper topics will report themselves as done and    ----- \\
		// ----- terminate the watch. NB: Alien external files can only be leafs.  ----- \\
		divObj.externalWatchID = window.setTimeout("expando_watchLoadState('" + tIFrameName + "')", 2000);
	}

	// ----- if any of the external subfiles aren't loaded yet, do it ----- \\
	subList = divObj.linkObj.unloadedFileList;

	if (subList) {
		for ( var i=0; i < subList.length; i++ ) {
			if ( !subList[i].externalLoaded ) {
				var tIFrameName = subList[i].externalFrame.name;

				apex.GLOBALFRAMES.Expando[tIFrameName].Loading = true;
				apex.GLOBALFRAMES.Expando[tIFrameName].Loaded = false;
				window.frames[tIFrameName].location.replace( subList[i].externalFile );

				trackExpandoUsage( "XPANDO", subList[i].externalFile );

				// ----- set up a timer watch to see if it's loaded. Useful for non-Help   ----- \\
				// ----- target files; proper topics will report themselves as done and    ----- \\
				// ----- terminate the watch. NB: Alien external files can only be leafs.  ----- \\
				subList[i].externalWatchID = window.setTimeout("expando_watchLoadState('" + tIFrameName + "')", 2000);
			}
		}
		divObj.linkObj.unloadedFileList = new Array();
	}
}


// ------------------------------------------------------------------- \\
// -----       RESIZING NESTED IFRAMES (EXTERNAL EXPANDOS)       ----- \\


function expando_watchLoadState ( frameName ) {
	var framething = apex.GLOBALFRAMES.Expando[frameName];
	var divObj = framething.DivObj;
	// ----- frameName = actual frame name plus GLOBALFRAMES idx key. ----- \\
	var iframeWin = window.frames[frameName];

	var failure = false;
	try {
		if ( iframeWin && iframeWin.document & iframeWin.document.body ) {
			failure = false;
			// ----- non-regulation file has loaded; finish it now.   ----- \\
			expando_childLoaded( frameName );
		} else {
			failure = true;
		}
	}
	catch(e) {
		// ----- If error is "Access is denied"... ----- \\

		if ( e.number == -2147024891 ) {		// IE only
			// ----- just resize it ----- \\
			expando_doFrameResize( frameName );
		}
		failure = true;
	}

	if (failure) {
		// ----- not loaded yet; wait a little bit and try again  ----- \\
		divObj.externalWatchID = window.setTimeout("expando_watchLoadState('" + frameName + "')", 3000);
	}
}

function onResize(e)
{
  updateScrollbar();
  expando_onresizeBrowser(e);
}

function updateScrollbar()
{
  // update the height of the scrollbar, so it will display correctly in the content portion
  var contentObj = document.getElementById("help_content");
  var headerObj = document.getElementById("help_header");

  if (!IS_EXPANDO_FRAME)
  {
    if (headerObj != null && contentObj != null)
    {
        var height = document.body.clientHeight - headerObj.offsetHeight;
        
        //QBW051705: Horizontal scroll bar in the middle of Blank_Help_topic.html
        // 9/25/07 cluk - check if h1 tag is display=none or not, if so, do not change
        // the height of the document.body   
        var child = headerObj.getElementsByTagName("h1");
        if (child)
        {
          for (i=0; i<child.length; i++)
          {
              if (child[i].style.display == "none")
              {
                height = document.body.clientHeight;
              }
          }
        }
        
        if (height > 0) // script error when minimize QuickBooks due to negative value is setting to style.height
        {
          contentObj.style.height = height + "px";
          
          //QBW051847: Horizontal scroll bar appears and disappears while max/min QuickBooks window 
          // 9/25/07 cluk - make sure the width of the content section is set to the width of the document.body   
          contentObj.style.width = document.body.clientWidth + "px";
        }
        parentContentDivObj = contentObj;
    }
    else
    {
      document.body.style.overflow = "auto";
    }
  }
  else
  { // expando should not be scrollable
    if (contentObj != null)
    {
      contentObj.style.overflow = "hidden";
    }
    else
    {
      document.body.style.overflow = "hidden";
    }
  }
}

function expando_onresizeBrowser(e) {
	// ----- wait briefly, to eliminate multiple calls from piling on ----- \\
	apex.clearTimeout(apex.GLOBALFRAMES.WaitingToResize);
	apex.GLOBALFRAMES.WaitingToResize = apex.setTimeout("expando_onresizeBrowserAction()", 100);
}

function expando_onresizeBrowserAction() {
	// ----- check global counters for external frames that are still ----- \\
	// ----- loading -- no resizing while external files are not yet  ----- \\
	// ----- loaded; otherwise you get onresize looping and a crash.  ----- \\
	if ( !expando_isAllLoaded() ) {
		expando_onresizeBrowser();
	}

	// ----- no frames are still loading; go ahead and resize all    ------ \\
	for (var i=0; i < window.frames.length; i++) {
		var fobj = window.frames[i];
		try {
  		if ( fobj.location && fobj.location.href != "about:blank" ) {
  			expando_doFrameResize( fobj );
  			if ( fobj.expando_onresizeBrowser ) {
  				// ----- not called automatically by resize event;
  				// ----- only attached to top window. Stops event looping.
  				fobj.expando_onresizeBrowserAction();
  			}
  			// ----- first crawl down, resizing; then crawl back up
  			expando_doFrameResize( fobj );
    		
  		}
  	}
  	catch (e) {
      if (e.number == -2146828218) {} // permission denied
    }
	}
}


function expando_onresizeFrame(e) {
}


function expando_resizeExternalChildFrame ( frameName ) {
	// ----- frameName = actual frame name, also GLOBALFRAMES idx key. ----- \\

	var iframeWin = window.frames[frameName];

	expando_doFrameResize( iframeWin );

	// ----- need to resize parent frames, if any ----- \\
	var parentDivObj = apex.GLOBALFRAMES.Expando[frameName].DivObj;
	expando_nestedFramesResize( parentDivObj );
}


function expando_nestedFramesResize ( divObj ) {

	// ----- if this is inside an included frame,     ----- \\
	// ----- keep expanding the parent frames to fit. ----- \\
	var tMe = self;
	while ( tMe.name.indexOf("_expando_") >= 0 ) {
		expando_doFrameResize( tMe );
		tMe = tMe.parent;
	}

	if ( !divObj.startOpen ) {
		// ----- this doesn't apply to auto-open links.   ----- \\
		// ----- if we're expanding, and the bottom will  ----- \\
		// ----- go past the bottom of the window, then   ----- \\
		// ----- scroll it up so it's visible.            ----- \\
		if (divObj.style.display == "block") {
		  if (parentContentDivObj != null) {
  			if (divObj.offsetHeight < parentContentDivObj.clientHeight) {
				// ----- if the expando section is bigger than the window, don't bother ----- \\
				var tZoneBottom = divObj.offsetTop + divObj.offsetHeight;
  				var tZoneY = tZoneBottom - parentContentDivObj.scrollTop;
  				if (tZoneY > parentContentDivObj.clientHeight) {
  				  parentContentDivObj.scrollTop = parentContentDivObj.scrollTop + (tZoneY - parentContentDivObj.clientHeight);
          }
				}
			}
		}
	}
}


function expando_doFrameResize ( frameWindow ) {

	// ----- frameName = actual frame name, also GLOBALFRAMES idx key. ----- \\
	var frameName = frameWindow.name;

	var iframeObj = apex.GLOBALFRAMES.Expando[frameName].IFrameObj;

	var parentDivObj = apex.GLOBALFRAMES.Expando[frameName].DivObj;

	// ----- turn off IE scrollbars to match FireFox           ----- \\
	frameWindow.document.body.scroll = 'no';

	// ----- find width of parent DIV - it needs to be visible ----- \\
	// ----- in order to report the width correctly            ----- \\
	parentDivObj.style.height = parentDivObj.scrollHeight + "px";
	iframeObj.style.display = "none";					// take out FRAME for DIV sizing
	var parentDisplay = parentDivObj.style.display;
	if (!parentDisplay) { parentDisplay = "block"; }
	parentDivObj.style.display = "block";
	//var maxWidth = parentDivObj.scrollWidth;
	var maxWidth = parentDivObj.offsetWidth;
	parentDivObj.style.display = parentDisplay;
	iframeObj.style.display = "block";
	parentDivObj.style.height = "";

	maxWidth -= 2;								// account for the DIV border

	var curWidth = frameWindow.document.body.scrollWidth;

	// ----- set width
	iframeObj.style.width = maxWidth;					// all browsers

	if ( curWidth == frameWindow.document.body.scrollWidth ) {
		// ----- In Mozilla/Firefox, in IFRAMES within IFRAMES, width won't change.
		// ----- (IFRAME is lost in space somewhere; can't resize, like it's invisible)
		// ----- need to bring it back here. Means visible flash, unfortunately.
		iframeObj.style.position = "static";
	}

	// ----- set height
	iframeObj.style.height = frameWindow.document.body.scrollHeight;

	// ----- this is the final size; now bring DIV back inline ----- \\
	iframeObj.style.position = "static";

	var xx = apex.document.getElementById("x"+frameName);
	if (xx) {
		xx.appendChild( apex.document.createTextNode( "["+iframeObj.style.width+","+iframeObj.style.height+"]" ) );
		xx.appendChild( apex.document.createElement( "BR" ) );
	}

/*
	if (parentDivObj.scrollWidth && frameWindow.innerWidth && frameWindow.innerWidth > parentDivObj.scrollWidth ) {
		// ----- Mozilla/FireFox has changed the width (added scrollbar); needs fixing
		// ----- call onresizeBrowser to get the timeout and "still loading" checks
// crashes FF.
//		expando_onresizeBrowser();
	}*/
}


// ------------------------------------------------------------------- \\

function expando_attachToDisplayParent( divObj, originalDivObj ) {
	// ----- search up the document tree to see if a "forced open" section ----- \\
	// ----- has an expando parent that it can be "attached" to, in order  ----- \\
	// ----- to delay loading until user clicks on a link.                 ----- \\
	// ----- Also, don't load if it's conditionally hidden.                ----- \\
	// ----- (This only applies to external expandos under regular ones)   ----- \\

	var foundparent = false;

	if ( !originalDivObj ) {
		// ----- first call to function; divObj = originalDivObj ----- \\
		foundparent = expando_attachToDisplayParent( divObj.parentNode, divObj );
	} else {
		if ( divObj.nodeName != "BODY" ) {
			// ----- is conditional text available? ----- \\
			if (window.validateSKUs) {
				// ----- check for a false conditional, and set "foundparent" to true          ----- \\
				// ----- this link isn't added to any file list, and so it can never display   ----- \\
				var tSKUs = divObj.getAttribute("skus");
				if (tSKUs) {
					foundparent = !validateSKUs(tSKUs);
				}
			}

			// ----- check for an unopened expando, then attach this div to its list ----- \\
			if (  ( divObj.className.toLowerCase() == "expando" ||
				divObj.className.toLowerCase().substring(0,8) == "expando_")
			   ) {
				if ( !divObj.startOpen ) {
					var tFiles = divObj.linkObj.unloadedFileList;
					tFiles[tFiles.length] = originalDivObj;
					foundparent = true;
				}
			}
		}
	}

	return foundparent;
}


function expando_checkCyclical ( filepath ) {
	// ----- Make sure it's not a cyclical reference.          ----- \\
	// ----- walk up the "_expando_" tree and check all src.   ----- \\

	var cyclical = false;
	var tWin = null;
	var tMaster = filepath;

	// ----- want to check every "_expando_" frame, plus one more - the ultimate parent.
	do {
		if (tWin) {
			tWin = tWin.parent;
		} else {
			tWin = self;
		}
		tCurrent = unescape(tWin.location.href);

		cyclical = cyclical || (tMaster.toLowerCase() == tCurrent.toLowerCase());
	}
	while ( tWin.name.indexOf("_expando_") >= 0 );

	return (!cyclical);
}


function trackExpandoUsage ( pCode, pURL ) {
	var submitted = false;
	if ( apex.Persistent ) {
		if ( apex.Persistent.saveDataLine ) {
			apex.Persistent.saveDataLine ( pCode, pURL, "" );
			submitted = true;
		}
	}
	return submitted;
}


// ------------------------------------------------------------------- \\
// -----                     COMMON ROUTINES                     ----- \\

function nothing() {
}


function expando_getFrameName ( n ) {
	return "_expando_" + n;
}

// ============================================================ \\
// =====       END OF CONDITIONAL/EXPANDO CODE            ===== \\
// ============================================================ \\

// ================================================== \\
// ===== SKU to IPH Conditional Tag Mapping        == \\
// ================================================== \\
//
// Author: C.Clabourne
// Date: 9/17/2007
//
// NOTE: These arrays must be defined at the top of this file...for some reason... DO NOT MOVE!
//
// Array name is the SKU and the value is the IPH conditional tag value.
//
  //Credit Card Processing Kit (CCPK)

  var aMasNeutron    = new Array();  
      aMasNeutron[0] = ',CCPK,';
      aMasNeutron[1] = ',IM_CCPK,';


  //Enterprise (generic)
  var aBel = new Array();  
      aBel[0]  = ',Enterprise_verts,';
      aBel[1]  = ',Premier_Enterprise_verts,';
      aBel[2]  = ',Premier_Enterprise_verts_not_Accountant,';
      aBel[3]  = ',Premier_Enterprise_verts_not_Contractor,';
      aBel[4]  = ',Premier_Enterprise_verts_not_Nonprofit,';
      aBel[5]  = ',Premier_Enterprise_verts_not_ProfServices,';
      aBel[6]  = ',Premier_Enterprise_verts_not_Retail,';
      aBel[7]  = ',Premier_Enterprise_verts_not_Wholesale,';
      aBel[8]  = ',Pro_Premier_Enterprise_verts,';
      aBel[9]  = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aBel[10] = ',Enterprise_not_verts,';
  
  //Enterprise Accountant
  var aBelAcct = new Array();  
      aBelAcct[0]   = ',Enterprise_verts,';
      aBelAcct[1]   = ',Premier_Enterprise_verts,';
      aBelAcct[2]   = ',Premier_Enterprise_verts_not_Contractor,';
      aBelAcct[3]   = ',Premier_Enterprise_verts_not_Nonprofit,';
      aBelAcct[4]   = ',Premier_Enterprise_verts_not_ProfServices,';
      aBelAcct[5]   = ',Premier_Enterprise_verts_not_Retail,';
      aBelAcct[6]   = ',Premier_Enterprise_verts_not_Wholesale,';
      aBelAcct[7]   = ',Pro_Premier_Enterprise_verts,';
      aBelAcct[8]   = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aBelAcct[9]   = ',Retail_Accountant,';
      aBelAcct[10]  = ',ProfServices_Accountant,';
      aBelAcct[11]  = ',Nonprofit_Accountant,';
      aBelAcct[12]  = ',Contractor_Accountant,';
      aBelAcct[13]  = ',Wholesale_Accountant,';
      aBelAcct[14]  = ',Accountant,';
  
    //Enterprise Contractor
    var aBelContractor = new Array();  
      aBelContractor[0]   = ',Enterprise_verts,';
      aBelContractor[1]   = ',Premier_Enterprise_verts,';
      aBelContractor[2]   = ',Premier_Enterprise_verts_not_Nonprofit,';
      aBelContractor[3]   = ',Premier_Enterprise_verts_not_ProfServices,';
      aBelContractor[4]   = ',Premier_Enterprise_verts_not_Retail,';
      aBelContractor[5]   = ',Premier_Enterprise_verts_not_Wholesale,';
      aBelContractor[6]   = ',Premier_Enterprise_verts_not_Accountant,';
      aBelContractor[7]   = ',Pro_Premier_Enterprise_verts,';
      aBelContractor[8]   = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aBelContractor[9]   = ',Contractor_Accountant,';

    //Enterprise Nonprofit
    var aBelNonProfit = new Array();  
      aBelNonProfit[0]   = ',Enterprise_verts,';
      aBelNonProfit[1]   = ',Premier_Enterprise_verts,';
      aBelNonProfit[2]   = ',Premier_Enterprise_verts_not_Accountant,';
      aBelNonProfit[3]   = ',Premier_Enterprise_verts_not_Contractor,';
      aBelNonProfit[4]   = ',Premier_Enterprise_verts_not_ProfServices,';
      aBelNonProfit[5]   = ',Premier_Enterprise_verts_not_Retail,';
      aBelNonProfit[6]   = ',Premier_Enterprise_verts_not_Wholesale,';
      aBelNonProfit[7]   = ',Pro_Premier_Enterprise_verts,';
      aBelNonProfit[8]   = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aBelNonProfit[9]   = ',Nonprofit_Accountant,';

    //Enterprise Professional Services
    var aBelProfessional = new Array();  
      aBelProfessional[0]   = ',Enterprise_verts,';
      aBelProfessional[1]   = ',Premier_Enterprise_verts,';
      aBelProfessional[2]   = ',Premier_Enterprise_verts_not_Accountant,';
      aBelProfessional[3]   = ',Premier_Enterprise_verts_not_Contractor,';
      aBelProfessional[4]   = ',Premier_Enterprise_verts_not_Nonprofit,';
      aBelProfessional[5]   = ',Premier_Enterprise_verts_not_Retail,';
      aBelProfessional[6]   = ',Premier_Enterprise_verts_not_Wholesale,';
      aBelProfessional[7]   = ',Pro_Premier_Enterprise_verts,';
      aBelProfessional[8]   = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aBelProfessional[9]   = ',ProfServices_Accountant,';
  
    //Enterprise Retail
    var aBelRetail = new Array();  
      aBelRetail[0]   = ',Enterprise_verts,';
      aBelRetail[1]   = ',Premier_Enterprise_verts,';
      aBelRetail[2]   = ',Premier_Enterprise_verts_not_Accountant,';
      aBelRetail[3]   = ',Premier_Enterprise_verts_not_Contractor,';
      aBelRetail[4]   = ',Premier_Enterprise_verts_not_Nonprofit,';
      aBelRetail[5]   = ',Premier_Enterprise_verts_not_ProfServices,';
      aBelRetail[6]   = ',Premier_Enterprise_verts_not_Wholesale,';
      aBelRetail[7]   = ',Pro_Premier_Enterprise_verts,';
      aBelRetail[8]   = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aBelRetail[9]   = ',Retail_Accountant,';

    //Enterprise Wholesale
    var aBelWholesale = new Array();  
      aBelWholesale[0]   = ',Enterprise_verts,';
      aBelWholesale[1]   = ',Premier_Enterprise_verts,';
      aBelWholesale[2]   = ',Premier_Enterprise_verts_not_Accountant,';
      aBelWholesale[3]   = ',Premier_Enterprise_verts_not_Contractor,';
      aBelWholesale[4]   = ',Premier_Enterprise_verts_not_Nonprofit,';
      aBelWholesale[5]   = ',Premier_Enterprise_verts_not_ProfServices,';
      aBelWholesale[6]   = ',Premier_Enterprise_verts_not_Retail,';
      aBelWholesale[7]   = ',Pro_Premier_Enterprise_verts,';
      aBelWholesale[8]   = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aBelWholesale[9]   = ',Wholesale_Accountant,';
  
    //Invoice Manager
    var aNeutron = new Array();  
      aNeutron[0]   = ',IM,';
      aNeutron[1]   = ',IM_CCPK,';

    //Premier (generic)
    var aSuperPro = new Array();  
      aSuperPro[0]    = ',Premier_Enterprise_verts,';
      aSuperPro[1]    = ',Premier_Enterprise_verts_not_Accountant,';
      aSuperPro[2]    = ',Premier_Enterprise_verts_not_Contractor,';
      aSuperPro[3]    = ',Premier_Enterprise_verts_not_Nonprofit,';
      aSuperPro[4]    = ',Premier_Enterprise_verts_not_ProfServices,';
      aSuperPro[5]    = ',Premier_Enterprise_verts_not_Retail,';
      aSuperPro[6]    = ',Premier_Enterprise_verts_not_Wholesale,';
      aSuperPro[7]    = ',Premier_verts,';
      aSuperPro[8]    = ',Pro_Premier_Enterprise_verts,';
      aSuperPro[9]    = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aSuperPro[10]   = ',Pro_Premier_verts,';
      aSuperPro[11]   = ',Premier_not_verts,';
      

    //Premier Accountant
    var aAccountant = new Array();  
      aAccountant[0]     = ',Premier_Enterprise_verts,';
      aAccountant[1]     = ',Premier_Enterprise_verts_not_Contractor,';
      aAccountant[2]     = ',Premier_Enterprise_verts_not_Nonprofit,';
      aAccountant[3]     = ',Premier_Enterprise_verts_not_ProfServices,';
      aAccountant[4]     = ',Premier_Enterprise_verts_not_Retail,';
      aAccountant[5]     = ',Premier_Enterprise_verts_not_Wholesale,';
      aAccountant[6]     = ',Premier_verts,';
      aAccountant[7]     = ',Pro_Premier_Enterprise_verts,';
      aAccountant[8]     = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aAccountant[9]     = ',Pro_Premier_verts,';
      aAccountant[10]    = ',Wholesale_Accountant,';
      aAccountant[11]    = ',Retail_Accountant,';
      aAccountant[12]    = ',ProfServices_Accountant,';
      aAccountant[13]    = ',Nonprofit_Accountant,';
      aAccountant[14]    = ',Contractor_Accountant,';
      aAccountant[15]    = ',Accountant,';
      

    //Premier Contractor
    var aContractor = new Array();  
      aContractor[0]     = ',Premier_Enterprise_verts,';
      aContractor[1]     = ',Premier_Enterprise_verts_not_Accountant,';
      aContractor[2]     = ',Premier_Enterprise_verts_not_Nonprofit,';
      aContractor[3]     = ',Premier_Enterprise_verts_not_ProfServices,';
      aContractor[4]     = ',Premier_Enterprise_verts_not_Retail,';
      aContractor[5]     = ',Premier_Enterprise_verts_not_Wholesale,';
      aContractor[6]     = ',Premier_verts,';
      aContractor[7]     = ',Pro_Premier_Enterprise_verts,';
      aContractor[8]     = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aContractor[9]     = ',Pro_Premier_verts,';
      aContractor[10]    = ',Contractor_Accountant,';

    //Premier Nonprofit
    var aNonProfit = new Array();  
      aNonProfit[0]     = ',Premier_Enterprise_verts,';
      aNonProfit[1]     = ',Premier_Enterprise_verts_not_Accountant,';
      aNonProfit[2]     = ',Premier_Enterprise_verts_not_Contractor,';
      aNonProfit[3]     = ',Premier_Enterprise_verts_not_ProfServices,';
      aNonProfit[4]     = ',Premier_Enterprise_verts_not_Retail,';
      aNonProfit[5]     = ',Premier_Enterprise_verts_not_Wholesale,';
      aNonProfit[6]     = ',Premier_verts,';
      aNonProfit[7]     = ',Pro_Premier_Enterprise_verts,';
      aNonProfit[8]     = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aNonProfit[9]     = ',Pro_Premier_verts,';
      aNonProfit[10]    = ',Nonprofit_Accountant,';

    //Premier Professional Services
    var aProfessional = new Array();  
      aProfessional[0]     = ',Premier_Enterprise_verts,';
      aProfessional[1]     = ',Premier_Enterprise_verts_not_Accountant,';
      aProfessional[2]     = ',Premier_Enterprise_verts_not_Nonprofit,';
      aProfessional[3]     = ',Premier_Enterprise_verts_not_Contractor,';
      aProfessional[4]     = ',Premier_Enterprise_verts_not_Retail,';
      aProfessional[5]     = ',Premier_Enterprise_verts_not_Wholesale,';
      aProfessional[6]     = ',Premier_verts,';
      aProfessional[7]     = ',Pro_Premier_Enterprise_verts,';
      aProfessional[8]     = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aProfessional[9]     = ',Pro_Premier_verts,';
      aProfessional[10]    = ',ProfServices_Accountant,';

    //Premier Retail
    var aRetail = new Array();  
      aRetail[0]     = ',Premier_Enterprise_verts,';
      aRetail[1]     = ',Premier_Enterprise_verts_not_Accountant,';
      aRetail[2]     = ',Premier_Enterprise_verts_not_Nonprofit,';
      aRetail[3]     = ',Premier_Enterprise_verts_not_ProfServices,';
      aRetail[4]     = ',Premier_Enterprise_verts_not_Contractor,';
      aRetail[5]     = ',Premier_Enterprise_verts_not_Wholesale,';
      aRetail[6]     = ',Premier_verts,';
      aRetail[7]     = ',Pro_Premier_Enterprise_verts,';
      aRetail[8]     = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aRetail[9]     = ',Pro_Premier_verts,';
      aRetail[10]    = ',Retail_Accountant,';

    //Premier Wholesale
    var aWholesale = new Array();  
      aWholesale[0]     = ',Premier_Enterprise_verts,';
      aWholesale[1]     = ',Premier_Enterprise_verts_not_Accountant,';
      aWholesale[2]     = ',Premier_Enterprise_verts_not_Nonprofit,';
      aWholesale[3]     = ',Premier_Enterprise_verts_not_ProfServices,';
      aWholesale[4]     = ',Premier_Enterprise_verts_not_Retail,';
      aWholesale[5]     = ',Premier_Enterprise_verts_not_Retail,';
      aWholesale[6]     = ',Premier_verts,';
      aWholesale[7]     = ',Pro_Premier_Enterprise_verts,';
      aWholesale[8]     = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aWholesale[9]     = ',Pro_Premier_verts,';
      aWholesale[10]    = ',Wholesale_Accountant,';


    //Pro
    var aPro = new Array();  
      aPro[0]     = ',Pro_Premier_Enterprise_verts,';
      aPro[1]     = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aPro[2]     = ',Pro_Premier_verts,';
      aPro[3]     = ',Pro,';


    //SimpleStart
    var aAtom = new Array();  
      aAtom[0]     = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aAtom[1]     = ',SimpleStart,';

    //SimpleStart OEM
    var aAtomLimited = new Array();  
      aAtomLimited[0]     = ',Pro_Premier_Enterprise_verts_SimpleStart,';
      aAtomLimited[1]     = ',SimpleStart,';

// ===============End of SKU Map================= \\

// This function validates the IPH SKU conditional tag against the "active" SKU (i.e., the 'current' product).
// If the passed in IPH sku tag is located in one of the lookup arrays; 'true' is returned indicating that the html tag should be displayed, otherwise, hide the html tag.
// Author: C.Clabourne
// Date: 9/17/2007
//
// Note: This is an existing function.  I just built out the core function.
//
function checkCondition(iph_sku_tag) {


  var fRetVa = false;
  var iphSKU = "," + iph_sku_tag + ",";
  

  // get external SKU from environment OR from Knova if available.
  var external_sku = getURLParam("sku").toLowerCase();
  
  // see if we are being called within Knova
  if(external_sku == '') {
  	external_sku = getURLParam("product").toLowerCase();
  }
  
  //external_sku = 'pro';  //TEST 
  //alert('external_sku ->' +external_sku); //TEST
  //alert('iphSKU ->' +iphSKU); //TEST
  
  
  //Credit Card Processing Kit (CCPK)
  if(external_sku == 'masneutron' || external_sku == 'sg_quickbookscreditcardprocessingkit4_0_1_3') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(a=0; a < aMasNeutron.length; a++) {        
     	if(aMasNeutron[a].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }
    
  //Enterprise (generic)
  if(external_sku == 'bel' || external_sku == 'sg_quickbooksenterprisesolutions8_0_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(b=0; b < aBel.length; b++) {        
     	if(aBel[b].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }
  
  //Enterprise Accountant
  if(external_sku == 'belacct' || external_sku == 'sg_quickbooksenterprisesolutions_accounantedition8_0_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(c=0; c < aBelAcct.length; c++) {        
     	if(aBelAcct[c].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }
  
  //Enterprise Contractor
  if(external_sku == 'belcontract' || external_sku == 'sg_quickbooksenterprisesolutions_contractoredition8_0_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(d=0; d < aBelContractor.length; d++) {        
     	if(aBelContractor[d].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }  
  
  //Enterprise Nonprofit
  if(external_sku == 'belnonprofit' || external_sku == 'sg_quickbooksenterprisesolutions_nonprofitedition8_0_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(e=0; e < aBelNonProfit.length; e++) {        
     	if(aBelNonProfit[e].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }  
  
  //Enterprise Professional Services
  if(external_sku == 'belprofessional' || external_sku == 'sg_quickbooksenterprisesolutions_professionalservicesedition8_0_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(f=0; f < aBelProfessional.length; f++) {        
     	if(aBelProfessional[f].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }  
  
  //Enterprise Retail
  if(external_sku == 'belretail' || external_sku == 'sg_quickbooksenterprisesolutions_retailedition8_0_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(g=0; g < aBelRetail.length; g++) {        
     	if(aBelRetail[g].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  } 
  
  //Enterprise Wholesale
  if(external_sku == 'belwholesale' || external_sku == 'sg_quickbooksenterprisesolutions_manufacturingandwholesaleedition8_0_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(h=0; h < aBelWholesale.length; h++) {        
     	if(aBelWholesale[h].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  } 
  
  //Invoice Manager
  if(external_sku == 'neutron' || external_sku == 'sg_quickbooksinvoicemanager2008_1_3') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(i=0; i < aNeutron.length; i++) {        
     	if(aNeutron[i].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  } 
  
  //Premier (generic)
  if(external_sku == 'superpro' || external_sku == 'sg_quickbookspremier2008_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(j=0; j < aSuperPro.length; j++) {        
     	if(aSuperPro[j].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  } 
  
  //Premier Accountant
  if(external_sku == 'accountant' || external_sku == 'sg_quickbookspremieraccountantedition2008_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(k=0; k < aAccountant.length; k++) {        
     	if(aAccountant[k].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }  
  
  //Premier Contractor
  if(external_sku == 'contract' || external_sku == 'sg_quickbookspremiercontractoredition2008_1_4') {   //Yes, this is 'contract' not 'contractor'!
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(l=0; l < aContractor.length; l++) {        
     	if(aContractor[l].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }  
  
  //Premier Nonprofit
  if(external_sku == 'nonprofit' || external_sku == 'sg_quickbookspremiernonprofitedition2008_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(m=0; m < aNonProfit.length; m++) {        
     	if(aNonProfit[m].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }    

  //Premier Professional Services
  if(external_sku == 'professional' || external_sku == 'sg_quickbookspremierprofessionalservicesedition2008_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(n=0; n < aProfessional.length; n++) {        
     	if(aProfessional[n].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }

  //Premier Retail
  if(external_sku == 'retail' || external_sku == 'sg_quickbookspremierretailedition2008_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(o=0; o < aRetail.length; o++) {        
     	if(aRetail[o].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }

  //Premier Wholesale
  if(external_sku == 'wholesale' || external_sku == 'sg_quickbookspremiermanufacturingandwholesaleedition2008_1_4') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(p=0; p < aWholesale.length; p++) {        
     	if(aWholesale[p].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }


  //Pro
  if(external_sku == 'pro' || external_sku == 'sg_quickbookspro2008_1_4') {

     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(q=0; q < aPro.length; q++) {
     	if(aPro[q].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }


  //SimpleStart
  if(external_sku == 'atom' || external_sku == 'sg_quickbookssimplestartedition2008_1_3') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(r=0; r < aAtom.length; r++) {        
     	if(aAtom[r].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }
  
  //SimpleStart OEM
  if(external_sku == 'atomlimited' || external_sku == 'sg_quickbookssimplestartedition2008_1_3') {
     
     // do lookup to see if this 'iph_sku_tag' should be displayed in the html for this 'product'.
     for(s=0; s < aAtomLimited.length; s++) {        
     	if(aAtomLimited[s].indexOf(iphSKU) > -1) {
     	   fRetVa = true;
     	   break;
     	}
     }
  }  
  
  return fRetVa;
}

// ============================================================ \\
// =====             "RATE THIS TOPIC" CODE               ===== \\
// ============================================================ \\
/*--------------------------------------------------------
 * function fnRunFB
 *
 * Description
	using the form field values not the QBCommand values
	refer the the feedback EDD for details.
 *
**-------------------------------------------------------*/
function fnRunFB(nScore) {

	/////////////////////////////////////////////////
	// Get Submit URL 
	/////////////////////////////////////////////////
	var feedbackURL = GetQBValue("HelpFeedbackURL");
	if (feedbackURL.length <= 0)
	{
    fnHideVoteButtons("Thanks for your feedback! However, submission fails.");
    return;
  }
	document.yesno_feedback_form.action = feedbackURL;

	////////////////////////////////////////////////////////////
	//
	// populate all the inputs for the form, then submit
	// start w/telling the server not to return with a 
	// UI (html), Yes votes display our own thank you
	// access point, feedback type
	//
	// refer to feedback EDD for values
	//
  // http://qube.intuit.com/library/docs/Reported%20Feedback%20Collection%20FastTrack%20EDD.doc 
	////////////////////////////////////////////////////////////
	
	var sUI = "<input type='hidden' name='ui' value='false'>";
	// for suggestion box feedback
	var sUIonly = sUI;
	sUI += "<input type='hidden' name='submit.x' value='1'>";
	var sAP = "<input type='hidden' name='access_point' value='help'>";
	var sFB = "<input type='hidden' name='feedback_type' value='help_suggestion'>";
	ui_div.innerHTML =  sUI;
	access_point_div.innerHTML = sAP;
	feedback_type_div.innerHTML = sFB;

	////////////////////////////////////////////////////////////
	// get the Package name, path and topic name
	////////////////////////////////////////////////////////////
  // QBW051751 8/29/2007 cluk - fix to parse the url into help file path 
  // and file name to send with the help feedback.
  var helpPath = "undefined";
  var helpFile = "undefined";
  var url = document.location.href.toLowerCase();
  url = trimspace(url);
  if (url.length > 0)  
  {
      url = url.replace(/\//g, "\\");
      var index = url.indexOf("intu-help-qb1:");
      if (index == 0)
      {
        // the url is started with "intu-help-qb1:"
        var zipPattern = ".zip::";
        var start_filepath = url.indexOf(zipPattern) + zipPattern.length; 
        var end_filepath = url.indexOf("?");  
        if (end_filepath < 0) // there is a case that the url does not contains "?"
        {
           end_filepath = url.length - 1;
        }
        var filepath = url.substring(start_filepath, end_filepath);
        var start_filename = filepath.lastIndexOf("\\");
        if (start_filename <= 0) // there is a case that there is no directory structure
        {
            helpFile = filepath;
            helpPath = "";
        }
        else
        { 
            helpFile = filepath.substring(start_filename+1, filepath.length);
            helpPath = filepath.substring(0, start_filename);
        }
      }
      else
      {
        helpPath = "undefined_parse_fail";
        helpFile = "undefined_parse_fail";
      }
  }
  
	var helpPathText		= "<input type='hidden' name='hlp_doc_chm' value='" + helpPath + "'>";
	var topicText	= "<input type='hidden' name='hlp_doc_name' value='" + helpFile + "'>";
	doc_path.innerHTML =  helpPathText;
	doc_name.innerHTML =  topicText;
  
	////////////////////////////////////////////////////////////
	// get the SKU/flavor/subproduct
	////////////////////////////////////////////////////////////
	
	var skuText		= "<input type='hidden' name='subproduct' value='" + GetQBValue("QBFlavor") + "'>";
	sku.innerHTML	= skuText;

	////////////////////////////////////////////////////////////
	// get ProductVersion and Release
	////////////////////////////////////////////////////////////
	
	var sProductText =	"<input type='hidden' name='product' value='quickbooks'>";
	var sVersionText =	"<input type='hidden' name='version' value='" + GetQBValue("QBProductVersion") + "'>";
	var sReleaseText =	"<input type='hidden' name='release' value='" + GetQBValue("QBRelease") + "'>";
	product_div.innerHTML =	sProductText;
	version_div.innerHTML = sVersionText;
	release_div.innerHTML = sReleaseText;

	////////////////////////////////////////////////////////////
	// add rating to form... always 1, since 'yes' was clicked, 
	// also add novote/yesvote label to name
	////////////////////////////////////////////////////////////
	var ratingText = "<input type='hidden' name='hlp_score' value='" + nScore + "'>";

	ratingText += "<input type='hidden' name='hlp_name' value='";
	if (nScore == 1) {
		ratingText +=  "yesvote'>";
	} else {
		ratingText +=  "novote'>";
	}
	rating.innerHTML = ratingText;

	////////////////////////////////////////////////////////////
	// get document date, get from document object.
	////////////////////////////////////////////////////////////
	
	var filedate = PACKAGE_DATE;	
	var docdateText = "<input type='hidden' name='hlp_doc_date' value='" + filedate + "'>";
	doc_date.innerHTML = docdateText;

	////////////////////////////////////////////////////////////
	// get last search
	////////////////////////////////////////////////////////////

	var lastsearchText =	
		"<input type='hidden' name='hlp_last_search' value='" + GetQBValue("LastSearchQueryString") + "'>";
	last_search.innerHTML = lastsearchText;
   
	////////////////////////////////////////////////////////////
	//
	// submit the form to hidden frame, remove the buttons, and 
	// replace with the "thank you" message
	//
	////////////////////////////////////////////////////////////
	
	document.yesno_feedback_form.submit(); 
	fnHideVoteButtons("Thanks for your feedback!");

	////////////////////////////////////////////////////////////
	//
	// If no vote then allow user to enter suggestion, along
	// with the novote we just entered
	//
	////////////////////////////////////////////////////////////

	// pass the feedback vars to the suggestion box form
	if (nScore == 0) {
		fnRunNoFB(sUIonly,sFB,helpPathText,topicText,skuText,sProductText,sVersionText,sReleaseText,docdateText,lastsearchText,feedbackURL);
	}
} // end of fnRunFB()

function fnHideVoteButtons(text) {
	var t = "";
	t+= "<table class='feedback'><tr><td width='15'><img src='" + ICON_HELP_FEEDBACK + "' border='0' align='left' alt='Help Feedback'>"
	t+= "<td><b>" + text + "</b></td></tr></table>";
	yes_no_feedback.innerHTML = t;
}

function DisplayHelpSupport()
{
  var helpSupportQBCommand = "";
  var supportUrl = "www.quickbooks.com/support";
  var lastSearchString = GetQBValue("LastSearchQueryString");
  // do not need to pass last search to neutron coz it only goes to cache page, not support page 
  if (lastSearchString == null || trimspace(lastSearchString).length <=0 || checkCondition("IM") == true)
  {
    helpSupportQBCommand = "qbw:informationandsupport"; // using QBMetaCommand
  }
  else
  {
    // encode some invalid character which will fail at QBCommand - i.e. &, > and %
    lastSearchString = EncodeToHex(lastSearchString);
    helpSupportQBCommand = "qbw:supportsiteorcachedpage?url=" + supportUrl + "&lastSearchQuery=" + lastSearchString + "&collectData=true";
  }
  
  // call the QBCommand to go to Help Support
  qbcommand(helpSupportQBCommand);
}

function makeFeedbackAndHelpSupportLink( divObj, resourceslink ) {
	var t = "<br><br>";
	
	// depending on flag, show resources link, link to help and support center.
	// this allows certain topics to omit displaying the link (Easy Step Interview) 
	// mkronber 9-23-2005
	if ( resourceslink == 1 ){
	   t += "<table class='feedback'>";
	   t += "<tr><td width='30' align='right'><a href='javascript:DisplayHelpSupport();'><img src='" + ICON_HELP_SUPPORT + "' border='0' align='right' alt='Help Support'></a>";
	   t += "<td><a href='javascript:DisplayHelpSupport();'>" + TEXT["helpsupport_linktext"] + "</a><br></table>";
	}
	
	var s = "";
	s += "<table class='feedback'>";
	s += "<tr><td width='30'><img src='" + ICON_HELP_FEEDBACK + "' border='0' align='right' alt='Help Feedback'>";
	s += "<td align='left' border='0'><b>Did this Help topic give you the information you needed?</b>";
	s += "</td></tr></table>";
	s += "<table class='feedback'><tr><td width='30'><td>";
	s += "<a href='javascript:click_yes();'><img src='" + ICON_FEEDBACK_YES + "' border='0' alt='Yes'></a>&nbsp;&nbsp;";
	s += "<a href='javascript:click_no();'><img src='" + ICON_FEEDBACK_NO + "' border='0' alt='No'></a>";
	s += "<tr><td width='30'>";
	s += "<td align='left' valign='top' border='0'><font size='1'>Requires an Internet connection.</font>";	
	s += "</td></tr></table><br><br>";

	t += "<IFRAME STYLE='border-width:0px; margin:0px; padding:0px; visibility:hidden; width:1px; height:1px;' name='submitTarget' ></IFRAME>";
  t +="<div id=\"yes_no_feedback\">" + s + "</div>";
  t +="<div id=\"comment_feedback\"></div>";
	t += "<form name='yesno_feedback_form' method='POST' enctype='text/html' target='submitTarget'>";
	t += "<div id='ui_div'></div>";
	t += "<div id='access_point_div'></div>";
	t += "<div id='feedback_type_div'></div>";
	t += "<div id='product_div'></div>";
	t += "<div id='version_div'></div>";
	t += "<div id='release_div'></div>"
	t += "<div id='sku'></div>";
	t += "<div id='doc_name'></div>";
	t += "<div id='doc_path'></div>"	;
	t += "<div id='doc_date'></div>";
	t += "<div id='rating'></div>";
	t += "<div id='last_search'></div>";
	t += "</form>";
	divObj.innerHTML = t;

} // end of makeFeedbackAndHelpSupportLink()

function click_yes (){
	fnRunFB(1);
}

function click_no (){
	fnRunFB(0);
} // end of click_no

	/////////////////////////////////////////////////
	//
	// jtaggart 6/22/06
	// fnRunNoFB : Creates a suggestion box if "no" was clicked
	// new for QB2007 R1
	// we will no longer launch the Feedback.CHM file for user feedback
	// params are the values obtained from ACE when the user submitted the yes/no vote
	// we will record the yes/no vote and then create a new form with the suggestion box	
	//
	/////////////////////////////////////////////////

function fnRunNoFB(ui,fb_type,help_doc_path,help_doc_name,help_subproduct,help_product,help_version,help_release,help_doc_date,help_last_search,submit_url) {
	
	// create the HTML for the suggestion box form
	var t = "";
	t += "<IFRAME STYLE='border-width:0px; margin:0px; padding:0px; visibility:hidden; width:1px; height:1px;' name='submitCommentsTarget'></IFRAME>";
	t+= "<form name='comments_feedback_form' method='POST' enctype='text/html' target='submitCommentsTarget'>";
  t += ui; // ui = false since we are not using the sflopp server for the success response
	t += fb_type; // feedback_type
	t += help_version; // version
	t += help_subproduct; // subproduct
	t += help_release; // release
	t += help_product; // product
	t += help_doc_name; // hlp_doc_name
	t += help_doc_path; // help_doc_path
	t += help_doc_date; // hlp_doc_date
	t += help_last_search; // hlp_last_search
	t += "<input type='hidden' name='hlp_score' value='0'>"; // help_score:0=no
	t += "<input type='hidden' name='hlp_name' value='novote_followup'>"; // hlp_name	
	t += "<table class='feedback_no'><tr><td width='15'><img src='" + ICON_HELP_FEEDBACK + "' border='0' align='left' alt='Help Feedback'>";
	t += "<td><b>How can we make this information more helpful?</b></td></tr>";
	t += "<tr><td width='15'>&nbsp;</td>";
	// QBW042108 7/18/06 because of the windowing model/event handling in Payroll Setup, onKeyUp event is not able to fire in payroll setup.
	// However, PS can only fire onKeyPress event, so adding one more event to handle. But onKeyPress event is fired when the key is pressed, 
	// there is one character off when determine enable/disable Submit button for PS. But the rest of the help feedback in the product works great
	// including ESI and others.
	t += "<td><textarea rows='3' name='text_data1' class='feedback_textarea' onkeyup='javascript:feedbackCommentOnKeyUp()' onkeypress='javascript:feedbackCommentOnKeyUp()'></textarea></td></tr>"; // comments_improve: this is the user comments
	t += "<tr><td width='15'>&nbsp;</td>";
	t += "<td align='right'><input type='button' name='comment_submit' value='Submit' class='feedback_button' onclick='SubmitFeedbackComment()' disabled></td></tr>";
	t += "<tr><td width='15'>&nbsp;</td><td align='left' valign='top' border='0'><span style='font-size:8pt;color:#222222;'>Requires an Internet connection.</span></td></tr>";	
	t += "</table>";
	t += "</form>";
	yes_no_feedback.innerHTML = t;
	document.comments_feedback_form.action = submit_url;
} // end of fnRunNoFB()
	
function SubmitFeedbackComment()
{
  document.forms.comments_feedback_form.submit();
  
  document.getElementById("yes_no_feedback").style.display = "none";
  
  var t = "";
  t+= "<table class='feedback'><tr><td width='15'><img src='" + ICON_HELP_FEEDBACK + "' border='0' align='left' alt='Help Feedback'>"
  t+= "<td><b>Thanks for your feedback!</b></td></tr></table>";
  document.getElementById("comment_feedback").innerHTML = t;
}
	
function feedbackCommentOnKeyUp()
{
   if (comments_feedback_form.text_data1.value.length > 0)
   {
      comments_feedback_form.comment_submit.disabled = false;
   }
   else
   {
    comments_feedback_form.comment_submit.disabled = true;
   }
}

// ============================================================ \\
// =====           Boiler plate functions                    == \\
// ============================================================ \\
// makeProAdvisorLink function - cluk (01/24/06)
function makeProAdvisorLink(divObj) {
  var text = "<br>";
  text += "<table class='feedback'><tr><td>" + TEXT["pro_advisor_text"] + " ";
  text += "<a href='IntuitHelpFile://H_LOCATE_ADVISOR'>find one.</a>";  // QBW051025 
  text += "</td></tr></table>";
  divObj.innerHTML = text;
} // end of makeProAdvisorLink

// makeCommunityLink function - cluk (01/24/06)
function makeCommunityLink(divObj) {
  var text = "<br>";
  text += "<table class='feedback'><tr><td>" + TEXT["community_text_1"] + " ";
  text += "<img src='" + PATH_PREFIX_IMAGES + "bolt.gif' border='0' alt='Go online' /> ";
  text += "<a href=\"javascript:QBURL('" + divObj.location + "&amp;HideURL=y')\">" + TEXT["community_text_2"] + " " + divObj.description + ".</a>";
  text += "</td></tr></table>";
  divObj.innerHTML = text;
} // end of makeCommunityLink

// ============================================================ \\
// =====           Wrapper functions of JS CALLABLE LIBRARY   == \\
// ============================================================ \\



// This function parses the URL for the sku parameter 'strParamName' and retrieves its value.
//
// Author: C.Clabourne
// Date: 9/17/2007
//
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  
  // test string
  //strHref = 'http://172.19.238.61/IPH/Core/QB2K4/Core/budgets/NF_BudgetIncreaseDecrease.html?blah=1&sku=masneutron&cat=dog&bird=fish';
  
    
  // the URL needs to have an & in front of the parameter in order to locate it!
  if ( strHref.indexOf("&") > -1 ){
    
     var strQueryString = strHref.substr(strHref.indexOf("&")).toLowerCase();
     var aQueryString = strQueryString.split("&");
    
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        
         var aParam = aQueryString[iParam].split("=");
        
         strReturn = aParam[1];
        
         break;
      }
    }
  }
    
  return strReturn;
}


function ShowTopic(helpItemID) {
  
    return;
    
}

function SearchTopics(searchQuery) {

    return;
    
}

function qbcommand(command) {
	
  alert("You must be running QuickBooks to access this function.");
  
}

function QBURL(url) {
  if (url.length >= 0)
    //location.href=url;
    window.open(url);
}

function GetQBValue(key) {
  if (key.length <= 0)
    return;
    
  var ret = window.external.GetStringValue(key);
  return ret;
}

//---------------------------------------------------
// Utility functions
//---------------------------------------------------

// Strip white space from beginning and end of query string
function trimspace(argvalue) {
  return argvalue.replace(/(^\s+)|(\s+$)/g, '')
}

// Encoding to HEX
function EncodeToHex(value) {
  // if needed, we can add more later
  value = value.replace(/%/g, "%25");
  value = value.replace(/&/g, "%26");
  return value.replace(/>/g, "%3E");
}
