<!--

fireworks_make = 0

//
//  Utility Code
//

function EFoilGetEMail(name)
{
  s1 = "\100"; s2 = "AmericanHealthCrisis"; s3 = "\056"; s4 = "com"
  return(name+s1+s2+s3+s4)
}

function EFoilOnly(name)
{
  document.write(EFoilGetEMail(name))
}

function EFoil(name, color)
{
  em = EFoilGetEMail(name)
  document.write("<a href="+"mail"+"to:"+em+" style='color:"+color+"'>"+em+"</a>")
}

function FormRecipient()
{
  document.write('<input type="hidden" name="recipient" value="forms@AmericanHealthCrisis.com">')
}

function maskcr(e)
{
  if( window.event )
    key = window.event.keyCode
  else if( e )
    key = e.which
  else
    key = 0
  if( key==13 ) return false
  return true
}

//
//  Form Functions
//

var form_count = 0

function FormText(name, size, req, type, styl)
{
  form_count += 1
  id = "fld"+form_count
  eval(id+"name = name")
  eval(id+"req  = req")
  eval(id+"type = type")
  document.write("<input type='text' name='"+name+"' size='"+size+"' style='"+styl+"' onKeyPress='return maskcr(event)'>")
}

function FormTextArea(name, cols, rows, req, styl)
{
  form_count += 1
  id = "fld"+form_count
  eval(id+"name = name")
  eval(id+"req  = req")
  eval(id+"type = 'text'")
  document.write("<textarea cols='"+cols+"' rows='"+rows+"' name='"+name+"' style='"+styl+"'></textarea>")
}

function ValidEMail(email)
{
  filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
  if( filter.test(email) )
    return(true)
  else
    return(false)
}

function ValidPhone(phone)
{
  delms = "()=+ "
  pure  = ""
  filt  = /\d+/

  for( i=0 ; i<phone.length ; i++ )
  {   
    c = phone.charAt(i)
    if( delms.indexOf(c)==(-1) )
      pure += c
  }
  return(filt.test(pure) && pure.length>=10)
}

function FormValidator(theForm)
{
  for( i=1 ; i<=form_count ; i++ )
  {
    id  = "fld"+i
    fld = eval("theForm."+eval(id+"name"))
    typ = eval(id+"type")

    if( eval(id+"req")=="bold" && fld.value=="" )
    {
      alert("Please enter a value for the \""+eval(id+"name")+"\" field.")
      fld.focus()
      return(false)
    }
    if( fld.value=="" ) continue

    if( typ=="email" && (!ValidEMail(fld.value)) )
    {
      alert("Invalid email address.")
      fld.focus()
      return(false)
    }
    if( typ=="phone" && (!ValidPhone(fld.value)) )
    {
      alert("Invalid phone number.")
      fld.focus()
      return(false)
    }
  }
  return(true)
}

//
//  Snow Code
//

var snow_margin
var snow_timer
var snow_i = 0
var snow_make = 0
var snow_http = ""

function SnowRandom(range)
{		
  rand = Math.floor(range*Math.random())
  return rand
}

function SnowMove()
{
  if( document.all )
  {
    for( i=0 ; i<=24 ; i++ )
    {
      var thissnow = eval("document.all['snow"+i+"'].style")
      var rand=Math.floor(24*Math.random())
      thissnow.posLeft += rand-12
      thissnow.posTop += rand
      if( thissnow.posTop>=snow_margin ){ thissnow.posTop =- 150 }
    }
    snow_timer = setTimeout("SnowMove()", 100)
  }
}

function SnowLoad()
{
  if( document.all )
  {
    snow_margin = document.body.clientHeight
    var thissnow = eval("document.all['snow"+snow_i+"'].style")
    thissnow.posLeft = (snow_i*40)-50
    thissnow.posTop = SnowRandom(snow_margin*2)-snow_margin
    if( snow_i>=24 )
    {
      snow_i = 0
      clearTimeout(snow_timer)
      SnowMove()
    }
    else
    {
      snow_i++
      SnowLoad()
    }
  }
}

