function get_state(sid)
{

    $.get(SITEROOT+"/modules/common/show_state.php",{sid:sid},function(data){
        if(data)
        {
            $('#state').html(data);
        }
        else
        {
            $('#state').html("<option value=''>Select</option>");
        }
    });

}


function get_city(cid)
{

$.get(SITEROOT+"/modules/common/show_city.php",{cid:cid},function(data){
    if(data)
    {
        $('#city').html(data);
    }
    else
    {
        $('#city').html("<option value=''>Select</option>");
    }
});

}

function get_state_b(sid)
{

    $.get(SITEROOT+"/modules/common/show_state.php",{sid:sid},function(data){
        if(data)
        {
          $('#state_b').html(data);
        }
        else
        {
          $('#state_b').html("<option value=''>Select</option>");
        }
    });

}

function get_city_b(cid)
{
    $.get(SITEROOT+"/modules/common/show_city.php",{cid:cid},function(data){
        if(data)
        {
            $('#city_b').html(data);
        }
        else
        {
            $('#city_b').html("<option value=''>Select</option>");
        }
    });
}

function get_locality(lid)
{
    $.get(SITEROOT+"/modules/common/show_local.php",{lid:lid},function(data){
            if(data){
                        $('#locality').html(data);
            }else{
                        $('#locality').html("<option value=''>Select</option>");
            }
    });
}

function get_locality_com(lid)
{
$.get(SITEROOT+"/modules/common/show_local.php",{lid:lid},function(data){
if(data)
{
$('#locality1').html(data);
}
else
{
$('#locality1').html("<option value=''>Select</option>");
}
});

}



var cityid = $('cityid').value;

function allcities(cityid)
{
	$.get(SITEROOT+"/modules/ajax_home_banner.php",{cityid:cityid},function(self){$("#banner_div").html(self);});
	$.get(SITEROOT+"/modules/ajax_banner_right.php",{cityid:cityid},function(self){$("#banner_div_right").html(self);});
	
	$.get(SITEROOT+"/modules/common/show_indian_city.php",{cityid:cityid},function(self){$("#property_city").html(self);});
	get_locality_city(cityid);
}

function get_locality_city(lid)
{	
	$.get(SITEROOT+"/modules/common/show_locality.php",{lid:lid},function(data){
		if(data)
		{
			$('#address').html(data);
			$('#address2').html(data);
		}
		else
		{
			$('#address').html("<option value=''>Select</option>");
			$('#address2').html("<option value=''>Select</option>");
		}
	});
}

function check_radius()
{
	if(document.getElementById('address2').value!='')
	{
		if(document.getElementById('address2').value == document.getElementById('address').value)
		{
			alert("Second location should not be same as first.");
			document.getElementById('address2').value = '';
			return false
		}
		document.getElementById('radius').value = 1;
		document.addr.radius.readOnly = true;
		
	}
	else
	{
		document.getElementById('radius').value = 1;
		document.addr.radius.readOnly = false;
	}	
	
}

function brdisable(prop){


if (prop=='8')
{
 $('#br').hide();
}
else
{
 $('#br').show();
}
}
         var clickCount = 1;
	function display(str, SITEROOT, string ,total)
	{
	                if(string == 'next')
		{
                        document.getElementById('next').value = ++clickCount;
                        var str = document.getElementById('next').value;
                        
			if (str > total)
			{
			glbl = total;
			}
			else
			{
			glbl = document.getElementById('next').value;
			}
		}

	var url = SITEROOT+"/modules/common/ajax_show_location.php";
	ajax.sendrequest("GET", url, { pagenum:str }, '', 'prod');
	}
	
	function prev(str, SITEROOT, string)
	{	
                 if(string == 'prev')
                {
                 document.getElementById('prev').value = --glbl;
                  var str = document.getElementById('prev').value;
                            if(str < 1)
                            {
                                  clickCount = 1;
                            }
                            else
                            {
                                   
                                   // clickCount = document.getElementById('next').value;
                                    clickCount = document.getElementById('prev').value - 1;
                            }
                }
		
      	var url = SITEROOT+"/modules/common/ajax_show_location.php";
	ajax.sendrequest("GET", url, { pagenum:str }, '', 'prod');
	}



