
function goOver(item, img){
  document.getElementById(item).src = "images/" + img;
}

function toggleBox(szdivID, iState, item, img){ // 1 visible, 0 hidden
  if(document.layers){ //NN4+
    document.layers[szdivID].visibility = iState? "show" : "hide";
  } else if(document.getElementById){ //gecko(NN6) + IE 5+
    var obj = document.getElementById(szdivID);
    obj.style.visibility = iState? "visible" : "hidden";
  }
  else if(document.all){// IE 4
    document.all[szdivID].style.visibility = iState? "visible" : "hidden";
  }

goOver(item, img)
}



function evalscale(q1,q2,q3,q4,q5,q6,q7,q8) {
 
  var subTotal = 0; 
  
  if (q1[1].checked)
            subTotal = subTotal + 1;
  if (q1[2].checked)
            subTotal = subTotal + 2;
  if (q1[3].checked)
            subTotal = subTotal + 3;

  if (q2[1].checked)
            subTotal = subTotal + 1;
  if (q2[2].checked)
            subTotal = subTotal + 2;
  if (q2[3].checked)
            subTotal = subTotal + 3;
			
  if (q3[1].checked)
            subTotal = subTotal + 1;
  if (q3[2].checked)
            subTotal = subTotal + 2;
  if (q3[3].checked)
            subTotal = subTotal + 3;
			
  if (q4[1].checked)
            subTotal = subTotal + 1;
  if (q4[2].checked)
            subTotal = subTotal + 2;
  if (q4[3].checked)
            subTotal = subTotal + 3;
			
  if (q5[1].checked)
            subTotal = subTotal + 1;
  if (q5[2].checked)
            subTotal = subTotal + 2;
  if (q5[3].checked)
            subTotal = subTotal + 3;
			
  if (q6[1].checked)
            subTotal = subTotal + 1;
  if (q6[2].checked)
            subTotal = subTotal + 2;
  if (q6[3].checked)
            subTotal = subTotal + 3;
			
  if (q7[1].checked)
            subTotal = subTotal + 1;
  if (q7[2].checked)
            subTotal = subTotal + 2;
  if (q7[3].checked)
            subTotal = subTotal + 3;
			
  if (q8[1].checked)
            subTotal = subTotal + 1;
  if (q8[2].checked)
            subTotal = subTotal + 2;
  if (q8[3].checked)
            subTotal = subTotal + 3;

  //var total = 0;
  total = subTotal;
    
  if  (total < 9) score = "- You are most likely a sound sleeper.";
  if  (total > 8) score = "- A score over 9 indicates a possible sleep disorder.";
  
  //score = Less than 44 ? Low // 44-48 ? Moderate // More than 48 - High
  
  alert("Your total score is: " + total  + " " + score);
  
}

function evaltest(neck,conv,blood,snoring,gasping) {
 
  var subTotal = 0; 
  
  if (conv[0].selected)
            neckValue = eval(neck.value) * 2.5;

  if (conv[1].selected)
            neckValue = eval(neck.value);  

  if (blood[0].checked == true) {
            subTotal += 4; }
			
  if (snoring[0].checked == true)
            subTotal += 3;
			
  if (gasping[0].checked == true)
            subTotal += 3;			
 
  var total = 0;
  total = subTotal + neckValue;
    
  if  (total < 44) score = "(Low)";
  if  (total > 43 && total < 49) score = "(Moderate)";
  if  (total > 48) score = "(High)";
  
  //score = Less than 44 ? Low // 44-48 ? Moderate // More than 48 - High
  
  alert("Your total score is: " + total  + " " + score);
  
}


function ajaxFunction()
{

var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  document.getElementById("email").value="test"

    // document.getElementById("overlay").visibility = "visible"
      }
    }
	alert('test2');
  xmlHttp.open("GET","submit.asp",true);
  xmlHttp.send(null);
  }




function verifyemail(str) { 
  if(str.match(/^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,6}$/i)) { 
      return false; 
  } else { 
      return true; 
  } 
} 

function formVerify() {


  if(document.form1.name1.value=="enter your name")
  {
  alert('Please provide your name');
  document.form1.name1.focus();
  return false;
  }

    if(verifyemail(document.form1.email.value))
  {
  alert('Please provide a valid e-mail address.');
  document.form1.email.focus();
  return false;
  }


}


function formVerify2() {


    if(verifyemail(document.form2.yemail.value))
  {
  alert('Please provide a valid e-mail address.');
  document.form2.yemail.focus();
  return false;
  }

    if(verifyemail(document.form2.femail.value))
  {
  alert('Please provide a valid e-mail address.');
  document.form2.femail.focus();
  return false;
  }


}