//DO NOT CUSTOMISE THIS FILE.
//ALL JAVASCRIPT CUSTOMISATION SHOULD BE POSSIBLE BY USING THE gg_*.js FILE.
//IF ADDITIONAL CUSTOMISATION IS REQUIRED ALTER THIS FILES TO ALLOW CUSTOMISATION IN THE gg_*.js FILE.
//(OR ASK PHIL HANNA TO.)
//IF YOU WANT TO MAKE CHANGES FOR A COMPANY OR PRODUCT COPY THE FUNCTIONS YOU NEED INTO gg_*.js AND ALTER THEM THERE.
//ONLY DO THIS WITH FUNCTION THAT INTERACT WITH YOUR PAGE THOUGH. NEVER COPY AND REWRITE FUNCTIONS THAT DO CALCULATIONS. THEY WORK AND DONT WANT TO BE CHANGED.
//DO NOT COPY onloadAllGG() THOUGH. EVER.
//IT SHOULD NEVER BE NECCESSARY TO COPY THIS FILE. (unless you have say 2 graphs on the same actual page, but when is that likely).

//For NS4
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//Variables
agt = navigator.userAgent.toLowerCase()
mac=(agt.indexOf('mac')!=-1)?true:false
verReal = navigator.appVersion
verFloat = parseFloat(verReal)
app = navigator.appName.toLowerCase()
ie = (agt.indexOf('msie') != -1 || agt.indexOf('microsoft') != -1)?true:false
//Since version 5.5 of IE there's been a miss calculation of offsetTop(offsetLeft)/offsetParent resulting in a doubling of the true figure.
//Below we assume the bug continues in ie7+.  If it doesn't some zoom lines will be miss placed so an extra condition should be added to the below.
autoCalcContainerDivOffsetBuggy =  (ie && verFloat >= 5.5)?true:false 

//change in gg_*.js
setTimeoutDisplay = 0;
setTimeoutHide = 0;
setLineTimeoutDisplay = 0;
setLineTimeoutHide = 0;
toolTipsMovingMethod = document.all ? true : false//Note 7
if(mac){toolTipsMovingMethod = false}
toolTipsMovingBoundedMethod = false
tooltipDivLineMethod = false
toolTipsStaticMethod = false//Note 7 + Note 8
zoomLinesMethod = document.all ? true : false
steplineMethodCheckbox = false
steplineMethodRadio = false
steplineMethodSelect = false
steplineRadioSelectIndex = 1
isGraphDivRelative = false//for NS
autoCalcContainerDivOffset = false
reloadLocationSelf = false
msgUsingWriteToDiv = true
defaultReturnPeriod = 4
graphAreaOffsetY = -48
earliestDateYear = false
earliestDateMonth = false
earliestDateDay = false
comparisonsAsSeperate = false

function getPreFloatMsg(){
  return "A date entered is prior to the company's floatation on " + earliestDateDay + "/" + earliestDateMonth + "/" + earliestDateYear
}
//vars controlling the swapping of text to Day Close
dayOpenTimeSecs = (8 * 60 * 60)
dayCloseTimeSecs = (((16 * 60) + 30) * 60)
intervalTimeSecs = 5 * 60 //sometimes the first point isn't plotted because of the graph size so wait for second point.
dayCloseLateTimeSecs = 5 * 60

function setDefaultsForMaxFeatures(){
  toolTipsMovingMethod = true
  zoomLinesMethod = true 
  dragMethodDisabled = false
  msgUsingWriteToDiv = false
  autoCalcContainerDivOffset = true
  reloadLocationSelf = true
}

//unused function values check and remove.
var tday = 0;
var tmonth = 0;
var tyear = 0;

lineThicknessX = 1
lineThicknessOffsetX = (lineThicknessX + 1)/2//note: reset at onload

lineThicknessY = 1
lineThicknessOffsetY = (lineThicknessY + 1)/2

//xsl js vars initialised. Can't old xsl's have gifgraph.js before the so this declaration redeclares them.
/*startX = 0;
endX = 0;
startDateMs = 0;
endDateMs = 0;
duration = endDateMs - startDateMs;
msPerPixel = duration / (endX - startX);
periodParam = ''
returnPeriod = '';
fromParam = ''
toParam = ''
yearMinus10 = 0
whenyear = 0
comparisonsParam = ''
hLinesParam = ''
vLinesParam = ''
chartSrc = ''
steplineParam = '' 
urlStart = ''*/

//best to leave these.
onlyDragZoom = 0
nsAndRelative = 0
currentGraphDivXToDocument = -100
nsRelGraphDivToDocX = 0
nsRelGraphDivToDocY = 0
documentOffsetFix = 0
dragMethodDisabled = ((document.getElementById && !document.all) || document.layers) ? 1 : 0

onGraphAreaOfDiv = 0
//Only required for IE.
if(ie && !mac){
  documentOffsetFix = 2
}
instructionOnZoomUseStr = 'Drag and release to zoom'
function resetZoomMessage(){
  if(dragMethodDisabled){
    instructionOnZoomUseStr = 'Click, move and click to zoom'
  }
}

inZoomCycle = false
mouseUpedWhileOutside = false
graphDivVar = 'graphDiv'
startShowZoomDivVar = 'startShowZoomDiv'
endShowZoomDivVar = 'endShowZoomDiv'
dragShowZoomDivVar = 'dragShowZoomDiv'
startShowZoomVolumeDivVar = 'startShowZoomVolumeDiv'
endShowZoomVolumeDivVar = 'endShowZoomVolumeDiv'
dragShowZoomVolumeDivVar = 'dragShowZoomVolumeDiv'
tooltipsDivVar = 'tooltipsDiv'
tooltipsLineDivVar  = 'tooltipsLineDiv'
tooltipsLineDivVolumeVar  = 'tooltipsLineVolumeDiv'
tooltipsDivStaticVar = 'tooltipsDivStatic'
containOverGraphElementsDivVar = 'containOverGraphElementsDiv'
function returnUrlStart(){
  return urlStart
}
function returnDefaultIdentifier(){
  return ''
}
function writeToDiv(whichDiv,whatText){
  if(document.getElementById){
    document.getElementById(whichDiv).innerHTML = whatText
  } else if(document.all){
    document.all(whichDiv).innerHTML = whatText
  } else if (document.layers){
    nsWriteToDivWidth = '440'//Note the next few lines differes from standard by additions.
    whatTextBefore = '<div id="nsRelativeFixDiv" style="position:absolute; left:0px; top:0px; width:'+nsWriteToDivWidth+'; height:1; z-index:1; visibility: visible;" class="textsmallprintbold">'
    whatTextBefore += '<font style="font-family: Verdana, Arial, sans-serif; font-size:12px"><nobr>'
    whatTextAfter = '</nobr></font>'
    whatTextAfter += '</div>'
    whatText = whatTextBefore+whatText+whatTextAfter
    eval('document.'+whichDiv+'.document.open()');
    eval('document.'+whichDiv+'.document.write(\''+whatText+'\')');
    eval('document.'+whichDiv+'.document.close()');
  }
}
function doMsg(whatText){
  if(msgUsingWriteToDiv){
    setDivProperty('errorDiv','visibility','visible')
    writeToDiv('errorDiv',whatText)
  } else if(whatText != ''){
    alert(whatText)
  }
}
function clearMsg(){
  if(msgUsingWriteToDiv){
    writeToDiv('errorDiv','')
    setDivProperty('errorDiv','visibility','hidden')
  }
}
///TOOLTIPS.
tooltipsHTMLBefore = '<table border="0" cellspacing="0" cellpadding="1" style="background-color: #000000"><tr><td><table width="1" border="0" cellspacing="0" cellpadding="1" style="font-family: Verdana, Arial, sans-serif; font-size:10px; background-color: #ffcc99; color: #000066"><tr><td><nobr>'
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></td></tr></table>'
tooltipsHTMLLineBefore = ''
tooltipsHTMLLineAfter = ''

