// Title: Nanny Pickle - javascript
// Author: Kalon Edser, http://www.kalonedser.com/
// Updated: 29 January 2010

jQuery(document).ready(function() {
	
	$('body').addClass('js');
	
	$('#slideshow').cycle({
		timeout: 5000,
	    speed:  2500
	});
	
	// smooth inline scrolling
	$.localScroll({
		target: '#content',
		margin: true
	});
	$.localScroll.hash({
		target: '#content',
		margin: true
	});
	
	// vertical align margin
	$.fn.vAlign = function() {
		return this.each(function(i){
		var ah = $(this).height();
		var ph = $(this).parent().height();
		var mh = (ph - ah) / 2;
		if (ah < ph) {
			$(this).css('margin-top', mh);
		}
		});
	};

	$('#visions-and-values .info-inner, #who-is-nanny-pickle .info-inner').vAlign();
	$('.info-inner p:last-child').addClass('last');
	
	// drop down menu
	$('#nav li, #nav-subscribe li').hover(
	  function () {
		$(this).addClass("over");
	  },
	  function () {
		$(this).removeClass("over");
	  }
	);
	
	// pram messages
	if($('.pram-msg').length > 0) {
		$('#pram-icon').effect("bounce", { times: 2, distance: 10 }, 300);
		$('.checkout-link').effect("highlight", {}, 3000);
	}
	
	$('.pram-msg').animate({ opacity: 1}, 3000, function() {
		$(this).fadeOut();
	});
	
	// toggle message
	$('a[rel^="message"]').toggle(
		function () { // toggle show
			$('#message-box').show("slide", {direction: 'up'}, 'normal', function() {
				$('#content').scrollTo( '#message-box', 800, {margin:true} );
			});
		},
		function () { // toggle hide
			$('#message-box').hide("slide", {direction: 'up'}, 'normal');
		}
	);
	
	// tooltips
	$('#pram-icon, .tooltip, .style-icon img').easyTooltip();
	
	$('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });

});