/*
Title:     What I do
Author:    gc@gcmingati.net
**********************************************
*/
jQuery.extend( jQuery.easing,
{
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	}
});

jQuery.fn.extend({ scramble :  function() {
    var i = this.size();
    if (!i) return this;
    while (--i) {
        var j = Math.floor(Math.random() * (i+1));
        var tmp1 = this.slice(i, i+1);
        this.slice(j, j+1).after(tmp1).insertAfter(tmp1);
    }
    return this;
}});


$(function(){ 




			



	/* css */
	$("#reel li a img").addClass("reflect");
	
	$('#email_link').safe_mail("gc", "gcmingati", "net", "ask");
	$("#reel li").scramble();
	





/* 
and what I've done.
*/
var step = 925; 
var itemFW = 185;
var $subnav = $("#reel ul");
var $thumbz = $("li img")
subListItems = $subnav.find("li").size();

$thumbz.hover(function(){ 
  $(this).css({cursor: "pointer"}) 
},function(){ 
  return false; 
});


$subnav.width(subListItems*itemFW);
$("<div id='left'><a href='#' class='lessthumbz' title='less'><img src='images/less.gif' /></a></div><div id='right'><a href='#' class='morethumbz' title='more'><img src='images/more.gif' /></a></div>").appendTo("#reel");
if($subnav.css("marginLeft") == 0+"px"){
	$("a.lessthumbz").css({display: "none"})
}
if($subnav.css("marginLeft").replace("px", "") <= -($subnav.width()-1900)){
	$("a.morethumbz").css({display: "none"})
}
// -->> morethumbz
$("a.morethumbz").click(function () {
	$subnav.filter("ul:not(:animated)").animate({ marginLeft: parseInt($subnav.css("marginLeft").replace("px", "")) - step }, 1100, "easeInOutExpo");
	limit = $subnav.width() - 1900;
	if($subnav.css("marginLeft").replace("px", "") <= -limit){
		$(this).fadeOut("slow");
	}
	if($subnav.css("marginLeft") <= 0+"px"){
		$("a.lessthumbz").fadeIn("slow");
	}
	return false;
});
// <<-- lessthumbz
$("a.lessthumbz").click(function () { 
	$subnav.filter("ul:not(:animated)").animate({ marginLeft: parseInt($subnav.css("marginLeft").replace("px", "")) + step }, 1100, "easeInOutExpo");
	limit = $subnav.width() - 1900;
	if($subnav.css("marginLeft").replace("px", "") <= limit){
		$("a.morethumbz").fadeIn("slow");
	}
	if($subnav.css("marginLeft") >= -925+"px"){
		$(this).fadeOut("slow");
	}
	return false;
});


var options = {
    resizeLgImages:     false,
    displayNav:         true,
    handleUnsupported:  'remove',
    initialHeight:			50,
    initialWidth:				120,
    keysClose:          ['c', 27] // c or esc
};

Shadowbox.init(options);


}); // ends ready

$(window).bind("load", function() { 
	$('img.reflect').reflect({height: 0.3, opacity: 0.3}); 
});