/* 
 *	Scripts
 */
$(document).ready(function(){
	// TARGET _blank
	$('a[rel=blank]').click(function(){
		window.open(this.href);
		return false;
	});
	// INPUT
	if ($('.input, .textarea').val() != ''){
		$(this).prev().hide();
	}
	$('.input, .textarea').focusin(function(){
		$(this).prev().hide();
	}).focusout(function(){
		if ($(this).val() == ''){
			$(this).prev().show();
		}
	});
	$('.input2, .textarea2').keydown(function(){
		$(this).prev().hide();
		if ($(this).val() == ''){ $(this).prev().show(); }
	}).change(function(){
		$(this).prev().hide();
		if ($(this).val() == ''){ $(this).prev().show(); }
	});
	$('.circulos li').hover(
		function(){
			$(this).find('.bg').stop().fadeTo(200,1);
		},
		function(){
			$(this).find('.bg').stop().fadeTo(500,0);
		}
	);
	$('.projeto').hover(
		function(){
			$(this).find('.mask').stop().fadeTo(200,1);
		},
		function(){
			$(this).find('.mask').stop().fadeTo(500,0);
		}
	);
	
}); //end document.ready

function selecionar(ele){
	var ele = $(ele);
	var val = ele.val();
	ele.prev().text(trad(val));
}

function buscar(ele){
	$(ele).toggleClass('ativo');
	$('#buscar').toggle();
	$('#busca').val('').focus()/*.keydown(function(){
		$(this).prev().hide();
	}).change(function(){
		$(this).prev().hide();
	}).prev().show();
	
	$('#topo .buscar').removeClass('ativo');
	$('#buscar').hide();
	$('#busca').focusout().val('');*/
}

/* FACEBOOK */
function share(tipo,extra,text){
//	return false;
	if(tipo=='fb-fan'){
		var _$BASE_DIR = 'http://www.ottawa.com.br/facebook/';
		var _extra = 'facebook_spr.css?1';
		$('#fb-fan').append('<'+'fb:fan profile_id="130431853682216" stream="0" connections="15" logobar="0" width="195" height="355" css="'+_$BASE_DIR+_extra+'"><'+'/fb:fan>');
	} else if(tipo=='fb-fan-blog'){
		var _$BASE_DIR = 'http://www.ottawa.com.br/facebook/';
		var _extra = 'facebook_blog_spr.css?3';
		$('#fb-fan').append('<'+'fb:fan profile_id="130431853682216" stream="0" connections="12" logobar="0" width="143" height="314" css="'+_$BASE_DIR+_extra+'"><'+'/fb:fan>');
	} else if(tipo=='fb-comments'){
		$('#fb-comments').html('<'+'fb:comments href="'+$BASE_DIR+extra+'" num_posts="5" width="724"><'+'/fb:comments>');
	} else if(tipo=='fb-like'){
		$('#fb-like').html('<'+'iframe id="like" src="http://www.facebook.com/plugins/like.php?href='+extra+'&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0"><'+'/iframe>');
	} else if(tipo=='g-plusone'){
		$('#g-plusone').html('<'+'g:plusone size="medium"><'+'/g:plusone>');
	} else if(tipo=='fb-share'){
		$('#fb-share').html('<'+'a href="http://www.facebook.com/sharer.php?u='+extra+'&src=sp" name="fb_share" share_url="'+extra+'"><'+'/a>');
	} else if(tipo=='tweet'){
		$('#tweet').html('<'+'a href="http://twitter.com/share" class="twitter-share-button twitter" data-url="'+extra+'" data-text="'+text+'" data-count="none" data-via="AgenciaSpr"><'+'/a>');
	} else if(tipo=='orkut-share'){
		$('#orkut-share').html('<'+'a href="http://promote.orkut.com/preview?nt=orkut.com&du='+extra+'&tt='+text+'" target="_blank"><'+'/a>');
	}
}

function buscarSite(val){
	$.post($BASE_DIR+'busca.php', { busca:val }, function(data){
		window.location = $BASE_DIR+'busca/'+val+'/';
	});
}

function EnviarFomulario(tipo){
	
	var nome = $('#nome').val();
	var email = $('#email').val();
	var telefone = $('#telefone').val();
	var empresa = $('#empresa').val();
	var site = $('#site').val();
	var mensagem = $('#mensagem').val();
	
	if ((email.length != 0) && ((email.indexOf("@") < 1))){
		$('#verifique').fadeIn(500);
	} else if ((nome.length < 1) || (email.length < 1)){
		$('#verifique').fadeIn(500);
	} else {
		$('#verifique').hide();
		$.post($BASE_DIR+"_post.contato.php", { tipo:tipo, nome:nome, email:email, telefone:telefone, empresa:empresa, site:site, mensagem:mensagem },
			function(data){
				$('#'+tipo+'-form div.holder').slideUp(500);
				$('#contatoEnviado').slideDown(500);
			},
		"html");
	}
	
	return false;	
}

