<!--

// Usage:
//   Always call the function "Show"
//     Show(parm1,parm2,parm3,parm4)
//       Parm1 = ScriptIndex  // The index of the script
//       Parm2 = ScriptName   // The name of the script
//       Parm3 = mode         // One of three modes; 1 (script changes), 2 (script, main.htm change), 3 (script, main.htm, demo arrow change)
//       Parm4 = group        // Used to identify app subdirectory when show contents for main.htm; values: home, executive, quality, sales
// Examples
//    Show(3,'intro')
//      This will show the third instance of the intro script and only the displayed script will change
//    Show(3,'salesrank') 
//      This will show the third instance of the salesrank script and display 

 var scriptIndex = 1;  
 var scriptName = 'intro' ;  
 var prevScriptIndex = scriptIndex ;
 var prevScriptName = scriptName ;
 var lastValidScriptName = scriptName ;
 var lastValidScriptIndex = scriptIndex ;
 var currScriptIndex = scriptIndex ;
 var currScriptName = scriptName ;
 var nextScriptIndex = scriptIndex ;
 var nextScriptName = scriptName ;
 var isScriptHidden = 'false' ;
 var isDemoHidden = 'false' ;
 var prevDemoIndex = 1 ;
 var prevDemoName = 'intro';
 var DemoNameVar ;
 var PageNumVar ;
 var demoCntr;
 var pageCntr;
 var lineCntr;
 var lastValidScriptName;
 var lastValidScriptIndex;
 var xmlDoc1=new ActiveXObject("microsoft.xmldom");
 var LastPage='N';
 var introTitle;
 var introText;
 var continBt;
 var backBt;  
 var demoImageDir = '/approot/ExcelDemos';
 var demoScript;
 
function startup() {
	DemoNameVar=currScriptName;
	PageNumVar=currScriptIndex;
	 MENUFORM.prevDemoName.value = scriptName ;
	 MENUFORM.prevDemoIndex.value = scriptIndex ;
	xmlDoc1.ondataavailable = ReadyStateChange;
	xmlDoc1.onreadystatechange = ReadyStateChange;
	xmlDoc1.async = true ;
	xmlDoc1.load("demoscriptdrill.xml"); 
	getBrowserType();
	if (ie) {	
		var nextScript = eval("document.all.DemoScript")
		nextScript.style.display = "block";
		}
	if (netscape) {
		var nextScript = eval("document.DemoScript")
		nextScript.visibility = "show" ;
		}
	 INSTRUCTIONS.innerHTML="Instructions ";
	 ScriptFrameNM.INFOTEXT.innerHTML='';
	 ScriptFrameNM.LINETEXT.innerHTML='';
	backBt = eval(" document.all.backBtn");
	continBt = eval(" document.all.continueBtn");
	resize()
}

function ReadyStateChange() {
// Validating script document ready state.
  if (xmlDoc1.readyState == 4 ) {
//	continBt = eval(" document.all.continueBtn");
//	continBt.style.visibility = "hidden";
//	backBt.style.visibility = "hidden";
	demoScript=xmlDoc1.getElementsByTagName('DEMO');
	Show(1,'startup')
	}
}

function ReadyStateChange2() {
// Validating script document ready state.
  if (xmlDoc1.readyState == 4 ) {
	demoScript=xmlDoc1.getElementsByTagName('DEMO');
	}
}

function Back(){
	scriptIndex =  MENUFORM.prevScriptIndex.value;
	scriptName =  MENUFORM.prevScriptName.value;
	Show(scriptIndex,scriptName);
}

function Continue(){
//alert(document.all.nextScriptIndex.value);
//alert(document.all.nextScriptName.value);
	scriptIndex =  document.all.MENUFORM.nextScriptIndex.value;
	scriptName =  document.all.MENUFORM.nextScriptName.value;
//	alert (scriptIndex + scriptName);
	Show(scriptIndex,scriptName);
//alert(scriptIndex,scriptName);
	}
