	var rollingFrontProjects, rollingFrontProjectsOut, rollingBackProjectsOut, rollingBackProjects, rollingSubmit, rollingSubmitOut, rollingLink, rollingLinkOut, rollingPageTitleBack, rollingPageTitleBackOut;
$(document).ready(function(){
	function cleanAll(rel){
	$("*.showContentServices"+rel).animate({
						height: 0
					  }, 'normal');
	
	}
$(window).resize(function() {
  $.recalcAll();
});
 var inLoop, inLoopThumb, inLoopItem;
    inLoop = inLoopThumb = inLoopItem = rollingFrontProjects = rollingFrontProjectsOut = rollingBackProjectsOut = rollingBackProjects = rollingSubmit = rollingSubmitOut = rollingLink = rollingLinkOut = rollingPageTitleBack = rollingPageTitleBackOut = false;
var ctrl = 0;
	
		$('#udGalery').click(function(){
				
				if($('.galeria').height() == 1){ 
					$('.galeria, #slider').animate({
						height: 360
					  }, 'normal', function(){$('#fullsize, #imgprev, #imgnext, #information, .thumbnails,').show();	$('#udGalery').css('background-image', 'url("imgs/hideGalery.png")');}
					);
				}
				else{
					$('#fullsize, #imgprev, #imgnext, #information, .thumbnails,').hide();
					$('.galeria, #slider').animate({
						height: 1
					  }, 'normal', function(){
						 
						  $('#udGalery').css('background-image', 'url("imgs/showGalery.png")');
						  }
					  
					);
				}
		});//end show/hide gallery
	
	
	
	

	
	
	
	
	
	
	
	
	
	
	$("*#link").hover(function() {
		$(this).animate({ color: "#fff" }, 90); 
			}, function() {
		$(this).animate({ color: "#666" }, 90); 
	});
	$("*#linkSel").hover(function() {
		$(this).animate({ color: "#666" }, 90); 
			}, function() {
		$(this).animate({ color: "#fff" }, 90); 
	});
	

$(".submitButton").hover(function() {
		$(this).css('backgrond-image' ,'url("imgs/ButtonSendOver.png")'); 
			}, function() {
		
		$(this).css('backgrond-image' ,'url("imgs/ButtonSend.png")');
	});


	
	

$(".submitButtonProj").hover(function() {
		$(this).animate({ backgroundColor: "#fff" }, 500); 
			}, function() {
		$(this).animate({ backgroundColor: "#333" }, 500);
	});



$("*.iconTitle").hover(function() {
	var rel = $(this).attr("rel");
		if($(".showContentServices[rel='"+rel+"']").height() != 150){
		$(this).css("background-image", "url('imgs/iconTitleBGOver.png')" )
	}
			}, function() {
				var rel = $(this).attr("rel");
		if($(".showContentServices[rel='"+rel+"']").height() == 0){
	$(this).css("background-image", "url('imgs/iconTitleBG.png')" );
	}
	
	});












$("*.iconTitle").click(function() {
	var rel = $(this).attr("rel");
	
	if($(".showContentServices[rel='"+rel+"']").height() == 150){
		
		$(".showContentServices[rel='"+rel+"'], .titleContainer").animate({
						height: 0
					  }, 'fast', function(){
						
					});
				}
	else{
	
	$(".showContentServices").animate({
						height: 0
					  }, 'slow', function(){
						 
					  $("*.iconTitle").css('background-image', 'url("imgs/iconTitleBG.png")');
					 });
	
	$(".showContentServices[rel='"+rel+"'], .titleContainer").animate({
						height: 150
					  }, 'fast', function(){
						
					  $(".iconTitle[rel='"+rel+"']").css('background-image', 'url("imgs/iconTitleBGDown.png")');
					  });
	
	}
	
	
	});

/*
$("*.cbcItem").mouseout(function() {
	$(this).animate({
    opacity: 1 }, 600);
	
});	
*/


$("*#itemImage").hover(function() {
		 var divToSlide = $(this).parent().find("#itemImageIMG");
	$(divToSlide).animate({
    opacity: 0.3 }, 110);
			}, function() {
		 var divToSlide = $(this).parent().find("#itemImageIMG");
	$(divToSlide).animate({
    opacity: 1 }, 110);
	});




$("*#itemImageIMG").hover(function() {
		 var divToSlide = $(this);
	$(divToSlide).animate({
    opacity: 0.3 }, 110);
			}, function() {
		 var divToSlide = $(this);
	$(divToSlide).animate({
    opacity: 1 }, 110);
	});





	//start show/hide selectItens
	$('.select').click(function(){
				if($('.SelectItens').css('display') == "none"){ 
						  
						  $('.SelectItens').fadeIn('slow');
						
				}
				
				else{
					
					$('.SelectItens').fadeOut('slow');
				}
				$.recalcAll();
		});//end show/hide selecItens
	
	
	
	$('*#thumbsModeView').click(function() {
		$('*#thumbsModeView').attr("src", "imgs/tumbsModeViewer.png");
		$("#listModeView").attr("src", "imgs/listModeViewer.png");
	$('.thumbModeViewer').show();
	$('.listModeViewer').hide();
			$("*#item").css("opacity", "0");
			$("*#item").each(function(data){$(this).delay(150 * data).animate({opacity: 1}, 400);}).delay(200);
	$.recalcAll();
	
	if($(this).attr('rel') == '2')window.scroll(0, $('body').height());
});



$('*#listModeView').click(function() {
	$('*#listModeView').attr("src", "imgs/listModeViewer2.png");
		$("#thumbsModeView").attr("src", "imgs/tumbsModeViewer2.png");
		$('*#listModeView').css("cursor", "");
    $('.hrcolor').last().css('height', 0);
	$('.thumbModeViewer').hide();
	$('.listModeViewer').show();
	$("*.separatorDiv, *.hrcolor").css("opacity", "0");
	$("*.separatorDiv").each(function(data){
	                            $(this).delay(150 * data).animate({opacity: 1}, 400);
	                            $('*.hrcolor').eq(data).delay(150 * data).animate({opacity: 1}, 400);
	                        }).delay(200);
	$.recalcAll();	
	if($(this).attr('rel') == '2')window.scroll(0, $('body').height());
});
	
$(".socialDownMenu").mouseleave(function() {
	$('.socialDownMenu').hide();
	
});

$("#openSocialMenu").mouseover(function() {
	$('.socialDownMenu').show();
	
});

$("#imagensProjetos").click(function() {
	 $(this).attr("class", "cfSelected");
	 $("#audioProjetos").attr("class", "cfnotSelected");
	  $("#videoProjetos").attr("class", "cfnotSelected");
	  $("*#cbImage").show();
	  $("#cbVideo").hide();
	  $("#cbAudio").hide();
});


$("#audioProjetos").click(function() {
	 $(this).attr("class", "cfSelected");
	 $("#imagensProjetos").attr("class", "cfnotSelected");
	  $("#videoProjetos").attr("class", "cfnotSelected");
	    $("*#cbImage").hide();
	  $("#cbVideo").hide();
	  $("#cbAudio").show();
});

$(".lik2home").click(function (){
	window.location="index.php";
});


$("#videoProjetos").click(function() {
	 $(this).attr("class", "cfSelected");
	 $("#audioProjetos").attr("class", "cfnotSelected");
	  $("#imagensProjetos").attr("class", "cfnotSelected");
	    $("*#cbImage").hide();
	  $("#cbVideo").show();
	  $("#cbAudio").hide();
});
	
$(".indiqueemailButton").click(function() {
	$(".indiqueemail").show();
	
	$(this).css('background-image', 'url("imgs/indiqueemail2.png")');
	
	
	
});
$("#close").click(function() {
	$(".indiqueemail").hide();
	$(".indiqueemailButton").css('background-image', 'url("imgs/indiqueemail.png")');
});

$("#cleanOnClick").click(function() {
	$(this).html("");
});

$("*#cleanOnClickInput").click(function() {
	$(this).attr("value", "");
});
	
	
	
$("*.MenuItem").click(function() {
	var linkTo = $(this).children().attr("rel");
if(linkTo == "home"){

	window.location = "index.php";
	}
	else { window.location = "showProjects.php?id="+linkTo; }
	
	
	
});


$("#openShowGalery").click(function(){
	
	
	var imagemNum = $(this).children().attr("rel");
	
	$(".showGalery").fadeIn('slow');
		
	$("#images").scrollTo(700*imagemNum, 0);

});
	
$(".cbRightPointer").click(function(){
	
	var position = $(".cbContent").scrollLeft();
	$(".cbContent").scrollTo( position+800, 1000 );
	
});



$("#showGaleryClose").click(function(){
		
		$(".showGalery").fadeOut('slow');
	
	
	
	
});
$(".cbLeftPointer").click(function(){
	var position = $(".cbContent").scrollLeft();
	
		
		$(".cbContent").scrollTo( position-800, 1000 );
	
	
	
	
});
$("#leftGalery").click(function(){
	var position = $("#images").scrollLeft();
	
		var position2Go = position-700;
		if(position2Go < 0) position2Go = 0;
		$("#images").scrollTo(position2Go, 500 );
	
	
	
	
});

function splashDescFade(){


$(".splashDesc").fadeTo("slow", 0, function(){ });
$(".splashDesc").fadeTo("slow", 1);
}










//Botao que retorna na gallery para a imagem anterior (nota: nao estou me referindo a pequena galeria com varias imagens e sim a imagem em si)
$(".galerySliderBack").click(function(){
    if(inLoop == false  && $(".slideArea").scrollLeft() > 0){
        inLoop = true;
        $(".splashDesc").hide();
	var position = $(".slideArea").scrollLeft();
	
		var position2Go = position-960;
		if(position2Go <= 0) position2Go = 0; 
		 //$(".slideArea").scrollTo(position2Go, 1000 ); 
		 //80 = espacamento + 1 pois comeca do 0 e sao 4 elementos
			 //if((position / 960) < (($("#imagesContainer").scrollLeft() / 85) + 3)) {	$("#imagesContainer").scrollTo($("#imagesContainer").scrollLeft()-85, 1000 ); }
		 	
			$(".slideArea").scrollTo(position2Go, 1000, {
     		     onAfter: function(){
         		        $(".splashDesc").html($("#text" + position2Go).html())
         		        $(".splashDesc").fadeTo("slow", 1);
         		        inLoop = false;
         	        }

     		});
		}
	
	
	
});
var FirstControl = 0;



$(".galerySliderForward").click(function(){
        if(inLoop == false && $(".slideArea").scrollLeft() < $(".galerySlider").width()){
    inLoop = true;
    $(".splashDesc").hide();
	var position = $(".slideArea").scrollLeft();
		
		 //if(position / 960 < $(".imagesContainer").scrollLeft() / 80) 

		
		var position2Go = position+960;
		if(position2Go >= $(".galerySlider").width()){position2Go = 0;$("#imagesContainer").scrollTo(0, 1000 );}
		else if(position / 960 >= (($("#imagesContainer").scrollLeft() / 85) + 3)) 	$("#imagesContainer").scrollTo($("#imagesContainer").scrollLeft()+85, 1000 );
		if(position2Go < 0) position2Go = 0;
		$(".slideArea").scrollTo(position2Go, 1000, {
		     onAfter: function(){
  		        $(".splashDesc").html($("#text" + position2Go).html())
  		        $(".splashDesc").fadeTo("slow", 1);
  		        inLoop = false;
    	        }
		    
		});
	}	

//	splashDescFade();
				

			
		
	
	
});



//$("#imagesSlider").css("width", ($("#numOfThums").val()*155)+"px");
$("#imagesSlider").css("width", (9*8500)+"px");


$("#imagesScroll").css("width", ($("#numOfImages").val()*700)+"px");

//$(".galerySlider").css("width", ($("#numOfSplashes").val()*960)+"px");

$(".galerySlider").css("width", ($(".size").val()*960)+"px");



$("#rightGalery").click(function(){
	
	var position = $("#images").scrollLeft();
	$("#images").scrollTo(position+700, 500 );
	
});



$("#slideright").click(function(){
	if($("#imagesContainer").scrollLeft()< $("#imagesContainer").width()&&inLoopThumb==false){
	    	    inLoopThumb = true;
	var position = $("#imagesContainer").scrollLeft();
	$("#imagesContainer").scrollTo(position+85, 500, function(){inLoopThumb = false;});
}
});


$("#slideleft").click(function(){

		if($("#imagesContainer").scrollLeft() > 0&&inLoopThumb==false){
	    inLoopThumb = true;
		var position = $("#imagesContainer").scrollLeft();
		var position2Go = position-85;
		if(position2Go < 0) position2Go = 0;
		$("#imagesContainer").scrollTo(position2Go, 500, function(){inLoopThumb = false;});
	}
	
	
	
	
	
});



$("*#movingSplash").click(function(){
		$("*#movingSplash").css("opacity", "1");
		$(this).css("opacity", "0.3");
		 if(inLoop == false){
        inLoop = true;
        $(".splashDesc").hide();
    	var position = $(".slideArea").scrollLeft();


    		var position2Go = $(this).attr("rel")*960;
    		if(position2Go < 0) position2Go = 0;
    		$(".slideArea").scrollTo(position2Go, 1000, {
    		     onAfter: function(){
      		        $(".splashDesc").html($("#text" + position2Go).html())
      		        $(".splashDesc").fadeTo("slow", 1);
      		        inLoop = false;
        	        }

    		});
    	}
	
	
	
	
	
});





	
	
	$("#backProjects").hover(function() {
		$("#projetoAnteriorLink").css("text-decoration", "underline");
	$("#projetoAnteriorLink").css("color", "#fff");
	$('#imagemAlphaBack').animate({
    opacity: 1.0 }, 900);
			}, function() {
		$("#projetoAnteriorLink").css("text-decoration", "none");
	$("#projetoAnteriorLink").css("color", "#999");
	$('#imagemAlphaBack').animate({
    opacity: 0.25 }, 900);
	});


	$(".pageTitleBack").hover(function() {
		//event mouseenter
		 $(this).find("#pageTitleBackA").animate({ color: "#fff" }, 500);
		 //end
			}, function() {
				//event mouseleave
		 $(this).find("#pageTitleBackA").animate({ color: "#999" }, 500);
	//end
	});
	
	
	$("*#thumbImagesItem").hover(function() {
		//event mouseenter
		$(this).find("#movingSplash").animate({
    opacity: 0.4
    
    
  }, 400);
		 //end
			}, function() {
				//event mouseleave
		if($(this).find("#movingSplash").css("opacity") != "0.3"){
	$(this).find("#movingSplash").css({'border': '1px solid #ccc'});
$(this).find("#movingSplash").animate({
    opacity: 1
    
    
  }, 400);
	}
	//end
	});



$("#visite").hover(function() {
		//event mouseenter
			$(this).css("background-image", "url('imgs/visitarwebsite_over.png')");
		 //end
			}, function() {
				//event mouseleave
		$(this).css("background-image", "url('imgs/visiteWebSite.png')");
	//end
	});

$(".item").hover(function() {
		//event mouseenter
			
	
	$(this).animate({
    opacity: 0.5 }, 200);
	
		 //end
			}, function() {
				//event mouseleave
		
	
	$(this).animate({
    opacity: 1 }, 200);

	
	//end
	});






$("#frontProjects").hover(function() {
		//event mouseenter
			$("#proximoProjetoLink").css("text-decoration", "underline");
	$("#proximoProjetoLink").css("color", "#fff");
	
	$('#imagemAlphaFront').animate({
    opacity: 1.0 }, 900);
	
		 //end
			}, function() {
				//event mouseleave
		if(rollingFrontProjectsOut == false){
	rollingFrontProjectsOut = true;
	
	$("#proximoProjetoLink").css("text-decoration", "none");
	$("#proximoProjetoLink").css("color", "#999");
	$('#imagemAlphaFront').animate({
    opacity: 0.25
    
    
  }, 500);

	}
	//end
	});




$("*#cbVideo").click(function(){
	
	if($(this).attr("rel") != 0){
		$(".videoAudioPlayer").fadeIn('slow');
		$(".imagePlayer").fadeOut('slow');
		$("*#cbVideo").attr("rel", 1);
		$("*#cbAudio").attr("rel", 1);
		$("*#cbImage").attr("rel", 1);
		$(this).attr("rel", 0);
var URL = $(this).children().attr("rel");
	$(".videoAudioPlayer").load('videoPlayer.php?projID='+URL);
	
	}
	
	
});
	








$("*#cbAudio").click(function(){
	
	if($(this).attr("rel") != 0){
		$(".videoAudioPlayer").fadeIn('slow');
		$(".imagePlayer").fadeOut('slow');
		$("*#cbVideo").attr("rel", 1);
		$("*#cbAudio").attr("rel", 1);
		$("*#cbImage").attr("rel", 1);
		$(this).attr("rel", 0);
var URL = $(this).children().attr("rel");
	$(".videoAudioPlayer").load('audioPlayer.php?projID='+URL);
	
	}
	
	
	
	
		

	
	
	
	
});






$("*#cbImage").click(function(){
	
	


	
	if($(this).attr("rel") != 0){
		$("*#cbVideo").attr("rel", 1);
		$("*#cbAudio").attr("rel", 1);
		$("*#cbImage").attr("rel", 1);
		$(this).attr("rel", 0);
$(".imagePlayer").fadeIn('slow');
	$(".videoAudioPlayer").fadeOut('slow');
	$(".imagePlayer").fadeIn('slow');
	
	 var ImageSRC = $(this).children().attr('src');
	var ImageREL = $(this).children().attr('rel');
	 $("#ChangeIMG").attr("src",ImageSRC);
	 $("#ChangeIMG").attr("rel",ImageREL);
	
	}
	
	



	
	

	
		

	
	
	
	
});
	
	$(".slideArea").scrollLeft(0);
    $("#imagesContainer").scrollLeft(0);
	
	}); //end function
	
	
