$(document).ready( function() {
   
    //sub main menu 
   
    $("ul[class='mmenu'] > li").mouseover( function() {
      
        var sThisID = $(this).children("a").attr("id").split("main_item_")[1];
      
        $("ul[id='submenu_"+sThisID+"']").css("display", "block");
        
      
    }).mouseleave( function() {
        
        var sThisID = $(this).children("a").attr("id").split("main_item_")[1];
         
        $("ul[id='submenu_"+sThisID+"']").css("display" , "none");
     
    });
    
    $("ul[id^='submenu']").mouseover( function() {
        
        var sThisID = $(this).attr("id").split("main_item_")[1];
        
        $("ul[id='submenu_"+sThisID+"']").css("display", "block");
        
    }).mouseleave( function() {
       
        var sThisID = $(this).attr("id").split("main_item_")[1];
        
        $("ul[id='submenu_"+sThisID+"']").css("display", "block");
    });
    
    
    //promo boxes 
    
    $("div[class='title']").mouseover( function() {
        
        $(this).children("span").children(".promoInfo").show("fast");
        
    }).mouseleave( function() {
      
        $(this).children("span").children(".promoInfo").hide("slow");
    });
        
 
    //mini galleries 
  
    $(".mini-gallery").each( function () {
        
        var number = 1; 
        
        var nLength = $(this).children("li").length;
        
        $(this).next().children("span[id='current_num']").html( "1" );
        $(this).next().children("span[id='total_num']").html( nLength );
        
        var aChildren = $(this).children("li");
       
        aChildren.each( function(i , n) {
          
            if ( i > 0 ) {
           
                $(this).css("display", "none");
              
            }
         
        });
        
        var nextChildren  = $(this).next().children(".next");
       
        $(this).next().children(".next").click( function() {
            
            if ( number == 0 ) {
             
                number++;
            }
            
            if (  parseInt( number+1)  <= parseInt( nLength ) ) {
                  
                aChildren.each( function(i , n) {
          
                    if ( i ==  number ) {
           
                        $(this).css("display", "block");
                        
                        nextChildren.parent().children("#current_num").html( number+1 );
              
                    }
                    else {
                        
                        $(this).css("display", "none");
                    }
         
                });
                      
                number++;
            }
            else {
             
                number = 0; 
               
                aChildren.each( function(i , n) {
          
                    if ( i ==  number ) {
           
                        $(this).css("display", "block");
                        
                        nextChildren.parent().children("#current_num").html( "1" );
              
                    }
                    else {
                        
                        $(this).css("display", "none");
                    }
         
                });
               
                number++;
            }
           
        });
        
        
        var prevChildren = $(this).next().children(".prev");
        
        $(this).next().children(".prev").click( function() {
            
            if ( number >  0 ) { 
            
                number--;
               
            }
            
            if (  parseInt( number-1 )  >= 0 ) {
                
                aChildren.each( function(i , n) {
                    
                    if (  i ==  parseInt ( number - 1 ) ) {
           
                        $(this).css("display", "block");
                        
                        prevChildren.parent().children("#current_num").html( number  );
              
                    }
                    else {
                        
                        $(this).css("display", "none");
                    }
         
                });
               
            }
           
        });
       
    });
       
 
    $.maxZIndex = $.fn.maxZIndex = function(opt) {

        var def = {
            inc: 10, 
            group: '*'
        };
        $.extend(def, opt);
        var zmax = 0;
        $(def.group).each(function() {
        
            var cur = parseInt($(this).css('z-index'));
            zmax = cur > zmax ? cur : zmax;
        });
        if (!this.jquery)
            return zmax;
        return this.each(function() {
            zmax += def.inc;
            $(this).css('z-index', zmax);
        });
    }


    // birdchecklists
 
    $("#showBigBirdTable").click( function() {
     
        if ( $("#bigTable").is(":visible") ) {
      
            $("#bigTable").css("display", "none"); 
        }
        else {
         
            $("#bigTable").css("display", "block");  
        }
     
    });
  
    $("#showSmallBirdTable").click( function() {
     
        if ( $("#smallTable").is(":visible") ) {
      
            $("#smallTable").css("display", "none"); 
        }
        else {
         
            $("#smallTable").css("display", "block");  
        }
     
    });
  
  
    $("#skillet_list").click( function() {
     
        if ( $("#skillet_list_table").is(":visible") ) {
      
            $("#skillet_list_table").css("display", "none"); 
        }
        else {
         
            $("#skillet_list_table").css("display", "table");  
        }
     
    }); 
    
    var holePos = 0;
    
    $("#hole_next").click ( function() {
        
        if ( parseInt( holePos )  <= 17 ) {
            
            holePos++;
      
            $("#hole_scroll").css("left", -( parseInt( holePos ) * 500 ) );

        }
        if ( parseInt( holePos )  > 17 ) { 
         
           holePos = 0; 
           $("#hole_scroll").css("left", 0 );
        }
    });
    
    $("#hole_prev").click ( function() {
        
        if ( parseInt( holePos ) >= 1 ) {
            
            holePos--;   
      
            $("#hole_scroll").css("left", -(parseInt( holePos ) * 500  ) );
               
        }
        else if ( holePos == 0 ) {
         
            $("#hole_scroll").css("left", 0);
        }
    });
    


});

function handicap(form) 
{
 form.hc.value = Math.round(form.ind.value * form.slp.value/113)
}