if(document.layers){
  tooltipsStaticHTMLBefore = '<font style="font-family: Verdana, Arial, sans-serif; font-size:12px; background-color: #ffcc99; color: #000066">'
  tooltipsStaticHTMLAfter = '</font>'
} else {
  tooltipsStaticHTMLBefore = ''
  tooltipsStaticHTMLAfter = ''
}

function imgMapTooltips1(e,whatText){
  settooltipsLineDivTop(e)
  if(!inZoomCycle){
    currentGraphDivXToDocument = getDivXToDocument(e)
    callTooltips(e,whatText)
    
  }
}

function imgMapTooltips2(e,whatText){
  if(!inZoomCycle){
    callTooltips(e,whatText)
  }
}

function callTooltips(e,whatText){
  if(toolTipsMovingMethod){
    tooltipsMouseDifX = 12
    tooltipsMouseDifY = 18
    if(toolTipsMovingBoundedMethod){
      writeToDiv(tooltipsDivVar,tooltipsHTMLBefore + whatText + tooltipsHTMLAfter)
      mousePos = mouseCoordsToDocument(e)
      boundarySizeX = parseInt(getDivProperty(graphDivVar,'width'))
      boundarySizeY = parseInt(getDivProperty(graphDivVar,'height'))
      tooltipsDivSizeX = document.getElementById("tooltipsDivWidthFinder").offsetLeft
      tooltipsDivSizeY = getDivProperty(tooltipsDivVar,'height')
      maxAllowableOffsetX = boundarySizeX - obtainOffsetX(e) - tooltipsDivSizeX
      maxAllowableOffsetY = boundarySizeY - obtainOffsetY(e) - tooltipsDivSizeY
      if(tooltipsMouseDifX > maxAllowableOffsetX){tooltipsMouseDifX = maxAllowableOffsetX}
      if(tooltipsMouseDifY > maxAllowableOffsetY){tooltipsMouseDifY = maxAllowableOffsetY}
      if(tooltipsMouseDifX <= 0 && tooltipsDivSizeX + tooltipsMouseDifX >= 0 && tooltipsMouseDifY <= 0 && tooltipsDivSizeY + tooltipsMouseDifY >= 0){
        tooltipsMouseDifX = - (tooltipsDivSizeX + 1)
        tooltipsMouseDifY = - (tooltipsDivSizeY + 1)
      }
      setDivProperty(tooltipsDivVar,'left',mousePos[0] + tooltipsMouseDifX)
      setDivProperty(tooltipsDivVar,'top',mousePos[1] + tooltipsMouseDifY)
      setTimeout("setDivProperty(tooltipsDivVar,'visibility','visible')",setTimeoutDisplay);
      
      if (tooltipDivLineMethod == 1) {
        tooltipsMouseDifX = -1
        tooltipsMouseDifY = 0

        //set up Price line
        setDivProperty(tooltipsLineDivVar,'top',midGraphDivY - parseInt(getDivProperty(tooltipsLineDivVar,'height'))/2 - graphAreaOffsetY)
        setDivProperty(tooltipsLineDivVar,'left',mousePos[0] + tooltipsMouseDifX)
        setTimeout("setDivProperty(tooltipsLineDivVar,'visibility','visible')",setLineTimeoutDisplay)


        //set up the volume bit
        setDivProperty(tooltipsLineDivVolumeVar,'top',midGraphDivY - parseInt(getDivProperty(tooltipsLineDivVolumeVar,'height'))/2 - volumeGraphAreaOffsetY)
        setDivProperty(tooltipsLineDivVolumeVar,'left',mousePos[0] + tooltipsMouseDifX)
        setTimeout("setDivProperty(tooltipsLineDivVolumeVar,'visibility','visible')",setLineTimeoutDisplay);
      }
      
    } else {
      mousePos = mouseCoordsToDocument(e)
      writeToDiv(tooltipsDivVar,tooltipsHTMLBefore + whatText + tooltipsHTMLAfter)
      setDivProperty(tooltipsDivVar,'left',mousePos[0] + tooltipsMouseDifX)
      setDivProperty(tooltipsDivVar,'top',mousePos[1] + tooltipsMouseDifY)
      setTimeout("setDivProperty(tooltipsDivVar,'visibility','visible')",setTimeoutDisplay);      
    }
    
  } else if(toolTipsStaticMethod){
    whatText = whatText.replace(/ /gi, '&#160;')
    writeToDiv(tooltipsDivStaticVar,tooltipsStaticHTMLBefore + whatText + tooltipsStaticHTMLAfter)
  }
}
function hideTooltips(){
  if(toolTipsMovingMethod){
    setTimeout("setDivProperty(tooltipsDivVar,'visibility','hidden')",setTimeoutHide);
  } else if(toolTipsStaticMethod){
    writeToDiv(tooltipsDivStaticVar,tooltipsStaticHTMLBefore + tooltipsStaticHTMLAfter)
  }
}
function setupBoundedMethod(){
  if(toolTipsMovingBoundedMethod){
    setDivProperty(tooltipsDivVar,'visibility','hidden')
    writeToDiv(tooltipsDivVar,tooltipsHTMLBefore + '' + tooltipsHTMLAfter)
  }
}
///////////////////////////////////////////////////////////////
function defineMouseEvents(divId,mEvent,callFunction){//NS4 NS 6/7 not IE5/6   Fixing would allow the removal of the onevents attributes in the div tags.
  /*if(document.getElementById){
    eval('document.getElementById(divId).' + mEvent + '= ' + callFunction)
  } else if(document.all){
    eval('document.all(divId).' + mEvent + '= ' + callFunction)
  } else*/ if (document.layers){
    eval('document.' + divId + '.' + mEvent + '= ' + callFunction)
  }
}
function nsCaptureEvents(){
  if (document.layers) { // NS needs to listen to the events explicitly
    //document.graphDiv.captureEvents(Event.DRAG);
    document.graphDiv.captureEvents(Event.DBLCLICK);
    document.graphDiv.captureEvents(Event.MOUSEDOWN);
    document.graphDiv.captureEvents(Event.MOUSEUP);
    document.graphDiv.captureEvents(Event.MOUSEMOVE);
    document.startShowZoomDiv.captureEvents(Event.DBLCLICK);
    document.startShowZoomDiv.captureEvents(Event.MOUSEUP);
    document.endShowZoomDiv.captureEvents(Event.DBLCLICK);
    document.endShowZoomDiv.captureEvents(Event.MOUSEDOWN);
    document.endShowZoomDiv.captureEvents(Event.MOUSEUP);
    document.endShowZoomDiv.captureEvents(Event.MOUSEMOVE);
    document.dragShowZoomDiv.captureEvents(Event.DBLCLICK);
    document.dragShowZoomDiv.captureEvents(Event.MOUSEDOWN);
    document.dragShowZoomDiv.captureEvents(Event.MOUSEUP);
    document.dragShowZoomDiv.captureEvents(Event.MOUSEMOVE);
  }
}
function obtainOffsetX(e){//IE5/6 IE4 NS6/7 NS4
  if(e.offsetX){
    return e.offsetX
  } else if(e.layerX){
    return e.layerX - nsRelGraphDivToDocX
  }
}
function obtainOffsetY(e){//IE5/6 IE4 NS6/7 NS4
  if(e.offsetY){
    return e.offsetY
  } else if(e.layerY){
    return e.layerY - nsRelGraphDivToDocY
  }
}
function setDivProperty(divId,propertyName,valueSetTo){//IE5/6 IE4  NS6/7 NS4
  if(propertyName == 'left'){
    containerDivOffSetXY = getContainerDivOffSet()
    valueSetTo -= containerDivOffSetXY[0]
  } else if(propertyName == 'top'){
    containerDivOffSetXY = getContainerDivOffSet()
    valueSetTo -= containerDivOffSetXY[1]
  }
  valueSetTo += addSizePx(propertyName)
  if(document.getElementById){
    if(divId == 'tooltipsLineDiv') {
      eval('document.getElementById(tooltipsLineDivVar).style.' + propertyName + '= "' + valueSetTo + '"')
    } else {
      eval('document.getElementById(divId).style.' + propertyName + '= "' + valueSetTo + '"')
    }    
  } else if(document.all){
    eval('document.all(divId).style.' + propertyName + '= "' + valueSetTo + '"')
  } else if (document.layers){
    propertyName = propertyNameNS(propertyName)//for differing names
    valueSetTo = valueSetToNS(valueSetTo)//for differing names
    eval('document.' + divId + '.' + propertyName + '= "' + valueSetTo + '"')
  }
}
function addSizePx(propertyName){
  if(document.getElementById && (propertyName == 'left' || propertyName == 'top' || propertyName == 'width' || propertyName == 'height')){
    return "px"
  } else {
    return ""
  }
}
function getDivProperty(divId,propertyName){//Depricated.  From now on for all numeric properties use getIntDivPropertyByObj
  if(document.getElementById){
    return eval('document.getElementById(divId).style.' + propertyName)
  } else if(document.all){
    return eval('document.all(divId).style.' + propertyName)
  } else if (document.layers){
    propertyName = propertyNameNS(propertyName)//for differing names
    valueSetTo = valueSetToNS(valueSetTo)//for differing names
    return eval('document.' + divId + '.' + propertyName)
  }
}
function getDivObject(divId){
  if(document.getElementById){
    return document.getElementById(divId)
  } else if(document.all){
    return document.all(divId)
  } else if (document.layers){
    return eval('document.' + divId)
  }
}

