var z;
z = 0
function sizeheight(){
 tableHeight = document.getElementById('maintable').style.height
 if(screen.availHeight){
  screenHeight = screen.availHeight - 15
 }
 else{
  screenHeight = screen.height - 15
 }
 if(tableHeight.substr(0, tableHeight.length - 2) < screenHeight){
   document.getElementById('maintable').style.height = screenHeight
 }
}

function popprivacy(){
 ppolicy = window.open("privacy.html","PrivacyPolicy","width=400,height=400,menubar=no,resize=no,toolbar=no,scrollbars=yes")
}

function validateemailandname(){
 z = 0
 if (document.getElementById('name').value==''){
  document.getElementById('name').style.backgroundColor = "#f59b49"
  alert('Please enter your full name in the field indicated below.')
 z++
 }
 if (document.getElementById('email').value==''){
  document.getElementById('email').style.backgroundColor = "#f59b49"
  alert('Please enter your e-mail address in the field indicated below.')
  z++
 }
 if (document.getElementById('email').value!=''){
  if (validateemailaddy()==false){z++}
 }
 if (z==0){
  return true;
 }
 if (z!=0){
  return false;
 }
}

function validateemailandnametc(){
 z = 0
 if (document.getElementById('nameb').value==''){
  document.getElementById('nameb').style.backgroundColor = "#f59b49"
  alert('Please enter your full name in the field indicated below.')
 z++
 }
 if (document.getElementById('emailb').value==''){
  document.getElementById('emailb').style.backgroundColor = "#f59b49"
  alert('Please enter your e-mail address in the field indicated below.')
  z++
 }
 if (document.getElementById('emailb').value!=''){
  if (validateemailaddy()==false){z++}
 }
 if (z==0){
  return true;
 }
 if (z!=0){
  return false;
 }
}


function validateclasspick(){
 z = 0
 var radiosel
 radiosel = 'null'
 if (document.getElementById('cname').value==''){
  document.getElementById('cname').style.backgroundColor = "#f59b49"
  alert('Please enter your full name in the field indicated below.')
 z++
 }
 if (document.getElementById('cemail').value==''){
  document.getElementById('cemail').style.backgroundColor = "#f59b49"
  alert('Please enter your e-mail address in the field indicated below.')
  z++
 }
 if (document.getElementById('cemail').value!=''){
  if (validateemailaddy()==false){z++}
 }
 if(document.getElementById('cl1').checked==false && document.getElementById('cl2').checked==false && document.getElementById('cl3').checked==false && document.getElementById('cl4').checked==false){
  alert('Please choose a class time from the options.')
  z++
 }
 if (z==0){
  return true;
 }
 if (z!=0){
  return false;
 }
}

function validatecontact(){
 z = 0
 if (document.getElementById('name').value==''){
  document.getElementById('name').style.backgroundColor = "#f59b49"
  alert('Please enter your full name in the field indicated below.')
 z++
 }
 if (document.getElementById('email').value==''){
  document.getElementById('email').style.backgroundColor = "#f59b49"
  alert('Please enter your e-mail address in the field indicated below.')
  z++
 }
 if (document.getElementById('email').value!=''){
  if (validateemailaddy()==false){z++}
 }
 if (document.getElementById('phone1').value.length < 3 || document.getElementById('phone2').value.length < 3 || document.getElementById('phone3').value.length < 4){
  document.getElementById('phone1').style.backgroundColor = "#f59b49"
  document.getElementById('phone2').style.backgroundColor = "#f59b49"
  document.getElementById('phone3').style.backgroundColor = "#f59b49"
  alert('Please enter a valid phone number with area code') 
  z++
 }
 if (document.getElementById('message').value==''){
  document.getElementById('message').style.backgroundColor = "#f59b49"
  alert('Please enter a message in the indicated area.')
  z++
 }
 if (z==0){
  return true;
 }
 if (z!=0){
  return false;
 }
}

function validateemailaddy(){
 if (document.getElementById('email').value.indexOf('@')<1){
  document.getElementById('email').style.backgroundColor = "#f59b49"
  alert('You seem to have entered an invalid e-mail address.\nPlease check the e-mail address field and try again.')
  return false;
 }
 if (document.getElementById('email').value.indexOf('.')<1){
  document.getElementById('email').style.backgroundColor = "#f59b49"
  alert('You seem to have entered an invalid e-mail address.\nPlease check the e-mail address field and try again.')
  return false;
 }
 if (document.getElementById('email').value.indexOf('@')>document.getElementById('email').value.length-4){
  document.getElementById('email').style.backgroundColor = "#f59b49"
  alert('You seem to have entered an invalid e-mail address.\nPlease check the e-mail address field and try again.')
  return false;
 }
 if (document.getElementById('email').value.indexOf('.')>document.getElementById('email').value.length-3){
  document.getElementById('email').style.backgroundColor = "#f59b49"
  alert('You seem to have entered an invalid e-mail address.\nPlease check the e-mail address field and try again.')
  return false;
 }
 if (document.getElementById('email').value.indexOf(' ')>-1){
  document.getElementById('email').style.backgroundColor = "#f59b49"
  alert('You seem to have entered an invalid e-mail address.\nPlease check the e-mail address field and try again.')
  return false;
 }
 if (document.getElementById('email').value.indexOf(' ')>-1){
  document.getElementById('email').style.backgroundColor = "#f59b49"
  alert('You seem to have entered an invalid e-mail address.\nPlease check the e-mail address field and try again.')
  return false;
 }
}

function resetbg(object){
  document.getElementById(object).style.backgroundColor = "#fff"
}

function resetphonebg(){
  document.getElementById('phone1').style.backgroundColor = "#fff"
  document.getElementById('phone2').style.backgroundColor = "#fff"
  document.getElementById('phone3').style.backgroundColor = "#fff"
}
