defaultReturnPeriod = 4//CUSTOMISE THIS:::::::::Note 5
graphAreaOffsetY = -29//Note 6
isGraphDivRelative = false //Note 1
lineThicknessX = 1
lineThicknessY = 2


if(document.layers && isGraphDivRelative){
  nsAndRelative = true//leave this one.
  nsRelGraphDivToDocX = 37//Note 2
  nsRelGraphDivToDocY = 30
}
function ggPageOnload(){
  setComparisonsSelected()
  setDateRange()
}



/* REMOVED BY JBB
function setComparisonsSelected(){
  if(indexParam != ''){document.chartForm.comparison1.checked = true}
  if(sectorParam != ''){document.chartForm.comparison2.checked = true}
}
*/
// ADDED BY JBB
function setComparisonsSelected(){
  for(i=3;document.chartForm["comparison"+i];i++){
    if(comparisonsParam.indexOf(document.chartForm["comparison"+i].value) != -1){document.chartForm["comparison"+i].checked = true}
  }
  if(indexParam != ''){document.chartForm.comparison1.checked = true}
  if(sectorParam != ''){document.chartForm.comparison2.checked = true}
}
/* REMOVED BY JBB

function getComparisons(){
  var comparisons = '';
  if(document.chartForm.comparison1.checked == true){comparisons = '&index=ALL_SHARE'}
  if(document.chartForm.comparison2.checked == true){comparisons += '&sector=' + document.chartForm.comparison2.value;}
  return comparisons
}
*/
// ADDED BY JBB
function getComparisons(){
   var indexTEST = "";
   if(document.chartForm.comparison1.checked == true){indexTEST = '&index=' + document.chartForm.comparison1.value;}
   else { indexTEST = "";}

   var sectorTEST = "";
   if(document.chartForm.comparison2.checked == true){sectorTEST = '&sector=' + document.chartForm.comparison2.value;}
   else { sectorTEST = "";}


  if(comparisonsAsSeperate){
   var comparisons = "";
    j=3;
    for(i=3;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=3;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}
  }
  comparisons = indexTEST + sectorTEST + comparisons;



/*
// CODE FOR FIND COMPANY FIELDS - Not needed now

   if(document.chartForm.isCoyid1.value != ""){if(comparisons != ""){comparisons += ","}else{comparisons = '&comparisons='} comparisons += document.chartForm.isCoyid1.value}
   if(document.chartForm.isCoyid2.value != ""){if(comparisons != ""){comparisons += ","}else{comparisons = '&comparisons='} comparisons += document.chartForm.isCoyid2.value}
*/

  return comparisons
}





function goToGraphURL(newURL){
  self.location.href = newURL;
}

///TOOLTIPS.
tooltipsHTMLBefore = '<table border="0" cellspacing="1" cellpadding="3" style="background-color: #82B45D;width:50px;"><tr><td style="font-family:Arial, sans-serif; font-size:1em; background-color: #ffffff; color: #323232"><nobr>'
tooltipsHTMLAfter = '<span id="tooltipsDivWidthFinder" style="position:absolute; left:0px; top:0px; width:0px; height:0px; z-index:4; visibility:visible;"></span></nobr></td></tr></table>'
if(document.layers){
  tooltipsStaticHTMLBefore = '<font style="font-family: Verdana, Arial, sans-serif; font-size:12px; background-color: #ffffff; color: #82B45D">'
  tooltipsStaticHTMLAfter = '</font>'
} else {
  tooltipsStaticHTMLBefore = ''
  tooltipsStaticHTMLAfter = ''
}

function setDateRange(){

  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 )
    document.chartForm.fromMonth.options.selectedIndex = parseInt(selFromMonth)
    document.chartForm.fromYear.options.selectedIndex = parseInt(selFromYear - yearMinus5 + 1)//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)
    document.chartForm.toMonth.options.selectedIndex = parseInt(selToMonth)
    document.chartForm.toYear.options.selectedIndex = parseInt(selToYear - yearMinus5 + 1)
  }

}

/*
// CODE FOR FIND COMPANY FIELDS - Not needed now

loadedCompName1 = ''
loadedCompName2 = ''
loadedCompId1 = ''
loadedCompId2 = ''
findTO = false;

function findCompany(whichComp){
  clearTimeout(findTO)
  clearHelpMsg()
  findWin = this.open("/servlet/HsPublic?context=ir&client=test_vod&path=compfund&service=getHsCompanySearch&noRedirect=true&fromIndex=1&len=100&listing_status=3&transform=popupfindcompany&company="+escape(eval('document.chartForm.isComp'+whichComp+'.value')), "findWindow", "toolbar=no,menubar=no,height=500,width=400,location=no,scrollbars=yes,resizable=no,status=no,left=100,top=100");
  changingWhichComp = whichComp
}

function receiveDetails(coyid,name){
  theCoyid = coyid
  theCompName = name
  eval('document.chartForm.isCoyid'+changingWhichComp+'.value = unescape(theCoyid)')
  eval('document.chartForm.isComp'+changingWhichComp+'.value = unescape(theCompName)')
  eval('doShowTempComp'+changingWhichComp+' = true')
  eval('hasCompName'+changingWhichComp+' = true')
  self.location.hash = 'hasherrorDiV'
  doHelpMsg('Please click &#145;Redraw Graph&#146; to obtain company data')
}

function getCoyid(theString){
  theStringSplit = theString.split('@')
  return theStringSplit[0]
}

function stopCompXSelection(theCompNum){
  if(eval('document.chartForm.isComp'+theCompNum+'.value == loadedCompName'+theCompNum)){
    clearHelpMsg()
    eval('document.chartForm.isCoyid'+theCompNum+'.value = loadedCompId'+theCompNum)
  } else {
    eval('document.chartForm.isCoyid'+theCompNum+'.value = ""')
    if(eval('document.chartForm.isComp'+theCompNum+'.value != ""')){
      findMessageTimeout()
    } else {
      clearHelpMsg()
    }
  }
  eval('document.chartForm.isComp'+theCompNum+'.focus()')
}

function findMessageTimeout(){
  findTO = setTimeout("doHelpMsg('Please click &#145;Find&#146; to verify this company')",200)
}
function clearHelpMsg(){
  writeToDiv('errorDiv','')
}
function doHelpMsg(whatText){
  writeToDiv('errorDiv',whatText)
}
function changedIndex(t){
  if(t.options[t.options.selectedIndex].value != ''){
    doHelpMsg('Please click &#145;Redraw Graph&#146; to obtain index data')
  } else {
    clearHelpMsg()
  }
}
function changedSector(t){
  if(t.options[t.options.selectedIndex].value != ''){
    doHelpMsg('Please click &#145;Redraw Graph&#146; to obtain sector data')
  } else {
    clearHelpMsg()
  }
}

*/