// =jQuery plugins ------------------------------------------------------------------------------ //
$(function() {
		   
// =Featured [malsup.com/jquery/cycle] ---------------------------------------------------------- //
$('#featured #slides').cycle({
pause: 1,
speed: 500,
timeout: 4000,
pager:  '#pager',
pagerAnchorBuilder: function(idx) { 
return '<a href="#">.</a>';}
});

// =Filter [net.tutsplus.com/tutorials/javascript-ajax/creating-a-filterable-portfolio-with...] - //
$('#filters a').click(function() {  
$('#filters a.current').removeClass('current');  
$(this).addClass('current');  
var filterVal = $(this).text().toLowerCase();  
if(filterVal == 'all') {  
$('#work').fadeOut('fast',function(){
$('#work li.hidden').removeClass('hidden');
$('#work').fadeIn('fast');
});
} else {
$('#work').fadeOut('fast',function(){
$('#work li').each(function() {
if(!$(this).hasClass(filterVal)) {
$(this).addClass('hidden');
} else {
$(this).removeClass('hidden');
}
});
$('#work').fadeIn('fast');
});
}
return false;  
});  

// =Form Hint [remysharp.com/2007/01/25/jquery-tutorial-text-box-hints] ------------------------- //
$.fn.hint = function(blurClass) {
if (!blurClass) { 
blurClass = 'blur';
}
return this.each(function() {
var $input = $(this),
title = $input.attr('title'),
$form = $(this.form),
$win = $(window);
function remove() {
if ($input.val() === title && $input.hasClass(blurClass)) {
$input.val('').removeClass(blurClass);
}
}
if (title) { 
$input.blur(function() {
if (this.value === '') {
$input.val(title).addClass(blurClass);
}
}).focus(remove).blur();
$form.submit(remove);
$win.unload(remove);
}
});
};
$('input:text, textarea').hint();

// =Spotlight ----------------------------------------------------------------------------------- //
$('.spotlight').hover(function() {
$(this).addClass('active');
$('.spotlight .loading').css({backgroundImage: 'none'});
$('.spotlight:not(.active)').find('img').stop().animate({opacity: 0.75},'fast');
}, function() {
$(this).removeClass('active');
$('.spotlight:not(.active)').find('img').stop().animate({opacity: 1.0},'fast');
});

// =Smooth Scroll [learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-p...] - //
$(document).ready(function(){
$('a[href*=#]').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target
|| $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body')
.animate({scrollTop: targetOffset}, 250);
return false;
}
}
});
});

// =Transparency (IE6) [allinthehead.com/retro/338/supersleight-jquery-plugin] ------------------ //
$.fn.supersleight = function(settings) {
settings=jQuery.extend({
imgs:true,
backgrounds:true,
shim:'images/transparent.gif',
apply_positioning:true
}, settings);
return this.each(function() {
if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7 && parseInt(jQuery.browser.version) > 4) {
jQuery(this).find('*').each(function(i,obj) {
var self = jQuery(obj);
if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
var bg = self.css('background-image');
var src = bg.substring(5,bg.length-2);
var mode = (self.css('background-repeat') == 'no-repeat'?'crop':'scale');
var styles={
'filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='"+mode+"')",
'background-image':'url('+settings.shim+')'
};
self.css(styles);
};
if (settings.imgs && self.is('img[src$=png]')) {
var styles = {
'width': self.width() + 'px',
'height': self.height() + 'px',
'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src = '" + self.attr('src') + "', sizingMethod = 'scale')"
};
self.css(styles).attr('src', settings.shim);
};
if (settings.applyPositioning && self.is('a, input') && self.css('position') === '') {
self.css('position', 'relative');
};
});
};
});
};
$('body').supersleight();

// =Twitter ------------------------------------------------------------------------------------- //
getTwitters('twitter', { 
id: 'jasonrudmann', 
count: 1, 
enableLinks: true, 
ignoreReplies: true, 
clearContents: true,
template: '<strong>Jason is&#8230;</strong> <em>"%text%"</em> <a href="http://twitter.com/%user_screen_name%/statuses/%id%/"><span>%time%</span></a>'
});

// =vJustify [michael.futreal.com/jquery/vjustify] ---------------------------------------------- //
$.fn.vjustify = function() {
var maxHeight = 0;
this.each(function() {
if (this.offsetHeight > maxHeight) {maxHeight = this.offsetHeight;}
});
this.each(function() {
$(this).height(maxHeight + 'px');
if (this.offsetHeight > maxHeight) {
$(this).height((maxHeight - (this.offsetHeight - maxHeight)) + 'px');
}
});
};
$('.vjustify').vjustify();

// =Misc ---------------------------------------------------------------------------------------- //
$('a').wrapInner('<span></span>');

});