// JavaScript Document

Cufon.replace('h1', {hover:true}); Cufon.replace('h2', {color: '-linear-gradient(red, #d01010)', textShadow: '#780808 -1px -1px'}); Cufon.replace('h3'); Cufon.replace('h4'); Cufon.replace('h5'); Cufon.replace('.menu li a', {hover:true, textShadow: '1px 1px #1d4659'}); Cufon.replace('.tuts li a', {hover:true}); Cufon.replace('h6', {color: '-linear-gradient(#174769, #0978c7)'});

$(function(){
		   
(function($) {
	$.fn.spotlight = function(options) {
		// Default settings
		settings = $.extend({}, {
			opacity: 0.5,
			speed: 400,
			color: '#111',
			animate: true,
			easing: '',
			exitEvent: 'click',
			onShow: function(){},
			onHide: function(){}
		}, options);
		
		// Do a compatibility check
		if(!jQuery.support.opacity) return false;
		
		if($('#spotlight').size() == 0){
			// Add the overlay div
			$('body').append('<div id="spotlight"></div>');
			
			// Get our elements
			var element = $(this);
			var spotlight = $('#spotlight');
			
			// Set the CSS styles
			spotlight.css({
				'position':'absolute', 
				'background':settings.color, 
				'opacity':'0', 
				'top':'0px', 
				'left':'0px', 
				'height':'100%', 
				'width':'100%', 
				'z-index':'9954'
			});
			
			// Set element CSS
			var currentPos = element.css('position');
			if(currentPos == 'static'){
				element.css({'position':'relative', 'z-index':'9955'});
			} else {
				element.css('z-index', '9955');
			}
			
			// Fade in the spotlight
			if(settings.animate){
				spotlight.animate({opacity: settings.opacity}, settings.speed, settings.easing, function(){
					// Trigger the onShow callback
					settings.onShow.call(this);
				});
			} else {
				spotlight.css('opacity', settings.opacity);
				// Trigger the onShow callback
				settings.onShow.call(this);
			}
			
			// Set up click to close
			spotlight.live(settings.exitEvent, function(){
				if(settings.animate){
					spotlight.animate({opacity: 0}, settings.speed, settings.easing, function(){
						if(currentPos == 'static') element.css('position', 'static');
						element.css('z-index', '1');
						$(this).remove();
						// Trigger the onHide callback
						settings.onHide.call(this);
					});
				} else {
					spotlight.css('opacity', '0');
					if(currentPos == 'static') element.css('position', 'static');
					element.css('z-index', '1');
					$(this).remove();
					// Trigger the onHide callback
					settings.onHide.call(this);
				}
			});
		}

		// Returns the jQuery object to allow for chainability.  
		return this;
	};

})(jQuery);		   


// create custom animation algorithm for jQuery called "bouncy" 
$.easing.bouncy = function (x, t, b, c, d) { 
    var s = 1.70158; 
    if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
    return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
} 
 
// create custom tooltip effect for jQuery Tooltip 
$.tools.tooltip.addEffect("bouncy", 
 
    // opening animation 
    function(done) { 
        this.getTip().animate({top: '+=15'}, 500, 'bouncy', done).show(); 
    }, 
 
    // closing animation 
    function(done) { 
        this.getTip().animate({top: '-=15'}, 500, 'bouncy', function()  { 
            $(this).hide(); 
            done.call(); 
        }); 
    } 
);

	$(document).bind("contextmenu",function(e){	return false;})
	$("a[href^=http://]").attr("target","_blank");	
	$("a[rel^='prettyPhoto']").prettyPhoto();
	$('#web').slideDown();
 //	$("#portfolio img[title]").tooltip({tip: '#demotip', effect: 'bouncy', position: "top center"});
	
	$('#portfolio a').click(function(){return false;})
	$('#exclama').fadeTo('fast',0.6);
	$('#exclama').hover(function(){
		$(this).fadeTo('normal',1);
	}, function(){
		$(this).fadeTo('fast',0.6);
	})
	
if (jQuery.support.opacity)
{
	$("#clientes, .info-div ").hover(function(){
			$(this).spotlight({exitEvent:'mouseover', speed:200});
	})
}
	
	$("#clientes").fadeTo("fast", 0.9);
		   
	$('.menu li a').hover(function(){
			$('.menu li a').stop().fadeTo("fast",0.5);				   
			var bubble = "<div></div>";
				if (jQuery.support.opacity)
				{
					$(this).append(bubble).fadeTo("fast",1)
					.children('div').animate({opacity: "show", top: "-50"}, "slow")
					.fadeTo("fast",0.8).fadeTo("fast",1);
				} else {
					$(this).append(bubble).children('div').animate({top: "-50"}, {queue:false, duration:400}).show();
				}
			},	
	  	 function()
		 {
			$(this).children('div').animate({top:"-40",opacity:"hide"},"slow").remove();
			$('.menu li a').stop().fadeTo("fast",1);	
	})
	
	$('#portfolio img').not('#ipad').fadeTo("slow",0.8);
	$('#portfolio img').hover(function(){$(this).stop().fadeTo("fast",1);
	}, function(){$(this).stop().fadeTo("fast", 0.8);})	
	
	$('#portfolio img, #conteudo img').click(function(){
			var nome = $(this).attr('alt');
			var pag = nome + ".php"+ "?sid="+Math.random();
			var prox = $(this).next
			$('.info-div').animate({width:"show"},500).html("<p>Carregando...</p>").load(pag);
			$('#fechar').fadeIn();
		})									   
	
	$('#fechar').click(function(){
		$('.info-div').animate({width:"hide"},500);			   
		$(this).hide();
   })
	
	$('.categorias-portfolio h2').hover(function(){
		$(this).stop().animate({fontSize: "2.5em"}, 500)}, function(){
		$(this).stop().animate({fontSize: "2em"}, 500);	
	})
	
	$('.categorias-portfolio h2 a').click(function(){
		var id = '#' + $(this).attr('title');
		$('.categorias-portfolio a').fadeTo("slow", 1).not(this).fadeTo("slow",0.5);
		$('#web, #graf, #tuts').hide();
		$(id).slideDown();
	})
	
$('#enviar_contato').click(function(){
		var nome = $("#nome").val();
		var email = $("#email").val();
		var telefone = $("#telefone").val();
		var msg= $("#msg").val();
		if (nome!='' & email!='' & msg!='')
		{
			$('.loading').show();
			$('form')[0].reset();
			$('#form-contato').fadeTo("slow", 0.5);					
			$.post("envia_contato.php",{nome: nome, email:email, msg:msg, telefone:telefone},
				function(retorno){
					$('.loading').fadeOut();
					$('#resposta').html(retorno);
					$('#form-contato').fadeTo("slow", 1);					
			}) 
		}else{
					alert("Existem campos incompletos no formulário. Favor preencher todos.");
					return false;
		}
		return false;
})

$('#portfolio a').imgPreview({containerID: 'imgPreviewWithStyles'
});

})


getTwitters(
	'twitter',
	{
	id:'maiconweb',
	count:1,
	enableLinks: true,
	ignoreReplies: true,
	clearContents: true,
	lang: 'pt-br',
	template: '<span class="texto"> "%text%"</span>'
	});