$(document).ready(function() {


	    		
		$('#rentbudget').hide();
		$('#pgbudget').hide();
		
		$('#rent').click(function(){
		$('#rentbudget').show();
		$('#buybudget').hide();
		$('#pgbudget').hide();
		$('#buybudget1').val('');
		$('#buybudget2').val('');
		$('#pgbudget1').val('');
		$('#pgbudget2').val('');
		});

		$('#pg').click(function(){
		$('#rentbudget').hide();
		$('#buybudget').hide();
		$('#pgbudget').show();
		$('#buybudget1').val('');
		$('#buybudget2').val('');
		$('#rentbudget1').val('');
		$('#rentbudget2').val('');
		
		});
		
		$('#buy').click(function(){
		$('#rentbudget').hide();
		$('#buybudget').show();
		$('#pgbudget').hide();
		$('#rentbudget1').val('');
		$('#rentbudget2').val('');
		$('#pgbudget1').val('');
		$('#pgbudget2').val('');
		
		});

		$('#forbudget').click(function(){
		$('#rentbudgetcom').hide();
		$('#buybudgetcom').show();
				
		});

		$('#comrent').click(function(){
		$('#rentbudgetcom').show();
		$('#buybudgetcom').hide();
		$('#buybudget11').val('');
		$('#buybudget12').val('');
		
		});

		$('#combuy').click(function(){
		$('#rentbudgetcom').hide();
		$('#buybudgetcom').show();
		$('#rentbudget11').val('');
		$('#rentbudget12').val('');		
		});

	
		 $(function() {
                $('#container-1').tabs();
            });
		
// 	$('#slideHot1').cycle({ 
//     fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
// });

            $("#addr").validate({
		errorElement:'label',
		rules: {			
			property_city:{
				required: true
			},
			address: {
				required: true
			}/*,		
			radius: {
				required: true							
			}*/
		},
		messages: {
		          property_city:{
				required: "Required."
			},
			address: {
				required: "Required."		
			}/*,
			radius: {
				required: "Required."
			}*/
		},	
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.hide();
			//document.frmRegister.submit();
		},
		submitHandler: function(){
			document.addr.submit();
		}
	});
	
	$("#res_search").validate({
		errorElement:'label',
		rules: {
// 			property_type_name:{
// 				required:true
// 			},
                        property_city:{
                                required:true
                        }
		},
		messages: {
//  			property_type_name: {
// 				required: "Required"				
// 				},
                        property_city: {
                                required: "Required"				
                                }			
		},
		success: function(label) {
			// set &nbsp; as text for IE
			label.hide();
			//document.frmRegister.submit();
		}

});

            $("#comSearch").validate({
		errorElement:'label',
		rules: {
//                             property_type_name:{
//                                     required:true
//                             },
			property_city:{
				required:true
			}
		},
		messages: {
// 			property_type_name_c: {
// 				required: "Required"				
// 				},
			property_city: {
				required: "Required"				
				}
			
		},
		success: function(label) {
			// set &nbsp; as text for IE
			label.hide();
			//document.frmRegister.submit();
		}

});

//var prid=$("#category").val();

	$("#bro_search1").validate({

		errorElement:'span',
		rules: {	
                    property_city:{
                                required: function(element)
                                {
                                            if($("#br_id2").val() == '')
                                            return true;
                                            else
                                            return false;
                                }
			},
//                         br_id:{
//                             required: function(element)
//                                 {          var pcval="";
//                                             pcval = $("#property_city").val();
//                                             if( pcval != '' || typeof pcval == 'undefined')
//                                                return true;
//                                             else
//                                                 return false;
//                                 }
// 			},
                        property_id:{
                            required: function(element)
                            {          var pcval="";
                                        
                                         var pcval = $("#property_city_prof").val();
                                            if( pcval == '' || typeof pcval == 'undefined')
                                               return true;
                                            else
                                                return false;
                            }
                        }			
		},
		messages: {
                        property_city: {
				required: "Required"
				},
//                         br_id: {
//                                         required: ""
//                                 },
                        property_id: {
                            required: "Required"
                            }
		},
		 errorPlacement: function(error, element) {
                     error.appendTo(element.siblings("span"));
                    },
		success: function(label) {
			// set &nbsp; as text for IE
			label.hide();
			//document.frmRegister.submit();
		}
});

$("#bui_search2").validate({
	
		errorElement:'span',
		rules: {			
                        property_city:{
                                required: function(element)
                                {
                                            if($("#bl_id2").val() == '')
                                            return true;
                                            else
                                            return false;
                                }
			},
//                         bl_id:{
//                             required: function(element)
//                                 {
//                                            var pcval = $("#property_city").val();
//                                             if( pcval != '' || typeof pcval == 'undefined')
//                                                return true;
//                                             else
//                                                 return false;
//                                 }
// 			},
                        property_id:{
                            required: function(element)
                            {
                                        
                                         var pcval = $("#property_city_pb").val();
                                            if( pcval == '' || typeof pcval == 'undefined')
                                               return true;
                                            else
                                                return false;
                            }
                        }
		},
		messages: {			
			property_city: {
				required: "Required"
				},
//                                 bl_id: {
// 				required: ""
// 				},
                                property_id: {
				required: "Required"
				}			
		},
		 errorPlacement: function(error, element) {
                     error.appendTo(element.siblings("span"));
                    },
		success: function(label) {
			// set &nbsp; as text for IE
			label.hide();
			//document.frmRegister.submit();
		}
            });
            
/*
	$("#bui_search2").validate({
	
		errorElement:'span',
		rules: {			
                        property_city:{
                                required: function(element)
                                {
                                            if($("#bl_id").val() == '' )
                                            return true;
                                            else
                                            return false;
                                }
			},
                        bl_id:{
                                required: function(element)
                                {
                                            //alert($("#property_id1").val())
                                            if($("#bl_id2").val() == '' )
                                                return false;
                                            else
                                                return true;
                                }
			},
                        bl_id2:{
                            required: function(element)
                            {
                                        //alert($("#property_id1").val())
                                        if($("#bl_id").val() == '')
                                            return false;
                                        else
                                            return true;
                            }
                        }
		},
		messages: {			
			property_city: {
				required: "Required"
				},
                                bl_id: {
				required: ""
				},
                                bl_id2: {
				required: "Required"
				}			
		},
		 errorPlacement: function(error, element) {
                     error.appendTo(element.siblings("span"));
                    },
		success: function(label) {
			// set &nbsp; as text for IE
			label.hide();
			//document.frmRegister.submit();
		}
            });
*/
		
		});