function Show(scriptIndex,scriptName) {
//alert(scriptIndex + scriptName);
	prevDemoName= document.all.MENUFORM.prevDemoName.value;
	prevDemoIndex= document.all.MENUFORM.prevDemoIndex.value;
	continBt = eval(" document.all.continueBtn");
	continBt.style.visibility = "visible";
	if ((scriptName == 'home') || (scriptName == 'startup')) {
		getBrowserType();
		if (ie) {	
/*
			 document.all.salesrank_arrow.style.visibility = "hidden";		
			 document.all.salestrend_arrow.style.visibility = "hidden";
			 document.all.salespdist_arrow.style.visibility = "hidden";
			 document.all.salesprofit_arrow.style.visibility = "hidden";
			 document.all.salesorders_arrow.style.visibility = "hidden";
			 document.all.qarank_arrow.style.visibility = "hidden";	
			 document.all.qatrends_arrow.style.visibility = "hidden";	
			 document.all.qapdist_arrow.style.visibility = "hidden";	
*/
		}
		if ((scriptName == 'home')) {
			parent.WFRIGHT.location.href = "welcome.htm" ;
			lastValidScriptName = 'intro' ;
			lastValidScriptIndex = 1 ;
		}
		ShowScript(1,'intro')
	}
	else if (scriptName == 'intro') 	{
		parent.WFRIGHT.location.href = "welcome.htm" ;
		ShowScript(1,'intro')
		}
	else if ( (scriptName == 'savar') 	|| (scriptName == 'thankyou') ) {
		ShowDemo(scriptIndex,scriptName)
		ShowScript(scriptIndex,scriptName)
		}
	else if (scriptName == 'moreinfo')  {
		 MENUFORM.prevScriptIndex.value =  MENUFORM.lastValidScriptIndex.value;
		 MENUFORM.prevScriptName.value =  MENUFORM.lastValidScriptName.value;
		backBt.style.visibility = "visible";
		continBt.style.visibility = "hidden";
		ShowDemo(scriptIndex,scriptName)
		ShowScript(scriptIndex,scriptName)
		}
	else {
		 MENUFORM.nextScriptIndex.value =  MENUFORM.lastValidScriptIndex.value;
		 MENUFORM.nextScriptName.value =  MENUFORM.lastValidScriptName.value;
		backBt.style.visibility = "hidden";
		continBt.style.visibility = "visible";
		ShowScript(1,'noscript')
		ShowDemo(scriptIndex,scriptName)
		}	
}

function ShowDemo(scriptIndex,scriptName) {
//alert ("showdemo:  "+scriptIndex);
	if ( (scriptIndex == 1) || (scriptIndex == 2) || ( scriptName != prevDemoName ) )  {
		if ((prevDemoName != 'intro') && (prevDemoName != 'thankyou') && (prevDemoName != 'moreinfo')  && (prevDemoName != 'startup') && (scriptName != prevDemoName) ){
// Sales Pivot is displayed as an embedded demo within Sales Rankings.  There is no link and no arrow for Sales Pivot.
// We must manipulate the Sales Rankings arrow if we are coming from Sales Pivot and changing to a different demo.
// This means if Sales Pivot is the next demo, then do not change the arrow settings for Sales Rankings.
			}
		if ( (scriptName != 'intro') && (scriptName != 'thankyou')  && (scriptName != 'moreinfo') && (scriptName != prevDemoName ) ) {
// Sales Pivot is displayed as an embedded demo within Sales Rankings.  There is no link and no arrow for Sales Pivot.
// We must manipulate the Sales Rankings arrow if we are going to Sales Pivot and changing from a different demo.
			}
		if ((scriptName == 'savar') || (scriptName == 'thankyou') || (scriptName == 'moreinfo')  ) {
			if (scriptIndex == 1 )  {
 				mainframesrc = scriptName + ".htm" ;
// 				alert(parent.WFRIGHT.location.href);
				parent.WFRIGHT.location.href = mainframesrc ;
				}
//			else if ( ((scriptIndex == 2 ) && (prevDemoIndex == 1 )) || (scriptName != prevDemoName ) ) {
//				    top.main.location.href = "sales/" + scriptName + ".htm" ;
//					}
			}
		if ((scriptName == 'intro')) {
//alert("back to intro");
		    parent.WFRIGHT.location.href = "welcome.htm" ;
//		    location.href = "indexleftdrill.htm";
		}
	 MENUFORM.prevDemoIndex.value = scriptIndex ;
	 MENUFORM.prevDemoName.value = scriptName ;
	}
	if ((scriptName == 'savar') || (scriptName == 'intro')  ) {
		lastValidScriptIndex = scriptIndex ;
		lastValidScriptName = scriptName ;
		 MENUFORM.lastValidScriptIndex.value = scriptIndex;
		 MENUFORM.lastValidScriptName.value = scriptName;
		}
}