function mouseCoordsToDocument(e) {//works in everything.
  if( !e ) { e = window.event; }
  if( !e || ( typeof( e.pageX ) != 'number' && typeof( e.clientX ) != 'number' ) ) { var posX = 0; var posY = 0; }
  if( typeof( e.pageX ) == 'number' ) {
    var posX = e.pageX; var posY = e.pageY;
  } else {
    var posX = e.clientX; var posY = e.clientY;
    if( !( ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) || ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) || window.navigator.vendor == 'KDE' ) ) {
       if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) ) {
         posX += document.documentElement.scrollLeft; posY += document.documentElement.scrollTop;
       } else if( document.body && ( document.body.scrollTop || document.body.scrollLeft ) ) {
         posX += document.body.scrollLeft; posY += document.body.scrollTop;
       }
    }
  }
  return [posX - documentOffsetFix,posY - documentOffsetFix];//I added documentOffsetFix to this standardfunction as IE is 2 out.
}
//getIntDivPropertyByObj is often used to find positions or sizes.  
//In many calculations we want to return 0 for IE even if the value is not 0 hence what currentStyleTrueFale is used for.
//currentStyleTrueFale is therefore set to false for IE as currentStyle is what IE uses.
//If it ever start using getComputedStyle I suspect it'll also be wanting a value too.
function getDivPropertyByObj(obj,propertyName,currentStyleTrueFale){
  if (document.defaultView && document.defaultView.getComputedStyle){
    return document.defaultView.getComputedStyle(obj,'')[propertyName];
  } else if (currentStyleTrueFale && obj.currentStyle){
    return obj.currentStyle[propertyName];//NOTE IE and BORDERS:: IE will often give 'medium' etc for border sizes.  luckily we should never need to ask for borders in IE.
  } else {
    return '';
  }
}
function getIntDivPropertyByObj(obj,propertyName,currentStyleTrueFale){
  intDivPropertyByObj = parseInt(getDivPropertyByObj(obj,propertyName,currentStyleTrueFale))
  if (isNaN(intDivPropertyByObj)){
    return 0;
  } else {
    return intDivPropertyByObj;
  }
}
function getContainerDivOffsetToDocumentX(obj){
  var curleft = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curleft += obj.offsetLeft
      curleft += getIntDivPropertyByObj(obj,'borderLeftWidth',!ie)//don't do for IE as it takes borders into account in offsetLeft
      obj = obj.offsetParent;
    }
  } else if (obj.x) {
    curleft += obj.x;
  }
  return curleft;
}

