jQuery(document).ready(function(){

//FEATURED ANIMATION
//=================================
var slideDuration = 4000; //how long will be displayed a single slide (in miliseconds)
var transitionTime = 400; //speed of transitions between slides (in miliseconds)

//Variable defaults
var slideCount = jQuery('.promo').children().size();
var slideHeight = jQuery('.promo li:first-child').outerHeight();

//Animation
function switchIt() {
	jQuery('.promo').stop().animate({top: '-='+slideHeight+'px'}, transitionTime, function() {
		jQuery('.promo li:last-child').after(jQuery('.promo li:first-child'));
		jQuery('.promo').css({top: 0});
		});
} // /switchItRight()

//Checking if cursor hovers over featured posts area
var notHoveringFeatured = true;
var hoveringElements = '.promo';
jQuery(hoveringElements).hover(function() {
		notHoveringFeatured = false;
	}, function() {
		notHoveringFeatured = true;
	});


//Repeated execution of switchIt() function
function repeatSwitchIt() {
	if (slideCount > 1 && notHoveringFeatured === true) switchIt();
} // /repeatSwitchIt()
setInterval(repeatSwitchIt, (slideDuration-transitionTime));
//==================================
// /FEATURED ANIMATION



//Mouse over scroll effect
var divWidth = jQuery('#content').width();
var ulWidth = jQuery('#content ul').children().size() * 260;
jQuery('#content ul').css({width: ulWidth+'px', margin: '0 auto'});
jQuery('#content').scrollLeft((ulWidth-divWidth)/2);
//When mouse moves over content list
jQuery('#content').mousemove(function(mousePos){
  var left = (mousePos.pageX) * (ulWidth - divWidth) / divWidth;
  jQuery('#content').scrollLeft(left);
});



//Newsletter button
jQuery('a.newsletter').click(function() {
	jQuery('.newsletter-form').animate({top: '120px'}, 400);
});
jQuery('.btn-close').click(function() {
	jQuery('.newsletter-form').animate({top: '-600px'}, 400);
});
function hideMsgForm() {
	jQuery('.newsletter-form.success').animate({top: '-600px'}, 400);
} // /hideMsgForm()
setTimeout (hideMsgForm, 7000);



//Portfolio hover
jQuery('#content li p').css({opacity: 0});
jQuery('#content li').hover(function() {
		jQuery(this).find('p').stop().animate({opacity: 1.0}, 250);
	}, function() {
		jQuery(this).find('p').stop().animate({opacity: 0}, 250, function() {
				jQuery(this).css({opacity: 0});
			});
	});


});

