function resetProtectedNCB()
    {
     if($('#no_claims_bonus').val()<4)
        {
         $('#protectNCB').hide();
         $('#protected_ncd').removeAttr("checked");

          //CHANGE LABEL OF CURRENT FIELD'S FLAG
          //var x = $('#protected_ncd').attr("onclick");
          //if(x!="")
            //  {
          //    var last_open_bracket = x.lastIndexOf("{");
            //  var last_close_bracket = x.lastIndexOf("}");
              //var $x_lenght = last_close_bracket-last_open_bracket-1;

              //var x2 = x.substr(++last_open_bracket,$x_lenght);
            
              //eval(x2);
              //}
        }
    else
        {
         $('#protectNCB').show();
        
        }
    }
function resetVXS()
    {
     if($('#base_rate').val()=='comprehensive')
        {
         $('#voluntary_excessRow').show();
        }
     else
        {
         $('#voluntary_excessRow').hide();
       }
    }
function resetAgeSelector(s,hide,dont_reset)
    {
    for(i=1;i<=3;i++)
        {
        if(i==2){s=s.replace(/age/,"sex");}
        if(i==3){s=s.replace(/sex_of/,"badge");}
        if(hide){$('#'+s+'_row').hide();}
        else{$('#'+s+'_row').show();}
        if(!dont_reset){$('#'+s).val('');}
        }
    }
function resetAgeSelectors(dont_reset)
    {
    if($('#driving_restriction').val()=='insured_and_spouse')
        {
        resetAgeSelector('age_of_spouse',false,dont_reset);
        resetAgeSelector('age_of_driver1',true,dont_reset);
        resetAgeSelector('age_of_driver2',true,dont_reset);
        resetAgeSelector('age_of_driver3',true,dont_reset);
        return;
        }
    if($('#driving_restriction').val()=='insured_and_one_named')
        {
        resetAgeSelector('age_of_spouse',true,dont_reset);
        resetAgeSelector('age_of_driver1',false,dont_reset);
        resetAgeSelector('age_of_driver2',true,dont_reset);
        resetAgeSelector('age_of_driver3',true,dont_reset);
        return;
        }
    if($('#driving_restriction').val()=='insured_and_two_named')
        {
        resetAgeSelector('age_of_spouse',true,dont_reset);
        resetAgeSelector('age_of_driver1',false,dont_reset);
        resetAgeSelector('age_of_driver2',false,dont_reset);
        resetAgeSelector('age_of_driver3',true,dont_reset);
        return;
        }
    if($('#driving_restriction').val()=='insured_and_three_named')
        {
        resetAgeSelector('age_of_spouse',true,dont_reset);
        resetAgeSelector('age_of_driver1',false,dont_reset);
        resetAgeSelector('age_of_driver2',false,dont_reset);
        resetAgeSelector('age_of_driver3',false,dont_reset);
        return;
        }
    else
        {
        resetAgeSelector('age_of_spouse',true,dont_reset);
        resetAgeSelector('age_of_driver1',true,dont_reset);
        resetAgeSelector('age_of_driver2',true,dont_reset);
        resetAgeSelector('age_of_driver3',true,dont_reset);
        return;
        }
    }
function resetVehiclePicker()
    {
    var params={quotiva_type:$('#vehicle_type').val(),ncf:1};
    $.get("bgr_ajx_vehicle_pickup.php",params, function(data){$('#vehiclePick').html(data);})
    v=$('#vehicle_type').val();
    if(v=='saloon'){$('#seats').val(5);}
    if(v=='mpv'){$('#seats').val(8);}
    if(v=='mpv+'){$('#seats').val(10);}
    if(v=='minibus'){$('#seats').val(12);}
    if(v=='black_cab'){$('#seats').val(7);}
    }
function updVP(data)
    {
    $('#vehiclePick').html(data);
    $('#vehicleLoading').toggleClass("ac_loading");    
    }
function abiMake()
    {
    $('#vehicleLoading').toggleClass("ac_loading");
    var params={quotiva_type:$('#vehicle_type').val(),ncf:1,make:$("#abi_make").val()};
    $.get("bgr_ajx_vehicle_pickup.php",params, function(data){updVP(data)})
    }
function abiModel()
    {
    $('#vehicleLoading').toggleClass("ac_loading");
    var params={quotiva_type:$('#vehicle_type').val(),ncf:1,make:$("#abi_make").val(),model:$("#abi_model").val()};
    $.get("bgr_ajx_vehicle_pickup.php",params, function(data){updVP(data)})  
    }
function formatItem(row) {
	return "<b>"+row[0]+"</b>" + "<br />" + row[1];
}
function valMe()
    {
    var fail=0;
    for(i=1;i<=8;i++)
        {
        if(!$('#Y'+i).is(":checked")){var fail=1;}
        }
    if(fail)
        {
         alert("Sorry, you need to answer 'yes' to \n"+
         "all the questions at the top of the page.\n\n"+
         "Please call us on 0870 1128013");
         return false;
        }
    return true;
    }