﻿$(document).ready(function() {
/*****Login Popup Functionality*******/
$(".signin").click(function(e) {       
	//e.preventDefault();
    $("fieldset#signin_menu").toggle();
    $("fieldset#signin_menu").find("input[type='text']").val("");
     $("fieldset#signin_menu").find("input[type='password']").val("");
    $("#divstatuslogin").html("");
	$(".signin").toggleClass("menu-open");
	if($('#LoginPopUpStatus').val()==0)
	{
	    $('#LoginPopUpStatus').val("1");
	     $('#lft_arrow').css('display','inline');
	    $('#dwn_arrow').css('display','none');
	}
	else
	{
	    $('#LoginPopUpStatus').val("0");
	  
	     $('#lft_arrow').css('display','none');
	    $('#dwn_arrow').css('display','inline');
	}
	
});

$("fieldset#signin_menu").mouseup(function() {
	return false
});

$("#maintable").click(function(e) {
    if($(e.target).parent("fieldset#signin_menu").length ==0 && $(e.target).parent("a#alogin.signin").length == 0 && $(e.target).parents("fieldset#signin_menu").length == 0)
    {
            try
          {
                if(GlobalTag != 1)
                {
                    $("fieldset#signin_menu").hide();
                }
          }
        catch(err)
          {
         
            $("fieldset#signin_menu").hide();
          }
        
    }  
   if($(e.target).parent("li.signin1").length ==0 && $(e.target).parent("li.signin2").length == 0 && $(e.target).parent("li.signin3").length == 0
   && $(e.target).parent("li.signin7").length ==0 && $(e.target).parents("fieldset#signin1_menu").length == 0 && $(e.target).parents("fieldset#signin2_menu").length == 0
   && $(e.target).parents("fieldset#signin3_menu").length == 0 && $(e.target).parents("fieldset#signin7_menu").length == 0)
    {
          try
          {
                if(GlobalTag != 1)
                {
                  //hide all drop down on search bar
                 $("fieldset#signin2_menu").hide();
                 $("fieldset#signin1_menu").hide();
   	             $("fieldset#signin3_menu").hide();
                 $("fieldset#signin7_menu").hide();
                 //remove class and style
                 $(".SearchDDBar ul li.signin1 a").removeClass("SearchDDBarClick");
	             $('.signin1 a').css("color","white");	             
	             $(".SearchDDBar ul li.signin2 a").removeClass("SearchDDBarClick");
	             $('.signin2 a').css("color","white");
	             $(".SearchDDBar ul li.signin3 a").removeClass("SearchDDBarClick");
	             $('.signin3 a').css("color","white");
	             $(".SearchDDBar ul li.signin7 a").removeClass("SearchDDBarClick");
	             $('.signin7 a').css("color","white");
                 
                }
           }
            catch(err)
          {
            $("fieldset#signin1_menu").hide();
          }
    } 
    if($(e.target).parents("div#searchById").length == 0 && $(e.target).parent("p.searchOptions").length == 0 )
    {
      try
          {
                if(GlobalTag != 1)
                {
                     $("#searchById").hide();
                 }
           }
            catch(err)
          {
          }
    }
     
    GlobalTag= 0;
    if($(e.target).parent("a.signin").length==0) {
		$(".signin").removeClass("menu-open");
		$('#dwn_arrow').css('display','none');
     	$('#lft_arrow').css('display','inline');
     $('#LoginPopUpStatus').val("1");
	}
});	
$(document).mouseup(function(e) {
	if($(e.target).parent("a.signin").length==0) {
		$(".signin").removeClass("menu-open");
		$('#dwn_arrow').css('display','none');
     	$('#lft_arrow').css('display','inline');
     $('#LoginPopUpStatus').val("1");
	}
});	
   /*****Forget Password*******/
 
$("#divforgetpassword").dialog({
autoOpen: false,
height: 200,
width: 400,
modal: true,
buttons: {
},
close: function() {	
}
});

$( "#divforgetpassword" ).dialog({ draggable: false });
$( "#divforgetpassword" ).dialog({ resizable: false });
$( "#divforgetpassword" ).dialog({ closeOnEscape: true });

		
$( "#divforgetpassword" ).dialog( "option", "closeText", 'X' );

 $("#txtemail").alphanumeric({allow:"@-. " });
 $("#txtmobile").alphanumeric({allow:"@-. " });

});
   
  /*******Login function*************/ 
  
   
 function ShowFGDialog()
 {  
    $('#txtemail').val("");
    $('#txtmobile').val("");
    $('#lblemail').html("");
    $('#lblphone').html("");
    $('#divforgetpwdstatus').html("");
    $('#divforgetpassword').dialog('open');
 } 
   
  function loginuser()
{
  var username=document.getElementById('loginusername').value;
    var pass=document.getElementById('loginpassword').value;
    if((username!="")&&(pass!=""))
    {
  /*  var submitbutt=document.getElementById('loginsubmitbutton');
    submitbutt.style.display="None";*/
    var img=document.getElementById('spinner');
    img.style.display="Block";
    document.getElementById('loading').style.display="Block";


  
    var logindetails="login*"+username+"*"+pass+"*";
    NewCommonAjaxCall(logindetails);  
    }
    else
    {
    document.getElementById('divstatuslogin').innerHTML="*Both Fields Required";
    }
    
    
}   
   
  /***************Post Your Requirement popup**********************/ 
