$(document).ready(function(){

  /* contact map hover */
  
  $('.godolloMap').animate({ 'opacity' : 0 });
  
  $('.godolloPlace .pic').hover(function() {
     $('.godolloMap').stop().animate({ 'opacity' : 1 });
  }, function() {
    $('.godolloMap').stop().animate({ 'opacity' : 0 });
  });
  
  /* services li more info */
  
  $('.moreInfo').hide();

  $('#servicesTab ul li').click(function() {
      
    $('.howtoInfo').hide();
      
    $('#servicesTab ul li').find('a').removeClass('active');
    $(this).find('a').addClass('active');
      
  	$('.moreInfo').hide();
  
  	var activeTab = $(this).find('.moreInfo');
  	$(activeTab).fadeIn();
  	return false;
  });
  	
  $('#homeNav, #aboutNav, #servicesNav, #medicalNav, #pricesNav, #contactNav').click(function() {
    $('.moreInfo').hide();
    $('#servicesTab ul li').find('a').removeClass('active');
    $('.howtoInfo').show();
  });

  /* tabs */
  
  $('.tab_content').hide();
  	$('ul.tabs li a:first').addClass('active').show();
  	$('ul.tabs li:first').addClass('active').show();
  	$('.tab_content:first').show();
  
  	$('ul.tabs li').click(function() {
  
  		$('ul.tabs li').find('a div').removeClass('active');
  		$('ul.tabs li').removeClass('active');
  		$(this).addClass('active');
  		$(this).find('a div').addClass('active');
  		$('.tab_content').hide();
  
  		var activeTab = $(this).find('a').attr('href');
  		$(activeTab).fadeIn();
  		return false;
  	});
    
});

/* presentation img slideshow */
$(function () {

    $insert_nav = $('.slideshow');
	
	$elements = $('.image');
    $nfo = $('.info');
    
    $image = $('.image');
    
    $elementsSize = $($elements).length;

    $n=0;
    $stop = false;

    loopelements();
           
    function loopelements (){
    
        if ($stop == 'next'){
            if($n == $elementsSize){
                $n = 0;
            }
            $($elements).animate({ 'opacity' : 0 }, {duration:500});
			
            $($elements[$n]).animate({ 'opacity' : 1 }, {duration:500});
			
		    }else if ($stop == 'back'){
            if($n == -1) {
                $n = $elementsSize -1;
            }
            
            $($elements).animate({ 'opacity' : 0 }, {duration:500});
			
            $($elements[$n]).animate({ 'opacity' : 1 }, {duration:500});

        } else {
        
            $($elements).animate({ 'opacity' : 0 }, {duration:500});
			
            $($elements[$n]).animate({ 'opacity' : 1 }, {duration:500});
            
            $n++;
            
            if($n == $elementsSize) $n = 0;
                setTimeout(loopelements, 5000);
       }
    }

});
