﻿//************************************************************************************* 
// File     :   graph.js
// Requires :   swfobject.js
// Author   :   Rusty Swayne (rss)
// Origin   :   mindfly.com
// Purpose  :   Embed the graph
//*************************************************************************************

// wta - disable enter key from submitting the form
//     - instead will display the graph

document.onkeypress = keyPressHandler;

if (document.layers) 
    document.captureEvents(Event.KEYPRESS);

function checkIfSingleDayCheckBoxIsChecked()
{
    return document.forms[0].checkShowSingleDay.checked ? "true" : "false";
}

function keyPressHandler(e) 
{
    var keyPressed = e ? e.which : window.event.keyCode;
    
    if (keyPressed == 13)
    {
        event.cancel = true;
        setGraph("1193", document.getElementById("textStartDate").value, checkIfSingleDayCheckBoxIsChecked());
    }
    
    return keyPressed != 13;
}

// wta - modified to pass in date for dynamic display
function setGraph(id, startDate, singleDay)
{
    if (startDate.length == 0 || startDate == "")
        return;
        
    var queryStringValue = id + "|" + startDate + "|" + singleDay;
        
    var flashObject = new SWFObject("/Controls/fcp-line-chart.swf?xml_file=/Controls/XmlData.aspx?graphValues=" + queryStringValue, "movie", "620", "480", "6", "#fdfbf3");  
    flashObject.write("graph");
    
    document.getElementById("graphDetails").style.display = '';
}
