/*
 Tooltip script 
 powered by jQuery (http://www.jquery.com)
 written by Alen Grakalic (http://cssglobe.com)
 for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 */

this.tooltip = function(){	
	/* CONFIG */		
		xOffset = -15;
		yOffset = 12;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<div id='tooltip'>"+ this.t +"</div>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("normal");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
	
};

	
$(document).ready(function(){

	tooltip();

  // Social Tab

   $("#networks li a").hover(
		function () {
			$(this).stop().animate({ paddingLeft: '17px' }, "fast" );
		}, 
		function () {
			$(this).stop().animate({ paddingLeft: '7px' }, "fast" );
		}
    );

  // Accordion

  
  $('#navigation').each(function () {
      var $links = $(this).find('a'),
      panelIds = $links.map(function() { return this.hash; }).get().join(","),
      $panels = $(panelIds),
      $panelwrapper = $panels.filter(':first').parent(),
      delay = 500,
      heightOffset = 0; // we could add margin-top + margin-bottom + padding-top + padding-bottom of $panelwrapper
      
    $panels.hide();
    
    $links.click(function () {
      var link = this, 
        $link = $(this);
      
      // ignore if already visible
      if ($link.is('.selected')) {
        return false;
      }
      
      $links.removeClass('selected');
      $link.addClass('selected');
              
      if ($.support.opacity) {
        $panels.stop().animate({opacity: 0 }, delay);
      }
      
      $panelwrapper.stop().animate({
        height: 0
      }, delay, function () {
        var height = $panels.hide().filter(link.hash).css('opacity', 1).show().height() + heightOffset;
        
        $panelwrapper.animate({
          height: height
        }, delay);
      });
    });
    
    $links.filter(window.location.hash ? '[hash=' + window.location.hash + ']' : ':first').click();
  });

  // prettyPhoto

  $("a[rel^='prettyPhoto']").prettyPhoto({
      animationSpeed: 'normal', /* fast/slow/normal */
      padding: 30, /* padding for each side of the picture */
      opacity: 0.50, /* Value betwee 0 and 1 */
      showTitle: true, /* true/false */
      allowresize: true, /* true/false */
      counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
      theme: 'light_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
  });

});

// PNG Fix for ie6

	DD_belatedPNG.fix('#logo h1'); 
	DD_belatedPNG.fix('#my_photo span'); 
	DD_belatedPNG.fix('.work-thumb span'); 
	DD_belatedPNG.fix('#networks img');
	DD_belatedPNG.fix('#footer');
	DD_belatedPNG.fix('#navigation');
	DD_belatedPNG.fix('#content');