function getContainerDivOffsetToDocumentY(obj){
  var curtop = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curtop += obj.offsetTop
      curtop += getIntDivPropertyByObj(obj,'borderTopWidth',!ie)
      obj = obj.offsetParent;
    }
  } else if (obj.y) {
    curtop += obj.y;
  }
  return curtop;
}
function getAutoContainerDivOffset(){
  containerDivOffsetToDocumentX = getContainerDivOffsetToDocumentX(getDivObject(containOverGraphElementsDivVar))
  containerDivOffsetToDocumentY = getContainerDivOffsetToDocumentY(getDivObject(containOverGraphElementsDivVar))
  if(autoCalcContainerDivOffsetBuggy){
    containerDivOffsetToDocumentX = containerDivOffsetToDocumentX/2
    containerDivOffsetToDocumentY = containerDivOffsetToDocumentY/2
  }
  return [containerDivOffsetToDocumentX,containerDivOffsetToDocumentY]
}
function getContainerDivOffSet(){
  if(autoCalcContainerDivOffset){
    return getAutoContainerDivOffset()
  } else {
    return [0,0]  
  }
}
function hideTooltipsTrStatic(){
  if(!toolTipsStaticMethod){
    setDivProperty('tooltipsTrStatic','display','none')
  }
}
function giveImageImgMap(){//This is the only function that both has an action and has browser detection.  shame. (now getAutoContainerDivOffSet too)
  if(toolTipsMovingMethod || toolTipsStaticMethod){
    if(document.getElementById){
      document.getElementById("graphImg").useMap = '#tooltips'
    } else if(document.images && document.all){
      document.all('graphImg').useMap = '#tooltips'
    }
  }
}
//Non-Browser sensitive functions
function propertyNameNS(propertyName){
  if(propertyName == 'height'){return 'clip.height'}
  else if(propertyName == 'width'){return 'clip.width'}
  else {return propertyName}
}
function valueSetToNS(valueSetTo){
  if(valueSetTo == 'visible'){return 'show'}
  else if(valueSetTo == 'hidden'){return 'hide'}
  else {return valueSetTo}
}
function getMidGraphDivY(e){
  graphDivTop =  getDivYToDocument(e)
  midGraphDivY = graphDivTop + parseInt(getDivProperty(graphDivVar,'height'))/2
    if (midGraphDivY >= 0) {
      //midGraphDivY value has been set 
      //if it not set set it to -1000 so it way off the page.
    } else {
      midGraphDivY = -1000;
    }
  return midGraphDivY
}
function getDivXToDocument(e){
  currentMouseX = mouseCoordsToDocument(e)[0]
  mouseRelativeToDivX = obtainOffsetX(e)
  divXToDocument =  currentMouseX - mouseRelativeToDivX
  return divXToDocument
}
function getDivYToDocument(e){
  currentMouseY = mouseCoordsToDocument(e)[1]
  mouseRelativeToDivY = obtainOffsetY(e)
  divYToDocument =  currentMouseY - mouseRelativeToDivY
  return divYToDocument
}
function graphMouseDown(e){
  if(zoomLinesMethod){
    setZoomLayerTop(e)
    if(!inZoomCycle){
      callTooltips(e,instructionOnZoomUseStr)
      inZoomCycle = true
      currentGraphDivXToDocument = getDivXToDocument(e)
      mouseDownOffsetX = obtainOffsetX(e)
      mouseDownX = mouseCoordsToDocument(e)[0]
      onGraphAreaOfDiv = true
      if(mouseDownOffsetX < startX){mouseDownX = startX + currentGraphDivXToDocument; mouseDownOffsetX = startX; onGraphAreaOfDiv = false}
      if(mouseDownOffsetX > endX){mouseDownX = endX + currentGraphDivXToDocument; mouseDownOffsetX = endX; onGraphAreaOfDiv = false}
      
      //remove the tool tip stuff.
      if (tooltipDivLineMethod == 1) {
        setTimeout("setDivProperty(tooltipsLineDivVar,'visibility','hidden')",setLineTimeoutHide);
        setTimeout("setDivProperty(tooltipsLineDivVolumeVar,'visibility','hidden')",setLineTimeoutHide);
      }
      
      setDivProperty(dragShowZoomDivVar,'width',1)
      setDivProperty(dragShowZoomDivVar,'left',-1*(1+lineThicknessX))
      setDivProperty(endShowZoomDivVar,'visibility','hidden')
      setDivProperty(startShowZoomDivVar,'left',mouseDownX + 1 - lineThicknessOffsetX)
      setDivProperty(startShowZoomDivVar,'visibility','visible')
      
      if (tooltipDivLineMethod == 1) {
        setDivProperty(dragShowZoomVolumeDivVar,'width',1)
        setDivProperty(dragShowZoomVolumeDivVar,'left',-1*(1+lineThicknessX))
        setDivProperty(endShowZoomVolumeDivVar,'visibility','hidden')
        setDivProperty(startShowZoomVolumeDivVar,'left',mouseDownX + 1 - lineThicknessOffsetX)
        setDivProperty(startShowZoomVolumeDivVar,'visibility','visible')
      }
      
      mouseUpedWhileOutside = false
    } else {
      graphMouseUp(e)
      mouseUpedWhileOutside = true
    }
  }
} 
function graphMouseUp(e){
  if(zoomLinesMethod){
    if(currentGraphDivXToDocument != -100){
      mouseUpOffsetX = mouseCoordsToDocument(e)[0] - currentGraphDivXToDocument //this looks like a long way to write obtainOffsetX(e) but obtainOffsetX(e) doesn't works for endShowZoomDivMouseUp(e)
      onGraphAreaOfDiv = false
      if(mouseUpOffsetX < startX){mouseUpOffsetX = startX; onGraphAreaOfDiv = true}
      if(mouseUpOffsetX > endX){mouseUpOffsetX = endX; onGraphAreaOfDiv = true}
      if(inZoomCycle){ 
        setDivProperty(endShowZoomDivVar,'left',mouseUpOffsetX + currentGraphDivXToDocument + 1 - lineThicknessOffsetX)
        if (tooltipDivLineMethod == 1) {
          setDivProperty(endShowZoomVolumeDivVar,'left',mouseUpOffsetX + currentGraphDivXToDocument + 1 - lineThicknessOffsetX)
        }
        if(onGraphAreaOfDiv){
          doSetDragShowZoomDiv(mouseUpOffsetX + currentGraphDivXToDocument)
        }
        hideTooltips()
      }
      if(checkIfZoomed()){
        inZoomCycle = false
        newUrl=returnUrlStart()
        newUrl+=returnDefaultIdentifier()
        startZoomDate = new Date(((mouseDownOffsetX - startX) * msPerPixel) + startDateMs);
        endZoomDate = new Date(((mouseUpOffsetX - startX) * msPerPixel) + startDateMs);       
        newUrl += returnCorrectDate(startZoomDate.getFullYear(),startZoomDate.getMonth() + 1,startZoomDate.getDate(),endZoomDate.getFullYear(),(endZoomDate.getMonth() + 1),endZoomDate.getDate(),'from','to','/')
        newUrl += getFormParams()
        newUrl += getReturnPeriod()
        goToGraphURL(newUrl);
      } else if(onlyDragZoom){
        hideZoomDivs()
        inZoomCycle = false
      }
    }
  }
}
function graphMouseMove(e){
  if(zoomLinesMethod){
    currentMouseX = mouseCoordsToDocument(e)[0]
    currentMouseOffsetX = currentMouseX-currentGraphDivXToDocument
    onGraphAreaOfDiv = true
    if(currentMouseOffsetX < startX){currentMouseX = startX + currentGraphDivXToDocument; onGraphAreaOfDiv = false}
    if(currentMouseOffsetX > endX){currentMouseX = endX + currentGraphDivXToDocument; onGraphAreaOfDiv = false}
    if(inZoomCycle){
      hideTooltips()
      setDivProperty(endShowZoomDivVar,'left',currentMouseX + 1 - lineThicknessOffsetX)
      setDivProperty(endShowZoomDivVar,'visibility','visible')
      if (tooltipDivLineMethod == 1) {
        setDivProperty(endShowZoomVolumeDivVar,'left',currentMouseX + 1 - lineThicknessOffsetX)
        setDivProperty(endShowZoomVolumeDivVar,'visibility','visible')
      }      
      doSetDragShowZoomDiv(currentMouseX)
    }
  }
}


