// JScript File
      function fillCountryCode(obj)
             {
                var txtCountryCode = document.getElementById('txtContactCountryCode');
                if(obj.options[obj.options.selectedIndex].value != "-1")
                {
                  var Code = obj.options[obj.options.selectedIndex].value.split('-') ;
                  txtCountryCode.value = Code[2];
                }
                else
                {
                     txtCountryCode.value = "";
                }
             }
             function validate()
             {
               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",1,25) && chkPattern(obj,"last name",/^\s*([A-Z]|[a-z])/)))
               {
                    return false;
               } 
                     
                          
                 obj = document.getElementById('txtContactAreaCode');
                if(!(chkEmpty(obj,"area code") && chkLength(obj,"Area code",1,3) && chkPattern(obj,"area code",/^\d*[0-9]?$/)))
               {
                    return false;
               } 
                     
                obj = document.getElementById('txtContactNo');
               if(!(chkEmpty(obj,"contact number") && chkLength(obj,"Contact number",5,9) && chkPattern(obj,"contact number",/^\d*[0-9]?$/)))
               {
                    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('ddlEnquiry');
                 if(obj.options[obj.options.selectedIndex].value == "Other")
                 {
                   var txtObejct = document.getElementById('htxtEnquiry');
                   if(!(chkEmpty(txtObejct,"enquiry about") && chkLength(obj,"Contact number",2,200)))
                     {
                            return false;
                    } 
                    
                 }
               obj = document.getElementById('ddlCountry');
               if(obj.options[obj.options.selectedIndex].value == "-1")
               {
                         alert("Please Select Country of residence");
                         obj.focus();
                         return false;
               }
                 return true;
            
                
             }
             function fillBudget(obj, enquiryTypeId,countryId,Path)
             {
                var txtObj = document.getElementById("hDivEnquiry");
                var rowObj = document.getElementById("rowBudget");
                var ddlObj = document.getElementById('ddlBudget');
                var txtBudgetObj = document.getElementById('txtBudget');
                if(obj.options[obj.options.selectedIndex].value != "-1" && obj.options[obj.options.selectedIndex].value != "Other" && obj.options[obj.options.selectedIndex].value != "Short-Term Rentals-3")
                {
                    txtObj.style.display ="none";
                    var URL = Path + "Search.aspx?type=Enquiry.budget&EnquiryTypeId="+enquiryTypeId+"&countryId="+countryId+"&EnquiryAboutId=" + obj.options[obj.options.selectedIndex].value;
                    CreateXmlHttpRequest();
                    var mydate = new Date();
                    URL+="&cacheId="+mydate.getTime();
                    request.onreadystatechange = fillBudgetValue;
                    request.open("GET", URL, true);
                    request.send(null);
                    var obj2 = document.getElementById('ddlBudget');
                    for(i=obj2.options.length -1; i >= 0; i--)
                    {
                        obj2.options[i] = null;
                    }
                    obj2.options[0] = document.createElement("option",true);
                    obj2.options[0].value = -1;
                    obj2.options[0].text = "Loading ...";
                    txtObj.style.display ="none";
                    txtBudgetObj.style.display ="none";
                    ddlObj.style.display ="block";
                    rowObj.style.display ="";                    
                    ddlObj.disabled='';
                  }
                     else if(obj.options[obj.options.selectedIndex].value == "Short-Term Rentals-3")
                     {
                        txtObj.style.display ="block";
                        rowObj.style.display ="";
                        
                        var k = 0;
                        for(k=ddlObj.options.length-1; k >= 0;k--)
                            {
                                ddlObj.options[k] = null;
                            }
                             ddlObj.disabled='';
                             ddlObj.style.display ="none";
                             txtBudgetObj.style.display ="block";
                     }
                     else if(obj.options[obj.options.selectedIndex].value == "Other")
                     {
                        rowObj.style.display ="none";
                        ddlObj.disabled='';
                        txtBudgetObj.style.display ="none";
                        ddlObj.style.display ="";
                     }
                      else if(obj.options[obj.options.selectedIndex].value == "-1")
                     {
                            var k = 0;
                            for(k=ddlObj.options.length-1; k >= 0;k--)
                            {
                                ddlObj.options[k] = null;
                            }
                            ddlObj.options[0] = document.createElement("option",true);
                            ddlObj.options[0].value = -1;
                            ddlObj.options[0].text = "Please select";
                            ddlObj.disabled='disabled';
                            rowObj.style.display ="";
                            txtBudgetObj.style.display ="none";
                            ddlObj.style.display ="block";
                     }
             }
             
           
             function fillBudgetValue()
             {
                 if(request.readyState == 4)
                    {
                        if(request.status == 200)
                        {
                          
			                var obj = document.getElementById('ddlBudget');
                            for(i=obj.options.length-1; i >= 0; i--)
                            {
                                obj.options[i] = null;
                            }
                            var newOptions = request.responseText.split("|");
                            for(i=0 ; i < newOptions.length ; i++)
                            {
                                obj.options[i] = document.createElement("option", true);
                                obj.options[i].value = newOptions[i];
                                obj.options[i].text = newOptions[i];
                            }
                        }
                        else
                        {
                            alert(request.status);
                        }
                    }
             }
             function getCommunities(obj,Path)
             {
                var stateId = "";
                if(obj.options[obj.options.selectedIndex].value != "-1")
                {
                    var stateId = obj.options[obj.options.selectedIndex].value.split('-');
                    var URL = Path + "Search.aspx?type=basic.community.selection&stateId=" +stateId[1];
                    CreateXmlHttpRequest();
                    var mydate = new Date();
                    URL+="&cacheId="+mydate.getTime();
                    request.onreadystatechange = fillBfillSubLocationsValue;
                    request.open("GET", URL, true);
                    request.send(null);
                    var obj2 = document.getElementById('divSubComm');
                    obj2.style.display = "block";
                    obj2.innerHTML ="Loading .... ";
                 }
                  else
                  {
                    var obj2 = document.getElementById('divSubComm');
                    obj2.style.display="none"
                  }
             }
             function fillBfillSubLocationsValue()
             {
                 if(request.readyState == 4)
                    {
                        if(request.status == 200)
                        {
                            var  FinalHTML = new String();
			                var obj = document.getElementById('divSubComm');
                            var newOptions = request.responseText.split("|");
                            for(i=0 ; i < newOptions.length ; i++)
                            {     var vals = newOptions[i].split("::");              
                                  FinalHTML += "<div style='height:20px;'>&nbsp;<input name='lstCommunity' type='Checkbox' value='"+vals[0]+"'/>&nbsp;"+vals[0]+"</div>";
                            }
                            obj.innerHTML = FinalHTML;
                        }
                        else
                        {
                            alert(request.status);
                        }
                    }
             }

