var usesDynamicNav = null;

// find out if dynamic tab navigation is in use
function isDynamic() {
	if (usesDynamicNav == null) {
		var strTmp;
		for (var i=0; i<document.links.length; i++) {
			// alert( document.links[i].href );
			strTmp = document.links[i].href;
			if (strTmp.indexOf('doDynamic') > -1) {
				usesDynamicNav = true;
			}
		}		
		if (usesDynamicNav == null) usesDynamicNav = false;
	}
	return usesDynamicNav;
}

// set element to visible
function setVisible( targetID ) {
	var strTmp = "";
	strTmp += "targetID: " + targetID + "\n";

	var newSelected = getElement( targetID );
	if ( newSelected != null ) {
		var priorClass = newSelected.className;
		strTmp += "priorClass: " + priorClass + "\n";

		var index = priorClass.indexOf( " HIDDEN" );
	
		if ( index >= 0 ) {
			var newClass = priorClass.substring( 0, index );
			newClass += priorClass.substring( index + 7 );
			newSelected.className = newClass;
			strTmp += "newClass: " + newClass + "\n";
		}
	} else {
		strTmp += "Element not found";
	}
	// alert(strTmp);
}

// Pick a dynamically visible object
function doDynamicFirst( targetID ) {
	// alert(isDynamic() );
	if ( !isDynamic() ) {
		setVisible( targetID );
	} else {
		// makes first dynamically-visible item visisble
		if ( dynamicSelect == null ) {
	            setVisible( targetID );
			var newLinkSelected = getElement( "sl_"+targetID );
			if ( newLinkSelected != null ) {
				var newClass = newLinkSelected .className + " ON";
				newLinkSelected.className = newClass;
			}
			dynamicSelect = targetID;
		}
		// make corresponding selflink highlighted.
		

	}
}
function doDynamic( targetID ) {
	// turn off currently visible content
	if ( dynamicSelect != null ) {
		if ( dynamicSelect == targetID ) return;
		if ( dynamicSelect != targetID ) {
			var oldSelected = getElement( dynamicSelect );
			if ( oldSelected != null ) {
				var newClass = oldSelected.className + " HIDDEN";
				oldSelected.className = newClass;
			}
			var oldLinkSelected = getElement( "sl_"+dynamicSelect );
 			if ( oldLinkSelected != null ) {
				var priorClass = oldLinkSelected .className;
				var index = priorClass.indexOf( "ON" );
				if ( index >= 0 ) {
					var newClass = priorClass.substring( 0, index );
					newClass += priorClass.substring( index + 2 );
					oldLinkSelected.className = newClass;
				}
			}
		}
	}
	if ( targetID != null ) {
		var newSelected = getElement( targetID );
		if ( newSelected != null ) {
			var priorClass = newSelected.className;
			var index = priorClass.indexOf( " HIDDEN" );
			if ( index >= 0 ) {
				var newClass = priorClass.substring( 0, index );
				newClass += priorClass.substring( index + 7 );
				newSelected.className = newClass;
			}
		}
		var newLinkSelected = getElement( "sl_"+targetID );
		if ( newLinkSelected != null ) {
			var newClass = newLinkSelected .className + " ON";
			newLinkSelected.className = newClass;
		}
	}
	dynamicSelect = targetID;
}


/* ------- GA tracking paths ----- */
var ga = new Array();

//  QVP Assets
ga[0] = "/QVP-SE-Prod-Fact-pdf";
ga[1] = "/QVP-Supported-Formats-pdf";
ga[2] = "/QVP-User-Guide-pdf";
ga[3] = "/QVP-CS-Tech-Resource-Center-pdf";
ga[4] = "/QVP-CS-High-Tech-Crime-pdf";
ga[5] = "/QVP-WP-Decrease-IT-pdf";
ga[6] = "/QVP-PE-Prod-Fact-pdf";

// Transit Assets
ga[10] = "/TRANSIT-User-Guide-pdf";
ga[11] = "/TRANSIT-Prod-Fact-pdf";
ga[12] = "/TRANSIT-CS-Connecticut-General-pdf";
ga[13] = "/TRANSIT-CS-Orange-County-pdf";
ga[14] = "/TRANSIT-CS-National-Semiconductor-pdf";
ga[15] = "/TRANSIT-CS-Washington-Courts-pdf";
ga[16] = "/TRANSIT-WP-Five-Ways-pdf";

// Metro Assets
ga[20] = "/METRO-Prod-Fact-pdf";

// Image Popups
ga[30] = "/Image/QVP-Main-Interface";
ga[31] = "/Image/QVP-File-Attachment";
ga[32] = "/Image/QVP-Sample-Native";
ga[33] = "/Image/QVP-Sample";
ga[34] = "/Image/QVP-Integration";
ga[35] = "/Image/QVP-File-Navigation";
ga[36] = "/Image/QVP-Zip-Archive";

