$(document).ready( function(){

	/************** GOOGLE MAPS API *********/
	/*google.load("maps", "2.x");
	function initializeGMAP() {
		var map = new GMap2(document.getElementById("mapa"));
		map.setCenter(new GLatLng(-54.4419, -20.1419));
	}
	google.setOnLoadCallback(initialize);
	$(window).unload(function(){ GUnload(); });
	$(window).load(function(){ initializeGMAP(); });

function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("mapa"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        map.setUIToDefault();
      }
    }

  /*****************************************/

	$cortinaaberta = false;
	$("#pushblog").click(function(){
		$(this).blur();
		if ($cortinaaberta == false){ 
			$('#cortina').animate({	
				top: "0px",
				opacity: 0.93
				},{
				duration: 600,
				easing: 'easeInBack'
				});
			$cortinaaberta = true;
		}
		else{
 
			$("#cortina").stop().animate({
				top: "-250px",
				opacity: 1
				},{
				duration: 600,
				easing: 'easeOutBounce'
				});
			$cortinaaberta = false;
		}
		return false;
	});

	/************ Carrosel index ***********/
	$(".trabalhos").jCarouselLite({
		start: 0,
		visible: 1,
		btnNext: "#navbotoes .proximo",
		btnPrev: "#navbotoes .anterior",
		btnGo:
		[".car_controles .trab1", ".car_controles .trab2", ".car_controles .trab3", ".car_controles .trab4", ".car_controles .trab5"]
	});

	
	$("img[class^=trab]").click(function() {
		$("img[class^=trab]").attr("src","imgs_site/dot_h.png");
		$(this).attr("src", "imgs_site/dot.png");
	});

	$("#navbotoes .proximo").click(function(){
		var pos = parseInt($("img[src$=dot.png]").attr("alt"));
		
		var soma = (pos % 5) + 1;
		$("img[alt="+ soma +"]").attr("src","imgs_site/dot.png");
		$("img[alt="+ pos +"]").attr("src","imgs_site/dot_h.png");
			
	});
	$("#navbotoes .anterior").click(function(){
		var pos = parseInt($("img[src$=dot.png]").attr("alt"));
		
		var soma = (pos -1) % 5;
		if (soma == 0)
			soma = 5;
		$("img[alt="+ soma +"]").attr("src","imgs_site/dot.png");
		$("img[alt="+ pos +"]").attr("src","imgs_site/dot_h.png");
			
	});
	
	/********* efeitos de focus e blur nos forms 
	$("input[type=text]").focus(function(){
		$(this).prev(".input_text_wrap").css({background: "url(imgs_site/bg_form_text_hover.gif) no-repeat top left"});
	});
	*******/

	/************* icones com hover effect ******/
	$('.i_twitter img').hover(
		function() {
			$(this).attr('src', 'imgs_site/twitterIcon_hover.gif');
		},
		function() {
			$(this).attr('src', 'imgs_site/twitterIcon.gif');
	});
	$('.i_orkut img').hover(
		function() {
			$(this).attr('src', 'imgs_site/orkutIcon_hover.gif');
		},
		function() {
			$(this).attr('src', 'imgs_site/orkutIcon.gif');
	});
	$('.i_delicius img').hover(
		function() {
			$(this).attr('src', 'imgs_site/deliciusIcon_hover.gif');
		},
		function() {
			$(this).attr('src', 'imgs_site/deliciusIcon.gif');
	});
	$('div .verMais img').hover(
		function() {
			$(this).attr('src', 'imgs_site/button_ver_mais_hover.gif').css('cursor', 'pointer');
		},
		function() {
			$(this).attr('src', 'imgs_site/button_ver_mais.gif');
	});

	/************** Tooltips ******************/
	$('<div id="livetip"></div>').hide().appendTo('body');
	var tipTitle = '';
	$('#navegue').bind('mouseover', function(event) {
	  var $link = $(event.target).closest('a');
	  if ($link.length) {
		var link = $link[0];
		tipTitle = link.title;
		link.title = '';
		$('#livetip')
		.css({
		  top: event.pageY + 12,
		  left: event.pageX + 12
		})
		.html('<h3>' + tipTitle + '</h3>')
		.fadeIn();
	  }
	}).bind('mouseout', function(event) {
	  var $link = $(event.target).closest('a');
	  if ($link.length) {
		$link.attr('title', tipTitle);
		$('#livetip').hide();
	  }
	}).bind('mousemove', function(event) {
	  if ($(event.target).closest('a').length) {
		$('#livetip').css({
		  top: event.pageY + 12,
		  left: event.pageX + 12
		});
	  }
	});
	$(".trabalhos_lista .item").hover(
		function(){ $(this).css({background: "url(imgs_site/bg_trabalhos_hover.png) no-repeat 3px 2px" }).addClass("png_bg"); },
		function(){ $(this).css({background: "none" }) ;
		
		}
	);
	$("#livetip").css("opacity", 0.8);
	$('.ondeEncontrar address').css({
		cursor: 'pointer'

	});
	
 /*
	$(".compartilhe").click(function() {
		$.scrollTo('#navbar', 600,{easing: 'easeOutBack'});
	});
	*/
	$("#navegue ul li:last-child").css('background', 'none');


	/************ FORMS ************/
	function valida(){	
		d = document.contato_form;
		
		if(d.nome.value==""){
			document.getElementById('valid').innerHTML ="<img src='http://www.shapeweb.com.br/imgs_site/exclamation.jpg' />" + " *Favor preencher o campo Nome!";
			d.nome.focus();
			return false;
		}
		if(d.email.value==""){
			document.getElementById('valid').innerHTML ="<img src='http://www.shapeweb.com.br/imgs_site/exclamation.jpg' />" + " *Favor preencher o campo E-mail!";
			d.email.focus();
			return false;
		}
		if(d.telefone.value==""){
			document.getElementById('valid').innerHTML ="<img src='http://www.shapeweb.com.br/imgs_site/exclamation.jpg' />" + " *Favor preencher o campo telefone!";
			d.telefone.focus();
			return false;
		}
		if(d.mensagem.value==""){
			document.getElementById('valid').innerHTML ="<img src='http://www.shapeweb.com.br/imgs_site/exclamation.jpg' />" + " *Favor preencher o campo mensagem!";
			d.mensagem.focus();
			return false;
		}
		return true;
	}
	/****** carrousel trabalhos ******/
	$(".screenshot").jCarouselLite({
		start: 0,
		visible: 1,
		btnNext: "#screenbotoes .proximo",
		btnPrev: "#screenbotoes .anterior",
		speed: 500,
		easing: 'easeOutBack'
	});


	/***** fancybox *****/
	/*$("a.zoom").fancybox();

	$("a.zoom1").fancybox({
		'overlayOpacity': 0.7,
		'overlayColor': '#FFF'
	});

	$("a.zoom2").fancybox({
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500
	});
	
	/******* Shadowbox start button :P ******/
	Shadowbox.init();


	/**** Abrir links externos em outra janela ****/

	$('a[rel="external"]').click(function(){
		window.open( $(this).attr('href') );
		return false;

	});

});



