//###If you wish you can remove all comments from your copy.
//###Start Feature Switching.
//toolTipsMovingMethod = true //true : The tooltips are on and will follow the mouse.
//zoomLinesMethod = true  //true : Zoomlines switched on for all browsers
//dragMethodDisabled = false  //(false adds functionality) true : Zooming can only occur by clicking letting go, moving and reclicking. not dragging (defaults to true for all but IE)
//msgUsingWriteToDiv = false //true : messages appear in a js alert.  Defaults to messages returned to div errorDiv.
//autoCalcContainerDivOffset = true //should always be true. requires a containAllGraphElementsDiv.
//reloadLocationSelf = true //true : reload location becomes self rather than top.
setDefaultsForMaxFeatures() //Set's the above 6
//toolTipsMovingBoundedMethod = true //true : tooltips will not extend outside the graph image div area.
//toolTipsStaticMethod = true  //true : tooltips are on but are stationary (also requires toolTipsMovingMethod = false and a div with id tooltipsDivStatic).
//steplineMethodCheckbox = true //true : required if you have a stepline checkbox.
//steplineMethodRadio = true //true : required if you have stepline/normal radio buttons.
//steplineMethodSelect = true //true : required if you have stepline/normal radio select's
//steplineRadioSelectIndex = 0 //0 or 1. which way round are your normal/stepline radios/selects.
//tooltipDivLineMethod = false //true : ???
//###End Feature Switching.

//###Start Config Values.
tooltipsHTMLBefore = '<table border="0" cellspacing="1" cellpadding="2" style="background-color: #006496"><tr><td style="font-family: Arial, sans-serif; font-size:11px; background-color: #F8F9FB; color: #006496"><nobr>'//style the tooltips
tooltipsHTMLAfter = '<span id="tooltipsDivWidthFinder" style="position:relative; left:0px; top:0px; width:0px; height:0px; z-index:5; visibility:visible;"></span></nobr></td></tr></table>'

//defaultReturnPeriod = 4 //index of default select period (note that the first is 0)
//lineThicknessX = 1 //reset's the width of the vertical zoom bars to this many px.
//lineThicknessY = 1 //reset's the height of the horizontal zoom bar(s) to this many px.
//###End Config Values.

function ggPageOnload(){
  //All page specific onloads must go in here. This is called by onloadAllGG()
}
//NOTE::No need to set up comparisons anymore as long as they are named comparison1, comparison2 etc...

//###Start Rarely Use.
//vars controlling the swapping of text to Day Close
//You'll want to alter these if your intraday graph isn't for the LSE or specifically
//if it shows times that don't start at 8:00 and end at 16:30 (excluding day close point).
//dayOpenTimeSecs = (8 * 60 * 60) //Change to equal the number of minutes till the start of the plotting
//dayCloseTimeSecs = (((16 * 60) + 30) * 60)//Change to equal the number of minutes till the end of the plotting
//tooltipsStaticHTMLBefore = '' //if toolTipsStaticMethod = true text before tooltip info in tooltipsDivStatic.
//tooltipsStaticHTMLAfter = '' //if toolTipsStaticMethod = true text after tooltip info in tooltipsDivStatic.
//setTimeoutDisplay = 0 //delay tooltips from appearing 
//setTimeoutHide = 0 //delay tooltips from hiding
//setLineTimeoutDisplay = 0 
//setLineTimeoutHide = 0 
//###End Rarely Use.

//###Start Other Features.
//Features not included in this js include;
//defaultIdentifier - allow any companys data
//Price and volume in tooltip
//###End Other Features.

function submitForm(){
var chart_Form = document.getElementById("chartForm");

  needToCorrectDate = false
  newUrl=returnUrlStart()
  newUrl+=returnDefaultIdentifier()
  var period = chart_Form.period.options[chart_Form.period.options.selectedIndex].value;
  if (period == "-") {
    returnCorrectDateStr = returnCorrectDateFormItems('from','to','/')
    if(returnCorrectDateStr){
      newUrl += returnCorrectDateStr
      newUrl += getReturnPeriod()
    } else {
      needToCorrectDate = true
    }
  } else {
    newUrl += '&period=' + period;                      
  }
  if(!needToCorrectDate){
    newUrl += getFormParams()
    goToGraphURL(newUrl);
  }
}

function getReturnPeriod(){
var chart_Form = document.getElementById("chartForm");

  periodSelected = chart_Form.period.options.selectedIndex;
  if(returnPeriod == ''){returnPeriod = periodSelected}
  if(returnPeriod != defaultReturnPeriod && returnPeriod != 0){
    return '&returnPeriod=' + returnPeriod
  } else {
    return ''
  }
}

function getAxis(){
var chart_Form = document.getElementById("chartForm");

  tempNewUrlAxis = ''
  if(chart_Form.horizontalGridlines.checked == true){tempNewUrlAxis += '&horizontalGridlines=false'}
  if(chart_Form.verticalGridlines.checked == true){tempNewUrlAxis += '&verticalGridlines=false'}
  if(chart_Form.noVolumes.checked == true){tempNewUrlAxis += '&noVolumes=true'}
  return tempNewUrlAxis
}

function getComparisons(){
  var comparisons = "";
  var chart_Form = document.getElementById("chartForm");
  
  for(i=1; chart_Form["comparison"+i]; i++){
    if(chart_Form["comparison"+i].checked == true){if(comparisons != ""){comparisons += ","} comparisons += chart_Form["comparison"+i].value}
  }
  if(comparisons != ""){comparisons = '&comparisons=' + comparisons}
  return comparisons
}

function resetDate(){
  var chart_Form = document.getElementById("chartForm");
  hideZoomDivs()
  inZoomCycle = false
  chart_Form.period_param.options.selectedIndex = returnPeriod
  submitForm()
}

function submitForm(){
  var chart_Form = document.getElementById("chartForm");
  
  needToCorrectDate = false
  newUrl=returnUrlStart()
  newUrl+=returnDefaultIdentifier()
  var period = chart_Form.period_param.options[chart_Form.period_param.options.selectedIndex].value;
  if (period == "-") {
    returnCorrectDateStr = returnCorrectDateFormItems('from','to','/')
    if(returnCorrectDateStr){
      newUrl += returnCorrectDateStr
      newUrl += getReturnPeriod()
    } else {
      needToCorrectDate = true
    }
  } else {
    newUrl += '&period_param=' + period;  
  }
  if(!needToCorrectDate){
    newUrl += getFormParams()
    goToGraphURL(newUrl);
  }
}

function getReturnPeriod(){
  var chart_Form = document.getElementById("chartForm");
  
  periodSelected = chart_Form.period_param.options.selectedIndex;
  if(returnPeriod == ''){returnPeriod = periodSelected}
  if(returnPeriod != defaultReturnPeriod && returnPeriod != 0){
    return '&returnPeriod=' + returnPeriod
  } else {
    return ''
  }
}

function resetPeriod(){
  var chart_Form = document.getElementById("chartForm");
  chart_Form.period_param.options.selectedIndex = 0
}

function onloadAllGG(){
  giveImageImgMap()
  ggPageOnload()
  nsCaptureEvents()
  setLineThickness()
  requiredMouseEvents()
  setupBoundedMethod()
  resetZoomMessage()
  //hideTooltipsTrStatic()
}