function doSetDragShowZoomDiv(currentMouseX){
  newDragShowZoomDivWidth = currentMouseX - mouseDownX
  setDivProperty(dragShowZoomDivVar,'visibility','visible')
  if (tooltipDivLineMethod == 1) {
    setDivProperty(dragShowZoomVolumeDivVar,'visibility','visible')
  }
  if(newDragShowZoomDivWidth >= 0){
    setDivProperty(dragShowZoomDivVar,'left',mouseDownX + 1 - lineThicknessOffsetX)
    if (tooltipDivLineMethod == 1) {
      setDivProperty(dragShowZoomVolumeDivVar,'left',mouseDownX + 1 - lineThicknessOffsetX)
    }
  } else {
    setDivProperty(dragShowZoomDivVar,'left',mouseDownX + newDragShowZoomDivWidth + 1 - lineThicknessOffsetX)
    if (tooltipDivLineMethod == 1) {
      setDivProperty(dragShowZoomVolumeDivVar,'left',mouseDownX + newDragShowZoomDivWidth + 1 - lineThicknessOffsetX)
    }
  }
  setDivProperty(dragShowZoomDivVar,'width',Math.abs(newDragShowZoomDivWidth))
  if (tooltipDivLineMethod == 1) {
    setDivProperty(dragShowZoomVolumeDivVar,'width',Math.abs(newDragShowZoomDivWidth))
  }
}


function startShowZoomDivMouseUp(e){
  if(onlyDragZoom){
    hideZoomDivs()
    inZoomCycle = false
  }
}


function endShowZoomDivMouseDown(e){
  if(inZoomCycle){
    mouseUpedWhileOutside = true
  }
  if(!mouseUpedWhileOutside){
    hideZoomDivs()
    mouseUpedWhileOutside = false
  }
  inZoomCycle = false
}
function endShowZoomDivMouseUp(e){
  graphMouseUp(e)
}
function endShowZoomDivMouseMove(e){
  graphMouseMove(e)
}
function dragShowZoomDivMouseUp(e){
  graphMouseUp(e)
}
function dragShowZoomDivMouseMove(e){
  graphMouseMove(e)
}
function dragShowZoomDivMouseDown(e){
  endShowZoomDivMouseDown(e)
}


function tooltipsLineDivMouseUp(e){
  graphMouseUp(e)
}


function tooltipsLineDivMouseMove(e){
  mouseRelativeToDivY = obtainOffsetY(e)  
  imgMapTooltips2(e,mapArrayXIndexed[0][mouseCoordsToDocument(e)[0]-currentGraphDivXToDocument])
  graphMouseMove(e)
}


function tooltipsLineVolumeDivMouseMove(e){
  mouseRelativeToDivY = obtainOffsetY(e)
  imgMapTooltips2(e,mapArrayXIndexed[1][mouseCoordsToDocument(e)[0]-currentGraphDivXToDocument])
  graphMouseMove(e)
}


function tooltipsLineDivMouseDown(e){
  endShowZoomDivMouseDown(e)
}

function hideZoomDivs(){
  setDivProperty(startShowZoomDivVar,'visibility','hidden')
  setDivProperty(endShowZoomDivVar,'visibility','hidden')
  setDivProperty(dragShowZoomDivVar,'visibility','hidden')
  if (tooltipDivLineMethod == 1) {
    setDivProperty(dragShowZoomVolumeDivVar,'visibility','hidden')
    setDivProperty(endShowZoomVolumeDivVar,'visibility','hidden')
    setDivProperty(startShowZoomVolumeDivVar,'visibility','hidden')
  }
}


function checkIfZoomed(){
  if(getDivProperty(startShowZoomDivVar,'left') == getDivProperty(endShowZoomDivVar,'left')){
    return false
  } else {
    return true
  }
}


function setZoomLayerTop(e){
  midGraphDivY = getMidGraphDivY(e)  
  if (tooltipDivLineMethod == 0) {
    setDivProperty(startShowZoomDivVar,'top',midGraphDivY - parseInt(getDivProperty('startShowZoomDiv','height'))/2 + graphAreaOffsetY)
    setDivProperty(endShowZoomDivVar,'top',midGraphDivY - parseInt(getDivProperty(endShowZoomDivVar,'height'))/2 + graphAreaOffsetY)
    setDivProperty(dragShowZoomDivVar,'top',midGraphDivY + 1 - lineThicknessOffsetY + graphAreaOffsetY)
  }
  
  if (tooltipDivLineMethod == 1) {
    setDivProperty(startShowZoomDivVar,'top',midGraphDivY - parseInt(getDivProperty('startShowZoomDiv','height'))/2 - graphAreaOffsetY)  
    setDivProperty(endShowZoomDivVar,'top',midGraphDivY - parseInt(getDivProperty(endShowZoomDivVar,'height'))/2 - graphAreaOffsetY)
    setDivProperty(dragShowZoomDivVar,'top',midGraphDivY + 1 - parseInt(getDivProperty('startShowZoomDiv','height'))/2 - graphAreaOffsetY)
    
    setDivProperty(startShowZoomVolumeDivVar,'top',midGraphDivY - parseInt(getDivProperty('startShowZoomVolumeDiv','height'))/2 - volumeGraphAreaOffsetY)  
    setDivProperty(endShowZoomVolumeDivVar,'top',midGraphDivY - parseInt(getDivProperty(endShowZoomVolumeDivVar,'height'))/2 - volumeGraphAreaOffsetY)
    setDivProperty(dragShowZoomVolumeDivVar,'top',midGraphDivY - parseInt(getDivProperty('startShowZoomVolumeDiv','height'))/2 - volumeGraphAreaOffsetY)
  }
}


function settooltipsLineDivTop(e){
  midGraphDivY = getMidGraphDivY(e)
  setDivProperty(tooltipsLineDivVar,'top',midGraphDivY - parseInt(getDivProperty(tooltipsLineDivVar,'height'))/2 + graphAreaOffsetY)
}


