// timeFrames
  $(document).ready(function(){
 

 //timeframe 1
    $("input[name='bidT1']").click(
        function()
        {
        switch ($(this).val())
        {
            case '0':
                $(".t1_tframe").hide();
                $(".t1_tframe").val('0');
                $("input[name='bidT1onValue']").val('');
                $("input[name='bidT1beforeValue']").val('');
                $("input[name='bidT1bet1Value']").val('');
                $("input[name='bidT1bet2Value']").val('');
                $("#t1_tframe").hide();
            break;

            case '1':
                $(".t1_tframe").show();
                $("#t1_tframe").show();
                $("#t1_1").hide();
                $("#t1_2").hide();
                $("#t1_3").hide();
            break;
        }
        });

    $(".t1_tframe").change(function()
    {
        switch ($(this).val())
        {
            case '1':
                $("#t1_1").show();
                $("#t1_2").hide();
                $("#t1_3").hide();
            break;
            case '2':
                $("#t1_1").hide();
                $("#t1_2").show();
                $("#t1_3").hide();
            break;
            case '3':
                $("#t1_1").hide();
                $("#t1_2").hide();
                $("#t1_3").show();
            break;
            default:
                $("#t1_1").hide();
                $("#t1_2").hide();
                $("#t1_3").hide();

        }
    });

    $("#t1_tframe").hide();
    $(".t1_tframe").hide();
 
 //timeframe2
      $("input[name='bidT2']").click(
        function()
        {
        switch ($(this).val())
        {
            case '0':
                $(".t2_tframe").hide();
                $(".t2_tframe").val('0');
                $("input[name='bidT2onValue']").val('');
                $("input[name='bidT2beforeValue']").val('');
                $("input[name='bidT2bet1Value']").val('');
                $("input[name='bidT2bet2Value']").val('');
                $("#t2_tframe").hide();
            break;

            case '1':
                $(".t2_tframe").show();
                $("#t2_tframe").show();
                $("#t2_1").hide();
                $("#t2_2").hide();
                $("#t2_3").hide();
            break;
        }
        });

    $(".t2_tframe").change(function()
    {
        switch ($(this).val())
        {
            case '1':
                $("#t2_1").show();
                $("#t2_2").hide();
                $("#t2_3").hide();
            break;
            case '2':
                $("#t2_1").hide();
                $("#t2_2").show();
                $("#t2_3").hide();
            break;
            case '3':
                $("#t2_1").hide();
                $("#t2_2").hide();
                $("#t2_3").show();
            break;
            default:
                $("#t2_1").hide();
                $("#t2_2").hide();
                $("#t2_3").hide();

        }
    });
    $("#t2_tframe").hide();
    $(".t2_tframe").hide();

  });
  
  
// earning

  $(document).ready(function(){
    
    $("#bidValue").keyup(function () {
        
        str = $(this).val();
        rou = (str*100/100).toFixed(2);
        distance = $("#distance").val().replace('&nbsp;mi','');
        
        //alert(distance);
        if ( rou == 0) { earn = 0; } 
        
        if ( (distance < 30) && (distance > 0) ) {
            if(str<5){
                earn = 0; //"Please bid an amount over £5.00";
            } else {
            earn = rou - 3;
            }
        } else {
            if(str<5){
                earn = 0;//"Please bid an amount over £5.00";
            }
            else if (str<=100){
                earn = (rou-5);
            }
            else if (str<=200){
                earn = (rou-10);
            }
            else if (str<=300){
                earn = (rou-20);
            }
            else if (str<=400){
                earn = (rou-30);
            }
            else if (str<=500){
                earn = (rou-40);
            }
            else if (str<=1000){
                earn = (rou-50);
            }
            else{
                earn = (rou-75);
            }
                
        }
        $("#earnings").text("You Earn: £" + earn.toFixed(2));
        
        
    })
        //.change();

  });
  

//bids box slider

$(document).ready(function() {
  $('.slickbox').hide();

  $('.bidClick').click(function() {
    $('.slickbox',this.parentNode).slideToggle('normal');
    return false;
  });
});

$(document).ready(function() {
  $('.subslickbox').hide();

  $('.subbidClick').click(function() {
    $('.subslickbox',this.parentNode).slideToggle('normal');
    return false;
  });
});



        $(document).ready(function() {
           if ( ($("#bidT1:checked").val() == 1) ) { $("#t1frame").css('display','block'); }            
           if ( ($("#bidT2:checked").val() == 1) ) { $("#t2frame").css('display','block'); }            
           
           if ( ($("#bidT1:checked").val() == 1) && ($("#t1frame:selected").val() == 1) )  { $("#bidT1onValue").css('display','block'); }
           if ( ($("#bidT1:checked").val() == 1) && ($("#t1frame").val() == 2) )  { $("#bidT1beforeValue").css('display','block'); }
           if ( ($("#bidT1:checked").val() == 1) && ($("#t1frame").val() == 3) )  { $("#bidT1bet1Value").css('display','block'); $("#bidT1bet2Value").css('display','block'); }
           
           //alert($("#bidT1:checked").val());
        });

        function verifyBid() {
            
            msg = '';
            err = 0;
            if ( $("#bidValue").val() < 5 ) { err = 1; msg='You need to bid amounts larger than £5!'+"\r\n"; }
            if ( ($("#bidT1:checked").val() == 1) && $("#t1frame").val() < 1 ) { err=1; msg = msg + 'Pick-up in timeframe missing!'+"\r\n"; }
            if ( ($("#bidT2:checked").val() == 1) && $("#t2frame").val() < 1 ) { err=1; msg = msg + 'Delivery in timeframe missing!'+"\r\n"; }
            
            if (
            
            ( ($("#bidT1:checked").val() == 1) && ($("#t1frame").val() == 1) && ($("#bidT1onValue").val() == '') ) ||
            ( ($("#bidT1:checked").val() == 1) && ($("#t1frame").val() == 2) && ($("#bidT1beforeValue").val() == '') ) || 
            ( ($("#bidT1:checked").val() == 1) && ($("#t1frame").val() == 3) && ( ($("#bidT1bet1Value").val() == '') || ($("#bidT1bet2Value").val() == '') ) ) 
            
            )
            { err = 1; msg = msg + 'Pick-up in timeframe not completed!'+"\r\n" }  
            
            if (
            
            ( ($("#bidT2:checked").val() == 1) && ($("#t2frame").val() == 1) && ($("#bidT2onValue").val() == '') ) ||
            ( ($("#bidT2:checked").val() == 1) && ($("#t2frame").val() == 2) && ($("#bidT2beforeValue").val() == '') ) || 
            ( ($("#bidT2:checked").val() == 1) && ($("#t2frame").val() == 3) && ( ($("#bidT2bet1Value").val() == '') || ($("#bidT2bet2Value").val() == '') ) ) 
            
            )
            { err = 1; msg = msg + 'Pick-up in timeframe not completed!'+"\r\n"} 
            
                        
            if (err == 1) {
                alert(msg);
                return false;
            }
            return true;
        }   
