$(document).ready(function () {
    if($('#live-preview').size()>0) {
        var top = $('#live-preview').offset().top - parseFloat($('#live-preview').css('marginTop').replace(/auto/, 0));
        $(window).scroll(function (event) {
          // what the y position of the scroll is
          var y = $(this).scrollTop();

          // whether that's below the form
          if (y >= top) {
            // if so, ad the fixed class
            $('#live-preview').addClass('fixed');
          } else {
            // otherwise remove it
            $('#live-preview').removeClass('fixed');
          }
        });
    }
});

//coda slider

$(function () {
	var beingShown = false;
	var beingFaded = false;
	var shown = false;
	
	$(".factoryDownload a.factoryMenuHead").hover(function(){
		if(!shown && !beingShown && !beingFaded) {
			beignShown = true;
			$(".popup",$(this).parent()).fadeIn('slow', function(){
				beignShown = false;
				shown = true;
			});
		}
	},
	function(){
		if(!beingFaded) {
			beingFaded = true;
			$(".popup",$(this).parent()).fadeOut('slow', function() {
				shown = false;
				beingFaded = false;	
			});
		}
		
	});
});
