/* javascript functions for full text search */

// True only for pages that have auto-refresh set up, like in play.
var isAutoRefreshPage = false;

		function FullTextSearchLoad()
		{	
		    var buttonsVisible = true;
			var siteSource = getElement('SiteSource').value;			
			
			if (siteSource == 'Investor') 
			{
				toggleGoldIndexButton('NavigationGoldIndexBox');
				preloadImages();
			} 
			else //Platinum/Trader
			{ 
			    var showButtons = getElement('ShowButtons').value;
			    if (showButtons == '0') 
			    {
			        //hide buttons			        
			        getElement('mainButtonDivId').innerHTML = '';
			        buttonsVisible = false;			        
			    } 
			    else 
			    {
			        //show the buttons			        
			        getElement('mainButtonDivId').style.visibility = 'visible';
			        buttonsVisible = true;			        
			    }
			}
			var initialLoad = getElement('InitialLoad').value; 			
			
			if (initialLoad == 'true') 
			{
				//check if SearchText is supplied in the query string
				// split the query string into an array of pairs:
				var href = document.location.href;
				var pos = href.indexOf("SearchText=")
				if (pos >= 0) {
					initialLoad = 'false';
					getElement('InitialLoad').value = 'false';
				}	
			}	
			//if this is initial load hide all the tab control buttons	
			if (initialLoad == 'true') 
			{
				getElement('InitialLoad').value = 'false';		
			} 
					
			if (initialLoad != 'true') 
			{
				var activeTabButtonId = getElement('PageName').value; 
				var prevActiveTabButtonId = getElement('LastPageName').value; 	
				if (buttonsVisible) 
				{
				    getElement(prevActiveTabButtonId).className = 'NormalTabButtonStyle';
				    getElement(activeTabButtonId).className = 'ActiveTabButtonStyle';
				}
				if (getElement('PageName').value == 'InPlay') 
				{
					getElement('SearchPageName').innerHTML = "-&nbsp;In Play<sup>&#174;</sup>"
				} 
				else 
				{
					getElement('SearchPageName').innerHTML = "-&nbsp;" + getElement(activeTabButtonId).value;    
				}
			}			
		}
		 
		function KeyDownHandler(btn)
		{
			// process only the Enter key
			if (event.keyCode == 13)
			{
				// cancel the default submit
				event.returnValue=false;
				event.cancel = true;
				// submit the form by programmatically clicking the specified button
				btn.click();
			}
		}
		 
		function HandleMouseOver(tabButtonId)
		{	 
			getElement(tabButtonId).className = 'MouseOverTabButtonStyle';	 
		}

		function HandleMouseOut(tabButtonId)
		{	
			getElement(tabButtonId).className = 'NormalTabButtonStyle';			
			if (getElement('PageName').value != getElement('LastPageName').value) 
			{
				var activeTabButtonId = getElement('PageName').value;
				getElement(activeTabButtonId).className = 'ActiveTabButtonStyle';
			}
		}

		function TabButtonClicked(tabButtonId, btn)
		{
			//get previous active tab id
			var previousActiveTabButtonId = getElement('PageName').value;
			getElement('LastPageName').value = previousActiveTabButtonId;	
			getElement('PageName').value = tabButtonId;
			// cancel the default submit
			event.returnValue=false;
			event.cancel = true;
			// submit the form by programmatically clicking the specified button
			btn.click();
		}

		function getElement(id) 
		{ 
			var element = null; 
		  
			if( document.getElementById ) 
				element = document.getElementById(id); 
			else 
				if( document.all ) 
					element = document.all[id]; 
			return element; 
		} 
