/***********************************************************************\
*                        CUSTOM HTML TAG SCANNER                        *
\***********************************************************************/

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 = "";
	var at_relatedtopics = "";


	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();

		// --------------------------------------------------- \\
		// -----      ACTIVATE CONDITIONAL ELEMENTS      ----- \\
		if (window.validateSKUs) {
			// ----- Only check if not XML object ----- \\
			if (tNode.substring(0,1) != "#") {

				// ----- Old-style conditions: skus="CONDITION"
				var tSKUs = nodeObj.getAttribute("skus");
				if (tSKUs) {
					tSKUs = tSKUs.replace(/\s+/g, ",");
					// ----- make this item conditional ----- \\
					if ( validateSKUs(tSKUs) ) {
						if ( tNode == "SPAN" || tNode == "A" ) {
							nodeObj.style.display = "inline";
						} else if ( tNode == "LI" ) {
							nodeObj.style.display = "list-item";
						} else {
							nodeObj.style.display = "block";
						}
					} else {
						nodeObj.style.display = "none";
					}
				}

				// ----- DITA conditions: taxview="{DESKTOP|WEB}", taxproduct="{BASIC|STANDARD|PLATINUM|BUSINESS}"
				var tView = nodeObj.getAttribute("taxview");
				var tFlav = nodeObj.getAttribute("taxproduct");
				if (tView || tFlav) {
					if (tView) { tView = tView.replace(/\s+/g, ","); }
					if (tFlav) { tFlav = tFlav.replace(/\s+/g, ","); }
//alert( "<"+tNode+">\n  PRODUCT.Edition = "+PRODUCT.Edition+"\n  PRODUCT.isEasyStep = "+PRODUCT.isEasyStep+"\n  PRODUCT.isExpress = "+PRODUCT.isExpress+"\n\n  taxview = "+tView+" : ("+validateSKUs(tView)+")\n  taxproduct = "+tFlav+" : ("+validateSKUs(tFlav)+")\n------------------------\n"+nodeObj.innerHTML );
					if ( validateSKUs(tView) && validateSKUs(tFlav) ) {
						if ( tNode=="SPAN" || tNode=="A" ) {
							nodeObj.style.display = "inline";
						} else if ( tNode=="LI" ) {
							nodeObj.style.display = "list-item";
						} else {
							nodeObj.style.display = "block";
						}
					} else {
						nodeObj.style.display = "none";
					}
				}
			}
		}

		// --------------------------------------------------- \\
		// -----        ACTIVATE HTML VARIABLES          ----- \\
		if (window.setHTMLvariable) {
			if ( tNode == "VAR" ) {
				// ----- evaluate variable ----- \\
				setHTMLvariable( nodeObj );
			}
		}

		// --------------------------------------------------- \\
		// -----      CODE AFFECTING ALL ANCHOR TAGS     ----- \\
		if ( tNode == "A" ) {
			linkObj = nodeObj;

			if (iTarget) {
				if ( !(linkObj.target) ) {
					linkObj.target = iTarget;
				}
			}

			// ------------------------------------------- \\
			// -----    ACTIVATE CONDITIONAL LINKS   ----- \\
			// ----- scan links; implement "iref"s ("Intelligent" or "Intuit" References) ----- \\
			// ----- if the target of the link is appropriate for this SKU, turn it on.   ----- \\
			if (window.validateSKUs) {
				var tIref = linkObj.getAttribute("iref");
				if (tIref) {
					var tTargetSKUs = linkObj.getAttribute("targetSKUs");
					if ( !tTargetSKUs ||
					     ( tTargetSKUs && validateSKUs(tTargetSKUs) )
					   ) {
						linkObj.href = tIref;
					}
				}
			}

			// ----- popups are irefs too, just ones that call a popup window. ----- \\
			// ----- much the same code as above.                              ----- \\
			if (window.validateSKUs) {
				var tPop = linkObj.getAttribute("popup");
				if (tPop) {
					var tTargetSKUs = linkObj.getAttribute("targetSKUs");
					var tTargetValid = true;
					if (window.validateSKUs) { tTargetValid = validateSKUs(tTargetSKUs); }
					if ( !tTargetSKUs ||
					     ( tTargetSKUs && tTargetValid )
					   ) {
						linkObj.href = tPop;
						// ----- set up an "onclick" call to get the mouse X+Y ----- \\
						// ----- also, reformat the link to use dotted line.   ----- \\
						if (window.MarkPopup) {
							linkObj.onclick = MarkPopup;
							linkObj.style.textDecoration = "none";
							linkObj.style.borderBottom = "1px dotted";
						}
					}
				}
			}

			// ----- encase popup URL in popup calling code ----- \\
			if (tPop) {
				linkObj.href = "javascript:Popup('" + linkObj.href + "')";
			}


			// ------------------------------------------- \\
			// -----     ACTIVATE EASYSTEP LINKS     ----- \\
			// ----- "ezlink"s are just like hrefs, only they call custom code  ----- \\
			// ----- as provided by Drew LaHaie.                                ----- \\
			if (window.QTEZLink) {
				var tEZref = linkObj.getAttribute("EZlink");
				if (tEZref) {
					linkObj.href = "javascript:QTEZLink('" + tEZref + "')";
				}
			}

			// ------------------------------------------- \\
			// -----      ACTIVATE IN-FORM LINKS     ----- \\
			// ----- "formlink"s are just like hrefs, only they call custom code  ----- \\
			// ----- as provided by Drew LaHaie.                                  ----- \\
			if (window.QTFormLink) {
				var tFormRef = linkObj.getAttribute("FormLink");
				if (tFormRef) {
					linkObj.href = "javascript:QTFormLink('" + tFormRef + "')";
				}
			}

			// ------------------------------------------- \\
			// -----  HIDE EZ-LINKS IF NOT INTERVIEW ----- \\
			if ( window.PRODUCT ) {
				if ( !PRODUCT.isEasyStep || PRODUCT.isExpress || PRODUCT.isIncomplete ) {
					var tEZref = linkObj.getAttribute("ezlink");
					//this is an ezlink, so make it not visible
					if(tEZref) {
						linkObj.style.display = "none";
						linkObj.style.visibilty = "hidden";
					}
				}
			}

			// ------------------------------------------- \\
			// -----      ACTIVATE EXPANDO LINKS     ----- \\
			if (window.makeExpandoLink) {
				var tDivID = linkObj.getAttribute("expando");
				if ( tDivID != null ) {
					makeExpandoLink( linkObj, tDivID );
				}
			}

			// ------------------------------------------- \\
			// -----   ACTIVATE MULTIEXPANDO LINKS   ----- \\
			if (window.makeMultiExpandoLink) {
				var tDivID = linkObj.getAttribute("multiexpando");
				if ( tDivID ) {
					makeMultiExpandoLink( linkObj, tDivID );
				}
			}

		}

		// -----  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";
				if (tNode.substring(0,1) == "H") {
					nodeObj.style.display = "none";
				}
			}

			if ( !at_body && tNode == "BODY" ) {
				at_body = "AT";
			}

			// ----- hide all <h5> and <h6> tags ----- \\
			if ( tNode == "H5" || tNode == "H6" ) {
				nodeObj.style.display = "none";
			}
		
			// ----- hide any <h4>See Also</h4> blocks along with any following content ----- \\
			if ( !at_relatedtopics &&
			     ( tNode == "H4" && nodeObj.innerText.toUpperCase() == "SEE ALSO" ) ||
			     ( tNode == "HR" && nodeObj.nextSibling.innerText.toUpperCase() == "SEE ALSO" ) ||
			     ( tNode == "H4" && nodeObj.innerText.toUpperCase() == "CONSULTEZ ÉGALEMENT" ) ||
			     ( tNode == "HR" && nodeObj.nextSibling.innerText.toUpperCase() == "CONSULTEZ ÉGALEMENT" ) ||
			     ( tNode == "H4" && nodeObj.innerText.toUpperCase() == "CONSULTEZ ÉGALEMENT :" ) ||
			     ( tNode == "HR" && nodeObj.nextSibling.innerText.toUpperCase() == "CONSULTEZ ÉGALEMENT :" )
			) {
				at_relatedtopics = "AT";
			}
			if ( at_relatedtopics == "AT" ) {
				nodeObj.style.display = "none";
//				if ( tNode != "H4" && tNode != "OL" && tNode != "UL" ) {
//					at_relatedtopics = "";
//				}
			}
		}
*/

		// -------------------------------------------- \\
		// -----      ACTIVATE INCLUDO BLOCKS     ----- \\
		if (window.makeIncludoBlock) {
			if ( tNode == "DIV" ) {
				var tInc = nodeObj.getAttribute("includo");
				if ( tInc != null ) {
					makeIncludoBlock( nodeObj );
				}
			}
		}

		// ----- finished checking this node; loop to the next one ----- \\
	}
}