function ShowScript(scriptIndex,scriptName) {
	LoadScript(scriptIndex,scriptName);
}

function HideScript(prevScriptIndex,prevScriptName) {
	getBrowserType();
	if (ie) {	
		var disappearer = eval("document.all." + prevScriptName + prevScriptIndex)
		disappearer.style.display = "none";
	}
}

function ToggleScript() {
	if (isScriptHidden) {
		getBrowserType();
		if (ie) {	
			var nextScript = eval(" document.all.DemoScript")
			nextScript.style.display = "none";
			}
		document.btnToggleScript.src = "show_instr3.gif";
		isScriptHidden = false;
		}
	else {
		getBrowserType();
		if (ie) {	
			var disappearer = eval(" document.all.DemoScript")
			disappearer.style.display = "block";
			}
		document.btnToggleScript.src = "hide_instr3.gif";
		isScriptHidden = true;
		}
}

function callout(callout) {
	getBrowserType();
	var calloutfile = callout + ".htm";

	if (ie) {	
	switch (callout) {
		case "DataAdapters" : 
//			Use the following for showing data adapter info from www.InformationBuilders.com
			calloutfile ='http://www.informationbuilders.com/products/webfocus/data_access.html'; 
//			calloutfile ='DataAdapters2.htm'; 
			window.open(calloutfile, 'WebFOCUS','Height=400,width=600,left=0,top=0,scrollbars,toolbar,resizable');
			break;
		case "rptoutput" : 
			window.open(calloutfile, 'WebFOCUS','Height=150,width=375,left=0,top=0,scrollbars,toolbar,resizable');
			break;
		case "OutputFormat" :
			window.open(calloutfile, 'WebFOCUS','Height=385,width=475,left=0,top=0,scrollbars,toolbar,resizable');
			break;
		case "OnDemandPaging" :
			window.open(calloutfile, 'WebFOCUS','Height=375,width=475,left=0,top=0,scrollbars,toolbar,resizable');
			break;
		case "datavisualization" :
			window.open(calloutfile, 'WebFOCUS','Height=275,width=375,left=0,top=0,scrollbars,toolbar,resizable');
			break;
		case "olap" :
			window.open(calloutfile, 'WebFOCUS','Height=400,width=600,left=0,top=0,scrollbars,toolbar,resizable');
			break;
		case "conditionalstyling" : 
			window.open(calloutfile, 'WebFOCUS','Height=175,width=375,left=0,top=0,scrollbars,toolbar,resizable'); 
			break;
		case "financialreports" : 
			calloutfile='http://informationbuilders.com/products/webfocus/financial_reporting.html';
			window.open(calloutfile, 'WebFOCUS','Height=400,width=600,left=0,top=0,scrollbars,toolbar,resizable'); 
			break;
		}
	}
}

// determines browser type
function getBrowserType() {
	netscape = false;
	ie = false;
	if (parseInt(navigator.appVersion) >= 4) {
		if (navigator.appName == "Microsoft Internet Explorer")
			ie = true;
		if (navigator.appName == "Netscape")
			netscape = true;
	}
}


