   var url='http://www.flyzone.com/base/pro/2008/8/3/G-COL-FLA.jf';   var lines;   var updateLegendTimeout;   var mousePosition;    function doHoverClear(){   doHover(mousePosition); }  var homeName="Home"; var visName="Visitor";  function extractNames(lines){    if (lines[1].indexOf('H:')>=0){       homeName=lines[1].substring(lines[1].indexOf('H:')+2,lines[1].indexOf('}'));       }    if (lines[2].indexOf('H:')>=0){       homeName=lines[2].substring(lines[2].indexOf('H:')+2,lines[2].indexOf('}'));       }     if (lines[1].indexOf('V:')>=0){       visName=lines[1].substring(lines[1].indexOf('V:')+2,lines[1].indexOf('}'));       }    if (lines[2].indexOf('V:')>=0){       visName=lines[2].substring(lines[2].indexOf('V:')+2,lines[2].indexOf('}'));       } }   function doHover(i){    var parts=lines[i].split(',');    var tx='<i>'+parts[0]+'</i>';    $('#atbat').html(tx);    $('#action').html(parts[4]);     $('#pitcher').html(parts[15]);     $('#outs').html(parts[10]);     $('#strikes').html(parts[8]);     $('#balls').html(parts[9]);     $('#result').html(parts[14]);    $('#onfirst').text(parts[1]);    $('#onsecond').text(parts[2]);    $('#onthird').text(parts[1]);       $('#score').html(parts[7]+'-'+parts[6]);         }  function fetchFile(url){   $.get( url, {},     function(data){ splitFile( data ); }); }  function doInnings(lines, max){    var ans=[];    for (var i=1;i<lines.length;i++){      var parts=lines[i].split(',');      if (parts[12]=='H'){         ans.push([i-1,max]);      } else {         ans.push([i-1,0]);      }    }    if (parts[12]=='H'){         ans.push([i,max]);      } else {         ans.push([i,0]);      }        return ans; }  function doInningTicks(lines, max){    var ans=[];    var last='H';    var count=1;    for (var i=1;i<lines.length;i++){      var parts=lines[i].split(',');      if ((parts[12]!=last) && (parts[12]=='V')){         ans.push([i-1, ''+count]);         count++;      }       last=parts[12];    }            return ans; }      function splitFile(d){   var homeScore=[];   var visScore=[];    lines=d.split('\n');    extractNames(lines);   var parts;   for (var i=0;i<lines.length;i++){    if (lines[i].length>5){     parts=lines[i].split(',');           homeScore.push([i,parts[6]]);          visScore.push([i,parts[7]]);          }   }   var max=parseInt(parts[6]);   var other=parseInt(parts[7]);   if (other>max){      max=other;   }      var inn=doInnings(lines,max);   var innTicks=doInningTicks(lines,max);          $.plot($("#placeholder"), [        {             data: inn,                          bars: { show: true, lineWidth:0, fill: true },             hoverable: false,             color: "#11aa11"         },          {             data: homeScore,             label: homeName,             lines: { show: true, fill: false, lineWidth:8, color: "#ff0000" }         },          {             data: visScore,             label: visName,             lines: { show: true, fill: false, lineWidth:8,color: "#0000ff" }         }                         ]     , { grid: { hoverable: true, color: "#ffff33" } , crosshair: { mode:"x" }, colors: ["#d11111", "#1111ee", "#919733"],     yaxis:{ticks: [0, 1, 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27] }     ,xaxis:{ticks: innTicks},     legend:{position:"nw", backgroundOpacity:0.2, color:"#000000"} }     );         $("#placeholder").bind("plothover", function (event, pos, item) {        // alert("You clicked at " + pos.x + ", " + pos.y);         // secondary axis coordinates if present are in pos.x2, pos.y2,         // if you need global screen coordinates, they are pos.pageX, pos.pageY                  mousePosition=Math.round(pos.x);          $('#dataWindow').css('left',''+pos.pageX+'px');         $('#dataWindow').css('top',''+pos.pageY+'px'); 		//if (!updateLegendTimeout)          //   updateLegendTimeout = setTimeout(doHoverClear, 50); 		doHover(mousePosition);         if (item) {           // doHover(item.dataIndex);           //highlight(item.series, item.datapoint);          // alert("You clicked a point!");         }     });   }      var root='http://www.flyzone.com/base/pro/';   function loadItem(item){    var u="'"+item.link.replace("-D.html",".jf")+"'";    var i=item.link.replace("-D.html",".gif").replace("G-","T-G-");    //var x='<li><div class="arrow" onclick="fetchFile('+u+')">'+item.title+'</div></li>';     var x='<li><a class="flip" href="#graph" onclick="fetchFile('+u+')">'+item.title+'</a> </li>';     var x1='<li><a class="flip" href="#graph" onclick="fetchFile('+u+')">'+item.title+'<br><img src="'+i+'"></a> </li>'  	$('#games').append(x1); }   function loadDate(date){   var url=root+date+'/proscore.rss';   jQuery("#games").html("...loading...");   jQuery.getFeed({        url: url,        success: function(feed) {            jQuery("#games").html("");            for (var i=0;i<feed.items.length;i++){              loadItem(feed.items[i]);            }         },         failure: function (feed){            jQuery("#games").html("No Games Found");         },          error: function (XMLHttpRequest, textStatus, errorThrown){            jQuery("#games").html("No Games Found"); // note this needs a fix to jFeed!         }    });   }  function loadFeed(feed){   }   $(function () {     fetchFile(url); });  $('#defaultInlineDatepicker').datepick( {onSelect: function(date) { loadDate(date); },      showOn: 'both', buttonImageOnly: true, buttonImage: 'calendar.gif',dateFormat:'yy/m/d'}); 