function resetDate(){
  hideZoomDivs()
  inZoomCycle = false
  document.chartForm.period.options.selectedIndex = returnPeriod
  submitForm()
}
function setLineThickness(){
  lineThicknessOffsetX = (lineThicknessX + 1)/2
  lineThicknessOffsetY = (lineThicknessY + 1)/2
  setDivProperty(startShowZoomDivVar,'width',lineThicknessX)
  setDivProperty(endShowZoomDivVar,'width',lineThicknessX)
  setDivProperty(dragShowZoomDivVar,'height',lineThicknessY)
  if (tooltipDivLineMethod == 1) {
    setDivProperty(startShowZoomVolumeDivVar,'width',lineThicknessX)
    setDivProperty(endShowZoomVolumeDivVar,'width',lineThicknessX)
    setDivProperty(dragShowZoomVolumeDivVar,'height',lineThicknessY)
  }
}
function requiredMouseEvents(){
  defineMouseEvents('graphDiv','ondblclick','resetDate')
  defineMouseEvents('graphDiv','onmousedown','graphMouseDown')
  defineMouseEvents('graphDiv','onmouseup','graphMouseUp')
  defineMouseEvents('graphDiv','onmousemove','graphMouseMove')
  defineMouseEvents('startShowZoomDiv','ondblclick','resetDate')
  defineMouseEvents('startShowZoomDiv','onmouseup','startShowZoomDivMouseUp')
  defineMouseEvents('endShowZoomDiv','ondblclick','resetDate')
  defineMouseEvents('endShowZoomDiv','onmouseup','endShowZoomDivMouseUp')
  defineMouseEvents('endShowZoomDiv','onmousedown','endShowZoomDivMouseDown')
  defineMouseEvents('endShowZoomDiv','onmousemove','endShowZoomDivMouseMove')
  defineMouseEvents('dragShowZoomDiv','ondblclick','resetDate')
  defineMouseEvents('dragShowZoomDiv','onmouseup','dragShowZoomDivMouseUp')
  defineMouseEvents('dragShowZoomDiv','onmousedown','dragShowZoomDivMouseDown')
  defineMouseEvents('dragShowZoomDiv','onmousemove','dragShowZoomDivMouseMove')
}
///////////////////////////
function submitForm(){
  needToCorrectDate = false
  newUrl=returnUrlStart()
  newUrl+=returnDefaultIdentifier()
  var period = document.chartForm.period.options[document.chartForm.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 returnCorrectDateFormItems(fromDateName,toDateName,dateDelimeter){
    var fromDay = document.chartForm.fromDay.options[document.chartForm.fromDay.options.selectedIndex].value
    var fromMonth = document.chartForm.fromMonth.options[document.chartForm.fromMonth.options.selectedIndex].value
    var fromYear = document.chartForm.fromYear.options[document.chartForm.fromYear.options.selectedIndex].value
    var toDay = document.chartForm.toDay.options[document.chartForm.toDay.options.selectedIndex].value
    var toMonth = document.chartForm.toMonth.options[document.chartForm.toMonth.options.selectedIndex].value
    var toYear = document.chartForm.toYear.options[document.chartForm.toYear.options.selectedIndex].value
    return returnCorrectDate(fromYear,fromMonth,fromDay,toYear,toMonth,toDay,fromDateName,toDateName,dateDelimeter)
}
function verifyDate(theYear,theMonth,theDay){
  currentDate = new Date()
  currentDate.setHours(0);currentDate.setMinutes(0);currentDate.setSeconds(0)
  thisDate = new Date(theYear,(parseInt(theMonth)-1),(parseInt(theDay)+1))
  leapYear = false
  if(theYear % 4 == 0) leapYear = true
  if(theYear % 100 == 0) leapYear = false
  if(theYear % 400 == 0) leapYear = true
  if(theDay == '' || theMonth == '' || theYear == ''){
    validDate = false
  } else if(theDay == 31  && (theMonth == 4 || theMonth == 6 || theMonth == 9 || theMonth == 11)){
    validDate = false
  } else if(leapYear && theDay > 29 && theMonth == 2){
    validDate = false
  } else if(!leapYear && theDay > 28 && theMonth == 2){
    validDate = false
  } else if(thisDate > currentDate){
    validDate = 'future'
  } else {
    validDate = true
  }
  return validDate
}
function verifyCompanyDate(theYear,theMonth,theDay){
  verifiedDate = verifyDate(theYear,theMonth,theDay)
  if(verifiedDate === true && earliestDateYear && earliestDateMonth && earliestDateDay){
    earliestDate = new Date(earliestDateYear,earliestDateMonth-1,earliestDateDay)
    earliestDate.setHours(0);earliestDate.setMinutes(0);earliestDate.setSeconds(0)
    thisDate = new Date(theYear,(parseInt(theMonth)-1),(parseInt(theDay)))
    if(thisDate < earliestDate){
      return 'prefloat'
    } else {
      return true
    }
  } else {
    return verifiedDate
  }
}
function getReturnPeriod(){
  periodSelected = document.chartForm.period.options.selectedIndex;
  if(returnPeriod == ''){returnPeriod = periodSelected}
  if(returnPeriod != defaultReturnPeriod && returnPeriod != 0){
    return '&returnPeriod=' + returnPeriod
  } else {
    return ''
  }
}
function returnCorrectDate(fromYear,fromMonth,fromDay,toYear,toMonth,toDay,fromDateName,toDateName,dateDelimeter){
  if(!fromDateName){fromDateName = 'from'}
  if(!toDateName){toDateName = 'to'}
  if(!dateDelimeter){fromDateName = '/'}
  validFromDate = verifyCompanyDate(fromYear,fromMonth,fromDay)
  validToDate = verifyCompanyDate(toYear,toMonth,toDay)
  if(validFromDate == 'prefloat' || validToDate == 'prefloat'){
    doMsg(getPreFloatMsg());
    return false;
  } else if(validFromDate == 'future'){
    doMsg('The from date is in the future');
    return false;
  } else if(validToDate == 'future'){
    doMsg('The to date is in the future');
    return false;
  } else if(validFromDate && validToDate){
    from = fromDay + dateDelimeter + fromMonth + dateDelimeter +  fromYear;
    to = toDay + dateDelimeter + toMonth + dateDelimeter +  toYear;
    fromDate = new Date(fromYear,fromMonth,fromDay)
    toDate = new Date(toYear,toMonth,toDay)
    if(fromDate < toDate){
      return '&'+fromDateName+'=' + from + '&'+toDateName+'=' + to;
    } else {
      return '&'+fromDateName+'=' + to + '&'+toDateName+'=' + from;
    }
  } else if(!validFromDate){
    doMsg('The from date is not valid');
    return false;
  } else if(!validToDate){
    doMsg('The to date is not valid');
    return false;
  }
}

function getComparisons(){
  if(comparisonsAsSeperate){
    var comparisons = "";
    j=1;
    for(i=1;document.chartForm["comparison"+i];i++){
      if(document.chartForm["comparison"+i].checked == true){
        comparisons += "&comparison" + (j++) + "=" + document.chartForm["comparison"+i].value
      }
    }
  } else {
    var comparisons = "";
    for(i=1;document.chartForm["comparison"+i];i++){
      if(document.chartForm["comparison"+i].checked == true){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm["comparison"+i].value}
    }
    if(comparisons != ""){comparisons = '&comparisons=' + comparisons}
  }
  return comparisons
}

function getAxis(){
  tempNewUrlAxis = ''
  if(document.chartForm.horizontalGridlines.checked == false){tempNewUrlAxis += '&horizontalGridlines=false'}
  if(document.chartForm.verticalGridlines.checked == false){tempNewUrlAxis += '&verticalGridlines=false'}
  return tempNewUrlAxis
}

function getAxisSwap(){
  //return a blank for older graphs without this variable defined in page specific js
  tempNewUrlAxis = ''
  return tempNewUrlAxis 
}

function getStepline(){
  if(steplineMethodCheckbox && document.chartForm.stepline.checked){
    return '&stepline=true'
  } else if(steplineMethodRadio && document.chartForm.stepline[steplineRadioSelectIndex].checked){
    return '&stepline=true'
  } else if(steplineMethodSelect && document.chartForm.stepline.options.selectedIndex == steplineRadioSelectIndex){
    return '&stepline=true'
  } else {
    return ''
  }
}

function getFormParams(){
  tempNewUrl = getComparisons()
  tempNewUrl += getAxis()
  tempNewUrl += getAxisSwap()
  tempNewUrl += getStepline()
  return tempNewUrl
}
function changeDate(){
  resetPeriod()
  clearMsg()
}
function resetPeriod(){
  document.chartForm.period.options.selectedIndex = 0
}
//All Below set for items to correct values onload.
function setReturnPeriod(){
  initialPeriodSelected = document.chartForm.period.options.selectedIndex
  if(returnPeriod == ''){
    if(initialPeriodSelected != 0){
      returnPeriod = initialPeriodSelected
    } else {
      returnPeriod = defaultReturnPeriod
    }
  }
}
function setPeriod(){
  selectedPeriod = periodParam
  for(i=0;i<document.chartForm.period.options.length;i++){
    if(document.chartForm.period.options[i].value == selectedPeriod){
      document.chartForm.period.options[i].selected = true
      break
    }
  }
}
function setComparisonsSelected(){
  for(i=1;document.chartForm["comparison"+i];i++){
    if(comparisonsParam.indexOf(document.chartForm["comparison"+i].value) != -1){document.chartForm["comparison"+i].checked = true}
  }
}

function getSecs(timeText){
  timeTextArr = timeText.split(':')
  timeTextHours = parseInt(timeTextArr[0],10)
  timeTextMins = parseInt(timeTextArr[1],10)
  return (((timeTextHours * 60) + timeTextMins) * 60)
}

function swapTextIfIsDayClose(thisPoint){
  if(thisPoint.indexOf(' : ') != -1){
    thisTime = thisPoint.split(' : ')[0]
    thisTimeSecs = getSecs(thisTime)
    if((thisTimeSecs == dayCloseTimeSecs + dayCloseLateTimeSecs)){
      thisPoint = thisPoint.replace(thisTime,'Day Close')
    }
  }
  return thisPoint
}
function isFirstPointExpectedDayOpen(firstPoint){
  if(firstPoint.indexOf('~') != -1 && firstPoint.indexOf(' : ') != -1){
    firstTime = firstPoint.split('~')[5].split(' : ')[0]
    firstTimeSecs = getSecs(firstTime)
    return (firstTimeSecs >= dayOpenTimeSecs) && (firstTimeSecs <= (dayOpenTimeSecs + intervalTimeSecs))
  } else {
    return false
  }
}

function writeMapAndArray(){
  mapArray=mapArrayStr.split(';')
  mapArrayXIndexed = new Array()
  mapArrayXIndexed[0] = new Array()//Prices
  mapArrayXIndexed[1] = new Array()//Volume
  onclickStr = ''
  if(document.layers){onclickStr = ' href="javascript: return false;"'}
  lastOne = mapArray.length - 1
  if(toolTipsMovingMethod || toolTipsStaticMethod){
    document.write('<map name="tooltips">')
    for(i=0;i<lastOne;i++){
      mA = mapArray[i].split('~')
      
      imgMapX1 = parseInt(mA[1])-nsRelGraphDivToDocX
      imgMapX2 = parseInt(mA[3])-nsRelGraphDivToDocX
      imgMapY1 = parseInt(mA[2])-nsRelGraphDivToDocY
      imgMapY2 = parseInt(mA[4])-nsRelGraphDivToDocY
      
      //set midGraphDivY to 0 before the graph is called because the onmousemove event is firing 
      //before the onmouseover and this value should only be set once.
      
      midGraphDivY = 0;
      
      document.write('<AREA SHAPE="RECT" COORDS="'+imgMapX1+','+imgMapY1+','+imgMapX2+','+imgMapY2+'" onmouseover="imgMapTooltips1(event,\''+mA[5]+'\')" onmousemove="imgMapTooltips2(event,\''+mA[5]+'\')" onmouseout="hideTooltips(); hideTooltipsLine()"' + onclickStr+ '>\r')
      if(imgMapY1 == 0){
        whichMapSection = 0
      } else if(imgMapY1 == dividingPosition1top){
        whichMapSection = 1
      }
      for(imgMapXToX=imgMapX1;imgMapXToX<imgMapX2;imgMapXToX++){
        mapArrayXIndexed[whichMapSection][imgMapXToX]=mA[5]
      }
    }
    document.write('</map>')
  }
}

function writeMap(){
  mapArray=mapArrayStr.split(';')
  onclickStr = ''
  if(document.layers){onclickStr = ' href="javascript: return false;"'}
  lastOne = mapArray.length - 1 //actually it's -2 as theres a ; at the end.
  if(toolTipsMovingMethod || toolTipsStaticMethod){
    swapDayCloseMode = isFirstPointExpectedDayOpen(mapArray[0])
    document.write('<map name="tooltips">')
    for(i=0;i<lastOne;i++){
      mA = mapArray[i].split('~')
      imgMapX1 = parseInt(mA[1])-nsRelGraphDivToDocX
      imgMapX2 = parseInt(mA[3])-nsRelGraphDivToDocX
      imgMapY1 = parseInt(mA[2])-nsRelGraphDivToDocY
      imgMapY2 = parseInt(mA[4])-nsRelGraphDivToDocY
      mA[5] = swapTextIfIsDayClose(mA[5])
      document.write('<AREA SHAPE="RECT" COORDS="'+imgMapX1+','+imgMapY1+','+imgMapX2+','+imgMapY2+'" onmouseover="imgMapTooltips2(event,\''+mA[5]+'\')" onmousemove="imgMapTooltips2(event,\''+mA[5]+'\')" onmouseout="hideTooltips()"' + onclickStr+ '>\r')
    }    
    document.write('</map>')
  }
}


function writeMapAllDetailsInOne(){
  mapArray=mapArrayStr.split(';')
  onclickStr = ''
  if(document.layers){onclickStr = ' href="javascript: return false;"'}
  lastOne = mapArray.length - 1
  if(toolTipsMovingMethod || toolTipsStaticMethod){
    swapDayCloseMode = isFirstPointExpectedDayOpen(mapArray[0])
    document.write('<map name="tooltips">')
    mapArrayPrice=mapArrayPriceStr.split(';')
    lastOnePrice = mapArrayPrice.length - 1
    toolTipPriceDetails = new Array()
    for(i=0;i<lastOnePrice;i++){
      mAPrice = mapArrayPrice[i].split('~')
      currentToolTipTextArray = mAPrice[5].split(' : ')
      toolTipPriceDetails[currentToolTipTextArray[0]] = currentToolTipTextArray[1]
    }
    mapArrayVolume=mapArrayVolumeStr.split(';')
    lastOneVolume = mapArrayVolume.length - 1
    toolTipVolumeDetails = new Array()
    for(i=0;i<lastOneVolume;i++){
      mAVolume = mapArrayVolume[i].split('~')
      currentToolTipTextArray = mAVolume[5].split(' : ')
      toolTipVolumeDetails[currentToolTipTextArray[0]] = currentToolTipTextArray[1]
    }
    for(i=0;i<lastOne;i++){
      mA = mapArray[i].split('~')
      imgMapX1 = parseInt(mA[1])-nsRelGraphDivToDocX
      imgMapX2 = parseInt(mA[3])-nsRelGraphDivToDocX
      imgMapY1 = parseInt(mA[2])-nsRelGraphDivToDocY
      imgMapY2 = parseInt(mA[4])-nsRelGraphDivToDocY
      mA[5] = swapTextIfIsDayClose(mA[5])
      currentToolTipTextArray = mA[5].split(' : ')
      document.write('<AREA SHAPE="RECT" COORDS="'+imgMapX1+','+imgMapY1+','+imgMapX2+','+imgMapY2+'" onmouseover="imgMapTooltips2(event,\''+getAllDetailsInOneToolTip(currentToolTipTextArray[0])+'\')" onmousemove="imgMapTooltips2(event,\''+getAllDetailsInOneToolTip(currentToolTipTextArray[0])+'\')" onmouseout="hideTooltips()"' + onclickStr+ '>\r')
    }    
    document.write('</map>')
  }
}

function getAllDetailsInOneToolTip(toolTipDate){
  toolTipPrice = toolTipPriceDetails[toolTipDate]
  if(toolTipPrice == null){
    toolTipPrice = ''
  }
  toolTipVolume = toolTipVolumeDetails[toolTipDate]
  if(toolTipVolume == null){
    toolTipVolume = ''
  }
  return formatAllDetailsInOneToolTip(toolTipDate,toolTipPrice,toolTipVolume)
}
function formatAllDetailsInOneToolTip(toolTipDate,toolTipPrice,toolTipVolume){
  return toolTipDate + ' ' + toolTipPrice + ' ' + toolTipVolume
}
function setDateRange(){
  dateDashOffset = 0
  if(document.chartForm.fromDay.options[0].value == '1'){
    dateDashOffset = -1
  }
  selectedFrom = fromParam
  if(selectedFrom.indexOf('/') != -1){
    selFrom = selectedFrom.split('/')
    selFromDay = selFrom[0]
    selFromMonth = selFrom[1]
    selFromYear = selFrom[2]
    document.chartForm.fromDay.options.selectedIndex = parseInt(selFromDay) + dateDashOffset
    document.chartForm.fromMonth.options.selectedIndex = parseInt(selFromMonth) + dateDashOffset
    document.chartForm.fromYear.options.selectedIndex = parseInt(selFromYear - yearMinus10 + 1) + dateDashOffset//Plus one due to addition on empty option first.
  }
  selectedTo = toParam
  if(selectedTo.indexOf('/') != -1){
    selTo = selectedTo.split('/')
    selToDay = selTo[0]
    selToMonth = selTo[1]
    selToYear = selTo[2]
    document.chartForm.toDay.options.selectedIndex = parseInt(selToDay) + dateDashOffset
    document.chartForm.toMonth.options.selectedIndex = parseInt(selToMonth) + dateDashOffset
    document.chartForm.toYear.options.selectedIndex = parseInt(selToYear - yearMinus10 + 1) + dateDashOffset
  }
}
function goToGraphURL(newURL){
  if(reloadLocationSelf){
    self.location.href = newURL;
  } else {
    top.location.href = newURL;
  }
}
function goToExcelURL(newURL){
  top.location.href = newURL;
}
function ggPageOnload(){
  //dummy function.  over written in page specific js
}
function setAxisSelected(){
  if(hLinesParam == 'false'){document.chartForm.horizontalGridlines.checked = false}
  if(vLinesParam == 'false'){document.chartForm.verticalGridlines.checked = false}
}
function setStepline(){
  if(steplineMethodCheckbox && steplineParam == 'true'){
    document.chartForm.stepline.checked = true
  } else if(steplineMethodRadio && steplineParam == 'true'){
    document.chartForm.stepline[steplineRadioSelectIndex].checked = true
  } else if(steplineMethodSelect && steplineParam == 'true'){
    document.chartForm.stepline.options.selectedIndex = steplineRadioSelectIndex
  }
}
function popupHelp(){
  gginfoWin = this.open('http://online.hemscottir.com/helppages/gifgraphs.htm', 'gginfoWindow', 'toolbar=no,menubar=no,height=580,width=600,location=no,scrollbars=yes,resizable=yes,status=no,left=50,top=50')
  return false
}
function popupHelpAbs(){
  gginfoWin = this.open('http://online.hemscottir.com/helppages/gifgraphs.htm', 'gginfoWindow', 'toolbar=no,menubar=no,height=580,width=600,location=no,scrollbars=yes,resizable=yes,status=no,left=50,top=50')
  return false
}
function detachGraph(popupWidth,popupHeight){
  detachedChartWin = this.open(chartSrc, 'detachedChartWindow', 'toolbar=no,menubar=no,width='+popupWidth+',height='+popupHeight+',location=no,scrollbars=yes,resizable=no,status=no,left=100,top=100');
}
function getExcelPage() {
  newUrl = urlExcelStart
  returnCorrectDateStr = returnCorrectDateFormItems('fromDate','toDate','-')
  if(returnCorrectDateStr){
    newUrl += returnCorrectDateStr
    goToExcelURL(newUrl)
  }
}
function onloadAllGG(){
  setPeriod()
  setComparisonsSelected()
  setReturnPeriod()
  setDateRange()
  setAxisSelected()
  setStepline()
  giveImageImgMap()
  ggPageOnload()
  nsCaptureEvents()
  setLineThickness()
  requiredMouseEvents()
  setupBoundedMethod()
  resetZoomMessage()
  //hideTooltipsTrStatic()
}

/////////////////////////////////////////////////////////
//tool tips the line version
/////////////////////////////////////////////////////////

function hideTooltipsLine(){
  if(toolTipsMovingMethod){
    setTimeout("setDivProperty(tooltipsLineDivVar,'visibility','hidden')",setLineTimeoutHide);
    setTimeout("setDivProperty(tooltipsLineDivVolumeVar,'visibility','hidden')",setLineTimeoutHide);
  } else if(toolTipsStaticMethod){
    writeToDiv(tooltipsDivStaticVar,tooltipsStaticHTMLBefore + tooltipsStaticHTMLAfter)
  }
}
