// JavaScript Document

function show(id)
{
  document.getElementById(id).style.display = "block";
}

function hide(id)
{
  document.getElementById(id).style.display = "none";
}

function onA(obj) { obj.className='over'; }
function offA(obj) { obj.className=''; }

function fScrollDown(maxdown)
{
  var obj = document.getElementById('fFullList');
  if(obj.style.top){
    var y = parseInt(obj.style.top);
  }
  else{
    var y = 0;
  }
  
  if(y > maxdown){
    var newY = y - 70;
    if(newY <= maxdown){
      document.getElementById('arrowDown').style.display = "none";
    }
    if(newY < 0){
      document.getElementById('arrowUp').style.display = "block";
    }
    obj.style.top = newY + 'px';
  }
}

function fScrollUp(maxdown)
{
  var obj = document.getElementById('fFullList');
  if(obj.style.top){
    var y = parseInt(obj.style.top);
  }
  else{
    var y = 0;
  }
  
  if(y < 0){
    var newY = y + 70;
    if(newY >= 0){
      document.getElementById('arrowUp').style.display = "none";
    }
    if(newY > maxdown){
      document.getElementById('arrowDown').style.display = "block";
    }
    obj.style.top = newY + 'px';
  }
}

function openWindow(page){
  var myWind = window.open(page, 'Presentation', 'height=500,width=460,z-lock=yes,toolbar=no,titlebar=no,screenX=100,screenY=100,resizable=no,menubar=no,scrollbars=1')
}

function clearField(obj){
  if(obj.value != ''){
    obj.value = "";
  }
}

function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}

function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}

function validate_tellafriend(thisform)
{
with (thisform)
  {
  
  if (validate_required(yourname,"You must input your name")==false)
    {yourname.focus();return false;}
  
  if (validate_email(youremail,"Your e-mail address is not valid")==false)
    {youremail.focus();return false;}
  
  if (validate_required(friendname,"You must input your friend's first name")==false)
    {friendname.focus();return false;}  
  
    if (validate_email(friendemail,"Your friend's e-mail address is not valid")==false)
    {friendemail.focus();return false;}
  }
}

function validate_share(thisform)
{
with (thisform)
  {
  
  if (validate_required(firstname,"You must input your first name")==false)
    {firstname.focus();return false;}
    
  if (validate_required(lastname,"You must input your last name")==false)
    {lastname.focus();return false;}
  
  if (validate_email(email,"Your e-mail address is not valid")==false)
    {email.focus();return false;}
  
  if (validate_required(solution,"You cannot leave the solution field blank")==false)
    {solution.focus();return false;}  
  }
}
