jQuery.extend(jQuery.easing, {
	easeX: function(x,t,b,c,d){
		return Math.cos(20*Math.PI*x);
	},
	easeY: function(x,t,b,c,d){
		return Math.sin(20*Math.PI*x);
	}
})
function doAnimate(obj){
	obj.animate({
		marginLeft: ['-300','easeX'],
		marginTop: ['-300','easeY']
	},1000000);
}
$(window).resize(function(){
	if ($('.container').height()<$(window).height()) $('.container').height($(window).height());
})
$(function(){
	
	$(document).pngFix();
	
	$('.container .wrapper:first').append('<a href="./index.html" class="homelink">Re-touch</a>')
	
	$('.menu-l1 li:last').css('border','0');	
	$('.menu-l2 li:last').css('border','0');
	
	if ($('.portfolio').html()) {
		
		if ($('.data-source').html()) {
			var obj = $('.data-source');
			obj.children('.item').each(function(){
				var _href = $(this).children('.href').html();
				$('.portfolio .previews ul').append('<li ref="'+$(this).attr('id')+'">'+_href+'</li>')
			})
		}
		
		$('.portfolio .previews li:first').css('marginLeft', '0');
		$('.portfolio .previews li a').hover(function(){
			$(this).addClass('hover')
		}, function(){
			$(this).removeClass('hover')
		})
		$('.portfolio .previews li a').bind('click',function(){
			$('.portfolio .previews .current').removeClass('current');
			$(this).addClass('current');
			$('.portfolio .frame .img img').attr('src', $(this).attr('href'));
			$('.portfolio .frame .img-hover img').attr('src',$(this).attr('ref'));
			$('.portfolio .frame .desc .wrapper').html($('#'+$(this).parent().attr('ref')).children('.desc').html());
			$('.portfolio .frame .img img').load(function(){
				$('.portfolio .frame').css('width', $('.portfolio .frame .img img:first').width() + 2);
			})
			return false;
		})
		$('.portfolio .frame').hover(function(){
			$('.portfolio .frame .img-hover').fadeIn(0);
		},function(){
			$('.portfolio .frame .img-hover').fadeOut(0);
		})

		$('.portfolio .previews ul li:first a').click();
		$('.portfolio').fadeIn(0);

	}
		
})
$(window).load(function(){
	if ($('.portfolio').html()) {
		$('.portfolio .frame').css('width', $('.portfolio .frame .img img:first').width() + 2);
	}
	if ($('.animated-wrapper').html()) doAnimate($('.animated'));

	$(window).resize();
	
})
