/*-----------------------------------------------------------------------------------*/
/*	Preload - images
/*-----------------------------------------------------------------------------------*/
$(document).ready(function(){
    $('.image.big').wrap('<div class="image_holder big"></div>').hide();
    $('.image.medium').wrap('<div class="image_holder medium"></div>').hide();
    $('.image.small').wrap('<div class="image_holder small"></div>').hide();
    $('a.fade').fadeTo(0,0.3);
    $('div#header a#title').hide().css('top', '-70px'); 
});

$(window).bind('load', function() {
	 $('div#header a#title').show().animate({top: "0"},1000,"easeOutExpo");
     var i = 1;
     var imgs = $('.image').length;
     var int = setInterval(function() {
     //console.log(i); check to make sure interval properly stops

     if(i >= imgs) clearInterval(int);
     $('.image:hidden').eq(0).fadeIn(200);
     i++;
     }, 500);
     
});


/*-----------------------------------------------------------------------------------*/
/*	Preload - images - Quicksand
/*-----------------------------------------------------------------------------------*/
function preload_images(){
	 $('.image.big').wrap('<div class="image_holder big"></div>');
     $('.image.medium').wrap('<div class="image_holder medium"></div>');
     $('.image.small').wrap('<div class="image_holder small"></div>');
};

$(document).ready(function(){
    preload_images();
});

/*-----------------------------------------------------------------------------------*/
/*	Slide panel
/*-----------------------------------------------------------------------------------*/
function slide_panel(){
	$('div.section_content a.info').toggle(function(){
		$(this).parent('div.section_content').animate({top: "5"},400,"easeInOutBack");
		}, function() {
		$(this).parent('div.section_content').animate({top: "40"},400,"easeInOutBack");
	});
};
$(document).ready(function(){
    slide_panel();
});


/*-----------------------------------------------------------------------------------*/
/*	Slide Title
/*-----------------------------------------------------------------------------------*/
function slide_title(){
	$('div#header a#title').hover(function(){
		$(this).stop().animate({top: "30"},350,"easeInOutBack");
		}, function() {
		$(this).stop().animate({top: "0"},350,"easeInOutBack");
	});
};
$(document).ready(function(){
    slide_title();
});

  

/*-----------------------------------------------------------------------------------*/
/*	Search Effect
/*-----------------------------------------------------------------------------------*/
$(function(){
    
$('#search_header input').focus(function(){
	$(this).animate({width: "100"},300,"easeOutCubic").css('background-position','-83px -311px');  
	}).blur(function(){
	$(this).animate({width: "42"},200,"easeInCubic").css('background-position','-83px -311px');
	});
});

/*-----------------------------------------------------------------------------------*/
/*	Slideshow
/*-----------------------------------------------------------------------------------*/

// Arrow - right
$(function(){
    
 $('#slideshow').hover(function(){
 
   $("a.nivo-nextNav",this).stop().animate({right: "-4", opacity: "1"},100,"easeOutCubic");
     
 }, function() {
 $("a.nivo-nextNav",this).stop().animate({right: "-20", opacity: "0"},150,"easeInCubic");
    
 });
 
});

// Arrow - left
$(function(){
    
 $('#slideshow').hover(function(){
   $("a.nivo-prevNav",this).stop().animate({left: "-4", opacity: "1"},100,"easeOutCubic");
     
 }, function() {
 $("a.nivo-prevNav",this).stop().animate({left: "-20", opacity: "0"},150,"easeInCubic");
    
 });
 
});



/*-----------------------------------------------------------------------------------*/
/*	Main - Menu
/*-----------------------------------------------------------------------------------*/
function mainmenu(){
$("#nav li").hover(function(){
		$(this).find("ul:first > li").stop().animate({height: "50"},300);
		},function(){
		$(this).find("ul:first > li").stop().animate({height: "0"},300);
		});
};

 
 
 $(document).ready(function(){					
	mainmenu();
});


/*-----------------------------------------------------------------------------------*/
/*	Image - Hover
/*-----------------------------------------------------------------------------------*/
function hover(){

	$('a.image_link').hover(function(){
	    $('.image',this).stop().fadeTo(400, 0.3);
	    $('.image_holder',this).css("background-image", 'url(img/assets/magnifier.png)');
		}, function() {
		$('.image',this).stop().fadeTo(300, 1);
	});
};

$(document).ready(function(){
    hover();
});




// Placeholder-text
$(document).ready(function(){

	$('[placeholder]').focus(function() {
	  var input = $(this);
	  if (input.val() == input.attr('placeholder')) {
		input.val('');
		input.removeClass('placeholder');
	  }
	}).blur(function() {
	  var input = $(this);
	  if (input.val() == '' || input.val() == input.attr('placeholder')) {
		input.addClass('placeholder');
		input.val(input.attr('placeholder'));
	  }
	}).blur();
	$('[placeholder]').parents('form').submit(function() {
	  $(this).find('[placeholder]').each(function() {
		var input = $(this);
		if (input.val() == input.attr('placeholder')) {
		  input.val('');
		}
	  })
	});

});

/*-----------------------------------------------------------------------------------*/
/*	Fade On :Hover
/*-----------------------------------------------------------------------------------*/
$(function(){
	 $('a.fade').hover(function(){
	     $(this).stop().fadeTo(600, 1);
	 }, function() {
	     $(this).stop().fadeTo(200, 0.2);
	 });
});



/*-----------------------------------------------------------------------------------*/
/*	Twitter
/*-----------------------------------------------------------------------------------*/
$(document).ready(function(){
        $("#tweets").tweet({
            username: "envato",
            join_text: "auto",
            avatar_size: 32,
            count: 1,
            auto_join_text_default: "we said,", 
            auto_join_text_ed: "we",
            auto_join_text_ing: "we were",
            auto_join_text_reply: "we replied to",
            auto_join_text_url: "we were checking out",
            loading_text: " ",
            template: "{text}{time}"
        });
    });




/*-----------------------------------------------------------------------------------*/
/*	TipTip
/*-----------------------------------------------------------------------------------*/
$(document).ready(function(){
	$('a').tipTip({
	activation: "hover",
	keepAlive: false,
	maxWidth: "200px",
	edgeOffset: 0,
	defaultPosition: "top",
	delay: 0,
	fadeIn: 150,
	fadeOut: 150,
	attribute: "title",
	content: false

	});
	
});

/*-----------------------------------------------------------------------------------*/
/*	Fix nth explorer
/*-----------------------------------------------------------------------------------*/
function fix_nth(){
    $("div#content div.block_2").removeClass("nth");
    $("div#content div.block_2:nth-child(2n)").addClass("nth");
    
    $("div#content div.block_3").removeClass("nth");
    $("div#content div.block_3:nth-child(3n)").addClass("nth");
};

$(document).ready(function(){
    fix_nth();
});

/*-----------------------------------------------------------------------------------*/
/*	StyleChanger
/*-----------------------------------------------------------------------------------*/
$(document).ready(function(){
	$('.container_12').append('<div id="styleChanger"></div>');
    $('#styleChanger').load('scripts/styleChanger/styleChanger.html');    
});
