$(document).ready(function(){
    $(".link22").click(function(){
        $(".item4").hide();
        $(".item3").show();
        $(this).addClass(' selected1');  
        $(".link23").removeClass(' selected2');
        return false;
    });
    $(".link23").click(function(){    
        $(".item3").hide();
        $(".item4").show();
        $(this).addClass(' selected2');  
        $(".link22").removeClass(' selected1');  
        return false;          
    });
    $(".link28").click(function(){
        $(".item6").hide();
        $(".item7").hide();
        $(".item5andthreequaters").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();
        $(".item5").show();
        $(this).addClass(' link29');  
        $(".link30").removeClass(' link31');
        $(".link32").removeClass(' link33');   
        return false;     
    });
    $(".link30").click(function(){
        $(".item5").hide();
        $(".item7").hide();
        $(".item5andthreequaters").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();
        $(".item6").show();
        $(this).addClass(' link31');  
        $(".link28").removeClass(' link29');
        $(".link32").removeClass(' link33');   
        return false;     
    });
    $(".link32").click(function(){
        $(".item5").hide();
        $(".item6").hide();
        $(".item5andthreequaters").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();
        $(".item7").show();
        $(this).addClass(' link33');  
        $(".link30").removeClass(' link31');
        $(".link28").removeClass(' link29');  
        return false;      
    });
    $(".teamProfile").click(function(event) {
        event.stopPropagation();
        $(".item5").hide();
        $(".item6").hide();
        $(".item7").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();        
        $(".item5andthreequaters").show();
        return false;
    });
    $(".teamProfilereturn").click(function() {
        $(".item5").show();
        $(".item6").hide();
        $(".item7").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();        
        $(".item5andthreequaters").hide();
        return false;
    });
    $(".teamProfile2").click(function() {
        $(".item5").hide();
        $(".item6").hide();
        $(".item7").hide();
        $(".item6andthreequaters").show();
        $(".item7andthreequaters").hide();        
        $(".item5andthreequaters").hide();
        return false;
    });
    $(".teamProfilereturn2").click(function() {
        $(".item5").hide();
        $(".item6").show();
        $(".item7").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();        
        $(".item5andthreequaters").hide();
        return false;
    });
    $(".teamProfile3").click(function() {
        $(".item5").hide();
        $(".item6").hide();
        $(".item7").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").show();        
        $(".item5andthreequaters").hide();
        return false;
    });
    $(".teamProfilereturn3").click(function() {
        $(".item5").hide();
        $(".item6").hide();
        $(".item7").show();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();        
        $(".item5andthreequaters").hide();
        return false;
    });
    $(".title13").mouseover(function(){
        $(".overlay2").hide();
        $(".overlay3").hide();
        $(".overlay1").fadeIn("slow");
        return false;			
    });
    $(".title14").mouseover(function(){
        $(".overlay1").hide();
        $(".overlay3").hide();
        $(".overlay2").fadeIn("slow");	
        return false;			
    });
    $(".title15").mouseover(function(){
        $(".overlay1").hide();
        $(".overlay2").hide();
        $(".overlay3").fadeIn("slow");	
        return false;			
    });
    
    
    $('.the-menu, .the-drop').hover(function() {
       if (obj) {
          // $(".the-drop").fadeOut('fast');
          // obj.removeClass('current');
          obj = null;
       } //if

       $(".the-drop").show();
       $(".the-menu").addClass("selected");
    }, function() {
       obj = $(".the-drop");
       setTimeout(
          "checkHover()",
          400);
    });


        // 
        //     $(".the-menu").mouseover(function(event){
        //         event.stopPropagation();
        // $(".the-drop").show();
        //     });
        //     
        //     $(".subwrapper").mouseover(function(){
        // $(".the-drop").hide();
        //     });
        //     
        //     $(".the-drop").mouseover(function(){
        // $(".the-drop").show();
        //     });
        //     
        //     $(".the-drop").mouseout(function(){
        // $(".the-drop").hide();
        //     });   
        
        
    
    if (v && v == "navy") {
        $(".item5").hide();
        $(".item6").hide();
        $(".item7").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();        
        $(".item5andthreequaters").show();
    };
    if (v && v == "army") {
        $(".item5").hide();
        $(".item6").hide();
        $(".item7").hide();
        $(".item6andthreequaters").show();
        $(".item7andthreequaters").hide();        
        $(".item5andthreequaters").hide();
        $(".link30").addClass("link31");
        $(".link28").removeClass("link29");
    };
    if (v && v == "airforce") {
        $(".item5").hide();
        $(".item6").hide();
        $(".item7").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").show();        
        $(".item5andthreequaters").hide();
        $(".link32").addClass("link33");
        $(".link28").removeClass("link29");
    }; 


    if (v && v == "navywelcome") {
        $(".item5").show();
        $(".item6").hide();
        $(".item7").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();        
        $(".item5andthreequaters").hide();
    };

    if (v && v == "armywelcome") {
        $(".item5").hide();
        $(".item6").show();
        $(".item7").hide();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();        
        $(".item5andthreequaters").hide();
        $(".link30").addClass("link31");
        $(".link28").removeClass("link29");     
    };
    
    if (v && v == "airforcewelcome") {
        $(".item5").hide();
        $(".item6").hide();
        $(".item7").show();
        $(".item6andthreequaters").hide();
        $(".item7andthreequaters").hide();        
        $(".item5andthreequaters").hide();
        $(".link32").addClass("link33");
        $(".link28").removeClass("link29");        
    };    




    $(".cycle").cycle();


});

$(function() {
    $('a[rel*=external]').click( function() {
        window.open(this.href);
        return false;
    });
});


var prices=[{"id":"adult","name":"Adult Tickets","description":"","price":12},{"id":"over65","name":"Over 65s' Tickets","description":"","price":6},{"id":"under16","name":"Children under 16's Tickets","description":"","price":5}]

function setupPrices () {
  $("#the_fields").html("");
  $("#checkout").hide();
  var tickets = false
  var p = 1
  for (var i=0; i < prices.length; i++) {
    var v = parseInt($("#"+prices[i]['id']).val())
    if (v > 0) {
      $("#the_fields").append('<input type="hidden" name="item_name_'+p+'" value="'+prices[i]['name']+'"/>')
      $("#the_fields").append('<input type="hidden" name="item_description_'+p+'" value="'+prices[i]['description']+'"/>');
      $("#the_fields").append('<input type="hidden" name="item_quantity_'+p+'" value="'+v+'">');
      $("#the_fields").append('<input type="hidden" name="item_price_'+p+'" value="'+prices[i]['price']+'"/>');
      $("#the_fields").append('<input type="hidden" name="item_currency_'+p+'" value="GBP"/>');
      tickets = true
      p++
    }
  };
  if (tickets) {
      $("#the_fields").append('<input type="hidden" name="item_name_'+p+'" value="Booking fee"/>')
      $("#the_fields").append('<input type="hidden" name="item_description_'+p+'" value="Handling fee, postage and packaging."/>');
      $("#the_fields").append('<input type="hidden" name="item_quantity_'+p+'" value="1">');
      $("#the_fields").append('<input type="hidden" name="item_price_'+p+'" value="5"/>');
      $("#the_fields").append('<input type="hidden" name="item_currency_'+p+'" value="GBP"/>');
      if ($('#terms:checked').val() == 1) {
        $("#checkout").show();
      }
  };
}


var obj = null;
function checkHover() {
   if (obj) {
     $(".the-drop").hide();
       $(".the-menu").removeClass("selected");
   } //if
} //checkHover