function Snow()
{
  for( i=0 ; i<=24 ; i++ )
  {
    document.write("<div id='snow"+i+"' style='position:absolute'>")
    document.write("<img src='"+snow_http+"snow.gif'></div>")
  }
  snow_make = 1
}

//
//  Text Fader Code
//

var fade_timer
var fade_index = 0
var fade_count = 0

function FadeText(text, fInOut, fHang, x1, y1, x2, y2)
{
  fade_count += 1
  id = "ftxt"+fade_count
  document.write("<div id='"+id+"' style='position:absolute;")
  document.write("font-family:times;")
  document.write("font-size:28;color:#F00000;filter:alpha(opacity=0);")
  document.write("left:1600;top:0'>\n")
  document.write(text)
  document.write("</div>\n")

  eval(id+"fInOut = fInOut")
  eval(id+"fHang  = fHang")
  eval(id+"x1     = x1")
  eval(id+"y1     = y1")
  eval(id+"x2     = x2")
  eval(id+"y2     = y2")
  eval(id+"tick   = 0")
}

function FadeMove(n)
{
  id = "ftxt"+n
  ftxt = document.getElementById(id)
  fInOut = eval(id+"fInOut")
  maxo = 100
  if( fInOut<0 )
  {
    fInOut = -fInOut
    maxo = 40
  }
  fHang = eval(id+"fHang")
  x1    = eval(id+"x1")
  y1    = eval(id+"y1")
  x2    = eval(id+"x2")
  y2    = eval(id+"y2")
  tick  = eval(id+"tick")

  tot = (fInOut*2)+fHang
  x   = ((x2-x1)*tick)/tot+x1
  y   = ((y2-y1)*tick)/tot+y1
  ftxt.style.posLeft = x
  ftxt.style.posTop  = y

  ft = eval("ftxt"+n)

  if( tick<fInOut )
  {
    ft.filters.alpha.opacity = (tick*maxo)/fInOut
    eval(id+"tick++")
  }
  else
  {
    if( tick<(fInOut+fHang) ) eval(id+"tick++")
    else
    {
      off = fInOut-(tick-(fInOut+fHang))
      ft.filters.alpha.opacity = (off*maxo)/fInOut
      eval(id+"tick++")
      if( eval(id+"tick")==tot )
      {
        ft.filters.alpha.opacity = 0
        clearInterval(eval(id+"timer"))
        eval(id+"tick = 0")
        FadeNext()
      }
    }
  }
}

function FadeNext()
{
  fade_index++
  if( fade_index>fade_count )
  {
    fade_index = 0
    setTimeout("FadeNext()", 20000)
    return
  }

  id = "ftxt"+fade_index
  eval(id+"timer = setInterval('FadeMove("+fade_index+")', 50)")
}

//
//  Text Highlight Code
//

var txhi_style  = ""
var txhi_color1 = "#000000"
var txhi_color2 = "#808080"

function TxHiOver(name)
{
  elm = document.getElementById(name)
  elm.style.color = eval(name+"Clr2")
}

function TxHiOut(name)
{
  elm = document.getElementById(name)
  elm.style.color = eval(name+"Clr1")
}

function TxHiSetup(style, color1, color2)
{
  txhi_style  = style
  txhi_color1 = color1
  txhi_color2 = color2
}

function TxHiLink(name, text, url)
{
  TxHiLinkBase(name, text, url, 0)
}

function TxHiLinkBase(name, text, url, newWin)
{
  cl = "color:" + txhi_color1
  if( url=="" )
  {
    s1 = "<div id=" + name + " "
    s4 = "</div>"
  }
  else
  {
    if( newWin ) targ = "target='_blank'"
    else         targ = ""
    if( txhi_color1==txhi_color2 )
      s1 = "<a "+targ+" href='" + url + "' id=" + name + " "
    else
      s1 = "<a "+targ+" href='" + url + "' id=" + name + " onmouseover='TxHiOver(\"" +
           name + "\")' onmouseout='TxHiOut(\"" + name + "\")' "
    s4 = "</a>"
  }
  s2 = "style='"
  s3 = ";" + txhi_style + "'>"
  document.write(s1+s2+cl+s3+text+s4+"\n")

  eval(name+"Clr1 = txhi_color1")
  eval(name+"Clr2 = txhi_color2")
}

