jQuery(document).ready(function($) {
		
	jQuery.fn.fadeToggle = function(speed, easing, callback) {
  	 return this.animate({opacity: 'toggle'}, speed, easing, callback);
	
	}; 
	



$(document).ready(function(){
 
 
 
	numberEle = $(".slide a.imagem img");
	$('#sm li a, .sites li a').each(function(){
		$(this).before($(this).clone().removeClass().addClass('hoverMenu'));
	});
	
	$('#sm li, .sites li').hover(function(){
			$(this).find('.hoverMenu').stop().animate({marginTop:'0px'},200);
		},
		function(){
			$(this).find('.hoverMenu').stop().animate({marginTop:'-45px'},200);
	});

	number = $('#page-wrap table tr td');
	
	$('html').mousewheel(function (event, delta) {
		this.scrollLeft -= (delta * 50);
				
	});

	hideall = function (){
		$('.slide').each(function(){
			$(this).next('.box').css({height: "45px"})	
			//$(this).next('.box').children("div").hide();
		})
					//$('.iLikeThis').hide();

	}

		i=0;
		e=0;
		donoth= function(){}
		leftScrollInterval = setInterval(donoth,100);
		rightScrollInterval = setInterval(donoth,100);
		
		doScrollLeft = function(){
			i=i+3;
				$(document).scrollLeft($(document).scrollLeft() - (5+i));
		}
		
		$('.scrollingHotSpotLeft').bind('mouseover',function(){
				leftScrollInterval = setInterval(doScrollLeft, 6);
			});	

		

			// mouseout right hot spot
		$('.scrollingHotSpotLeft').bind('mouseout',function(){
				i=0;
				clearInterval(leftScrollInterval);
				if($(document).scrollLeft()<70){
					$('.scrollingHotSpotLeft').hide();
					}
			});
		
		
		doScrollRight = function(){
			e=e+3;

				$(document).scrollLeft($(document).scrollLeft() + (5+i));
		}	
		
		
		// mouseover right hot spot
		$('.scrollingHotSpotRight').bind('mouseover',function(){
				
				rightScrollInterval = setInterval(doScrollRight, 6);
					$('.scrollingHotSpotLeft').show();
					
				
			});	
		
		$('.scrollingHotSpotRight').bind('mouseout',function(){
				e=0
				clearInterval(rightScrollInterval);
			});
		
		
						clearInterval(leftScrollInterval);
						clearInterval(rightScrollInterval);
	
	w=$(window).width();
	h=$(window).height();

	$('#player_a, #player_a .panel, , #player_a .panel img').width(w).height(h);
	$('#player_a').cycle({
				fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
				timeout: 500,
				speed: 16000,
				cleartype: true, cleartypeNoBg: true
			});


$('.scrollingHotSpotLeft').hide();

loadAjax = function (){
	
		
		

		
		
		
		/*if($('.slidesing').length > 0){
				var firstimg;
				
				$('.slidesing').each(function(){
					img=$(this).children('img').attr('src');
					if(!firstimg){firstimg=img}
					$(this).html('<a href="'+img+'" class="imageSingle"><img src="'+img+'" /></a>');
				})
			
			$('#player_a').html('<img width="150%" style="margin-top:-15%;" src="'+firstimg+'" />');
			
			$('.imageSingle img').hover(
			  function () {
				imagem=$(this).attr('src');
				if(imagem){
					$('#player_a').html('<img width="150%" style="margin-top:-15%;" src="'+imagem+'" />');
				}
			  }, 
			  function () {
			  }
			);
		}
		if($('.post').length > 0){
			var firstimg;
			$('.post').each(function(){
					img=$(this).children('.slide').children('a.imagem').children('img').attr('src');
					if(!firstimg){firstimg=img}
				
				})
			$('#player_a').html('<img width="150%" src="'+firstimg+'" />');

			//$('.box').hide();
			
			$('.post').hover(
			  function () {
				$(this).children('div.box').show();
				imagem=$(this).children('.slide').children('a.imagem').children('img').attr('src');
				if(imagem){
					$('#player_a').html('<img width="150%" src="'+imagem+'" />');
				}
			  }, 
			  function () {
				//$(this).children('div.box').hide();
			  }
			);
		
		
		}*/
		a=0;
		   $('a.imagem').click(function(){
			  if($(this).children("img").length>0){
				   $('.loading').fadeIn();
				   href=$(this).attr('href');
				   //$(".conteudo").fadeTo('slow', 0.3);
				   //$("#loadCont").fadeOut("slow", function(){$(this).remove()});
				   //$(this).parent('.slide').parent('.post').fadeOut().after('<table class="loadCont" style="display:none;margin-top: 0px;"><tr></tr></table>');
				   //$(this).parent('.slide').parent('.post');
				   ID=$(this).parent('.slide').parent('.post').parent('td').attr("id");
				   conteID="#loadCont_"+ID;
				   conteID2l=conteID+" tr";
				   $('.contentLoaded').hide();
				   $('.postlist').show();
				  
				   $(conteID2l).load(href + " .conteudo", function(response, status, xhr) {
					  if (status == "error") {
							var msg = "Sorry but there was an error: ";
							//e.parent().parent().after("<div id='error'>");
							//	$("#error").html(msg + xhr.status + " " + xhr.statusText);
							//alert(msg + xhr.status + " " + xhr.statusText);
							window.location= "http://hugomineiro.com"+u;
					  }else{
						 //  alert($("#id-"+ID))
						 $("#id-"+ID).fadeOut("slow", function(){
							$(conteID).fadeIn(); 
							xpos=$(conteID).offset();
							$(document).scrollLeft(xpos.left);
						});
						 
						// $(ele+" .conteudo").fadeIn();
						
						
						numberEle = $(".slidesing img");
						i=0;
						$.each(numberEle, function() { 
							i++;
							linkImg = $(this).attr('src');
							$(this).wrap('<a href="'+linkImg+'" rel="group" class="colorbox" />');
							$('.colorbox').colorbox();
						
						})
						number = $('#page-wrap td');
						$('#page-wrap').width(number.length*600);	
					//$(document).scrollLeft($("#loadCont'+i+'").scrollLeft());
					
					  }
					})
					$('.loading').fadeOut();
					return false;
			  }else{
				  return false;
				}
				
			}) 
	
}

loadAjax();





$(window).resize(function() {

w=$(window).width();
	h=$(window).height();

	$('#player_a, #player_a .panel, , #player_a .panel img').width(w).height(h);
	});

});


});