function LoadScript(PageNumVar,DemoNameVar){
// Main function for loading script. It will return the first node of the tree : DEMOSCRIPT.  
// The XML node will thus be skipped.
	treeNode=xmlDoc1.documentElement;
	CheckDemo(PageNumVar,DemoNameVar);
}

function CheckDemo(PageNumVar,DemoNameVar) {
 ScriptFrameNM.INFOTEXT.innerHTML='';
 ScriptFrameNM.LINETEXT.innerHTML='';
// Loading DEMO nodes
	demoCount=demoScript.length;
	CheckforDemos :
// Checking DEMO nodes for the selected DEMO
	for (demoCntr=0;demoCntr<demoCount;demoCntr++) {
		demoNode=demoScript.item(demoCntr);
		demoName=demoNode.getElementsByTagName('DEMONAME').item(0).firstChild.data;
		demoTitle=demoNode.getElementsByTagName('DEMOTITLE').item(0).firstChild.data;
		if (demoName==DemoNameVar){
// DEMO node found
			pageNode=demoNode.getElementsByTagName('PAGE');
			pageCount=pageNode.length;
// Checking PAGE nodes
			for (pageCntr=0;pageCntr<pageCount;pageCntr++) {
				pageNum=pageNode.item(pageCntr).getElementsByTagName('PAGENUM').item(0).firstChild.data;
				if (pageNum==PageNumVar){
// PAGE node found ; setting INFOTEXT
				   if ( (DemoNameVar != 'noscript') || (DemoNameVar != 'moreinfo') )  {
						setScriptNav(PageNumVar,DemoNameVar);
				 		}
					if (DemoNameVar == 'moreinfo') {
						InstrLabel=demoTitle;
						}
					else {
						InstrLabel="Instructions " + demoTitle;
						}
					 INSTRUCTIONS.innerHTML=InstrLabel;
					infoText=pageNode.item(pageCntr).getElementsByTagName('INFOTEXT').item(0).firstChild.data;
					 ScriptFrameNM.INFOTEXT.innerHTML= ScriptFrameNM.INFOTEXT.innerHTML + infoText;
					actionNode=pageNode.item(pageCntr).getElementsByTagName('LINE');
					lineCount=actionNode.length;
					lineText=actionNode.item(0).text;
					if ((lineText =='') || (lineText==null)) {
						var lineTextObj = eval(" ScriptFrameNM.LINETEXT.style") ;
						lineTextObj.visibility = "hidden";
						}
					else if (lineText!=''){
// LINE node found ; setting LINETEXT
						var lineTextObj = eval(" ScriptFrameNM.LINETEXT.style") ;
						lineTextObj.visibility = "visible";
						for (lineCntr=0;lineCntr<lineCount;lineCntr++) {
							lineText=actionNode.item(lineCntr).text;
							 ScriptFrameNM.LINETEXT.innerHTML= ScriptFrameNM.LINETEXT.innerHTML +
								 " <img align=absmiddle src=bullet3.gif> " +	lineText + " <BR> ";
							}
						break CheckforDemos;
						}
					break CheckforDemos;
					}
				}
			break CheckforDemos ;
			}
		}
}