function TxHiLinkAbs(name, text, url, x, y)
{
  cl = "color:" + txhi_color1
  if( url=="" )
  {
    s1 = "<div id=" + name + " "
    s4 = "</div>"
  }
  else
  {
    if( txhi_color1==txhi_color2 )
      s1 = "<a href='" + url + "' id=" + name + " "
    else
      s1 = "<a href='" + url + "' id=" + name + " onmouseover='TxHiOver(\"" +
           name + "\")' onmouseout='TxHiOut(\"" + name + "\")' "
    s4 = "</a>"
  }
  s2 = "style='position:absolute;left:" + x + ";top:" + y + ";"
  s3 = ";" + txhi_style + "'>"
  document.write(s1+s2+cl+s3+text+s4+"\n")

  eval(name+"Clr1 = txhi_color1")
  eval(name+"Clr2 = txhi_color2")
}

//
//  Collapse
//

function Collapse(n)
{
  elm = document.getElementById("clps"+n)
  if( elm.style.display=="none" )
    elm.style.display = "block"
  else
    elm.style.display = "none"
}

//
//  Scroll Text Code
//

var scrtx_make = 0
var scrtx_ht
var scrtx_boxht
var scrtx_outer
var scrtx_inner
var scrtx_ref

var scrtx_w3c = (document.getElementById) ? true : false
var scrtx_ie4 = (document.all && !scrtx_w3c) ? true : false
var scrtx_ie5 = (document.all && scrtx_w3c) ? true : false

function ScrTxTop(el)
{
  var y = 0

  if( scrtx_ie4 || scrtx_w3c )
  {
    while( el.offsetParent!=null )
    {
      y += el.offsetTop
      el = el.offsetParent
    }
    y += el.offsetTop
  }
  return(y)
}

function ScrTxMove()
{
  scrtx_inner.style.top = parseInt(scrtx_inner.style.top)-1
  if( parseInt(scrtx_inner.style.top)<(-scrtx_ht)+scrtx_boxht )
    scrtx_inner.style.top = scrtx_adj
}

function ScrTxLoad()
{
  if( scrtx_make )
  {
    scrtx_outer = (scrtx_ie4) ? document.all['st_outer'] : document.getElementById('st_outer')
    scrtx_inner = (scrtx_ie4) ? document.all['st_inner'] : document.getElementById('st_inner')
    scrtx_ref   = (scrtx_ie4) ? document.all['st_ref'] : document.getElementById('st_ref')

    i = scrtx_inner
    if( scrtx_ie4 || scrtx_ie5 )
      scrtx_ht = i.style.height ? i.style.height : i.clientHeight
    else
      scrtx_ht = i.style.height ? parseInt(i.style.height) : parseInt(i.offsetHeight)

    scrtx_outer.style.top  = ScrTxTop(scrtx_ref)
    scrtx_inner.style.top  = 0

    setInterval('ScrTxMove()', 100)
  }
}

function ScrollText(wd, ht, txt, bgClr, ftAttrs, adjust)
{
  scrtx_make  = 1
  scrtx_boxht = ht
  scrtx_adj   = adjust

  document.write("<div id='st_ref' style='position:relative;width:"+wd+";height:"+ht+";background-color:"+bgClr+"'></div>")
  document.write("<div id='st_outer' style='position:absolute;width:"+wd+";height:"+ht+";overflow:hidden'>")
  document.write("<div id='st_inner' style='position:absolute;left:2px;top:2px;width:"+(wd-4)+";overflow:hidden;cursor:default;"+ftAttrs+"'>")
  document.write(txt)
  document.write("</div></div>")
}

//
//  Menu Code
//

var menu_current
var menu_curdead
var menu_animate
var menu_offset  = 300
var menu_offset2 = 550

