//this js file contains the methods and vars for the marketsnapshot
var chartImageNames, chartImages, chartHref;
var nCurIndex = 0;
var DQPage = "/DelayedQuote/QuoteTable.aspx?TICKER=";
var DQPage1 = "/DelayedQuote/SimpleQuote.aspx?TICKER=";

function InitCharts(){
  if(document.images) {
    chartImageNames = new Array();
    for(i = 0; i < ChartInit.length; i++){
      chartImageNames[i] = chartImageURL + ChartInit[i][1] + "&includeintraday=" + ChartInit[i][3];
    }

    chartImages = new Array()

    for (i=0;i<chartImageNames.length;i++) {  // Cache the images here
      chartImages[i] = new Image
      chartImages[i].src = chartImageNames[i]
    }

    //now set up initial chart
    document.chartImage.src = chartImages[0].src

    chartHref = new Array();
    for(i = 0; i < ChartInit.length; i++){
	    chartHref[i] = "/DelayedQuote/" + ChartInit[i][2] + ".aspx?TICKER=" + ChartInit[i][1];
    }
  }
}
//functions
  function showChart(iIndex) {
    // (display a frame of the animation)
    nCurIndex = iIndex;
    if (chartImages[iIndex] != null) {
      document.chartImage.src = chartImages[iIndex].src
    }
  }
  function GoToCharPage(iIndex)
  {
    if (chartImages[iIndex] != null) {
      top.window.location = chartHref[iIndex];
    }
  }

function CreateButtons(){
	document.write('<TABLE cellspacing="0" cellpadding="0">');
        for(y = 0; y < numOfCols; y++){
		document.write('<TR>');
		for(x = 0; x < rowLen; x++){
			var itemIndex = (y*rowLen) + x;
			document.write('<td font-size: 11px; onclick="javascript:GoToCharPage('+ itemIndex +');" onMouseOver="javascript:showChart('+ itemIndex +')" class="blueButtonSnapShot" align="center">' + ChartInit[itemIndex][0] + '</TD>');
		}
		document.write('</TR>');
		}
	document.write('</TABLE>');
}