﻿// JScript File

             function fillCountryCode(obj)
             {
                if(obj.options[obj.options.selectedIndex].value != "-1")
                {
                  var Code = obj.options[obj.options.selectedIndex].value.split('-') ;
                  var txtCountryCode = document.getElementById('txtContactCountryCode');
                  txtCountryCode.value = Code[2];
                }
                else
                {
                    document.getElementById('txtContactCountryCode').value = "";
                }
             }
             function validateLL()
             {
               var obj = document.getElementById('ddltitle');
               if(obj.options[obj.options.selectedIndex].value == "-1")
               {
                         alert("Please select title");
                         obj.focus();
                         return false;
               }
               obj = document.getElementById('txtName');
               if(!(chkEmpty(obj,"first name") && chkLength(obj,"first name",3,25) && chkPattern(obj,"first name",/^\s*([A-Z]|[a-z])/)))
               {
                    return false;
               }               
               obj = document.getElementById('txtLastName');
               if(!(chkEmpty(obj,"last name") && chkLength(obj,"last name",3,25) && chkPattern(obj,"last name",/^\s*([A-Z]|[a-z])/)))
               {
                    return false;
               } 
               
                     
               obj = document.getElementById('ddlCountry');
               if(obj.options[obj.options.selectedIndex].value == "-1")
               {
                         alert("Please select country of residence");
                         obj.focus();
                         return false;
               }     
                obj = document.getElementById('txtContactAreaCode');
                if(!(chkEmpty(obj,"area code") && chkLength(obj,"area code",1,3)))
               {
                    return false;
               }
               else
               {
                        var filter  = /^\d*[0-9]?$/;
                        if(!filter.test(obj.value))
                        {
                            alert('Please check the format of your area code and ensure it has been entered correctly, no spaces or symbols');
                            return false;
                        }
               } 
                     
               obj = document.getElementById('txtContactNo');
               
               if(!(chkEmpty(obj,"contact number") && chkLength(obj,"contact number",5,9)))
               {
                    return false;
               } 
               else
               {
                        var filter  = /^\d*[0-9]?$/;
                        if(!filter.test(obj.value))
                        {
                            alert('Please check the format of your contact number and ensure it has been entered correctly, no spaces or symbols');
                            return false;
                        }
               } 
               
               obj = document.getElementById('txtEmail');
               if(!(chkEmpty(obj,"email address") && chkPattern(obj,"email address",/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)))
               {
                    return false;
               }
               
                obj = document.getElementById('ddlCity');
               if(obj.options[obj.options.selectedIndex].value == "-1")
               {
                         alert("Please select city");
                         obj.focus();
                         return false;
               }
               
               
               obj = document.getElementById('ddlDistrict');
               if(obj.options[obj.options.selectedIndex].value == "-1")
               {
                         alert("Please select district");
                         obj.focus();
                         return false;
               }
               
               
               obj = document.getElementById('ddlCommunity');
               if(obj.options[obj.options.selectedIndex].value == "-1")
               {
                         alert("Please select community");
                         obj.focus();
                         return false;
               }
               
               
               obj = document.getElementById('ddlSubcommunity');
               if(obj.options[obj.options.selectedIndex].value == "-1")
               {
                         alert("Please select subcommunity");
                         obj.focus();
                         return false;
               }
                      
                 //obj = document.getElementById('txtPropertyLocated');
              // if(!chkEmpty(obj,"property located"))
              // {
              //      return false;
              // } 
                obj = document.getElementById('ddlPropertyType');
                if(obj.options[obj.options.selectedIndex].value == "Not Specified")
               {
                         alert("Please select property type");
                         obj.focus();
                         return false;
               }
			   
			    obj1 = document.getElementById('ddlEnquiry');
               obj = document.getElementById('ddlbedrooms');
               if (obj.options[obj.options.selectedIndex].value == "Please select" && obj1.options[obj1.options.selectedIndex].value != "Property Management") {
                   alert("Please select no. of bedrooms");
                   obj.focus();
                   return false;
               }

               obj1 = document.getElementById('ddlEnquiry');
               obj = document.getElementById('ddlPropertyStatus');
               if (obj.options[obj.options.selectedIndex].value == "Please select" && obj1.options[obj1.options.selectedIndex].value != "Property Management") {
                   alert("Please select property status");
                   obj.focus();
                   return false;
               }
             
             }
             
