$(document).ready(function(){		
	$(function(){ 
		$('input:text').each(function(){
			var txtval = $(this).val();
			$(this).focus(function(){
				$(this).val('')
			});
			$(this).blur(function(){
				if($(this).val() == ""){
					$(this).val(txtval);
				}
			});
		});
	});
	$(function(){
		$("#lwork li, #posts li, #portfull li, #recwork li").hover(function() {
		  $(this).find("span").stop().fadeTo(200, 1);
		  } , function() {
		  $(this).find("span").stop().fadeTo(200, 0);	
		});
	});
	$(function(){
		$('.tip').tipsy({gravity: 'w'});
		$('#footer #links ul li a, .subnav li a, #social ul li a').hover(function() { 
		 	$(this).animate({ paddingLeft: '15px' }, 200);
		 }, function() { 
		 	$(this).animate({ paddingLeft: '10px' }, 200);
		 });
	});
	$(function(){
		$("#posts").carouFredSel({
			curcular: false,
			infinite: false,
			auto : false,
			prev : "#post_prev",
			next : "#post_next",
			items  : 4,
			scroll : 4,	
		});
	});
	$(function(){
		$("#lwork").carouFredSel({
			curcular: false,
			infinite: false,
			auto : false,
			prev : "#work_prev",
			next : "#work_next",
			items  : 2,
			scroll : 2,
			scroll: {
					fx: "crossfade",
					duration : 200
				},	
		});
	});
	$(function(){
		$("#test").carouFredSel({
			curcular: false,
			infinite: false,
			auto : false,
			prev : "#test_prev",
			next : "#test_next",
			items  : 1,
			scroll : 1,
			scroll: {
					fx: "fade",
					duration : 200
				},	
		});
	});
	
	function filterPath(string) {
	  return string
	    .replace(/^\//,'')
	    .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
	    .replace(/\/$/,'');
	  }
	  var locationPath = filterPath(location.pathname);
	  var scrollElem = scrollableElement('html', 'body');
	
	  $("a[href^='http://']").attr("target","_blank");
	  $('a.backtop').each(function() {
	    var thisPath = filterPath(this.pathname) || locationPath;
	    if (  locationPath == thisPath
	    && (location.hostname == this.hostname || !this.hostname)
	    && this.hash.replace(/#/,'') ) {
	      var $target = $(this.hash), target = this.hash;
	      if (target) {
	        var targetOffset = $target.offset().top;
	        $(this).click(function(event) {
	          event.preventDefault();
	          $(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
	            location.hash = target;
	          });
	        });
	      }
	    }
	  });
	  function scrollableElement(els) {
	    for (var i = 0, argLength = arguments.length; i <argLength; i++) {
	      var el = arguments[i],
	          $scrollElement = $(el);
	      if ($scrollElement.scrollTop()> 0) {
	        return el;
	      } else {
	        $scrollElement.scrollTop(1);
	        var isScrollable = $scrollElement.scrollTop()> 0;
	        $scrollElement.scrollTop(0);
	        if (isScrollable) {
	          return el;
	        }
	      }
	    }
	    return [];
	  }
});

	


