$.easing.bouncy = function (x, t, b, c, d) { 
    var s = 1.70158; 
    if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
    return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
} 
 
// create custom tooltip effect for jQuery Tooltip 
$.tools.tooltip.addEffect("bouncy", 
 
    // opening animation 
    function(done) { 
        this.getTip().animate({top: '+=15'}, 500, 'bouncy', done).show(); 
    }, 
 
    // closing animation 
    function(done) { 
        this.getTip().animate({top: '-=15'}, 500, 'bouncy', function()  { 
            $(this).hide(); 
            done.call(); 
        }); 
    } 
);
$(document).ready(function(){
	if (typeof(InitilizeMap)==='function')
		{
				InitilizeMap();	
		}
    $('.menu ul li.main_li').hover(function(){
            $(this).children('ul').show();
            $(this).addClass('menu_hover');
        },function(){
            $(this).children('ul').hide();
            $(this).removeClass('menu_hover');
        });    
        
	 //init uploadify, the function is inline defined in views/pages/contact_page
	 
		if (typeof(Init_uploadify)==='function')
		{
				Init_uploadify();	
		}
		if (typeof(newpicturesControls)==='function'){
					newpicturesControls();
		}
	 if (typeof(galleryInit)==='function'){
		 galleryInit();
		 
    }
    if (typeof(contactPage_clickEvents)==='function'){
		 contactPage_clickEvents();
    }
	 
     if($('.menu ul li').length>0) $('.menu ul li').ahover({toggleEffect: 'width',moveSpeed:150})
     
     $('#lazy').lazyslider({btnsHeight:47,btnsWidth:47,slowcontrols:false,fastrightPos:35,fastleftPos:40}); 
	 
     $('#lazy li').hover(function(){
            $(this).find('span').fadeIn();    
     },function(){
            $(this).find('span').hide();
     });
     
     
     /*$('#lazy li').click(function(){
         var href = $(this).find("a").attr("href");
         if(href) {
         window.location = href;
         }
     }); */
     
     
     
     
     $('#mycarousel').jcarousel();
     
     $(".services p").hover(function(){$('.tooltip_holder').show()},function(){$('.tooltip_holder').hide;});
     
     
     $('.quote').lazytooltip();
     
 /*    
     $('#google-map').hover(function(){
         
    
     $('#locationlocationlocation').animate({left:$(this).offset().left,top:$(this).offset().top},500,function(){});
     },
     function(){
         return false;
     })
     $('#close-location').click(function(){
          //$('#locationlocationlocation').css({left:-1400+'px'});
          $('#locationlocationlocation').animate({left:-1400+'px'},500,function(){});
          return false;
     });
           */
           
           $('#google-map').lazytooltiper();
           $('.logo').pngFix();
           
			  $('#facebook_link').click(function(){
				  if ($(this).prev().hasClass('facebook_hidden')){
                      $(this).prev().stop().animate({top:'0'});
					  $(this).stop().animate({top:'112px'});
					  $(this).prev().removeClass('facebook_hidden');
				  }
				  else {
                      $(this).prev().stop().animate({top:'-112px'});
					  $(this).stop().animate({top:'0'});
					  $(this).prev().addClass('facebook_hidden');
					  
					  
				  }
			  });
     
});