function OpenArea(temp) 
{
  if (document.getElementById('a'+temp).style.display=='') 
  {
    document.getElementById('a'+temp).style.display='none';
  } 
  else 
  {
    for (x=1; x<33; x++) 
    {
        document.getElementById('a'+x).style.display='none';
    }
    document.getElementById('a'+temp).style.display='';
  }
}

var tempVar=0;
function opendescription(tempopen) {
  for (num=1;num<10;num++) {
    document.getElementById('text0'+num).style.display='none';
  }
  if (tempopen==tempVar) {
    document.getElementById('text0'+tempopen).style.display='none';
	tempVar=0;
  } else {
	tempVar=tempopen;
    document.getElementById('text0'+tempopen).style.display='';
  }
}

function MM_openBrWindow(theURL,winName,features) //v2.0
{ 
  window.open(theURL,winName,features);
}

function OpenAnswer(temp) 
{
  if (document.getElementById('a'+temp).style.display=='') 
  {
    document.getElementById('a'+temp).style.display='none';
  } 
  else 
  {
    for (x=1; x<49; x++) 
    {
      document.getElementById('a'+x).style.display='none';
    }
    document.getElementById('a'+temp).style.display='';
  }
}

function isNeedOpenFAQ()
{
    var pageFrom = getParam("pagefrom");
    if (pageFrom == "opencall")
    {
        var faqnum = getParam("faqnum");
        OpenAnswer(faqnum);
        document.location = "#a"+faqnum;
    }
}

function getParam(getParam)
{
	var Params = location.search.substring(1).split("&");
	var variable = "";
	for (var i = 0; i < Params.length; i++)
	{
		if (Params[i].split("=")[0] == getParam)
		{
			if (Params[i].split("=").length > 1) variable = Params[i].split("=")[1];
			return variable;
		}
	}
	return "";
}

function setAction(temp) {

  document.formid.action=temp;
}

function validateNewsletter() 
{
  var fname=document.form.fname.value.length;
  var lname=document.form.lname.value.length;
  var hospital=document.form.hospital.value.length;
  var city=document.form.city.value.length;
  var country=document.form.country.value.length;
  var email=document.form.email.value.length;
  var tele=document.form.tele.value.length;
  var chr=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
 
  if ((fname<1)||(lname<1)||(hospital<1)||(country<1)||(city<1)||(tele<1)||(email<1)) {
  alert("Please fill in all the required fields");
  return false;
  }
  if (!chr.test(form.email.value)){
  alert("Invalid E-mail Address! Please re-enter.")
  return false;
  }
}


function validateContactUs() 
{
  var fname=document.form.fname.value.length;
  var lname=document.form.lname.value.length;
  var hospital=document.form.hospital.value.length;
  var city=document.form.city.value.length;
  var country=document.form.country.value.length;
  var email=document.form.email.value.length;
  var tele=document.form.tele.value.length;
  var chr=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
 
  if ((fname<1)||(lname<1)||(hospital<1)||(country<1)||(city<1)||(tele<1)||(email<1)) 
  {
      alert("Please fill in all the required fields");
      return false;
  }
  /*if (!chr.test(form.email.value))
  {
      alert("Invalid E-mail Address! Please re-enter.")
      return false;
  }*/
  
  var x=0;
  if (document.form.checkbox9.checked==true) { x=1; }
  if (document.form.checkbox10.checked==true) { x=1; }
  if (document.form.checkbox11.checked==true) { x=1; }
  if (document.form.checkbox12.checked==true) { x=1; }
  if (document.form.checkbox13.checked==true) { x=1; }
  if (x==0) { alert("Please chose an interest"); }
  if (x==1) { return true; }
  return false;
  
}


function validateOpenCall() 
{
  if (document.formid.action == "other")
  {
      var body = "";
      /*body = body + "First Name: " + document.formid.fname.value + "vbCrLf"
      body = body + "Last Name: " + document.formid.lname.value
      body = body + "Department: " + document.formid.department.value
      body = body + "Institution: " + document.formid.institution.value
      body = body + "City: " + document.formid.city.value
      body = body + "Country: " + document.formid.country.value
      body = body + "Telephone: " + document.formid.tele.value
      body = body + "Email: " + document.formid.email.value*/
      
      window.open("mailto:service@medoc-web.com?subject=Service call from Medoc's website&body="+body);
      return false;
  }
  else
  {
      var firstname=document.formid.fname.value.length;
      var lastname=document.formid.lname.value.length;
      var department=document.formid.department.value.length;
      var institution=document.formid.institution.value.length;
      var country=document.formid.country.value.length;
      var email=document.formid.email.value;
      var selproduct=document.formid.selproduct.value.length;
      function isValidEmail(str) {
        return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
      }
      var statusr=true;  
      var statusr=isValidEmail(email);
      if (selproduct<3) {
        statusr=false;
      }
      if ((firstname<1)||(lastname<1)||(department<1)||(institution<1)) {
	    statusr=false;
      }
      if (statusr==false) {
        alert("Please fill in all the required fields")
        return statusr;
      }
  }
}

function validateOpenCallPathway() 
{
  var serialnumber=document.formid.serialnumber.value.length;
  var problem=document.formid.problem.value.length;

  var statusr=true;  
  if ((serialnumber<1)||(problem<1)) {
	statusr=false;
  }
  
  if (statusr==false) {
    alert("Please fill in all the required fields")
    return statusr;
  }
}

function validateOpenCallTsa() {
  var sn=document.formid.sn.value.length;
  var version=document.formid.version.value.length;
  var software=document.formid.software.value.length;
  var problem=document.formid.problem.value.length;

  var statusr=true;  
  if ((sn<1)||(version<1)||(software<1)||(problem<1)) 
	{
	statusr=false;
  }

  if (statusr==false) {
    alert("Please fill in all the required fields")
    return statusr;
  }
}

function OpenAnswer(index)
{
var item = document.getElementById("a" + index);
if(item.style.display == "none")
	item.style.display = "block"
else
	item.style.display = "none"
}

function InitFAQ()
{
	$('#divFAQ div').hide();
}

$(document).ready(function(){
	InitFAQ();
});