
// tooltip

this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		
	/* END CONFIG */		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

$(document).ready(function(){
	tooltip();
});

// variable grid

$(function(){
	$("#grid-content").vgrid({
		easeing: "easeOutQuint",
		time: 400,
		delay: 20,
		fadeIn: {
			time: 500,
			delay: 50
		}
	});

	var hsort_flg = false;
	$("#hsort").click(function(e){
		hsort_flg = !hsort_flg;
		$("#grid-content").vgsort(function(a, b){
			var _a = $(a).find('h3').text();
			var _b = $(b).find('h3').text();
			var _c = hsort_flg ? 1 : -1 ;
			return (_a > _b) ? _c * -1 : _c ;
		}, "easeInOutExpo", 300, 0);
		return false;
	});

	$("#rsort").click(function(e){
		$("#grid-content").vgsort(function(a, b){
			return Math.random() > 0.5 ? 1 : -1 ;
		}, "easeInOutExpo", 300, 20);
		return false;
	});
});

// fancybox lightbox

$(document).ready(function() {

			$(".expand").fancybox();
		});
		
		
// scroll

$(function() {
 
    function scroll(direction) {
 
        var scroll, i,
                positions = [],
                here = $(window).scrollTop(),
                collection = $('.post');
 
        collection.each(function() {
            positions.push(parseInt($(this).offset()['top'],10));
        });
 
        for(i = 0; i < positions.length; i++) {
            if (direction == 'next' && positions[i] > here) { scroll = collection.get(i); break; }
            if (direction == 'prev' && i > 0 && positions[i] >= here) { scroll = collection.get(i-1); break; }
        }
 
        if (scroll) {
            $.scrollTo(scroll, {
                duration: 650       
            });
        }
 
        return false;
    }
 
    $(".scrolltoanchor").click(function() {
        $.scrollTo($($(this).attr("href")), {
            duration: 650
        });
        return false;
    });
 
    $(".contact-butt").click(function() {
        $.scrollTo($($(this).attr("href")), {
            duration: 650
        });
        return false;
    });
    
     $(".totop").click(function() {
        $.scrollTo($($(this).attr("href")), {
            duration: 650
        });
        return false;
    });
 
});


// thumbnail fades

$(document).ready(function(){
						   $(".thumbshow img").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to fade to 100% when the page loads
						   $(".thumbshow img").hover(function(){
						   $(this).fadeTo("slow", 0.6); // This should set the opacity to 60% on hover
						   },function(){
						   $(this).fadeTo("slow", 1.0); // This should set the opacity back to 100% on mouseout
						   });
						   });