ga[37] = "/Image/TR-How-It-Works";
ga[38] = "/Image/TR-Workflow";
ga[39] = "/Image/TR-Edit-Template-Window";
ga[40] = "/Image/TR-Choose-Template-Window";
ga[41] = "/Image/TR-Edit-Source";

ga[42] = "/Image/QVP-Sample-MSProject-Native"; 	//MS Project Screenshot
ga[43] = "/Image/QVP-PE-Sample-MSProject";		//MS Project in QVP 11
ga[44] = "/Image/QVP-Search-Highlight";		
ga[45] = "/Image/QVP-Metadata-View";		

// User Actions
ga[50] = "/Start-Download";
ga[51] = "/Questions/Link-Contact-Us";  //Special case - link from shared "Questions?" sidebar
ga[52] = "/Webinar-Register/Transit9";
ga[53] = "/Ad-Promo/Link-Legal-LearnMore";
ga[54] = "/Ad-Promo/Link-Enterprise-LearnMore";
ga[55] = "/Ad-Promo/Link-SmBusiness-LearnMore";
ga[56] = "/Ad-Promo/Link-Govmt-LearnMore";
ga[57] = "/button-HowToBuy";
ga[58] = "/button-Download";
ga[59] = "/button-LearnMore";

ga[60] = "/MailToLink/Support";
ga[61] = "/MailToLink/Sales";
ga[62] = "/MailToLink/QVPGovernment";
ga[63] = "/MailToLink/QVPLegal";
ga[64] = "/MailToLink/QVPIntegration";
ga[65] = "/MailToLink/Info";
ga[66] = "/MailToLink/Partners";

ga[70] = "/Link-QVP-Download";
ga[71] = "/Link-QVP-WhatsNew";
ga[72] = "/Link-QVP-Specs";
ga[73] = "/Link-QVP-SoftwareStore";
ga[74] = "/Link-Transit-Download";
ga[75] = "/3rdParty/Link-Contact-Us";  	//Special case - link from Integrators sidebar
ga[76] = "/Link-Transit-LearnMore";
ga[77] = "/Link-QVP-Reviews-LearnMore";
ga[78] = "/Link-Transit-WhatsNew";
ga[79] = "/Link-Metro-ContactToEvaluate";
ga[80] = "/Link-Contact-Us";
ga[81] = "/Link-Support-QVP";
ga[82] = "/Link-Support-Transit";
ga[83] = "/Link-Support-Metro";
ga[84] = "/Ad-Promo/Reviews-LAW-Comp/More";
ga[85] = "/QuickLinks"+ga[0]; 		// QVP SE Fact Sheet from Quicklinks
ga[107] = "/QuickLinks"+ga[6]; 		// QVP PE Fact Sheet from Quicklinks
ga[86] = "/QuickLinks/Case-Studies"; 	// Case Studies 
ga[87] = "/QuickLinks"+ga[71]; 		// What's New in QVP
ga[88] = "/QuickLinks"+ga[72]; 		// Supported File Formats
ga[89] = "/QuickLinks/Reviews-Awards"; 	// Reviews and Awards
ga[90] = "/QuickLinks/Testimonials"; 	// Testimonials
ga[91] = "/QuickLinks"+ga[11];		// Transit Fact Sheet from Quicklinks
ga[92] = "/QuickLinks"+ga[78]; 		// What's New in Transit
ga[93] = "/QuickLinks"+ga[20]; 		// Mertro Fact Sheet from Quicklinks
ga[94] = "/Free-Trial-Sidebar"+ga[70]; 	// QVP Download from Free Trial Sidebar
ga[95] = "/Free-Trial-Sidebar"+ga[74]; 	// Transit Download from Free Trial Sidebar
ga[96] = "/Featured-Product-Sidebar/QuickViewPlusSE"; 	// 
ga[108] = "/Featured-Product-Sidebar/QuickViewPlusPE"; 	// 
ga[97] = "/Featured-Product-Sidebar/Transit"; 	// 

// QVP Reviews and Awards External Links
ga[98] = "/GovernmentComputerNews"; 	
ga[99] = "/LegalAssistantToday"; 	
ga[100] = "/SmartComputing"; 	
ga[101] = "/ChannelWeb"; 	
ga[102] = "/PCWorld"; 	
ga[103] = "/PCMagazine"; 	
ga[104] = "/PCToday"; 	
ga[105] = "/LawOfficeComputing"; 	
ga[106] = "/Webinar-Register/QuickViewPlus";
// ga[107] - listed below [85] above for clarity ... start with 108
// ga[108] - listed below [96] above for clarity ... start with 109
ga[109] = "/Microsoft-.NetFrameworkV2";
ga[110] = "/Microsoft-VisualC++2005Redistributable";


/* --
ga[] = "";
ga[74] = "FAQ/";
ga[75] = "FAQ/";
-- */