function MenuButton(name, url)
{
  step = (name.length-1)*6+40
  style = "font-family:arial;font-size:15px;font-weight:bold;text-decoration:none"
  if( menu_current==name )
    TxHiSetup(style, "#000000", "#000000")
  else
    TxHiSetup(style, "#0000C0", "#000000")
  if( menu_current==name && menu_curdead )
    TxHiLinkAbs("m"+name, name, "", menu_offset, 75)
  else
    TxHiLinkAbs("m"+name, name, url, menu_offset, 75)
  menu_offset += step
}

function Menu2Button(name, url)
{
  step  = name.length*7+30
  style = "font-family:arial;font-size:11px;font-weight:bold;text-decoration:none"
  TxHiSetup(style, "#606060", "#000000")
  TxHiLinkAbs("m"+name, name, url, menu_offset2, 3)
  menu_offset2 += step
}

function MenuHoliday()
{
  dat = new Date()
  month = dat.getMonth()
  day   = dat.getDate()
  dayw  = dat.getDay()
  if( month==10 && dayw==4 && day>=22 && day<=28 )
  {
    FadeText("Happy Thanksgiving!", 30, 200, 300, 25, 300, 25)
    return(1)
  }
  if( month==11 && (day>=20 && day<=25) )
  {
    FadeText("Merry Christmas!", 30, 200, 300, 25, 300, 25)
    Snow()
    return(1)
  }
  if( (month==11 && day>25) || (month==0 && day==1) )
  {
    FadeText("Happy New Year!", 30, 200, 300, 25, 300, 25)
    if( month==0 && day==1 )
      fireworks_make = 1
    return(1)
  }
  if( month==1 && day==14 )
  {
    FadeText("Don't forget", 10, 20, 340, 25, 340, 25)
    FadeText("It's Valentine's Day!", 10, 100, 300, 25, 300, 25)
    return(1)
  }
  if( month==6 && day==4 )
  {
    FadeText("Let freedom ring", 10, 20, 300, 25, 300, 25)
    FadeText("Happy July 4th!!!", 10, 200, 300, 25, 300, 25)
    fireworks_make = 1
    return(1)
  }
  if( month==9 && day==31 )
  {
    FadeText("Happy Halloween!", -80, 10, 100, 0, 600, 50)
    return(1)
  }
  return(0)
}

function Menu(current, curdead, animate, http)
{
  menu_current = current
  menu_curdead = curdead
  menu_animate = animate
  snow_http    = http

  document.write("<div style='position:relative'>\n")
  document.write("<img src='"+http+"banner.jpg' id=mBanner>\n")

  /*  Define Main Menu Here  */

  MenuButton("Intro",     http+"index.htm")
  MenuButton("StartPoint",http+"start.htm")
  MenuButton("Disease",   http+"disease.htm")
  MenuButton("Tools",     http+"tools.htm")
  MenuButton("Articles",  http+"articles.htm")
  MenuButton("Download",  http+"download.htm")

  /*  Define Secondary Menu Here  */

  Menu2Button("search",  http+"search.htm")
  Menu2Button("contact", http+"contact.htm")

  /*  Define fading text - regular or holiday  */

  if( animate )
  {
    /*if( MenuHoliday()==0 )
    {*/
      if( animate==1 )
      {
        FadeText("2 million people will die this year", 30, 25, 200, 25, 200, 25)
        FadeText("from diseases that modern medicine can't cure", 30, 25, 180, 25, 180, 25)
        FadeText("Billions of dollars have been raised for research", 30, 25, 200, 25, 200, 25)
        FadeText("Why are we worse off today than ever before?", 30, 25, 200, 25, 200, 25)
        FadeText("You are about to learn the truth", 30, 25, 240, 25, 240, 25)
      }
      if( animate==2 )
      {
        /*FadeText("Get the nutrients your body needs", 30, 25, 240, 25, 240, 25)
        FadeText("at lab manufacturer's cost", 30, 25, 240, 25, 240, 25)
        FadeText("and start letting your body heal itself", 30, 25, 200, 25, 200, 25)*/
      }
    /*}*/
  }

  document.write("</div>\n")

  if( animate ) FadeNext()
}

function MenuLoad()
{
  if( menu_animate )
  {
    if( snow_make ) SnowLoad()
    if( fireworks_make ) Fireworks()
  }
  ScrTxLoad()
}

//-->
