$(document).ready(function(){
	var pos=0;
	var max=$('#home-wrap').attr('class')*340*(-1);
	
	$('#anterior').css({opacity:0.5,cursor:'default'});
	
	if (pos<max+TamVentana()[0]+340)
		$('#siguiente').css({opacity:0.5,cursor:'default'});
	
	$('#anterior').click(function() {
		if (pos<0)
		{
			pos+=340;
			$('#home-wrap').animate({left:pos},800,'easeOutQuart');

			if (pos>-340)
			{
				$('#anterior').css({opacity:0.5,cursor:'default'});
				$('#siguiente').css({opacity:1,cursor:'pointer'});
			}
			else
			{
				$('#anterior').css({opacity:1,cursor:'pointer'});
				$('#siguiente').css({opacity:1,cursor:'pointer'});
			}
		}
	});
	
	$('#siguiente').click(function() {
		if (pos>max+TamVentana()[0])
		{
			if (pos<max+TamVentana()[0]+340)
			{
				$('#anterior').css({opacity:1,cursor:'pointer'});
				$('#siguiente').css({opacity:0.5,cursor:'default'});
			}
			else
			{
				$('#anterior').css({opacity:1,cursor:'pointer'});
				$('#siguiente').css({opacity:1,cursor:'pointer'});
			}
			
			pos-=340;
			$('#home-wrap').animate({left:pos},800,'easeOutQuart');
		}
	});
});

function TamVentana() 
{ 
	var tam=[0, 0]; 
	if (typeof window.innerWidth != 'undefined')
		tam=[window.innerWidth,window.innerHeight];
	else 
		if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined'
				&& 	document.documentElement.clientWidth != 0)
			tam=[document.documentElement.clientWidth, document.documentElement.clientHeight];
		else
			tam=[document.getElementsByTagName('body')[0].clientWidth, document.getElementsByTagName('body')[0].clientHeight];
	return tam;
}
