﻿// JScript File

function submitForm()
    {
    document.form2.submit();
 
    } 
    
  ///////// contact us validation fields///////////
  
  

    function ValidateFromEmailAddress()
   
   {
        var fromemail=document.getElementById("txtFromEmail");
        if (fromemail.value == "")
            {
                alert ("You should enter From Email");
                return false;
            }
        else
            {
                return check_email(fromemail.value);
            }
  
    }
    
   function validate()
  {
  var name = document.getElementById("txtname").value;
  var email = document.getElementById("txtemail").value;
  var phone = document.getElementById("txtphone").value;
          if (name == "")
          {
          alert ("You should enter the name");
          return false;
          }
          
          if (email == "")
            {
            alert ("You should enter email address");
            return false;
            }
            else
            {
            return check_email(email);
            }
     return true;
  }
  
  function check_email(address)

{

	if ((address == "") || (address.indexOf ('@') == -1) || (address.indexOf ('.') == -1))
       {
	    alert("Invalid Email address")
	 	return false;
        }
        else
        {
	   return true;
    }
}
  
  
    
    function formatPhoneNumber(phone)
    {
    
        var tempPhone = '(' + phone.substring(0,3) + ')';
        tempPhone += ' ' + phone.substring(3,6);
        tempPhone += '-' + phone.substring(6,10);
        return tempPhone;
    }
  
  //////////////////////////
  
  
   function validateEmailForm()
  {
  var FromEmail = document.getElementById("txtFromEmail").value;
  
   if(document.getElementById("txtEventName"))
   {
    if(document.getElementById("txtEventName").value=="")
    {
    alert("Please select an Event")
    return false;
    }
    
   }
  if(document.getElementById("txtEventName")!=null)
  {
  var EventName = document.getElementById("txtEventName").value;
  }
  if(document.getElementById("txtEmail"))
  {
  var ToEmail = document.getElementById("txtEmail").value;
 
 // var phone = document.getElementById("txtphone").value;
          if (EventName == "")
          {
          alert ("You should Select Event");
          return false;
          }
          if (ToEmail == "")
          {
          alert ("You should enter To Email");
          return false;
          }else
          {
            var list=ToEmail.split(',');
            if(list.length>5)
            {
                alert("Maximium Five Emails are Allowed");
                return false;
            }
            else
            {
                for(i=0;i<list.length;i++)
                {
                if(!(check_email(list[i])))
                {
                    alert("Please enter a valid Email Address");
                    return false;
                }
            }
          }
        }
          if (FromEmail == "")
          {
            alert ("You should enter From Email");
            return false;
          }
          else
          {
            return check_email(FromEmail);
          }
            
     return true;
  }
  }