<!--

//
//  Utility Code
//

function EFoilGetEMail(name)
{
  s1 = "\100"; s2 = "QHSOnline"; 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="roger@qhsonline.com">')
}

function TrashFrom()
{
  document.write('<input type="hidden" name="email" value="trash@trash.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)
}

function CaseValidator(theForm)
{
  bflds = ["item_2_qty", "item_3_qty", "item_4_qty", "item_5_qty", "item_6_qty",
           "item_7_qty", "item_8_qty"]
  tot = 0
  for( i=0 ; i<7 ; i++ )
  {
    if( isNaN(theForm.elements[bflds[i]].value) )
    {
      alert("Bottle fields must contain only whole numbers.")
      return(false)
    }
    tot = tot+parseInt(theForm.elements[bflds[i]].value)
  }
  ctot = parseInt(theForm.item_1_qty.value)*12
  if( tot!=ctot )
  {
    alert("Make sure total number of bottles equal number of cases times twelve.")
    return(false)
  }
  return(true)
}

function Case2Validator(theForm)
{
  if( !theForm.partnerID.value )
  {
    alert("Please specify your Partner ID.")
    return(false)
  }
  if( !CaseValidator(theForm) )
  {
    return(false)
  }
  theForm.email_text.value = "Partner ID: "+theForm.partnerID.value
  return(true)
}

function Case3Validator(theForm)
{
  if( !theForm.resellerID.value )
  {
    alert("Please specify your Reseller ID.")
    return(false)
  }
  if( !theForm.company.value )
  {
    alert("Please specify your business name.")
    return(false)
  }
  if( !CaseValidator(theForm) )
  {
    return(false)
  }
  theForm.email_text.value = "Reseller ID: "+theForm.resellerID.value+"\n"+"Business Name: "+theForm.company.value
  return(true)
}

function FreeValidator(theForm)
{
  ffld  = "item_13_qty"
  rfld  = "item_11_qty"
  cflds = ["item_1_qty", "item_3_qty", "item_5_qty", "item_7_qty", "item_9_qty"]

  if( theForm.elements[ffld].value=="" )
  {
    return(true)
  }
  tot = 0
  for( i=0 ; i<5 ; i++ )
  {
    if( theForm.elements[cflds[i]].value!="" )
    {
      tot = tot+parseInt(theForm.elements[cflds[i]].value)
    }
  }
  if( theForm.elements[rfld].value!="" )
  {
    tot = tot+parseInt(theForm.elements[rfld].value)*2
  }
  if( tot<2 )
  {
    alert("You must purchase at least 2 bottles to receive the free QuantumProtect.")
    return(false)
  }
  return(true)
}

function PAppValidator(theForm)
{
  rflds = ["first_name", "last_name", "address", "city", "state", "zip",
           "phone", "email", "birth_month", "birth_day", "birth_year"]
  for( i=0 ; i<11 ; i++ )
  {
    if( !theForm.elements[rflds[i]].value )
    {
      alert("Please specify: "+rflds[i])
      return(false)
    }
  }
  today  = new Date()
  tDate  = today.getDate()
  tMonth = today.getMonth()+1
  tYear  = today.getYear()%100
  tyear  += (tyear<38)?2000:1900 
  return(true)
}

function PBoxValidator(theForm)
{
  rflds = ["partnerID", "name", "email", "comments"]
  for( i=0 ; i<4 ; i++ )
  {
    if( !theForm.elements[rflds[i]].value )
    {
      alert("Please specify: "+rflds[i])
      return(false)
    }
  }
  return(true)
}

function POrderValidator(theForm, url)
{
  if( !theForm.password.value )
  {
    alert("Please specify the password in order to proceed.")
    return(false)
  }
  if( theForm.password.value!="crown" )
  {
    alert("Incorrect password. Please contact us via email.")
    return(false)
  }
  document.location = url
  return(false)
}

function RAppValidator(theForm)
{
  rflds = ["first_name", "last_name", "company", "store_type", "n_employees",
           "n_stores", "years_business", "address", "city", "state", "zip",
           "phone", "email", "cases_qtr"]
  for( i=0 ; i<14 ; i++ )
  {
    if( !theForm.elements[rflds[i]].value )
    {
      alert("Please specify: "+rflds[i])
      return(false)
    }
  }
  return(true)
}

function RBoxValidator(theForm)
{
  rflds = ["resellerID", "name", "email", "company", "comments"]
  for( i=0 ; i<5 ; i++ )
  {
    if( !theForm.elements[rflds[i]].value )
    {
      alert("Please specify: "+rflds[i])
      return(false)
    }
  }
  return(true)
}

function ROrderValidator(theForm, url)
{
  if( !theForm.password.value )
  {
    alert("Please specify the password in order to proceed.")
    return(false)
  }
  if( theForm.password.value!="trumpet" )
  {
    alert("Incorrect password. Please contact us via email.")
    return(false)
  }
  document.location = url
  return(false)
}

//
//  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 TxHiLinkLocal(name, text, url)
{
  cl = "color:" + txhi_color1

  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='"
  s3 = ";" + txhi_style + "'>"
  document.write(s1+s2+cl+s3+text+s4+"\n")

  eval(name+"Clr1 = txhi_color1")
  eval(name+"Clr2 = txhi_color2")
}

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 = "target='_top'"
    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 target='_top' href='" + url + "' id=" + name + " "
    else
      s1 = "<a target='_top' 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  = 360
var menu_offset2 = 590

function MenuButton(name, url)
{
  step = (name.length-1)*6+48
  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*5+25
  style = "font-family:arial;font-size:11px;font-weight:bold;text-decoration:none"
  TxHiSetup(style, "#808080", "#404040")
  TxHiLinkAbs("m"+name, name, url, menu_offset2, 3)
  menu_offset2 += step
}

function Menu(current, curdead, animate, http)
{
  menu_current = current
  menu_curdead = curdead
  menu_animate = animate

  document.write("<div style='position:relative'>\n")
  document.write("<img src='"+http+"banner.jpg' id=mBanner>\n")

  /*  Define Main Menu Here  */

  MenuButton("Home",     http+"index.htm")
  MenuButton("Store",    http+"store.htm")
  MenuButton("Info",     http+"info.htm")
  MenuButton("Programs", http+"programs.htm")
  MenuButton("Company",  http+"company.htm")

  /*  Define Secondary Menu Here  */

  Menu2Button("ViewCart", http+"cart.htm")
  Menu2Button("Orders",   http+"orders.htm")
  Menu2Button("Partners", http+"ptback.htm")

  document.write("</div>\n")
}

function MenuLoad()
{
  ScrTxLoad()
}

//-->
