		// window.load
		$(window).load(function(){
		
			// retrieve and randomize posts
			if($("#posts").length > -1){
				// get length
				len = $("#posts img").length - 1;
				// set order
				if(len > -1){
					randStart = Math.round(Math.random(0,len));
					x = randStart;
					while(x<=len){
						$(".infinite").append($("#posts img:eq("+x+")"));
						x++;
					}
					x=0;
					$("#posts img").each(function(){
						$(".infinite").append($(this));
					});
				}
				$("#posts").hide();
			}
		
			// .content imgs
			$(".content img, .postContent img").each(function(){
				newHeight = $(".content, .blog").height();
				originalHeight = $(this).height();
				originalWidth = $(this).width();
				ratio = newHeight/originalHeight;
				$(this).height(newHeight);
				$(this).width(originalWidth*ratio);
			});
			
			// .post
			if($(".post").length > 0){
				$(".postContent img").each(function() {
					$(this).appendTo($(this).parents(".post").children(".images"));
				});
				fullWidth = 0;
				$(".post").each(function(){
					$(this).find(".images img:gt(0)").hide();
					fullWidth += $(this).width()+30;
				});
				if(fullWidth > $(window).width()){
					$("body,html,.infinite").css({"width":fullWidth+"px"});
				}else{
					$("body,html,.infinite").css({"width":$(window).width()+"px"});
				}
			}
			
			// initiate Scrollr
			$(".content").each(function(i){
				next = i+1;
				$("#content"+next+" img:gt(0)").css({"opacity":".1"});
				scrollrInterval = setInterval("Scrollr("+next+")",5000);
			});
			
			// Twitter
			$.getJSON("http://twitter.com/statuses/user_timeline/bbenton.json?count=1&callback=?", function(data){
				$.each(data, function(i,item){
					$("#twitterHold").html(item.text + "<br />&mdash<br />via <a href='http://twitter.com/bbenton'>Twitter</a>");
				});
			});
			
			// PostContent height
			$(".postContent").height($(window).height()-300);
			
			// Fade in
			$("#cover").fadeOut();
			
			// Start Auto-fade
			//setInterval("autoFade()",5000);
			
		});
		
		// auto fade
		function autoFade(){
			$(".images").each(function(){
				$("body,html,.infinite").css({"width":"999999px"});
				if($(this).children("img").length > 1){
					$(this).find("img:eq(0)").stop().fadeOut(function(){
						$(this).parent().find("img:eq(1)").stop().fadeIn(function(){
							$(this).parents(".images").append($(this).parent().find("img:eq(0)"));
							$(this).parent().children("img:gt(0)").hide(function(){
								fullWidth = 0;
								$(".post").each(function(){
									$(this).children("img:gt(0)").hide();
									fullWidth += $(this).width()+30;
								});
								$("body,html,.infinite").css({"width":fullWidth+"px"});
							});
						});
					});
				}
			});
		}

		// fade gallery
		$("img").click(function(){
			$("body,html,.infinite").css({"width":"999999px"});
			if($(this).parent().children("img").length > 1){
				if($(this).parent(".images")){
					$(this).stop().fadeOut(function(){
						$(this).parents(".images").children("img:eq(1)").stop().fadeIn(function(){
							$(this).parents(".images").append($(this).parents(".images").children("img:eq(0)"));
							$(this).parents(".images").children("img:gt(0)").hide(function(){
								fullWidth = 0;
								$(".post").each(function(){
									$(this).find(".images img:gt(0)").hide();
									fullWidth += $(this).width()+30;
								});
								$("body,html,.infinite").css({"width":fullWidth+"px"});
							});
						});
					});
				}
			
				
			}
		});

	
		// nav mouseenter
		$("#navigation li a").mouseenter(function(){
			theLeft = $(this).position().left;
			theWidth = $(this).width();
			
			$("#active").css({
				"display" : "block"
			});
			$("#active").stop().animate({
				"left" : theLeft+"px",
				"width" : theWidth+"px"
			});
		});
		
		// #active
		if($(".current_page_item").length != 0){
			theLeft = $("li.current_page_item a").position().left;
			theWidth = $("li.current_page_item a").width();
			
			$("#active").css({
				"display" : "block"
			});
			$("#active").stop().animate({
				"left" : theLeft+"px",
				"width" : theWidth+"px"
			});
		}
		
		// #logo mouseenter/out
		$("#logo").mouseenter(function(){
			$("#twitter,#arrow").stop().fadeIn();
		});
		$("#logo").mouseleave(function(){
			twitterFade = setTimeout("startFade2()",300);
		});
		$("#twitter").mouseenter(function(){
			clearTimeout(twitterFade);
		});
		$("#twitter").mouseleave(function(){
			startFade2();
		});
		function stopFade2(){
			$("#twitter,#arrow").stop();
		}
		function startFade2(){
			$("#twitter,#arrow").stop().fadeOut();
		}
		
		// #porfolio mouseenter/out
		$("#navigation li a").each(function(){
			if($(this).text() == "Portfolio"){
				$(this).attr("id","portfolio");
				$("#filters").css({
					"left":$(this).offset().left-128+"px",
				});
				$("#arrow2").css({
					"left":$(this).offset().left+9+"px",
				});
			}
		});
		$("#portfolio").mouseenter(function(){
			$("#filters,#arrow2").stop().fadeIn();
		});
		$("#portfolio").mouseleave(function(){
			portfolioFade = setTimeout("startFade()",300);
		});
		$("#filters").mouseenter(function(){
			clearTimeout(portfolioFade);
		});
		$("#filters").mouseleave(function(){
			startFade();
		});
		function stopFade(){
			$("#filters,#arrow2").stop();
		}
		function startFade(){
			$("#filters,#arrow2").stop().fadeOut();
		}
		
		// Scrollr
		function Scrollr(what){
			$("#content"+what+" img").css({"marginLeft":"0"});
			$("#content"+what+" img").css({"opacity":".1"});
			var cw = $("#content"+what+" img:eq(0)").width();
			$("#content"+what+" img:eq(0)").stop().animate({
				"marginLeft" : "-"+cw+"px"
			}, 500, function(){
				$("#content"+what+" img:eq(0)").css({"marginLeft":"0"});
				$("#content" + what + " .infinite").append($("#content"+what+" img:eq(0)"));
				$("#content"+what+" img:eq(0)").stop().animate({
					"opacity":"1"
				});
			});
		}
		
		// click functions
			$("#next1").click(function(){
				what = 1;
				$("#content"+what+" img").css({"marginLeft":"0"});
				$("#content"+what+" img").css({"opacity":".1"});
				len = $("#content"+what+" img").length-1;
				var cw = $("#content"+what+" img:eq("+len+")").width();
				$("#content"+what+" img:eq("+len+")").css({"marginLeft":"-"+cw+"px"});
				$("#content" + what + " .infinite").prepend($("#content"+what+" img:eq("+len+")"));
				$("#content"+what+" img:eq(0)").stop().animate({
					"marginLeft" : "0"
				}, 500, function(){
					$(this).animate({
						"opacity":"1"
					});
				});
			});
			$("#prev1").click(function(){
				what = 1;
				$("#content"+what+" img").css({"marginLeft":"0"});
				$("#content"+what+" img").css({"opacity":".1"});
				var cw = $("#content"+what+" img:eq(0)").width();
				$("#content"+what+" img:eq(0)").stop().animate({
					"marginLeft" : "-"+cw+"px"
				}, 500, function(){
					$("#content"+what+" img:eq(0)").css({"marginLeft":"0"});
					$("#content" + what + " .infinite").append($("#content"+what+" img:eq(0)"));
					$("#content"+what+" img:eq(0)").stop().animate({
						"opacity":"1"
					});
				});
			});
			$("#pause1").click(function(){
				if(scrollrInterval){
					clearInterval(scrollrInterval);
					scrollrInterval="";
					$(this).html("/");
				}else{
					scrollrInterval = setInterval("Scrollr(1)",5000);
					$(this).html("");
				}
			});
		
		/* .images img hover
		$("img").mouseleave(function(){
			if($(this).parents(".post").length > 0){
				$(this).animate({"opacity":".6"});
			}
		});
		$("img").mouseenter(function(){
			if($(this).parents(".post").length > 0){
				$(this).animate({"opacity":"1"});
			}
		});
		*/
		
		//Scroll Functions
	
		function rightScroll() {
			window.scrollBy(50,0); // horizontal and vertical scroll increments
			scrolldelay = setTimeout('rightScroll()',20); // scrolls every 100 milliseconds
		}
		function leftScroll() {
			window.scrollBy(-50,0); // horizontal and vertical scroll increments
			scrolldelay = setTimeout('leftScroll()',20); // scrolls every 100 milliseconds
		}
		function stopScroll() {
			clearTimeout(scrolldelay);
		}
		
		
		
		