function setScriptNav(PageNumVar,DemoNameVar) {
// 'salespivot' is the demo exception.  Setting the next demo to skip 'salespivot' 
// Setting nextScriptIndex and nextScriptName to go to the first demo after salespivot
if ( (DemoNameVar=='salespivot') && (PageNumVar==1) ) {
	currDemo = demoCntr + 1 ;
	currPage = pageCntr + 1 ;
	prevScriptIndex=demoScript.item(demoCntr-1).getElementsByTagName('PAGE').length;
	prevScriptName=demoScript.item(demoCntr-1).getElementsByTagName('DEMONAME').item(0).firstChild.data;
	nextScriptIndex = 1;
	nextScriptName = demoScript.item(demoCntr+1).getElementsByTagName('DEMONAME').item(0).firstChild.data;
	backBt.style.visibility = "visible";
	continBt = eval(" document.all.continueBtn");
	continBt.style.visibility = "visible";
	 MENUFORM.nextScriptIndex.value=nextScriptIndex;
	 MENUFORM.nextScriptName.value=nextScriptName;
	 MENUFORM.prevScriptIndex.value=prevScriptIndex;
	 MENUFORM.prevScriptName.value=prevScriptName;
	 MENUFORM.prevDemoName.value=prevDemoName;
	}
else if ( (DemoNameVar=='salespivot') && (PageNumVar==2) ) {
	currPage = pageCntr + 1 ;
	prevScriptIndex = currPage - 1;
	prevScriptName = DemoNameVar;
	nextScriptIndex = currPage + 1;
	nextScriptName = DemoNameVar;
	}
else {
// pageCntr and demoCntr start at 0 (top node) ; create currPage currDemo for correct script navigation settings
	nextScriptIndex= MENUFORM.nextScriptIndex.value;
	nextScriptName= MENUFORM.nextScriptName.value;
	prevScriptIndex= MENUFORM.prevScriptIndex.value;
	prevScriptName= MENUFORM.prevScriptName.value;
	currDemo = demoCntr + 1 ;
	currPage = pageCntr + 1 ;
	if (currPage > 1)  {
		prevScriptIndex=currPage - 1 ;
		prevScriptName=demoName;
		backBt.style.visibility = "visible";
		if (currPage < pageCount){
			nextScriptIndex = currPage + 1;
			nextScriptName = demoName ;
			continBt = eval(" document.all.continueBtn");
			continBt.style.visibility = "visible";
			}
		else {
			if (currDemo < demoCount) {
				nextScriptIndex = 1;
				nextScriptName = demoScript.item(demoCntr + 1).getElementsByTagName('DEMONAME').item(0).firstChild.data;
				continBt = eval(" document.all.continueBtn");
				continBt.style.visibility = "visible";
				}
			else {
				if (demoScript.item(demoCntr+1)==null){
// This means you have reached the end of the demo		
					LastPage='Y';	
					continBt = eval(" document.all.continueBtn");
					continBt.style.visibility = "hidden";
					}
				}
			}
		}
	else {
		if ((currPage == 1) && (demoName == 'intro')) {
			prevScriptIndex=currPage;
			prevScriptName=demoName;
			backBt.style.visibility = "hidden";
			if (currPage < pageCount){
				nextScriptIndex = currPage + 1;
				nextScriptName = demoName ;
				continBt = eval(" document.all.continueBtn");
				continBt.style.visibility = "visible";
				}
			else {
				if (currDemo < demoCount) {
					nextScriptIndex = 1;
					nextScriptName = demoScript.item(demoCntr+1).getElementsByTagName('DEMONAME').item(0).firstChild.data;
					continBt = eval(" document.all.continueBtn");
					continBt.style.visibility = "visible";
					}
				}
			}	
		else {
			if ( (currPage == 1) && (demoName != 'intro') && (demoName != 'noscript' ) && (demoName != 'moreinfo') ) {
				prevScriptIndex=demoScript.item(demoCntr-1).getElementsByTagName('PAGE').length;
				prevScriptName=demoScript.item(demoCntr-1).getElementsByTagName('DEMONAME').item(0).firstChild.data;
// Since we are skipping 'salespivot' when going forward, we have to skip 'salespivot' when going backward
// Setting prevScriptIndex and prevScriptName to go backward by 2 demos
				if ( (prevScriptName=='salespivot') ) {
					prevScriptIndex=demoScript.item(demoCntr-2).getElementsByTagName('PAGE').length;
					prevScriptName=demoScript.item(demoCntr-2).getElementsByTagName('DEMONAME').item(0).firstChild.data;
					}
				backBt.style.visibility = "visible";
				if (currPage < pageCount){
					nextScriptIndex = currPage + 1;
					nextScriptName = demoName ;
//					continBt.style.visibility = "visible";
					}
				else {
					if (currDemo < demoCount) {
						nextScriptIndex = 1;
						nextScriptName = demoScript.item(demoCntr+1).getElementsByTagName('DEMONAME').item(0).firstChild.data;
						continBt = eval(" document.all.continueBtn");
						continBt.style.visibility = "visible";
						}
					else {
						if (demoScript.item(demoCntr+1)==null){
// This means you have reached the end of the demo		
							LastPage='Y';	
							continBt = eval(" document.all.continueBtn");
							continBt.style.visibility = "hidden";
							}
						}
					}
				}
			}
		}
	}
	 MENUFORM.nextScriptIndex.value=nextScriptIndex;
	 MENUFORM.nextScriptName.value=nextScriptName;
	 MENUFORM.prevScriptIndex.value=prevScriptIndex;
	 MENUFORM.prevScriptName.value=prevScriptName;
}

