﻿  var serverURLComm = "Function_Ajax.aspx";
        var ajaxObjComm;
        var callType = 0;
            
        function Ajax_MakeAJAXGetCommonCall(varQueryString)
        {
            var URLC = "?" + varQueryString ;
            ajaxObjComm = ajax_CreateXMLHTTPRequest();
            if ( ajaxObjComm != null)
            {
                var URLComm = serverURLComm + URLC;
                ajaxObjComm.open("GET", URLComm ,true);
                ajaxObjComm.onreadystatechange = ajax_CallCommonBack ;
                ajaxObjComm.send(null);
            }
            return false;
        }
                                            function ajax_CallCommonBack()
                                            {
                                                if(ajaxObjComm.readyState == 4)//If the readyState is in the "Ready" state
		                                        {
			                                        if(ajaxObjComm.status == 200)//If the returned status code was 200. Everything was OK.
			                                        {
			                                             var ajaxReponse = ajaxObjComm.responseText;
			                                             /****************login Response*********************/
			                                             var divdata = ajaxReponse.split('$');
			                                                   if(ajaxReponse.split('!')[0]=="sucesscreatetype")
                                                                {
                                                                  window.location="list.aspx";
                                                                }
                                                                 if(ajaxReponse.split('!')[0]=="ExceptionOccur")
                                                                {
                                                                  window.location="home.aspx";
                                                                }
                                                            if(divdata[0]=="Login")
                                                            {
                                                                    document.getElementById('divstatuslogin').innerHTML=divdata[2];
                                                                    var submitbutt=document.getElementById('loginsubmitbutton');
                                                                    submitbutt.style.display="Block";
                                                                    var img=document.getElementById('spinner');
                                                                    img.style.display="None";
                                                                    document.getElementById('loading').style.display="None";
                                                                    if(divdata[1]!="0")
                                                                    {
                                                                            document.getElementById('signin_menu').style.display="None";
                                                                           
                                                                            document.getElementById('divregisterlogin').style.display="None";
                                                                            document.getElementById('divmyaccount').style.display="inline";
                                                                            document.getElementById('hiddenloggeduserid').value=divdata[1];
                                                                           
                                                                           window.location="myaccount.aspx";
                                                                    }
                                                                    else
                                                                    {
                                                                       document.getElementById('signin_menu').style.display="Block";
                                                                    }
                                                            }  
                                                              if(ajaxReponse=="logout")
                                                                {
                                                                    document.getElementById('divmyaccount').style.display="none";
                                                                    document.getElementById('divregisterlogin').style.display="inline";
                                                                    window.location="home.aspx";
                                                                }
                                        			             
                                                            /*************************************/
                                                            //search Bar menu Response
			                                             var ajaxReponse = ajaxObjComm.responseText ;
			                                             if(ajaxReponse.split('!')[0]="SearchByID")
			                                             {
			                                                switch(ajaxReponse.split('!')[1])
			                                                {
			                                                    case "Property":window.location="propertydetails.aspx?propertyid="+ajaxReponse.split('!')[2]+""; 
			                                                        break;
			                                                    case "PG": window.location="pgprofile.aspx?propertyid="+ajaxReponse.split('!')[2]+"";
			                                                        break;
			                                                    case "Not Available":
			                                                        $("#SPReq").html("Id Does't Exist");
        			                                                        $("#SPReq").css("display","inline");
			                                                        break;
			                                                }
			                                             }
                                                         if(ajaxReponse.split('~!')[0]=="HomeMenu")
                                                         {  
                                                            $("#"+ajaxReponse.split('~!')[1]+"_menu").empty();
                                                            $("#"+ajaxReponse.split('~!')[1]+"_menu").append(ajaxReponse.split('~!')[2]);
                                                           // $("."+ajaxReponse.split('~!')[1]).children("fieldset.ChildItem").css("display","inline")
                                                         }
                                                         /***********Post Your Requirement Response*************/
                                                           var cities=document.getElementById('prydropcities');
                                                          if(ajaxReponse.split('$')[0]=="state")
                                                          {
                                                           $("select[id$="+cities.id+"]> option").remove();
                                                            BindValues(cities.id,ajaxReponse);
                                                          }
                                                                  
                                                            if(ajaxReponse=="PYRSuccess")
                                                          {
                                                                $('#PyrSelecttype').val("");
                                                                $('#prydropstates').val("");
                                                                $('#prydropcities').val("");
                                                                $('#PyrSelectbudget').val("");
                                                                $('#PyrSelectbudget').val("");
                                                                $('#pyrtextcaptcha').val("");
                                                                $('#PyrTextphone').val("");
                                                                $('#PyrTextname').val("");
                                                                $('#PyrTextemail').val("");
                                                                
                                                                
                                                             document.getElementById('pyrstatus').innerHTML="Thank You For Posting Your Requirement";
                                                             document.getElementById('pyrstatus').style.color="Green";
                                                          }     
                                                          if(ajaxReponse=="PYRFailure")
                                                          {
                                                            
                                                             document.getElementById('pyrstatus').innerHTML="Please Try Again Later";
                                                             document.getElementById('pyrstatus').style.color="Red";
                                                          }    
                                                          if(ajaxReponse=="Captchaerror")
                                                          {
                                                           document.getElementById('pyrstatus').innerHTML="Please Enter Same Value";
                                                             document.getElementById('pyrstatus').style.color="Red";
                                                          } 
                                                          /************Forgot Password Response***********/
                                                          if(ajaxReponse.split('!')[0]=="SuccessForgotPassword")
                                                         {
                                                         
                                                                document.getElementById('divforgetpwdstatus').innerHTML="Your Password Has Been Sent On Your Email.";
                                                                document.getElementById('divforgetpwdstatus').style.color="Green";
                                                                document.getElementById('divforgetpwdstatus').style.fontSize="Small";
                                                                document.getElementById('divforgetpwdstatus').style.fontWeight="Bold";
                                                                document.getElementById('imgforgetpwd').style.display="none";
                                                                document.getElementById('lblforgetpwd').style.display="none";
                                                                document.getElementById('forgetsubmit').style.display="inline";
                                                         }
                                                         if(ajaxReponse.split('!')[0]=="FailureForgotPassword")
                                                         { 
                                                                document.getElementById('divforgetpwdstatus').innerHTML="Invalid Emailid or Mobileno.";
                                                                document.getElementById('divforgetpwdstatus').style.color="Red";
                                                                document.getElementById('divforgetpwdstatus').style.fontSize="10px";
                                                                document.getElementById('divforgetpwdstatus').style.fontWeight="Bold";
                                                                document.getElementById('imgforgetpwd').style.display="none";
                                                                document.getElementById('lblforgetpwd').style.display="none";
                                                                document.getElementById('forgetsubmit').style.display="inline";
                                                         }
                                                         
                                                         /***********In login Session On Click List Your Profile Response*****************/
                                                          if(ajaxReponse.split('!')[0]=="sucesscreatetype")
                                                          {
                                                          window.location="list.aspx";
                                                          }
                                                          
                                                          if(ajaxReponse.split('!')[0]=="responsesearchcities")
                                                          {
                                                                    debugger ;//RemoveItems('droppgstate');
                                                                    var dropcityid=ajaxReponse.split('!')[2];
                                                                    $("select[id$="+dropcityid+"] > option").remove();
                                                                    BindValues(dropcityid,ajaxReponse.split('!')[1]);
                                                                   
                                                          
                                                          
                                                          }
                                                      }
                                                  }
                                               } 
   function NewCommonAjaxCall(type)
    {
   
       var dt = new Date(); 
       callType = 1;
       var str = "type=" + type + "&dt=" + dt.getMinutes() + dt.getSeconds() + dt.getMilliseconds();
       Ajax_MakeAJAXGetCommonCall(str);
    }
