$(document).ready(function() {
    
    $('li').hover(function(){ 
          $(this).addClass('hover'); 
    },function(){ 
          $(this).removeClass('hover'); 
    });
    
    $('.home #content .col2 .image_container').cycle({
            fx: 'fade'
        });
    
    //only show first nine of image grid
    $('.image_grid img').each(function(i){ 
      if (i>=9) {
          $(this).hide();
      }
    });
    
    
    //hide all divs in left column on products & doctors pages 
    $('.products #content .col1 div,.doctors #content .col1 div').hide();
    
    //hide all divs in right column on products & doctor pages & show first div
    $('.products #content .col2 div,.doctors #content .col2 div').hide();
    $('.products #content .col2 div:first-child,.doctors #content .col2 div:first-child').show();
    
    $('.products #content .col1 h4,.doctors #content .col1 h4').css({'cursor':'pointer'}).click(function(){
        thisClass = $(this).attr('class');
        
        //first check for image grid
        if ( ($('.col2 div.' + thisClass + ' .image_grid').size()) > 0) {
            $('.col2 div.' + thisClass + ' .image_grid img').show()
        }
        
        
        if ($('.col1 div.' + thisClass).is(':visible')) {
            $('.col1 div.' + thisClass).hide();
        } else {
            $('.col1>div,.col2>div').hide()
            $('div.' + thisClass).show();
        }
        return(false);
    });
    
    //dental labs
    $('.dental-labs #content .col1 ul ul').hide();
    $('.dental-labs #content .col1 ul li').css('cursor','pointer').find('ul li').css('cursor','default');
    $('.dental-labs #content .col1 ul li').toggle(function(){ 
        $(this).find('ul').show('slow');
    },function(){ 
        $(this).find('ul').hide('slow');
    });
    
    
    $('a[rel="no_link"]').css('cursor','default').click( function() {
        return(false);
    });
    
    
    var page_url = document.location.href;
    var this_page = $('body').attr('class');
    
    
    if (this_page == 'products') {
        split_url = page_url.split('#');
        if (split_url[1]) {
            $('.col1>div,.col2>div').hide()
            $('div.' + split_url[1]).show();
        }
    }
    
});

