/***************** FUNCTION FOR FRONT END ********************/
var prac_names=new Array();
      
function js_f9_pracname()
{
    if ($('#idPracName').val().length == 2 && prac_names.length ==0)
    {
        //Make Autocomplete text box
        search_str =  $('#idPracName').val();
        action = "action=ajax_suggest_pracnames&r="+Math.random();
        furl = '/index.php?'+action+'&prac_name='+$('#idPracName').val();
        $.ajax({
                type: "GET",
                url:furl,
                cache :false,
                async:false,
                dataType:'json',
                success: function(data)
                        {
                            i =0;
                            $.each(data, function(memno,pname) 
                            {
                                prac_names[i] = pname;
                                //prac_names[i] = pname.replace(search_str,'<b>'+search_str+'</b>')
                                i++;
                             });
                            js_fill_pracnames(prac_names);
                        }
            });
    }
    
    if ($('#idPracName').val().length ==1)
    {
        prac_names=[];
        js_fill_pracnames(prac_names);
          
    }
    
}

function js_fill_pracnames(prac_names)
{
    $("#idPracName").autocomplete({
            source: prac_names,
            minLength:3
        });
     
        
    
}

/*
*
*/
function js_show_building_type()
{
    if ($('#idShowBuildingType').val() == 0 )
    {
        
        $('#btypeWrapper').hide();
        $('#bdtlWrapper').hide();    
    }else{
        $('#btypeWrapper').show();
        $('#bdtlWrapper').show();    
    }
    
}

function js_building_type()
{
    
    if ($('#idShowBuildingType').val() == 0 )
    {
        $('#idShowBuildingType').val(1);
    }else{
        $('#idShowBuildingType').val(0);
    }
    js_show_building_type();
    return false;
}

function js_bdtl()
{
    if ($('#idBuildType_1').attr('checked'))
    {
        btype = 1;
    }
    
    if ($('#idBuildType_2').attr('checked'))
    {
        btype = 2;
    }
    
    url = '/index.php?action=ajax_build_type&btype='+btype;
    $.get(url, function(data) 
    {
        
        $("#bdtlWrapper").html(data);
    });
}

function js_select_cat()
{
    cat_id = $('#idCategory').val();
    url = '/index.php?action=ajax_sub_cat&cat_id='+cat_id;
    $.get(url, function(data) 
    {
        $("#idSubCat").html(data);  
    });
}