/* ------- /GA tracking paths ----- */


/* ------------------------
 doClick(0)
 doClick() - reports a click action to Google Analytics
 args: 
 0 intIn   - req'd. - Position number in the ga array containing the message to be passed.
 1 anchorIn - optional - reference to the anchor object that called this function.  Only used for links to online store.
 ------------------------ */

function doClick(intIn) {
	if (intIn == 73) { 
		// special case - link to software store should call different GA function
		if(arguments[1]!= void(0)){
			var anchorIn = arguments[1];
			pageTracker._link(anchorIn.href);
			return false;
		}
	} else {
		pageTracker._trackPageview( window.location.pathname+ga[intIn] );
	      return true;
	}
}


/* ------------------------
 openWindow (this,0)

 openWindow() - Opens something in a new Window, reports action to Google Analytics
 args: 
 1 objIn (req'd) - the Link object passed in by the 'this' keyword in the onclick attribute of the anchor tag
                   Used to get href attribute to open new window
 2 intTrackNum (req'd) - integer, the array position in the ga array defined above that contains
                         the tracking string that will be sent to Google Analytics in the _trackPageview method.
 3 int (anon)	- optional.  If one value specified, value will override both height and width
			  default values.  If a second value is also passed, this will be override the height
 4 int (anon)     - optional.  Will override the default width setting if specified.
 ------------------------ */

var theWin = null;
var defaultHeight = 1000;
var defaultWidth = 690;

function openWindow(objIn, intTrackNum) {
	// close window if open, so that resize happens
	if (theWin != null) {
		theWin.close();
	}

	//alert(objIn.href);
	var height = defaultHeight;
	var width = defaultWidth;
	if (arguments.length < 2) {
		// fire Google analytics - yell for help
		pageTracker._trackPageview( window.location.pathname+'-openWindow_Error-'+objIn.pathname );
	} else {
		
            // fire Google analytics - real path
		pageTracker._trackPageview( window.location.pathname+ga[intTrackNum] );
	}
	// open the window
	if (arguments.length ==4 ) {
		height = arguments[2];
		width = arguments[3];
	} else if (arguments.length == 3) {
		height = arguments[2];
		width = arguments[2];
	}
	// open the window.
	theWin = openMinimalWindow( "", "theWin", height, width, "yes", "yes", true ); 
	theWin.location.href=objIn.href;	
	theWin.focus();
	return false;
}

/* ------------------------
 openScreenShot (this,0)

 openScreenShot() - Reports action to Google Analytics, opens a new Window then writes a document to that window
                    containing an image tag, setting the src of the image to the href of the object passed in.
 args: 
 1 objIn (req'd) - the Link object passed in by the 'this' keyword in the onclick attribute of the anchor tag
                   Used to get href attribute to open new window
 2 intTrackNum (req'd) - integer, the array position in the ga array defined above that contains
                         the tracking string that will be sent to Google Analytics in the _trackPageview method.
 3 int (anon)	- optional.  If one value specified, value will override both height and width
			  default values.  If a second value is also passed, this will be override the height
 4 int (anon)     - optional.  Will override the default width setting if specified.
 ------------------------ */

function openScreenShot(objIn, intTrackNum) {
	// close window if open, so that resize happens
	if (theWin != null) {
		theWin.close();
	}

	//alert(objIn.href);
	var height = defaultHeight;
	var width = defaultWidth;
	if (arguments.length < 2) {
		// fire Google analytics - yell for help
		pageTracker._trackPageview( window.location.pathname+'-openWindow_Error-'+objIn.pathname );
	} else {
            // fire Google analytics - real path
		pageTracker._trackPageview( window.location.pathname+ga[intTrackNum] );
	}
	// open the window
	if (arguments.length ==4 ) {
		height = arguments[2];
		width = arguments[3];
	} else if (arguments.length == 3) {
		height = arguments[2];
		width = arguments[2];
	}
	// open the window.
	theWin = openMinimalWindow( "", "theWin", height, width, "yes", "no", true ); 
	// write to window
	theWin.document.open();
	theWin .document.write('<html><head>\n<link rel="stylesheet" type="text/css" href="/site/laf/id215-avantstar/css/popup.css">\n\n');
	theWin .document.write('<title</title>\n');
	theWin .document.write('</head>\n<body>\n');
	theWin .document.write('<table style="height: 100%; width: 100%;"><tr><td align="center"><img src="' + objIn.href + '"></td></tr>\n');
	//theWin .document.write('<tr><td style="text-align: center;">[ <a href="#" onclick="self.close()">Close</a> ]</td></tr>\n');
	theWin .document.write('</table>\n');
	theWin .document.write('</body>\n</html>\n');
	theWin .document.close()

	theWin.focus();
	return false;
}


function doPageLoad() {
  return true;
}
