/*
 * Copyright (c) 2010 Johan Ekhager
 *
 * @version 1.0
 *
 */

/* Shadowbox JS */       
Shadowbox.init({
	overlayOpacity: 0.9,
	continuous: true,	
	handleOversize: 'drag',
	viewportPadding: 0
});
/* END Shadowbox JS */ 
      
$(function () {
    // find the div.fade elements and hook the hover event
    $('div.fade-prev').hover(function() {
        // on hovering over find the element we want to fade *up*
        var fade = $('> div', this);
        // if the element is currently being animated (to fadeOut)...
        if (fade.is(':animated')) {
            // ...stop the current animation, and fade it to 1 from current position
            fade.stop().fadeTo(250, 1);
        } else {
            fade.fadeIn(250);
        }
    }, function () {
        var fade = $('> div', this);
        if (fade.is(':animated')) {
            fade.stop().fadeTo(2500, 0);
        } else {
            fade.fadeOut(250);
        }
    });
});

$(function () {
    // find the div.fade elements and hook the hover event
    $('div.fade-next').hover(function() {
        // on hovering over find the element we want to fade *up*
        var fade = $('> div', this);
        // if the element is currently being animated (to fadeOut)...
        if (fade.is(':animated')) {
            // ...stop the current animation, and fade it to 1 from current position
            fade.stop().fadeTo(250, 1);
        } else {
            fade.fadeIn(250);
        }
    }, function () {
        var fade = $('> div', this);
        if (fade.is(':animated')) {
            fade.stop().fadeTo(2500, 0);
        } else {
            fade.fadeOut(250);
        }
    });
});
      
/* SLIDESHOW FIRSTPAGE */
$(function() {
    $('#slideshow').after('<ul id="nav">').cycle({ 
	    fx:     'fade', 
	    speed:  'slow', 
	    timeout: 5000, 
	    pager:  '#nav', 

	    // callback fn that creates a thumbnail to use as pager anchor 
	    pagerAnchorBuilder: function(idx, slide) { 
	        return '<li><a href="#"><img src="http://campdavidfilm.com/wp-content/themes/campdavid/img/ui/slideshow_off.png" /></a></li>'; 
	    } 
	}); 
});        

$(document).ready(function() {
	$("ul#menu-nav li.cat-item a").wrapInner("<span></span>");
	$("ul#menu-nav li.cat-item a span").css({"opacity" : 0});
	$("ul#menu-nav li.cat-item a").hover(function(){
		$(this).children("span").animate({"opacity" : 1}, 300);
	}, function(){
		$(this).children("span").animate({"opacity" : 0}, 300);

	});


	$(".dir-post h3 a").append("<span class='dir1'></span>");
	$(".dir-post h3 a span").css({"opacity" : 0,"width":"100%","float":"left"}); 
	$(".dir-post .fade-dir span").css({"opacity" : 0}); 
	$(".dir-post").hover(function(){
		$(this).find("h3 a span.dir1").animate({"opacity" : 1}, 250);
		$(this).find(".fade-dir span.dir2").animate({"opacity" : 1}, 250);
	}, function(){
		$(this).find("h3 a span.dir1").animate({"opacity" : 0,}, 250);
		$(this).find("span.dir2").animate({"opacity" : 0}, 250);
	});


	$(".port-post .fade-dir span.dir2").css({"opacity" : 0}); 
	$(".port-post").hover(function(){
		$(this).find(".fade-dir span.dir2").animate({"opacity" : 1}, 250);
	}, function(){
		$(this).find("span.dir2").animate({"opacity" : 0}, 250);
	});


  $('#showlink').load( function() {
   $('div#showmore').hide('slow');
  });


  /* hover thumb fade 0.7 - 1 */ 
	$('#start-blog img').hover(function() {
		$(this).fadeTo("fast", 0.8);
	}, function() {
		$(this).fadeTo("fast", 1);
	});



  // $('.show-long').load('?more=20000', function() {
  //   console.log('ASD');
  // });
  
     
  $('.show-long').click(function() {
    $('.short-movie').hide();
    $('.long-movie').show();
  });

  $('.show-short').click(function() {
    $('.long-movie').hide();
    $('.short-movie').show();
  });

  // $('.show-all').click(function() {
  //   $('.long-movie').show();
  //   $('.short-movie').show();
  // });

  $('.marlind-stein .dir-post').click(function() {
    $('.marlind-stein .dir-post').hide();
	console.log('Hide dir posts, show urls');
    $('.urls').show();
  });

  $('.urls').click(function() {
    $('.marlind-stein .dir-post').show();
    $('.long-movie').hide();
    $('.short-movie').hide();
    $('.urls').hide();
  });

  
});
