var display;

	$(document).ready(function() {
		$("#itens_sociais	 .show_tooltip").tooltip({position: 'top center'});
		$("#imgFlickr").tooltip({position: 'top left'});
		$("#imgYouTube").tooltip({position: 'bottom left'});
		
		$("#titPortfolio").click(function(){
			showPortfolio();
		});
		
		$("#titOQueFazemos").click(function(){
			showOqueFazemos();
		});
		
		$("#bar #logo a").click(function(){
			hideWindow()
			display = '';
		});
		
		
		
		$("#mnuContato").click( function(){
			if(display != 'contato'){
				hideWindow();
				$("#contentContato").show('slow');
				display = 'contato';
			};
		});
		$("#mnuQuemSomos").click( function(){
			if(display != 'quemSomos'){
				hideWindow();
				$("#contentQuemSomos").show('slow');
				display = 'quemSomos';
			};
		});

		$("#mnuOqueFazemos").click( function(){
			if(display != 'oQueFazemos'){
				hideWindow()
				display = 'oQueFazemos'
				$("#contentOQueFazemos").show('slow');
			} else {
				display = 'oQueFazemos'
				showOqueFazemos()				
			}
		});


		$(".linkIframe").fancybox({
			'width'				: '95%',
			'height'			: '95%',
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe'
		});


//ajax form
    $('#formMail').bind('submit', function(){
        var $button = $('button',this).attr('disabled',true);
        var params = $(this.elements).serialize();
        var self = this;
        $.ajax({
            type: 'POST',
            url: this.action,
            data: params,
            beforeSend: function(){
                $('#loading').show();
                $('#loading').html("Enviando...");
            },
            success: function(txt){
                $button.attr('disabled',false);
                $('#loading').html(txt);
								txt = $.trim(txt);
								if(txt == '<span class="yellow">Mensagem enviada com sucesso!</span>')
								   self.reset();
            },
            error: function(txt){
                $('#loading').html(txt);
            }
        })
        return false;
    });
//jQuery Ajax Form

	});

	function hideWindow(){
		switch (display){
			case 'contato':
				$("#contentContato").hide('slow');
				break;
			case 'quemSomos':
				$("#contentQuemSomos").hide('slow');
				break;
			case 'oQueFazemos':
				$("#contentOQueFazemos").hide('slow');
				break;
		}
	}


	function showPortfolio(){
		$("#contentMktDigital").hide();
		$("#divOQueFazemos").hide();
		$("#divOQueFazemosMais").hide();
		
		$("#titOQueFazemos").removeClass('clsTitOQueFazemosSelected');
		$("#titPortfolio").addClass('clsTitPortfolioSelected');
		
		$("#divPortfolio").show();
	};
	
	function showOqueFazemos(){
		$("#contentMktDigital").hide();
		$("#divOQueFazemosMais").hide();
		$("#divPortfolio").hide();		
		$("#titOQueFazemos").addClass('clsTitOQueFazemosSelected');
		$("#titPortfolio").removeClass('clsTitPortfolioSelected');
		
		$("#divOQueFazemos").show('slow');
	}
	
	function fazemosMais(){
		$("#contentOQueFazemos").show();
		$("#contentMktDigital").hide();
		$("#divOQueFazemosMais").hide();
		$("#divOQueFazemos").hide('slow', function(){
			display = 'oQueFazemos';
			$("#divOQueFazemosMais").show('slow');																	 
		});
	};
	
	function showMktDigital(){
		$("#divOQueFazemos").hide();
		$("#divOQueFazemosMais").hide();
		$("#divPortfolio").hide();
		$("#contentMktDigital").show("slow");
	};
