﻿// JScript File
function FriendValidate()
{
                      var obj = document.getElementById('txtName');
                        if(!(chkEmpty(obj,"first name",'firstnameError')  && chkPattern(obj,"first name",/^\s*([A-Z]|[a-z])/,'firstnameError')))
                       {
                            return false;
                       } 
                       
                       obj = document.getElementById('txtLastName');
                        if(!(chkEmpty(obj,"last name",'lastnameError')  && chkPattern(obj,"last name",/^\s*([A-Z]|[a-z])/,'lastnameError')))
                       {
                            return false;
                       } 
                             
                       obj = document.getElementById('txtEmail');
                       if(!(chkEmpty(obj,"your email address",'yourEmailError') && chkPattern(obj,"email address",/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,'yourEmailError')))
                       {
                            return false;
                       }
                       
                       obj = document.getElementById("ddlCountry");
                       if(obj.options[obj.options.selectedIndex].value == "-1")
                       {
                            document.getElementById("CountryError").innerHTML = "";
                            document.getElementById("CountryError").innerHTML = "Select your country";
                            document.getElementById("CountryError").style.display = "block";
                            obj.focus();
                            return false;
                       }
                       else
                       {
                            document.getElementById("CountryError").style.display = "none";
                       }
                       
                       
                       obj = document.getElementById('txtContactMobileAreaCode');
                       if(obj != null)
                       {
                           if(!(chkEmpty(obj,"area code",'mobileError')))
                           {
                                return false;
                           }
                       }
                       
                        obj = document.getElementById('txtMobileContactNo');
                       if(obj != null)
                       {
                           if(!(chkEmpty(obj,"contact no",'mobileError')))
                           {
                                return false;
                           }
                       }
                                              
                       obj = document.getElementById('txtSubject');
                       if(obj != null)
                       {
                           if(!(chkEmpty(obj,"your subject",'subjectError')))
                           {
                                return false;
                           }
                       }
                       
                       obj = document.getElementById('ddlSource');
                       if(obj.options[obj.options.selectedIndex].value == "")
                       {
                            document.getElementById("sourceError").innerHTML = "";
                            document.getElementById("sourceError").innerHTML = "Select how did you hear about us?";
                            document.getElementById("sourceError").style.display = "block";
                            obj.focus();
                            return false;
                       }
                       else
                       {
                            document.getElementById("sourceError").style.display = "none";
                       }
                       
                       if(document.getElementById("otherDivSrouce").style.display == "block")
                       {
                           obj = document.getElementById('txtOtherSource');
                           if(!(chkEmpty(obj,"how did you heard about us?",'otherSourceErrorDiv')))
                           {
                                return false;
                           }
                       }
                       
                       
                       obj = document.getElementById('txtMessage');
                       if(obj != null)
                       {
                           if(!(chkEmpty(obj,"your message",'commentsError')))
                           {
                                return false;
                           }
                       }
                       
                       
                       obj = document.getElementById('txtCaptcha');
                       if(obj != null)
                       {
                           if(!(chkEmpty(obj,"the code",'txtCaptchaError')))
                           {
                                return false;
                           }
                       }
                 
                       return true;
                                     
        }


function ChangeSource(obj)
{
    if(obj.options[obj.options.selectedIndex].value == "Other Source")
   {
         document.getElementById("otherDivSrouce").style.display = "block";
   }
   else
   {
        document.getElementById("otherDivSrouce").style.display = "none";
   }
}