function validateSalesPivot() {
if ( (document.RUNFORM.BDATE.value == 'All') && (document.RUNFORM.EDATE.value != 'All') ){
	alert("You selected 'All' for the Beginning Date but not for the Ending Date.  Please change your selection and press Run.");
	return false
	}
else if ( (document.RUNFORM.BDATE.value != 'All') && (document.RUNFORM.EDATE.value == 'All') ) {
	alert("You selected 'All' for the Ending Date but not for the Beginning Date.  Please change your selection and press Run.");
	return false
	}
else if (document.RUNFORM.EDATE.value < document.RUNFORM.BDATE.value) {
	alert("The Ending Date must be greater than or equal to the Beginning Date.  Please change your selection and press Run.");
	return false
	}
	
}

function resize() {
	if ((screen.availWidth > 900) && (screen.availHeight > 600)) {
// 1024 x 768 or Higher Resolution Settings
// Setting Century Corp Logo
	if (document.ExecSummary!=null){
//		 document.all.ScriptFrameNM.style.height="256px";
		}
// Resize script text and Links index category (e.g., sales, quality, hr)
	var PNodes = document.getElementsByTagName('p')
	var max = PNodes.length
	for(var i = 0;i < max;i++)
	   {
	   var nodeObj = PNodes.item(i)
	   nodeObj.style.fontSize = '10pt';
	   }
// Resize Links index
	var tableNodes = document.getElementsByTagName('TABLE')
	var max = tableNodes.length
	for(var i = 0;i < max;i++)
	   {
	   var nodeObj = tableNodes.item(i) 
	   nodeObj.style.fontSize = '10pt';
	   }

// Resize Forms SELECT text
	var selectNodes = document.getElementsByTagName('select')
	var max = selectNodes.length
	for(var i = 0;i < max;i++)
	   {
	   var nodeObj = selectNodes.item(i)
	   nodeObj.style.fontSize = '10pt';
	   }

// Resize Forms INPUT SELECT text
	var inputNodes = document.getElementsByTagName('input')
	var max = inputNodes.length
	for(var i = 0;i < max;i++)
	   {
	   var nodeObj = inputNodes.item(i)
	   nodeObj.style.fontSize = '10pt';
	   }
// Position script text box
 	var divNodes = document.getElementsByTagName('div') ;
	var max = divNodes.length
	for(var i = 0;i < max;i++)
	   {
	   var nodeObj = divNodes.item(i) ;
	   if (nodeObj.id =='DemoScript') 
	   	{
	   	nodeObj.style.pixelTop = 20 ;
	   	}
	   }
	}
	else {
// 800 x 600 Resolution Settings
// Setting Century Corp Logo
// Resize demo title (e.g., Sales Ranking, Sales Trend, etc)
// Resize script text and Links index category (e.g., sales, quality, hr)
// Position script text box
	var divNodes = document.getElementsByTagName('DIV')
	var max = divNodes.length
	for(var i = 0;i < max;i++)
	   {
	   var nodeObj = divNodes.item(i)
	   nodeObj.style.pixelTop = 50 ;
//	   nodeObj.style.pixelTop = 268 ;
	   nodeObj.style.width = '100%' ;
	   }

	}

} 
// end function resize
// -->
