﻿// JScript File

var fields = new Array("lastName"
                     ,"company"
                     ,"position"
                     ,"country"
                     ,"email"
                     ,"text"
                     ,"department");
var message = new Array("Your last name is missing."
                     ,"Your company is missing."
                     ,"Your position is missing."
                     ,"Your country is missing."
                     ,"Your e-mail address is missing."
                     ,"Your comment or question is missing."
                     ,"Choose the type of the Issue.");

function checkContactFields()
{
   var i = 0;
   var text = "";
   var elem;
   for(i = 0; i < fields.length; ++i)
   {
      elem = document.getElementById(fields[i]);
      if(elem.tagName == "SELECT")
      {
         if(elem.value == 0)
         {
            elem.style.backgroundColor = "#FFDBDB";
            text += message[i] + "<br />";
         }
         else
         {
            elem.style.backgroundColor = "#FFFFFF";
         }
      }
      else
      {
         if(elem.value == "")
         {
            elem.style.backgroundColor = "#FFDBDB";
            text += message[i] + "<br />";
         }
         else
         {
            elem.style.backgroundColor = "#FFFFFF";
         }
      }
   }
   var container = document.getElementById("errorMsgsContainer");
   if(text != "")
   {
      document.getElementById("errorMsgs").innerHTML = text;
      container.style.visibility = "visible";
      container.style.display = "inline";
      return false;
   }
   else
   {
      container.style.visibility = "hidden";
      container.style.display = "none";
      return true;
   }
}
