function IsValidTicSym(StrVar)
{
	var strLength = StrVar.length;
	var integers = "0123456789 ~!@#$%^&*()-=+|<>,/?'\"\\[]{}";
	
	var Flag="T";
	for(i=strLength-1; i>=0; i--)
	{ 	 
		if (integers.indexOf(StrVar.charAt(i)) != -1)
		{
			Flag = "F";
			break;
		}
	}

	if(Flag=="F") 
		return false;
	else 
		return true;	
}

function validateTickerSymbol(tickerValue)
{	
	var temp	 = new String();
	var finalval = new String();
	var ticValue = new String(tickerValue + ",");
	var iLength = ticValue.length;

	for (var iInitialValue =0; iInitialValue < iLength ; iInitialValue ++)
	{
		var singleValue = ticValue.charAt(iInitialValue);
		if ( singleValue != ',')
		{
			temp+= singleValue;
		}
		else {
			if(IsValidTicSym(temp))
			{
				if (finalval.length > 0)
				{
					finalval = finalval + "," + temp;
				} else {
					finalval = temp;
				}
			}
			temp="";				
		}
	}
	return finalval;
}

function getQuickQuote()
{
  try
  {
	if (SYMLIST != null && typeof(SYMLIST) != 'undefined')
	{
		
		var noOfTicSym = SYMLIST.length;	
		if (SYMLIST != null && SYMLIST != "")
		{
			if ( noOfTicSym <= 1 )
			{
				var tempLength = tick0[0];//SYMLIST[0][0];
				if(tempLength != null && typeof(tempLength) != 'undefined')
				{
					var ticSym = tick0[6];//SYMLIST[0][6];
					var varLink = "/about/listed/lcddata.html?ticker="+ticSym;
					//location.href(varLink); 
					window.location.href=varLink;

				}
				else
				{					
					document.write("<div class='sp5'>");
					document.write("<table width='368' border='0' cellspacing='0' cellpadding='0'>");
					document.write("<tr>");
					document.write("<td colspan='2' height='20'><span class='error'><b>There were no matches to your search. Please try again.</b></span></td>");
					document.write("</tr>");
					document.write("<table>	");
					document.write("</div>");					
				}

			}
			else 
			{			
				document.write("<TABLE cellpadding='0' cellspacing='0' border='0' width='368'>");	
				document.write("<TR>");
				document.write("<TD >");
				document.write("NOTE: Market data delayed 20 min.");
				document.write("</TD>");
				document.write("</TR>");
				document.write("</TABLE>");

				document.write("<div class='sp10'>");
				document.write("<TABLE width='358' cellpadding='0' cellspacing='0'>");

				document.write("<TR>");
				document.write("<TD width='58' height='22' class='gratopleft' rowspan='2' >Symbol</TD>");
				document.write("<TD width='186' class='gratopleft' colspan='3' align='center' >Last Trade</TD>");
				document.write("<TD width='124' class='gratopright' colspan='2' align='center' >Change</TD>");
				document.write("</TR>");
				document.write("<TR>");
				document.write("<TD width='62' class='grabotleft' align='center'>Price</TD>");
				document.write("<TD width='62' class='grabotleft' align='center'>Date/Time</TD>");
				document.write("<TD width='62' class='grabotleft' align='center'>Volume</TD>");
				document.write("<TD width='65' class='grabotleft' align='center'>Price</TD>");
				document.write("<TD width='62' class='grabotright' align='center'>Percentage</TD>");
				document.write("</TR>");

				for(var iValue=0; iValue< noOfTicSym; iValue++) 
				{
					var tempticker = eval("tick"+iValue);
					var sign	   = "";
					var css_class  = "";
					var tempLength = tempticker[0];//SYMLIST[iValue][0];
					
					if(tempLength != null && typeof(tempLength) != 'undefined')
					{
						var ticSym     = tempticker[6];//SYMLIST[iValue][6];
						var ticSymName  = tempticker[6];//SYMLIST[iValue][6];	
						var price	   = tempticker[14];//SYMLIST[iValue][14];
						price		 = fnRound(price,2);  	
						var time	   = tempticker[11];//SYMLIST[iValue][11];
						var cur_volume = tempticker[18];//SYMLIST[iValue][18];
						var pre_volume = tempticker[12];//SYMLIST[iValue][12];
						var price1     = tempticker[19];//SYMLIST[iValue][19];
						var flag	   = tempticker[20];//SYMLIST[iValue][20];
						var volume	   = "";
						var cur_change = tempticker[19];//SYMLIST[iValue][19];	
						var pre_change = tempticker[45];//SYMLIST[iValue][45];	
						var change	   = "";	
						var percentage = tempticker[36];//SYMLIST[iValue][36];	
						percentage	   = fnRound(percentage,2);												
						ticSymName = fnReplace(ticSymName,'_','.');

						if(time == "00:00")
						{
							volume = pre_volume;
							change = fnRound(pre_change,2);
							price1 = Math.abs(pre_change);
							percentage = getPercentage(price,price1,flag);
							percentage = fnRound(percentage,2);							
						}
						else {
							volume = cur_volume;	
							change = fnRound(cur_change,2);	
						}					

						if (flag == "d")
						{
							sign = "-";
							css_class = "red";
						} 
						else if(flag == "u") 
						{ 
							sign = "+";
							css_class = "green";
						}
					
						document.write("<TR>");									
						document.write("<TD width='58' class='grabotleftyel'><A href='/about/listed/lcddata.html?ticker="+ ticSym +"'>" + getDisplayNameTicker(ticSymName) + "</A></TD>");

						document.write("<TD width='62' align='right' class='grabotleftyel' >" + price + "</TD>");
						document.write("<TD width='62' align='center' class='grabotleftyel'>" + time + "</TD>");
						document.write("<TD width='62' align='right' class='grabotleftyel'>" + volume + "</TD>");
						if (change == "n/a")
						{	
							document.write("<TD width='65' align='right' class='grabotleftyel'>" + change + "</TD>");	
						}
						else {
							document.write("<TD width='65' align='right' class='grabotleftyel'>" + sign + change + "</TD>");	
						}
						if (percentage == "n/a")
						{	
							document.write("<TD width='62' align='right' class='grabotrightyel'>" + percentage + "</TD>");
						}
						else {
							document.write("<TD width='62' align='right' class='grabotrightyel'><span class='" + css_class + "'>"+ percentage +" % </span></TD>");
						}						
						document.write("</tr>"); 
					}
				}
				document.write("</table>");
				document.write("</div>");			
			}
		}
		else
		{					
			document.write("<div class='sp5'>");
			document.write("<table width='368' border='0' cellspacing='0' cellpadding='0'>");
			document.write("<tr>");
			document.write("<td colspan='2' height='20'><span class='error'><b>There were no matches to your search. Please try again.</b></span></td>");
			document.write("</tr>");
			document.write("<table>	");
			document.write("</div>");					
		}
	}
	else
	{					
		document.write("<div class='sp5'>");
		document.write("<table width='368' border='0' cellspacing='0' cellpadding='0'>");
		document.write("<tr>");
		document.write("<td colspan='2' height='20'><span class='error'><b>There were no matches to your search. Please try again.</b></span></td>");
		document.write("</tr>");
		document.write("<table>	");
		document.write("</div>");					
	}
  } catch (exception){}
}

//Added on 07/Oct/2005

function replacePeriod(ticker) {

	var returnVal="";
	var temp = new Array();
	tokens = ticker.split(',');
	for(var i=0;i<tokens.length;i++){
		var sym = tokens[i].toUpperCase();
		try{
			var remDot=fnReplace(sym,'.','');
			var newQuote=eval('t_'+remDot);
			if(newQuote)
				retTicker=remDot;
				
		}catch(ex){
			retTicker=fnReplace(sym,'.','_');
		}

		returnVal=returnVal+","+retTicker;
			
	}//for
	
	returnVal = returnVal.substring(1);
	return returnVal;
}