$(document).ready(function() {

$("#dialog").dialog({
autoOpen: false,
height: 460,
width: 420,
modal: true,
buttons: {

},
close: function() {
	
}
});

$( "#dialog" ).dialog({ draggable: false });
$( "#dialog" ).dialog({ resizable: false });
$( "#dialog" ).dialog({ closeOnEscape: true });

		
$( "#dialog" ).dialog( "option", "closeText", 'X' );

 $("#loginusername").alphanumeric({allow:"@-. " });
 $("#loginpassword").alphanumeric({allow:"@-. " });


/***************End Post Your Requirement popup**********************/ 

/*******Select Property Type popup. Show on click on list your property when the user login**********/
$("#dialogpropertytype").dialog({
autoOpen: false,
height: 190,
width: 400,
modal: true,
buttons: {

},
close: function() {
 //to resolve problem of pyr and lyp
}
});

$( "#dialogpropertytype" ).dialog({ draggable: false });
$( "#dialogpropertytype" ).dialog({ resizable: false });
$( "#dialogpropertytype" ).dialog({ closeOnEscape: true });

		
$( "#dialogpropertytype" ).dialog( "option", "closeText", 'X' );

/****************List Your Property type Popup***********/
$("#dialogpropertytype").dialog({
autoOpen: false,
height: 190,
width: 400,
modal: true,
buttons: {
},
close: function() {
 //to resolve problem of pyr and lyp
}
});

$( "#dialogpropertytype" ).dialog({ draggable: false });
$( "#dialogpropertytype" ).dialog({ resizable: false });
$( "#dialogpropertytype" ).dialog({ closeOnEscape: true });

		
$( "#dialogpropertytype" ).dialog( "option", "closeText", 'X' );


/****************End List Your Property type Popup***********/
$("#divpleaselogin").dialog({
autoOpen: false,
height: 150,
width: 350,
modal: true,
buttons: {
},
close: function() {
 //to resolve problem of pyr and lyp
}
});
$( "#divpleaselogin" ).dialog({ draggable: false });
$( "#divpleaselogin" ).dialog({ resizable: false });
$( "#divpleaselogin" ).dialog({ closeOnEscape: true });
$( "#divpleaselogin" ).dialog( "option", "closeText", 'X' );
});
 
 /*************On Click on Proceed in Property type Popup****************************/
  function proceedlistyourproperty()
   {
   
     var s1="";
     if((document.getElementById("basiccount").innerHTML<=0)&&(document.getElementById("basicradio").checked==true))
    {
      document.getElementById("divbuystatus").innerHTML="<a href='advertisewithus.aspx' style='text-decoration:underline;' target='_blank' > Buy basicproperty listing pack to list your property</a>";
      document.getElementById("divbuystatus").style.display="inline";
    }
     else if((document.getElementById("premiumcount").innerHTML<=0)&&(document.getElementById("premiumradio").checked==true))
    {
      document.getElementById("divbuystatus").innerHTML="<a href='advertisewithus.aspx' style='text-decoration:underline;' target='_blank' > Buy premiumproperty listing pack to list your property</a>";
      document.getElementById("divbuystatus").style.display="inline";
    }
    else
    {
         if(document.getElementById("basicradio").checked==true)
        {
           s1=document.getElementById("basicradio").value;
        }
        if(document.getElementById("premiumradio").checked==true)
        {
            s1=document.getElementById("premiumradio").value;
        }
        NewCommonAjaxCall("Listproperty_te!"+s1);
    } 
 } 
 
 /***************On Click List Your Property **************************/
 
  function checklistyourproperty()
    {
          var a =$('#checklog').val();
          if(a!="")
            {
              $('#dialogpropertytype').dialog('open');
            }
        else
        {
        window.location="list.aspx";
        }
    }
    
    /*********Forgot Password**********/
     function valdateforgotpwd()
   {
   
         var error="";
         if(document.getElementById('txtemail').value!="")
        {
            var filter=/^.+@.+\..{2,3}$/
            if(filter.test(document.getElementById('txtemail').value))
            {
                 document.getElementById("lblemail").style.display ="none"; 
                 document.getElementById("lblemail").innerHTML="";    
            }
            else 
            {
                document.getElementById("lblemail").style.display ="inline";
                 document.getElementById("lblemail").innerHTML ="Invalid";
                 error+=error+"error" ;
            }
         }
        
        else 
        {
             document.getElementById("lblemail").style.display ="inline";
             document.getElementById("lblemail").innerHTML="Required";
             error+=error+"error" ;
        
        }
        
        
        
        
          if((document.getElementById('txtmobile').value!="")&&(document.getElementById('txtmobile').value.length==10))
                    {//check it contains only digits
                        var value=document.getElementById('txtmobile').value;
               	        var numericExpression = /^[0-9]+$/;
	                            if(value.match(numericExpression))
	                            {
	                             document.getElementById("lblphone").style.display ="none";
                                  document.getElementById("lblphone").innerHTML  =""; 
                                  }
          
                                       else 
                                       {
                                      document.getElementById("lblphone").style.display ="inline"; 
                                      document.getElementById("lblphone").innerHTML="Enter Only Digits";
                                      
                                       error+=error+"error" ;
                                      
                                       }
              }
               else 
               {
              document.getElementById("lblphone").style.display ="inline"; 
              document.getElementById("lblphone").innerHTML="Required";
              error+=error+"error" ;
              }
              
              if(error=="")
               {
                getvaluesforgetpwd();
                return false;
                }
                else 
                {
                return false;
                }
            
   
   }
   
   function getvaluesforgetpwd()
   {
     var s1="";
   
      var  sendemail= document.getElementById("txtemail") ;
   if(sendemail!="")
   {
    s1+=sendemail.value+"!";
  
   
   }
   else 
   {
   
   s1+="!";
   }
   
    var  sendphone= document.getElementById("txtmobile") ;
   if(sendphone!="")
   {
    s1+= sendphone.value+"!";
  
   
   }
   else 
   {
   
   s1+="!";
   }
     document.getElementById('imgforgetpwd').style.display="inline";
     document.getElementById('lblforgetpwd').style.display="inline";
     document.getElementById('forgetsubmit').style.display="none";
   
    NewCommonAjaxCall('forgetpassword!'+s1);
   }
 /*****************************/
  //it collects the login form details and then send it to database       
   function formdata()
   {
        var username=document.getElementById('TextBoxusernamelogin').value;
        var password=document.getElementById('TextBoxpasswordlogin').value;
        var userpass=username+"$"+password;
        document.getElementById('userlogin').value="$username$";
        NewCommonAjaxCall(userpass);
   }

   
   function loginuser()
   {
     var username=document.getElementById('loginusername').value;
     var pass=document.getElementById('loginpassword').value;
     if((username!="")&&(pass!=""))
     {
     /*  var submitbutt=document.getElementById('loginsubmitbutton');
     submitbutt.style.display="None";*/
     var img=document.getElementById('spinner');
     img.style.display="Block";
     document.getElementById('loading').style.display="Block";
     var logindetails="login*"+username+"*"+pass+"*";
     NewCommonAjaxCall(logindetails);  
      }
       else
       {
        document.getElementById('divstatuslogin').innerHTML="*Both Fields Required";
       }
    }
//it sets the image to orange when mouse is over the image
//it gets the name of image and image id
//*************************************************************************
        function mouseover(imgName,imgId)
        {
            // 
         var typeofproperty= document.getElementById('hiddentypeofproperty').value;
         var lastimage=document.getElementById('hiddenlastimgclkd').value;
        if((typeofproperty!=imgName)&&(lastimage!=imgName))
        {
        imgId.src="Images/HomeImages/HomePageTabs/"+imgName+"_btn.jpg";
        }

        }

//it sets the image to gray when mouse is out of  the image
//it gets the name of image and image id
//*************************************************************************
        function mouseout(imgName,imgId)
        {
       //

        
        var typeofproperty= document.getElementById('hiddentypeofproperty').value;
         var lastimage=document.getElementById('hiddenlastimgclkd').value;
        if((lastimage!=imgName)&&(typeofproperty!=imgName))
                   
                    {
                        imgId.src="Images/HomeImages/HomePageTabs/"+imgName+".jpg";
                    }

        }
