

function ggPageOnload(){
//  setComparisonsSelected();
  setIndexSector();
  //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...

loadedCompName1 = ''
loadedCompName2 = ''
loadedCompName3 = ''
loadedCompName4 = ''
loadedCompId1 = ''
loadedCompId2 = ''
loadedCompId3 = ''
loadedCompId4 = ''

findTO = false
/*function setComparisonsSelected(){
  for(i=0;i<comparatorsArray.length;i++){
      eval('document.chartForm.isCoyid'+(i+1)+'.value = "'+comparatorsArray[i][0] + '"')
      eval('document.chartForm.isComp'+(i+1)+'.value = "'+comparatorsArray[i][1] + '"')
      eval('loadedCompName'+(i+1)+' = "'+comparatorsArray[i][1]+'"')//These two create variables used by stopCompXSelection
      eval('loadedCompId'+(i+1)+' = "'+comparatorsArray[i][0]+'"')
    }
}

//JBB Adding Comparator code (I hOPE)

function setComparisonsSelectedmm(){
j=1;
l=0;
    for(i=0;i<comparatorsArray.length;i++){
      alert(comparatorsArray[i][1])
      setSelectOption('theComparitor'+(j),comparatorsArray[i][1])
      if(j>4){
        eval('document.chartForm.isCoyid'+(i+1)+'.value = "'+comparatorsArray[i][0] + '"')
        eval('document.chartForm.isComp'+(i+1)+'.value = "'+comparatorsArray[i][2] + '"')
        eval('loadedCompName'+(i+1)+' = "'+comparatorsArray[i][2]+'"')//These two create variables used by stopCompXSelection
        eval('loadedCompId'+(i+1)+' = "'+comparatorsArray[i][0]+'"')
      }
    j += 1
    }

}
comparatorsArrayTextField = new Array()
function setComparisonsSelected(){
  j=1
  for(i=0;i<comparatorsArray.length;i++){
      if(setSelectOption('theComparitor'+(j),comparatorsArray[i][1])){
        comparatorsArrayTextField[comparatorsArrayTextField.length] = [comparatorsArray[i][0],comparatorsArray[i][1],comparatorsArray[i][2]]
      } else {
        j += 1
      }
  }
  setComparisonsTextFieldSelected()
}
*//*
function setComparisonsTextFieldSelected(){
  for(i=0;i<comparatorsArrayTextField.length;i++){
    eval('document.chartForm.isCoyid'+(i+1)+'.value = "'+comparatorsArrayTextField[i][0] + '"')
    eval('document.chartForm.isComp'+(i+1)+'.value = "'+comparatorsArrayTextField[i][2] + '"')
    eval('loadedCompName'+(i+1)+' = "'+comparatorsArrayTextField[i][2]+'"')//These two create variables used by stopCompXSelection
    eval('loadedCompId'+(i+1)+' = "'+comparatorsArrayTextField[i][0]+'"')
  }
}
function setSelectOption(selectName,selectOption){
  compNotInSelect = true
  for(k=0;k<document.chartForm[selectName].options.length;k++){
    if(document.chartForm[selectName].options[k].value == selectOption){
      document.chartForm[selectName].options.selectedIndex = k
      compNotInSelect = false
      break
    }
  }
  return compNotInSelect
}
function getComparisons(){
  var comparisons = "";

  if(document.chartForm.comparison19.value != ""){comparisons += document.chartForm.comparison19.value + "@IT"}
  if(document.chartForm.comparison20.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.comparison20.value + "@GRP"}
  if(comparisonsAsSeperate){
    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 {
    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}
  }
  if(document.chartForm.comparison17.value != ""){if(comparisons != ""){comparisons += ","}else{comparisons = '&comparisons='} comparisons += document.chartForm.comparison17.value}
  if(document.chartForm.comparison18.value != ""){if(comparisons != ""){comparisons += ","}else{comparisons = '&comparisons='} comparisons += document.chartForm.comparison18.value}

  return comparisons
}

//  var comparisons = "";
// Prevents the same company being shown twice on chart - JBB
//  if(document.chartForm.theComparitor2.value == document.chartForm.theComparitor1.value) {document.chartForm.theComparitor2.value = ""; }
//  if(document.chartForm.theComparitor3.value == document.chartForm.theComparitor2.value || document.chartForm.theComparitor3.value == document.chartForm.theComparitor1.value) {document.chartForm.theComparitor3.value = ""; }
//  if(document.chartForm.theComparitor4.value == document.chartForm.theComparitor3.value || document.chartForm.theComparitor4.value == document.chartForm.theComparitor2.value || document.chartForm.theComparitor4.value == document.chartForm.theComparitor1.value) {document.chartForm.theComparitor4.value = ""; }


//  if(document.chartForm.comparison17.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.comparison17.value}
//  if(document.chartForm.comparison18.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.comparison18.value}
//  if(document.chartForm.theComparitor1.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.theComparitor1.value}
//  if(document.chartForm.theComparitor2.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.theComparitor2.value}
//  if(document.chartForm.theComparitor3.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.theComparitor3.value}
//  if(document.chartForm.theComparitor4.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.theComparitor4.value}

//  if(comparisons != ""){comparisons = '&comparisons=' + comparisons}
//  return comparisons

//}*/
/*
function submitForm1(){
  needToCorrectDate = false
  newUrl=returnUrlStart()
  var period = document.chartForm.period.options[document.chartForm.period.options.selectedIndex].value;
  if (period == "-") {
    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
    returnCorrectDateStr = returnCorrectDate(fromYear,fromMonth,fromDay,toYear,toMonth,toDay)
    if(returnCorrectDateStr){
      if(newUrl.indexOf('&') != -1){newUrl+='&';}
      newUrl += returnCorrectDateStr
      newUrl += getReturnPeriod()
    } else {
      needToCorrectDate = true
    }
  } else {
    if(newUrl.indexOf('&') != -1){newUrl+='&';}
    newUrl += 'period=' + period;
  }
  if(!needToCorrectDate){
    newUrl += getFormParams()
    goToGraphURL(newUrl);
  }
}
*/
/*
function returnCorrectDate(fromYear,fromMonth,fromDay,toYear,toMonth,toDay){
  validFromDate = verifyDate(fromYear,fromMonth,fromDay)
  validToDate = verifyDate(toYear,toMonth,toDay)
  if(validFromDate == 'future'){
    writeToDiv('errorDiv','The from date is in the future');
    return false;
  } else if(validToDate == 'future'){
    writeToDiv('errorDiv','The to date is in the future');
    return false;
  } else if(validFromDate && validToDate){
    from = fromDay + '/' + fromMonth + '/' +  fromYear;
    to = toDay + '/' + toMonth + '/' +  toYear;
    fromDate = new Date(fromYear,fromMonth,fromDay)
    toDate = new Date(toYear,toMonth,toDay)
    if(fromDate < toDate){
      return '&from=' + from + '&to=' + to;
    } else {
      return '&from=' + to + '&to=' + from;
    }
  } else if(!validFromDate){
    writeToDiv('errorDiv','The from date is not valid');
    return false;
  } else if(!validToDate){
    writeToDiv('errorDiv','The to date is not valid');
    return false;
  }
}
// end of JBB

*/
/*
// Replacing with older code
function getComparisons(){
  var comparisons = "";

    if(document.chartForm.comparison19.value != ""){comparisons += document.chartForm.comparison19.value + "@IT"}
    if(document.chartForm.comparison20.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.comparison20.value + "@GRP"}
    if(document.chartForm.comparison17.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.comparison17.value}
    if(document.chartForm.comparison18.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.comparison18.value}
    if(document.chartForm.isCoyid3.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.isCoyid3.value}
    if(document.chartForm.isCoyid4.value != ""){if(comparisons != ""){comparisons += ","} comparisons += document.chartForm.isCoyid4.value}

  if(comparisons != ""){comparisons = '&comparisons=' + comparisons}
  return comparisons
}

*/


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
  msgBox.innerHTML = 'Please click &#145;Redraw Graph&#146; to obtain company data';
  msgBox.style.display = '';
  eval('document.chartForm.comparison'+changingWhichComp+'.value = unescape(theCoyid)')
  eval('document.chartForm.isComp'+changingWhichComp+'.value = unescape(theCompName)')
  eval('doShowTempComp'+changingWhichComp+' = true')
  eval('hasCompName'+changingWhichComp+' = true')
  self.location.hash = 'hasherrorDiV'
}

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.value != "@IT" || t.value != ""){
    msgBox.innerHTML = 'Please click &#145;Redraw Graph&#146; to obtain index data';
	msgBox.style.display = '';
  }
  if(t.value == "@IT" || t.value == "") {
    msgBox.innerHTML = '';
	msgBox.style.display = 'none';
	t.value = "";
  }
}
function changedSector(t){
  if(t.value != "@IT" || t.value != ""){
    msgBox.innerHTML = 'Please click &#145;Redraw Graph&#146; to obtain sector data';
	msgBox.style.display = '';
  }
  if(t.value == "@GRP" || t.value == "") {
    msgBox.innerHTML = '';
	msgBox.style.display = 'none';
	t.value = "";
  }
}
