$(document).ready(function(){
	$("a[href='#']").attr('href','javascript:void()');

	var ClientesColorido = 	  ["cases_marcia_cl.jpg","cases_honda_cl.jpg","cases_marisa_cl.jpg","cases_hopihari_cl.jpg","cases_3m_cl.jpg","cases_educadora_cl.jpg","cases_integral_cl.jpg","cases_topz_cl.jpg","cases_ype_cl.jpg","cases_sapore_cl.jpg","cases_iris_cl.jpg","cases_rac_cl.jpg","cases_singer_cl.jpg","cases_100video_cl.jpg","cases_tecnol_cl.jpg","cases_educar_cl.jpg"];
	var ClientesPretoBranco = ["cases_marcia_pb.jpg","cases_honda_pb.jpg","cases_marisa_pb.jpg","cases_hopihari_pb.jpg","cases_3m_pb.jpg","cases_educadora_pb.jpg","cases_integral_pb.jpg","cases_topz_pb.jpg","cases_ype_pb.jpg","cases_sapore_pb.jpg","cases_iris_pb.jpg","cases_rac_pb.jpg","cases_singer_pb.jpg","cases_100video_pb.jpg","cases_tecnol_pb.jpg","cases_educar_pb.jpg"];
	
	$("ul.clientes li a").hover(function(){
		var index = $("ul.clientes li a").index(this);
		$("ul.clientes li a img").eq(index).attr("src","./images/"+ClientesColorido[index]);
	},function(){
		var index = $("ul.clientes li a").index(this);	
		$("ul.clientes li a img").eq(index).attr("src","./images/"+ClientesPretoBranco[index]);
	});					   

	//***********************
	$("#clientes-zoom ul li").hide();
	var indexGlobal = 0;
	
	//abre cases
	$("ul.clientes li a").click(function(){
		var index = $("ul.clientes li a").index(this);
		indexGlobal = index;
		$("#case_box").show();
		$("#clientes-zoom ul li").eq(index).fadeIn(1000);
		return false;
	});
	
	//fecha cases
	$(".voltar-menu").click(function(){
		$("#clientes-zoom ul li").hide();									 
		$("#case_box").fadeOut(1000);							 
		return false;
	});
	
	//ant-prox cases
	var numCases = $("#clientes-zoom ul li").length;
		
	$("a.proximo").click(function(){
		indexGlobal++;						  
		if (indexGlobal <= (numCases-1)){						  											  
			$("#clientes-zoom ul li").hide();				
			$("#clientes-zoom ul li").eq(indexGlobal).fadeIn(1000);		
		}else {
			indexGlobal=0;	
			$("#clientes-zoom ul li").hide();				
			$("#clientes-zoom ul li").eq(indexGlobal).fadeIn(1000);		
		}
		return false;
	});
	$("a.anterior").click(function(){
		indexGlobal--;
		if (indexGlobal >= 0){						  			
			$("#clientes-zoom ul li").hide();		
			$("#clientes-zoom ul li").eq(indexGlobal).fadeIn(1000);		
		}else {
			indexGlobal = (numCases-1);
			$("#clientes-zoom ul li").hide();		
			$("#clientes-zoom ul li").eq(indexGlobal).fadeIn(1000);					
		}
		return false;
	});
	
	//validação form contato
	/*
	$("#btnEnviar").click(function(){

		if($("#txtNome").val() == "" && $("#txtEmail").val() == "" && $("#txtMensagem").val() == "" ){ 
			$("div.erro").html("Favor preencher todos os campos."); 
		}
		
		$(".form-contato").validate({
			errorLabelContainer: $(".form-contato div.erro"),								
			rules:{
				nome:{
				required: true,
				},
				email:{ 
				required: true, 
				email: true
				},
				mensagem:{ 
				required: true, 
				},
			},
			messages:{
				nome:{ required: "" },
				email:{ required: "" },
				mensagem:{ required: "" },
			}
		});
	});
	*/
	
	
	//scrollTo
	
	$(".agenciaBtn").click(function(){
		$('html, body').animate({scrollTop: $('#wethinkweb').offset().top}, 2000);	
	})
	
	$(".casesBtn").click(function(){
		$('html, body').animate({scrollTop: ($('#cases').offset().top-20)}, 2000);							 
	})

	$(".contatoBtn").click(function(){
		$('html, body').animate({scrollTop: $('#rodape').offset().top}, 2000);							 
	})
	
	
	
	// flickr
    $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=25316242@N03&tags=2011&lang=pt-br&format=json&jsoncallback=?", displayImages);
	

        function displayImages(data) {
            // Randomly choose where to start. A random number between 0 and the number of photos we grabbed (20) minus 9 (we are displaying 9 photos).
            var iStart = Math.floor(Math.random() * (13));

            // Reset our counter to 0
            var iCount = 0;

            // Start putting together the HTML string
            var htmlString = "<ul>";

            // Now start cycling through our array of Flickr photo details
            $.each(data.items, function(i, item) {

                // Let's only display 9 photos (a 3x3 grid), starting from a random point in the feed					
                if (iCount > iStart && iCount < (iStart + 7)) {

                    // I only want the ickle square thumbnails
                    var sourceSquare = (item.media.m).replace("_m.jpg", "_s.jpg");

                    // Here's where we piece together the HTML
                    htmlString += '<li><a href="' + item.link + '" target="_blank">';
                    htmlString += '<img src="' + sourceSquare + '" alt="' + item.title + '" title="' + item.title + '"/>';
                    htmlString += '</a></li>';
                }
                // Increase our counter by 1
                iCount++;
            });

            // Pop our HTML in the #images DIV	
            $('#images').html(htmlString + "</ul>");

            // Close down the JSON function call
        }
	
	
	
});

//facebook
	function LikeFacebook(){
		document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FWebcompany%2F133464173375491&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" style="border:none; overflow:hidden; width:90px; height:22px;" scrolling="no" frameborder="0" allowTransparency="true"></iframe>');
	}
	

