window.onload = init

function init()
{ setRollovers()
  setWindows()
}




/*

after the html page loads, setRollovers() scans the HTML page for any img tag 
that has the class "rollOver". When it finds one, it attaches the mouseover events.

*/

function setRollovers()
{ imgs = document.getElementsByTagName("img")
  for (i=0;i<imgs.length;i++)
  { if (/rollOver/.test(imgs[i].className))
    { imgs[i].parentNode.onmouseover=function(){roll(this,true);}
      imgs[i].parentNode.onmouseout=function(){roll(this,false);}
      imgs[i].parentNode.onfocus=function(){roll(this,true);}
      imgs[i].parentNode.onblur=function(){roll(this,false);}
    }
  }
}

function setWindows()
{ var anchors = document.getElementsByTagName("a")
  for (var i=0; i<anchors.length; i++)
  { var anchor = anchors[i]
    if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "newWindow")
    { anchor.target = "_blank";
    }
  }
} 




/*

roll() handles the image rollovers.

*/

function roll(node,status)
{ nodeImg = node.firstChild
  srcImg = nodeImg.getAttribute("src")
  fileName = srcImg.substring(0,srcImg.length - 7)
  navState = srcImg.substring(srcImg.length - 7,srcImg.length - 4)
  fileType = srcImg.substring(srcImg.length - 3,srcImg.length - 0)
  
  if (status)
  { if (navState == "off")
    { fileName = fileName + "ovr." + fileType
      nodeImg.setAttribute("src",fileName)
    }
  }
  else
  { if ((navState != "sel") && (navState != "off"))
    { fileName = fileName + "off." + fileType
      nodeImg.setAttribute("src",fileName)
    }
  }
}




/*

create a pop-up window to show content

*/

function launchWin(fileName)
{	wdth = 470
  hght = 355

  x = (screen.availWidth - wdth) / 2 
	y = ((screen.availHeight - hght) / 2 ) - 40
	attribs = "width=" + wdth + ",height=" + hght + ",left=" + x + ",top=" + y
	attribs1 = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,"
  popWin = window.open(fileName,"popWindow",attribs)
}




/*

form routines

*/

function formAdd1()
{ t1 = document.panelForm.pct_stocks.value * 1
  t2 = document.panelForm.pct_options.value * 1
  t3 = document.panelForm.pct_etfs.value * 1
  t4 = document.panelForm.pct_commodities.value * 1
  t5 = document.panelForm.pct_foreign.value * 1
  t6 = document.panelForm.pct_currencies.value * 1
  t7 = document.panelForm.pct_other.value * 1
  
  total = (t1 + t2 + t3 + t4 + t5 + t6 + t7)
  
  if (isNaN(total))
  { total = "error"
  }
  
  document.panelForm.pct_total1.value = total

  if (total == 100)
  { document.panelForm.pct_total1.className = "pct100"
  }
  else
  { document.panelForm.pct_total1.className = "pctTotal"
  }
}

function formAdd2()
{ t1 = document.panelForm.pct_largecap.value * 1
  t2 = document.panelForm.pct_midcap.value * 1
  t3 = document.panelForm.pct_smallcap.value * 1
  t4 = document.panelForm.pct_microcap.value * 1
  
  total = (t1 + t2 + t3 + t4)
  
  if (isNaN(total))
  { total = "error"
  }
  
  document.panelForm.pct_total2.value = total

  if (total == 100)
  { document.panelForm.pct_total2.className = "pct100"
  }
  else
  { document.panelForm.pct_total2.className = "pctTotal"
  }
}





