/*-----------------------------------------------------------------------------------*/
/*	Preload
/*-----------------------------------------------------------------------------------*/
$(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.2);
	$('div#header a#title').hide().css('top', '-70px');
	$('#slider').css('opacity',0);
});

$(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>');
};


/*-----------------------------------------------------------------------------------*/
/*	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() {
	
	$('#nav li').has('ul').addClass('father');
	
	$('#nav ul').css('width', 940 );
	$('#navigation').after('<div class="subnav-background"></div>');

	$('#nav > li').hover(function() {
		$(this).children('ul').hide().stop(true, true).slideDown(800);
	}, function() {
		$(this).children('ul').stop(true, true).fadeOut(0, function() {
			$('.subnav-background').slideUp(200);
			$('#header').removeClass('active');
		});
	});
	
	
	$("#nav ul > li.father").hover(function(){

			$('.subnav-background').stop().animate({height: 100 },200);
			$(this).children('ul').hide().stop(true, true).slideDown(800);
			
			},function(){
 
			$('.subnav-background').stop().animate({height: 60 },200);
			$(this).children('ul').hide().stop(true, true).slideUp(800);
	});
	

	$('#nav > li').hover(function() {
		if( $(this).children('ul').length > 0 ) {
			var containerWidth = $('.container').width(),
				subWidth = $(this).children('ul').width(),
				pos = $(this).position(),
				left = containerWidth - subWidth - ( pos.left + ( $(this).width() / 2 )),
				margin = ( $(this).children('ul').children('li').size() - 1 ) * 30;
				
			$(this).children('ul').css('right', 0);
			$(this).addClass('hover');
			$('.subnav-background').stop(true, true).slideDown(200);
			$('#navigation').addClass('active');
		}
	}, function() {
		$(this).removeClass('hover');
		
	});
});

/*-----------------------------------------------------------------------------------*/
/*	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);
	 });
});





/*-----------------------------------------------------------------------------------*/
/*	Twitters
/*-----------------------------------------------------------------------------------*/
//	Home
$(document).ready(function(){
	$("#tweets").tweet({
		username: "DesireeLowry",
		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}"
	});
});
//	Footer
$(document).ready(function(){
	$("#widget_tweets.tweets_footer").tweet({
		username: "envato",
		join_text: "auto",
		template: "{text}{time}",
		count: 2,
		loading_text: " "
	});
});
// Sidebar
$(document).ready(function(){
	$("#widget_tweets.tweets_sidebar").tweet({
		username: "desireelowry",
		join_text: "auto",
		template: "{text}{time}",
		count: 3,
		loading_text: " "
	});
});

/*-----------------------------------------------------------------------------------*/
/*	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

	});
	
});*/
