
function CheckInput(pageId) {
	var target = '';
	selected = '';
	arSymbols = '';
	bLookup = false;
	var urlre = /^http/;
	
	if (urlre.test(pageId)) 
	{
		var headlinesurlre = /^http:\/\/www\.nasdaq\.com\/aspxcontent\/newsHeadlines\.aspx$/;
		var nasdaq100re = "http://www.nasdaq.com/quotedll/quote.dll?page=nasdaq100";
		var nasdaqf100re = "http://www.nasdaq.com/quotedll/quote.dll?page=nasdaqf100";
		var indure = "http://www.nasdaq.com/quotedll/quote.dll?page=indu";
		//if this is true then we are going to a static page
		//the pageId will be the url for the new page


		if(headlinesurlre.test(pageId))
		{
		
			
			quoteBoxNumSymbols = document.quotenav.selected.length;
	
			for (i=0;i<quoteBoxNumSymbols;i++)
			{
				quoteBoxSymbolArray[i] = document.quotenav.selected.options[i].value;
			}
			
				//headlines is a special case set selected to 9999
				//remember the selected symbol by its index
				var selectedIndex = document.quotenav.selected.selectedIndex;
				//document.quotenav.selected.options[selected].value = '9999';
				window.location.href = pageId+"?sel_sym_number="+selectedIndex+"&symbol=" + quoteBoxSymbolArray.join('&symbol=') + "&selected=9999";
				return;
			
		}
		//index flashquotes
		//if this is the target, add a custom page parameter to the querystring

		else if(nasdaq100re == pageId)
		{
			window.location.href = pageId;
			return;
		}

		else if(nasdaqf100re == pageId)
		{
			window.location.href = pageId;
			return;
		}

		else if(indure == pageId)
		{
			window.location.href = pageId;
			return;
		}
	} 
	else
	{   
		quoteBoxSelectedSymbol = document.quotenav.selected.value;
		if (document.getElementById("quotepage").value == 'NasdaqLastsale')
		{
			window.location.href = wwwURL + 'aspx/nasdaqlastsale_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'nlstrades')
		{
			window.location.href = wwwURL + 'aspx/nlstrades_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'quick') 
		{
			window.location.href = wwwURL + 'aspx/flashquotes_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			//window.location.href = 'http://quotes.nasdaq.com/quotedll/quote.dll?mode=stock&page=quick&symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'multi') 
		{
			window.location.href = 'http://quotes.nasdaq.com/quotedll/quote.dll?mode=stock&page=multi&symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'summaryquote')
		{
		
			window.location.href = 'http://quotes.nasdaq.com/asp/SummaryQuote_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;																					
		}
		else if (document.getElementById("quotepage").value == 'charting') 
		{
			
			if(myPage != "charting")
			{
				window.location.href = wwwURL + 'aspx/chartingbasics_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
				return;
			}
			else
			{
				var chartingOptions="";
				//carry over user parameters
				if(document.quotenav.intraday.value!="")
					chartingOptions += "&intraday="+document.quotenav.intraday.value;

				if(document.quotenav.timeframe.value!="")
					chartingOptions += "&timeframe="+document.quotenav.timeframe.value;

				if(document.quotenav.charttype.value!="")
					chartingOptions += "&charttype="+document.quotenav.charttype.value;
	
				if(document.quotenav.splits.value!="")
					chartingOptions += "&splits="+document.quotenav.splits.value;

				if(document.quotenav.comparison.value!="")
					chartingOptions += "&comparison="+document.quotenav.comparison.value;

				if(document.quotenav.movingaverage.value!="")
					chartingOptions += "&movingaverage="+document.quotenav.movingaverage.value;

				if(document.quotenav.lowerstudy.value!="")
					chartingOptions += "&lowerstudy="+document.quotenav.lowerstudy.value

				window.location.href = wwwURL + 'aspx/chartingbasics_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol + chartingOptions;
				return;
			}
		}
		else if(document.getElementById("quotepage").value == 'dynamic_charting')
		{
			window.location.href = wwwURL + 'aspx/dynamic_charting_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'redpage') 
		{
			window.location.href = wwwURL + 'aspx/revenueepssummary_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'full')
		{
			window.location.href = wwwURL + 'asp/ExtendFund_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'competitor')
		{
			window.location.href = quoteURL + 'screening/viewcompetitors_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'short') 
		{
			window.location.href = wwwURL + 'aspxcontent/shortinterests_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'news')
		{
			window.location.href = wwwURL + 'asp/quotes_news.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'companynews')
		{
			window.location.href = wwwURL + 'aspxcontent/newsheadlines_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'companypressrelease')
		{
			window.location.href = wwwURL + 'aspxcontent/newsheadlines_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol + "&SourceCode=PMZ";
			return;
		}		
		else if (document.getElementById("quotepage").value == 'analystinfo')
		{
			window.location.href = earningsURL + 'earnings/analyst_summary_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;			
		}
		else if (document.getElementById("quotepage").value == 'stockreports')
		{
			window.location.href = wwwURL + 'asp/quotes_reports_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'annualrpt') 
		{
			window.location.href = wwwURL + 'asp/quotesannualreportlink_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		// filings
		else if (document.getElementById("quotepage").value == 'holdingssummary')
		{
			window.location.href = earningsURL + 'asp/holdings_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'holdings') 
		{
			window.location.href = earningsURL + 'asp/holdings_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol + "&FormType=Institutional";
			return;
		}
		else if (document.getElementById("quotepage").value == 'insiderform4')
		{
			window.location.href = earningsURL + 'asp/holdings_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol + "&FormType=form4";
			return;
		}
		else if (document.getElementById("quotepage").value == 'insiderform144')
		{
			window.location.href = earningsURL + 'asp/holdings_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol + "&FormType=form144";
			return;
		}
		else if (document.getElementById("quotepage").value == 'companyfilings' || document.getElementById("quotepage").value == 'filings')
		{
			window.location.href = earningsURL + 'asp/quotes_sec_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'options')
		{
			window.location.href = quoteURL + 'aspxcontent/options_new.aspx?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
		else if (document.getElementById("quotepage").value == 'stockconsultant') 
		{
			window.location.href = wwwURL + 'asp/stock_consultant_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
	    }
		else if (document.getElementById("quotepage").value == 'guruanalysis')
		{
			window.location.href = wwwURL + 'asp/guruanalysis_new.asp?symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
		}
	    else if (document.getElementById("quotepage").value == 'afterhours')
		{
			if(quoteBoxNumSymbols>1)
				window.location.href = quoteURL + 'aspxcontent/ExtendedTradingTrades_new.aspx?selected=' + quoteBoxSelectedSymbol + '&mkttype=after&symbol=' + quoteBoxSymbolArray.join('&symbol=');
			else
				window.location.href = quoteURL + 'aspxcontent/ExtendedTradingTrades_new.aspx?selected=' + quoteBoxSelectedSymbol + '&mkttype=after';
			return;
		}
		else if (document.getElementById("quotepage").value == 'premarket') 
		{
			if(quoteBoxNumSymbols>1)
				window.location.href = quoteURL + 'aspxcontent/ExtendedTradingTrades_new.aspx?selected=' + quoteBoxSelectedSymbol + '&mkttype=pre&symbol=' + quoteBoxSymbolArray.join('&symbol=');
			else
				window.location.href = quoteURL + 'aspxcontent/ExtendedTradingTrades_new.aspx?selected=' + quoteBoxSelectedSymbol + '&mkttype=pre';
			return;
	    } 
		else if (document.getElementById("quotepage").value == 'afterhourscharts') 
		{
			window.location.href = quoteURL + 'aspxcontent/ExtendedTradingCharts_new.aspx?mkttype=after&symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
	    }
	 	else if (document.getElementById("quotepage").value == 'premarketcharts') 
		{
	        window.location.href = quoteURL + 'aspxcontent/ExtendedTradingCharts_new.aspx?mkttype=pre&symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
			return;
        }

		// set target
		if (myPage == 'fundamentalcharts')
		{
			if(document.getElementById("quotepage").value == 'fundamentalcharts')
				document.quotenav.target = '_parent';
			else
				document.quotenav.target = 'ParentWin';
				
		}
		else 
		{
			if(target == '')
				document.quotenav.target = '_parent';
			else
				document.quotenav.target = target;
		}

		//document.quotenav.submit();
		if (myPage == 'fundamentalcharts' && document.quotenav.page.value != 'fundamentalcharts')window.parent.close();
		
	}
}

function editSymbols()
{
		if (myPage == 'fundamentalcharts' || myPage == 'stockconsultant')
				document.quotenav.target = 'ParentWin';
			else
				document.quotenav.target = '_parent';

		//collect the symbols
		var quoteBoxSymbolArray = new Array();
		var quoteBoxSelectedSymbol;
		var temp;
		var quoteBoxNumSymbols;
		var quoteBoxSelectedIndex;
		
		quoteBoxNumSymbols = document.quotenav.selected.length;

		quoteBoxSelectedSymbol = document.quotenav.selected.value;

		quoteBoxSelectedIndex = document.quotenav.selected.selectedIndex;

		for (i=0;i<quoteBoxNumSymbols;i++)
		{
			quoteBoxSymbolArray[i] = document.quotenav.selected.options[i].value;
			//move selected to the first entry in the array
			if(i==quoteBoxSelectedIndex && i!=0)
			{
				//store selected
				temp = quoteBoxSymbolArray[i];
				//swap
				quoteBoxSymbolArray[i] = quoteBoxSymbolArray[0];
				quoteBoxSymbolArray[0] = temp;
			}
		}
		page = "page="+document.getElementById("quotepage").value; //add the page parameter
		path = "&pathname="+window.location.pathname; //add the pathname parameter
		window.location.href = quoteURL + 'asp/MasterDataEntry.asp?'+page+path+'&symbol=' + quoteBoxSymbolArray.join('&symbol=') + "&selected=" + quoteBoxSelectedSymbol;
		if(myPage=='fundamentalcharts' || myPage == 'stockconsultant')window.parent.close();
}

function open_new_window(url, width, height, statusbar, scrollbar, menubar) {
    window.name = "ParentWin";
    window.open(url, "newWin", "menubar="+(menubar?"yes":"no")+",toolbar=0,location=0,directories=0,copyhistory=0,scrollbars="+(scrollbar?"yes":"no")+",resizable=yes,status="+(statusbar?"yes":"no")+",width="+width+",height="+height);

}


function readResults(){
	readStockResults();
	return;
}

function readStockResults(){
		var result = window.frames["validateSymbolForm"].document.body.innerHTML.split('|');
		// [0] - symbol
		// [1] - is valid symbol?
		// [2] - is new symbol?
		// [3] - new symbol
		// [4] - change date.

		if(result[1].toLowerCase()=='true'){
				displaySymbolInfo(result[0]);
		} else if(result[2].toLowerCase()=='true'){
				alert(result[0] + ' is changed to ' + result[3] + ' on ' + result[4]);
				displaySymbolInfo(result[3]);
		} else {
				alert(result[0] + ' is Not a Valid Symbol');
				document.frmAddASymbol.symbol.value = '';
				document.frmAddASymbol.symbol.focus();
		}
	 return;
}

function displaySymbolInfo(symbol){
		
		var newIndex = document.quotenav.selected.length;
		var tempA;
		var tempB;
		if(newIndex==25){
				alert('Can not add more than 25 symbols. Please use Edit Symbol List to edit your symbol list.');
				return false;
		}
		
		
		//add a new option at the end
		document.quotenav.selected.options[newIndex] = new Option(symbol,symbol);
		document.quotenav.selected.options[newIndex].selected = true;
		quoteBoxSymbolArray.unshift(symbol);//add to first element in array
		CheckInput();

}


function isDuplicate(newSymbol){
		newSymbol = newSymbol.toUpperCase();
		for (var t=0;t<document.quotenav.selected.length;t++){
				if (document.quotenav.selected.options[t].value.toUpperCase() == newSymbol){
						return true;
				}
		}
	return false;
}

function selectSymbol(sym)
{
	document.quotenav.selected.value = sym;
	CheckInput();
}



function isSymbolInListbox(newSymbol){
		for (var t=0;t<document.quotenav.selected.length;t++){
				if (document.quotenav.selected.options[t].value.toUpperCase() == newSymbol.toUpperCase()){
						alert(newSymbol + ' already selected. Please enter another symbol.');
						document.frmAddASymbol.symbol.value = '';
						document.frmAddASymbol.symbol.focus();
						return true;
				}
		}
	return false;
}

function trimSymbol(str){
    return str.replace(/^\s*/, '').replace(/\s*$/, '');
}


function validateSymbol(){
		var url;
		var newSymbol = document.frmAddASymbol.symbol.value.toUpperCase();
		var str;
		newSymbol = trimSymbol(newSymbol);
		if (newSymbol=='') 
		{
            alert('Please enter a symbol and reselect the add button');
			document.frmAddASymbol.symbol.value = '';
			document.frmAddASymbol.symbol.focus();
   		   return false;
        }
		if(isDuplicate(newSymbol)) 
		{
			selectSymbol(newSymbol)
		}
		else
		{
			url = quoteURL + 'aspx/ValidateSymbol.aspx?mode=stock';
			url += '&selected=' + newSymbol;

			document.getElementById("validateSymbolForm").src = url;//calls readResults()
		}

		return false;
}


function CheckInput2(navigation) 
{
	var SymbolLookup = quoteURL + 'asp/NasdaqSymLookup.asp?parentLocation=window.opener.document.quotenav.userinput.value';
	
	if (navigation == 'symbollookup')	{
				//quotenav.action = SymbolLookup;
     
      open_new_window(SymbolLookup, 380, 340, false,true, false);
      
		
	}
     
}

//called from NasdaqSymLookup.asp
function AddSymbol(symbol) 
{
	if(isDuplicate(symbol))
	{
		selectSymbol(symbol);
	}
	else
	{
		displaySymbolInfo(symbol);
		alert(symbol + " has been added to your symbol list");
	}
}

function ShowELSSymbol(symbol)
{
	document.location.href = "http://www.nasdaq.com/aspx/els.aspx?selected="+symbol;
}

function initWidget()
		{
			
            selectPage();
			loadSymbols();
			//updateCookie();
			return;
		}

		function selectPage()
		{
			var currentPage;
			var newsIndex;
			for(var i=0;i<document.getElementById("quotepage").length;i++)
			{
				currentPage = document.getElementById("quotepage").options[i].value; 
				if(currentPage == myPage)
				{
					document.getElementById("quotepage").options[i].selected = true;
					return;
				}
				if(currentPage == "companynews")
					newsIndex = i;
			}
			
			//misc. news pages

			if(myPage == 'companynewsthestreet' || myPage == 'companynewsthefool')
				document.getElementById("quotepage").options[newsIndex].selected = true;
			return;
		}

var quoteBoxSelectedSymbol; //selected symbol
var quoteBoxSymbolArray = new Array(0); //symbol list
var quoteBoxNumSymbols;
var removedCookieSyms = new Array();//removed list

		function loadSymbols()
		{
			
			
			
			var symbol;
			var query = window.location.search.substring(1);
			
			var params = query.split('&');
			var j = 0;
			var bHasASymbol = false;
			var bHasASelected = false;
			var sel_sym_number = 0;

			for (var i=0;i<params.length;i++)
			{
				symbol = params[i].split('=');
				if (symbol[0].toLowerCase() == 'qm_symbol' && symbol[1] != null && symbol[1].length > 0)
				{
					bHasASelected = true;
					selected = symbol[1].toUpperCase();
					selected = unescape(trimTick(selected));
					quoteBoxSelectedSymbol = selected;
				}
				else if (symbol[0].toLowerCase() == 'selected' && symbol[1] != null && symbol[1].length > 0)
				{
					bHasASelected = true;
					selected = symbol[1].toUpperCase();
					selected = unescape(trimTick(selected));
					quoteBoxSelectedSymbol = trimTick(selected);
				}
				else if (symbol[0].toLowerCase() == 'symbol' && symbol[1] != null && symbol[1].length > 0 && j < 25)
				  {
						if (!isDuplicate(symbol[1]))
						{
							bHasASymbol = true;
							symbol[1] = unescape(trimTick(symbol[1]));
							var myOption = new Option(symbol[1].toUpperCase(),symbol[1].toUpperCase());
							document.quotenav.selected.options[j] = myOption;
							quoteBoxSymbolArray[j] = symbol[1].toUpperCase();
							j++;
						}
					}
				else if (symbol[0].toLowerCase() == 'formtype' && myPage == 'filings')
				{
						var holdingspage;
						if(symbol[1].toLowerCase() == 'form4')
								holdingspage = 'insiderform4';
						else if(symbol[1].toLowerCase() == 'form144')
								holdingspage = 'insiderform144';
						else if(symbol[1].toLowerCase() == 'institutional')
								holdingspage = 'holdings';
						else
								holdingspage = 'holdingssummary';

						for(var k=0;i<document.getElementById("quotepage").length;k++)
						{
							if(document.getElementById("quotepage").options[k].value == holdingspage)
							{
								document.getElementById("quotepage").options[k].selected = true;
								break;
							}
						}
				}
				else if (symbol[0].toLowerCase() =='mkttype' && myPage =='afterhours')
				{
					if (symbol[1].toLowerCase() == 'after')
					{
						document.quotenav.mkttype.value='after';
					}else
					{
						document.quotenav.mkttype.value='pre'
					}
				}
				else if (symbol[0].toLowerCase() == 'intraday' && symbol[1] != null && symbol[1].length > 0)
				{
						document.quotenav.intraday.value=symbol[1];
				}
				else if (symbol[0].toLowerCase() == 'timeframe' && symbol[1] != null && symbol[1].length > 0)
				{
						document.quotenav.timeframe.value=symbol[1];
				}
				else if (symbol[0].toLowerCase() == 'charttype' && symbol[1] != null && symbol[1].length > 0)
				{
						document.quotenav.charttype.value=symbol[1];
				}
				else if (symbol[0].toLowerCase() == 'splits' && symbol[1] != null && symbol[1].length > 0)
				{
						document.quotenav.splits.value=symbol[1];
				}
				else if (symbol[0].toLowerCase() == 'earnings' && symbol[1] != null && symbol[1].length > 0)
				{
						document.quotenav.earnings.value=symbol[1];
				}
				else if (symbol[0].toLowerCase() == 'movingaverage' && symbol[1] != null && symbol[1].length > 0)
				{
						document.quotenav.movingaverage.value=symbol[1];
				}
				else if (symbol[0].toLowerCase() == 'lowerstudy' && symbol[1] != null && symbol[1].length > 0)
				{
						document.quotenav.lowerstudy.value=symbol[1];
				}
				else if (symbol[0].toLowerCase() == 'comparison' && symbol[1] != null && symbol[1].length > 0)
				{
						document.quotenav.comparison.value=symbol[1];
				}
				else if (symbol[0].toLowerCase() == 'index' && symbol[1] != null && symbol[1].length > 0)
				{
						document.quotenav.index.value=symbol[1];
				}
				else if (symbol[0].toLowerCase() == 'sel_sym_number')
						sel_sym_number = symbol[1];
				
			}

			if (!bHasASymbol && bHasASelected)//no symbols, only a selected; add selected as a symbol
				{
						var myOption = new Option(selected.toUpperCase(),selected.toUpperCase());
						document.quotenav.selected.options[0] = myOption;
						//document.getElementById("quoteboxsymbol0").value = selected;
						document.quotenav.selected.options[0].selected = true;
						quoteBoxSymbolArray[j] = quoteBoxSelectedSymbol;
				}
			else
			{
				
				if(selected!='9999')
					for (i=0;i<document.quotenav.selected.length;i++)
					{
						if (document.quotenav.selected.options[i].value == selected)
						{
							document.quotenav.selected.options[i].selected = true;
							break;
						}
					}
				else
				{
					//if selected is '9999' this is news headlines page
					//set the selected symbol by the 'sel_sym_number' url parameter
					document.quotenav.selected.options[sel_sym_number].selected = true;
				}
			}
			quoteBoxNumSymbols = quoteBoxSymbolArray.length;
			return;
		}

		function trimTick(tmpSym)
		{
			var	myLen = tmpSym.length;

			if (tmpSym.indexOf('`') > 0)
				tmpSym = tmpSym.substr(0, eval(myLen - 1));

			if (tmpSym.indexOf('%60') > 0)
				tmpSym = tmpSym.substr(0, eval(myLen - 3));

			return tmpSym;
		}


//this function overrides the default page's loadPage() function
//if we're on a quote page, navigation should take us to a 
//quote page, not data entry page

function loadPage(pageId)
{
		if(pageId == "After Hours Market")
		{
			document.getElementById("quotepage").value = "afterhours";
			quotenav.mkttype.value = 'after';
		}
		else if(pageId == "Pre-Market")
		{
			quotenav.mkttype.value = 'PRE';
			document.getElementById("quotepage").value = "premarket";
		}
		else if(pageId == "companyfilings")
		{
			document.getElementById("quotepage").value = "filings";
		}
		else 
			document.getElementById("quotepage").value = pageId;

		CheckInput(pageId);//pass through the page ID in case we're going to a static page
}

function updateCookie()
{
	var page = document.getElementById("quotepage").value;

	if(page=="NasdaqLastsale" || page=="quick")
		return;// flash quotes and real time already do this so exit

	var params = document.location.search.substring(1);
	var paramsList = params.split('&');
	var is_bareSymArray = new Array();
	var current, is_selectedSymbol, index=0;
	is_selectedSymbol = get_querystring_value("selected").toUpperCase();
	

	if(navigator.cookieEnabled)
	{

		for(i=0;i<paramsList.length;i++)
		{
			current = paramsList[i].split('=');
			if(current[0]=='symbol')
			{
				if(index<25)
				{
					is_bareSymArray[index] = current[1].toUpperCase();
					index++;
				}
			}
		}

		var total = is_bareSymArray.length;
	
		if(document.cookie.indexOf("userSymbolList=")!=-1 || document.cookie.indexOf("newquick=")!=-1)
		{
					
			var i,j,unique=true,duplicates=0,first=true;
			if(document.cookie.indexOf("userSymbolList=")!=-1)//new cookie present, this is priority
			{
				i = document.cookie.indexOf("userSymbolList=")+15;
				j = document.cookie.indexOf(";",i);
			}
			else //old cookie
			{
				i = document.cookie.indexOf("newquick=")+9;
				j = document.cookie.indexOf(";",i);
			}
						
			if(j==-1)  //symbol list string is at the end of the cookie for some reason
				j = document.cookie.length;
			var list = unescape(document.cookie.substring(i,j));
			//var list = "aapl&dell&msft&ndaq";
			//alert("list at startup: " + list);
				
			if(list.search("&")>-1) //multiple symbols are present and split to form an array
			{
				var symbols = list.split("&");
			}
			else //only one symbol present in cookie, create an array to process
			{
				var symbols = new Array(1);
				symbols[0]=list;
			}
			var count = 0,reTest;
			for(i=0;i<symbols.length;i++)
			{
				symbols[i]=symbols[i].toUpperCase();
				for(j=0;j<is_bareSymArray.length;j++)
				{
					if ( (is_bareSymArray[j]) && (is_bareSymArray[j] != ''))
					{
						if(is_bareSymArray[j].toUpperCase()==symbols[i]) //this is already entered in querystring
						{                           //duplicated symbols are removed from the cookie symbol list      
													//since all querystring symbols are added back at the end
							unique=false;
									
						 	if(list.search("&"+symbols[i]+"&")>-1) //matched symbol is located after first and before the last
							{
								list=list.replace("&"+symbols[i]+"&","&");
								//alert("replaced1");
							}
							else  
							{
								reTest = new RegExp("^"+symbols[i]+"&");
								if(list.search(reTest)>-1) //matched symbol is first in cookie
								{
									list=list.replace(reTest,"");
								}
								else
								{
									reTest = new RegExp("&"+symbols[i]+"$");
									if(list.search(reTest)>-1) //matched symbol is last in cookie
									{
										list=list.replace(reTest,"");
									}
									else  //symbol is only on in the list, clear it
									{
										list="";
									}
								}
							}
							break;
						}
					}
				}
				if(!unique)
					duplicates++;
					
				unique=true;
							
			}
					
			j = symbols.length - duplicates; //# of unique cookie symbols
			if((total+j)>25) //truncate list if > 25 total
			{	
				if(symbols.length>1)
				{
					j = total + j - 25;//total # to be removed
					for(i=0;i<j;i++)
					{
						last = list.lastIndexOf("&");
						if(last != -1)
							list=list.slice(0,last); //remove oldest symbol from list
						else
							list = ""; //only 1 symbol left and being removed so now old list is empty
					}
				}
				else
					list="";
					
			}

			for(j=is_bareSymArray.length-1;j>=0;j--) //build new list for cookie
			{
				if ( (is_bareSymArray[j]) && (is_bareSymArray[j] != ''))
				{
					for(i=0;i<=j;i++)
					{
						if ( (is_bareSymArray[i]) && (is_bareSymArray[i] != '') && (i!=j) && (is_bareSymArray[i].toUpperCase()==is_bareSymArray[j].toUpperCase() ) )
						{ //this symbol was duplicated by the user, avoid storing duplicates in cookie
							if(i<j)
								is_bareSymArray[j]="";
							else
								is_bareSymArray[i]="";
							break;
						}
					}
					if(is_bareSymArray[j]!="")
					{
						if(list!="")
							list = is_bareSymArray[j].toUpperCase().concat("&"+list);
						else
							list = is_bareSymArray[j].toUpperCase();
			    	}
				}		
			}
			var exdate=new Date();
			exdate.setDate(exdate.getDate()+1);//expires in two weeks

			document.cookie="userSymbolList="+list+";expires="+exdate+";path=/;domain=nasdaq.com";

		}
		else //cookies are enabled but nothing stored yet
		{
			var list="";
			var j,count;
			count=is_bareSymArray.length;
			if(count>0)
			{
				for(j=count-1;j>=0;j--)
				{
					if ( (is_bareSymArray[j]) && (is_bareSymArray[j] != ''))
					{
						if(list!="")
							list = is_bareSymArray[j].toUpperCase().concat("&"+list);
						else
							list = is_bareSymArray[j].toUpperCase();
					}
				}
			
			var exdate=new Date();
			exdate.setDate(exdate.getDate()+1);//expires in two weeks

			document.cookie="userSymbolList="+list+";expires="+exdate+";path=/;domain=nasdaq.com";
			//document.cookie="newquick="+list+";expires="+exdate+";path=/;domain=www.nasdaq.com";
			//store first list
			}
		}
					
	}//cookies not enabled
				
}





var linkIndex = -1;
var currentPages;
var nlsquotesPages = new Array();
var flashquotesPages = new Array();
var infoquotesPages = new Array();
var summaryquotesPages = new Array();
var newsPages = new Array();
var chartsPages = new Array();
var researchPages = new Array();
var fundamentalsPages = new Array();
var holdingsPages = new Array();
var optionsPages = new Array();

//these pages will highlight the 'quotes' tab
//mypage var, link label, and load page var
//flash quotes tab

nlsquotesPages[0] = new Array('nlstrades','NLS Trade Reporting</a><span style="color: #fa9e0d; text-decoration: none;">&nbsp;&nbsp;New!</span>','nlstrades');
nlsquotesPages[1] = new Array('afterhours','After Hours Quotes','afterhours');
nlsquotesPages[2] = new Array('premarket','Pre-Market Quotes','premarket'); 
nlsquotesPages[3] = new Array('','NASDAQ-100','http://www.nasdaq.com/quotedll/quote.dll?page=nasdaq100'); 
nlsquotesPages[4] = new Array('','NASDAQ Financial-100','http://www.nasdaq.com/quotedll/quote.dll?page=nasdaqf100'); 
nlsquotesPages[5] = new Array('','DJIA','http://www.nasdaq.com/quotedll/quote.dll?page=indu'); 

flashquotesPages[0] = new Array('afterhours','After Hours Quotes','afterhours');
flashquotesPages[1] = new Array('premarket','Pre-Market Quotes','premarket'); 
flashquotesPages[2] = new Array('','NASDAQ-100','http://www.nasdaq.com/quotedll/quote.dll?page=nasdaq100'); 
flashquotesPages[3] = new Array('','NASDAQ Financial-100','http://www.nasdaq.com/quotedll/quote.dll?page=nasdaqf100'); 
flashquotesPages[4] = new Array('','DJIA','http://www.nasdaq.com/quotedll/quote.dll?page=indu'); 

//info quotes tab
infoquotesPages[0] = new Array('afterhours','After Hours Quotes','afterhours');
infoquotesPages[1] = new Array('premarket','Pre-Market Quotes','premarket');
infoquotesPages[2] = new Array('','NASDAQ-100','http://www.nasdaq.com/quotedll/quote.dll?page=nasdaq100'); 
infoquotesPages[3] = new Array('','NASDAQ Financial-100','http://www.nasdaq.com/quotedll/quote.dll?page=nasdaqf100'); 
infoquotesPages[4] = new Array('','DJIA','http://www.nasdaq.com/quotedll/quote.dll?page=indu'); 

//summary quotes tab
summaryquotesPages[0] = new Array('afterhours','After Hours Quotes','afterhours');
summaryquotesPages[1] = new Array('premarket','Pre-Market Quotes','premarket'); 
summaryquotesPages[2] = new Array('','NASDAQ-100','http://www.nasdaq.com/quotedll/quote.dll?page=nasdaq100'); 
summaryquotesPages[3] = new Array('','NASDAQ Financial-100','http://www.nasdaq.com/quotedll/quote.dll?page=nasdaqf100'); 
summaryquotesPages[4] = new Array('','DJIA','http://www.nasdaq.com/quotedll/quote.dll?page=indu'); 

//news tab - no sub nav links
newsPages[0] = new Array('companynews','Company News','companynews');


//charts tab - no sub nav links
chartsPages[0] = new Array('charting','Company Charts','charting');
chartsPages[1] = new Array('dynamic_charting','Interactive Stock Charts</a><span style="color: #fa9e0d; text-decoration: none;">&nbsp;&nbsp;New!</span>','dynamic_charting');

//Stock Analysis tab
researchPages[0] = new Array('analystinfo','Analyst Stock Research','analystinfo');
researchPages[1] = new Array('guruanalysis','Guru Analysis','guruanalysis');
//researchPages[2] = new Array('sector','Stock Sector','');
researchPages[2] = new Array('stockreports','Stock Report','stockreports');
researchPages[3] = new Array('competitor','View Competitors','competitor');

//fundamentals tab
fundamentalsPages[0] = new Array('full','Financials','full');
fundamentalsPages[1] = new Array('redpage','Revenue/EPS','redpage');
fundamentalsPages[2] = new Array('filings','Real Time SEC Filings','filings');
fundamentalsPages[3] = new Array('short','Short Interest','short');

//holdings tab
holdingsPages[0] = new Array('holdingssummary','Holdings Summary (Ownership)','holdingssummary');
holdingsPages[1] = new Array('holdings','Detailed Institutional Holdings','holdings');
holdingsPages[2] = new Array('insiderform4','Insider Form 4','insiderform4');

//options tab - no sub nav links
optionsPages[0] = new Array('quickoptions','','');
optionsPages[1] = new Array('options','','');
optionsPages[2] = new Array('optionmulti','','');
optionsPages[3] = new Array('optionsdisplay','','');



function getNavId()
{
    //find out which quotes tab should be highlighted
	//by checking each section's array against myPage var
	//set the linkLabel var to the current page name
	var i;
	var page;
	if(myPage == 'NasdaqLastsale' || myPage == 'nlstrades')
	{
		if(myPage == 'nlstrades')
			linkIndex = 0;
		currentPages = nlsquotesPages;
		return 'nlsquotesnav';
	}

	if(myPage == 'afterhours' || myPage == 'premarket')
	{
		var previousPage = get_querystring_value("prevPage");
		
		if(previousPage == false)
		{
			currentPages = nlsquotesPages;
			page = 'nlsquotesnav';
		}
		else
		{
			switch(previousPage)
			{
				case "quick":	currentPages = flashquotesPages;
								page = 'flashquotesnav';
								break;

				case "multi":	currentPages = infoquotesPages;
								page = 'infoquotesnav';
								break;

				case "summaryquote":currentPages = summaryquotesPages;
									page = 'summaryquotesnav';
									break;

				case "NasdaqLastsale": currentPages = nlsquotesPages;
								page = 'nlsquotesnav';
								break;
			}
		}

		if(myPage == 'afterhours')
			linkIndex = 1;
		else
			linkIndex = 2;
		return page;
	}

	if(myPage == 'quick' || myPage == 'premarketcharts' || myPage == 'afterhourscharts')
	{
		currentPages = flashquotesPages;
		return 'flashquotesnav';
	}

	if(myPage == 'multi')
	{
		currentPages = infoquotesPages;
		return 'infoquotesnav';
	}

	if(myPage == 'summaryquote')
	{
		currentPages = summaryquotesPages;
		return 'summaryquotesnav';
	}
	
	
	for(i=0;i<newsPages.length;i++)
		if(myPage == newsPages[i][0])
		{
			currentPages = newsPages;
			if(newsPages[i][1]!='')
				linkIndex = i;
			return 'newsnav';
		}

	if(myPage == "companynews" || myPage == "companypressrelease" || myPage == "companynewsthefool" || myPage == "companynewsthestreet" || myPage == "companynewsstory" || myPage == "marketnews" || myPage == "sentiment") 
	{
		currentPages = newsPages; //just set quote section
		return 'newsnav'
	}

	for(i=0;i<chartsPages.length;i++)
		if(myPage == chartsPages[i][0])
		{
			currentPages = chartsPages;
			if(chartsPages[i][1]!='')
				linkIndex = i;
			return 'chartsnav';
		}

	for(i=0;i<researchPages.length;i++)
		if(myPage == researchPages[i][0])
		{
			currentPages = researchPages;
			if(researchPages[i][1]!='')
				linkIndex = i;
			return 'researchnav';
		}

	for(i=0;i<fundamentalsPages.length;i++)
		if(myPage == fundamentalsPages[i][0])
		{
			currentPages = fundamentalsPages;
			if(fundamentalsPages[i][1]!='')
				linkIndex = i;
			return 'fundamentalsnav';
		}

	for(i=0;i<holdingsPages.length;i++)
		if(myPage == holdingsPages[i][0])
		{
			currentPages = holdingsPages;
			if(holdingsPages[i][1]!='')
				linkIndex = i;
			return 'holdingsnav';
		}

	for(i=0;i<optionsPages.length;i++)
		if(myPage == optionsPages[i][0])
		{
			currentPages = optionsPages;
			if(optionsPages[i][1]!='')
				linkIndex = i;
			return 'optionsnav';
		}
	
	return false;
}

function getQuotePageVar(quotePageName)
{
	switch(quotePageName)
			{
				case 'flashquotesnav': return "quick";

				case 'infoquotesnav':	return "multi";

				case 'summaryquotesnav':return "summaryquote";

				case 'nlsquotesnav': return "NasdaqLastsale";
			}
}