/* Copyright 2008 Paul Bennett - http://paulicio.us
 * Scroller.js
 * Captures mouse wheel events and runs the ScrollSmoothly
 * function based on their output.
 * Aims to aid usability by allowing the user to scroll the 
 * page horizontally smoothly using only their mousewheel.
 * Mousewheel event capture by Adomas PaltanaviÄius at http://adomas.org/
 */

function handle(delta) {
        if (delta <0)
                ScrollSmoothly(10,10,'right');
        else if (delta >0)
                ScrollSmoothly(10,10,'left');
        else
        	;
}
 
function wheel(event){
        var delta = 0;
        if (!event) 
                event = window.event;
        if (event.wheelDelta) {
                delta = event.wheelDelta/120;
                if (window.opera)
                        delta = -delta;
        } else if (event.detail) {
                delta = -event.detail/3;
        }
        if (delta)
                handle(delta);
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}

var repeatCount = 0;

function ScrollSmoothly(scrollPos,repeatTimes, direction) {
	if(repeatCount < repeatTimes)
		if(direction == 'right')
			window.scrollBy(10,0);
		else
			window.scrollBy(-10,0);
	else
	{
		repeatCount = 0;
		clearTimeout(cTimeout);
		return;
	}
	repeatCount++;
	cTimeout = setTimeout("ScrollSmoothly('" + scrollPos + "','"+ repeatTimes +"','"+ direction +"')",10);
}
 
/* Initialization code. */
if (window.addEventListener)
        window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;
 
