/*************************************************/
/**												**/
/**		Development: Hudson Marinho				**/
/**		Phone: +55 (84) 8821 5277				**/
/**		URL: http://hudsonmarinho.co.cc/		**/
/**		-----------------------------------		**/
/**		Agency: Balaio Ideias					**/
/**		URL: http://balaioideias.com.br/		**/
/**		-----------------------------------		**/
/**		Year/month:		2011/Octo				**/
/**												**/
/*************************************************/


/* all functions
.....................................*/

$(function(){
	
	$('.menu span').hide();
	
	$('.dropdown').each(function(){
		var classe = $(".dropdown-hover").attr('class');
		if(classe != "dropdown-hover active")
		{	
			$(this).parent().eq(0).hover(function(){
				$('.dropdown-hover:eq(0)', this).show(0).stop().animate({
					'-moz-opacity'		: '1',
					'-khtml-opacity'	: '1',
					'-webkit-opacity'	: '1',
					'-o-opacity'		: '1',
					'opacity'			: '1'
				}, 500);
				$('span', this).show();
			}, function(){
				$('.dropdown-hover:eq(0)', this).hide(0).stop().animate({
					'-moz-opacity'		: '0',
					'-khtml-opacity'	: '0',
					'-webkit-opacity'	: '0',
					'-o-opacity'		: '0',
					'opacity'			: '0'
				}, 500, function(){
					$(this).hide(0);
				});
				$('span', this).hide();
			});
		}
	});
	
	$("a[rel^='prettyPhoto2']").prettyPhoto();
	

	
	$('.carousel').jcarousel({
		animation: 400,
		scroll: 1
	});

	$("form").submit(function(){
		var retorno = true;
		var label = '';
		var campo = '';
		$(".required").each(function(){
			label= $(this).parent().find("label").text();
			valor = $(this).val();
			if(valor == label){
				campo = label;
			}
			retorno = false;
		});
		if(campo != ''){
			alert("Preencha todos os campos");
			retorno = false;
		}else{
			retorno = true;
		}
		return retorno;
	});
	
	
	
	$('[class*="table-ficha"]').each(function(){
		$('tr', this).each(function(e){
			if(e%2)
			{
				$(this).addClass('table-impar');
			}
			else
			{
				$(this).addClass('table-par');
			}
			
			$('td:eq(0)', this).addClass('table-left');
		});
		
		$('tr:first').addClass('table-first');
		$('tr:last').addClass('table-last');
	});

	
	
	$('ul.list-empreendimento').each(function(){
		$('li', this).each(function(e){
			var porcentagem = parseInt($('span', this).text());
			
			if(e%3)
			{
				$(this).css({ 'margin-left' : '26px' });
			}
			else
			{
				$(this).addClass('margin-left-none');
			}
			
			if(		 (porcentagem >= 0) && (porcentagem <= 11)){	$('span', this).css({'background-position' : '0 0'});	  }
			else if((porcentagem >= 12) && (porcentagem <= 23)){	$('span', this).css({'background-position' : '0 -15px'}); }
			else if((porcentagem >= 24) && (porcentagem <= 35)){	$('span', this).css({'background-position' : '0 -30px'}); }
			else if((porcentagem >= 34) && (porcentagem <= 47)){	$('span', this).css({'background-position' : '0 -45px'}); }
			else if((porcentagem >= 46) && (porcentagem <= 59)){	$('span', this).css({'background-position' : '0 -60px'}); }
			else if((porcentagem >= 60) && (porcentagem <= 71)){	$('span', this).css({'background-position' : '0 -75px'}); }
			else if((porcentagem >= 72) && (porcentagem <= 83)){	$('span', this).css({'background-position' : '0 -90px'}); }
			else if((porcentagem >= 82) && (porcentagem <= 95)){	$('span', this).css({'background-position' : '0 -105px'});}
			else if((porcentagem >= 94) && (porcentagem <= 99)){	$('span', this).css({'background-position' : '0 -120px'});}
			else{													$('span', this).css({'background-position' : '0 -120px'});}
		});
	});	
	
	$('#twtr-widget').prepend('<h3><a href="http://twitter.com/#!/conisanatal" target="_blank">Twitter</a></h3>');
	$('#twtr-widget-1 > h3').css({ height : $('#twitter').height() });
	
	$('a#balaioideias').hover(function(){
		$(this).stop().animate({'width' : '50px'}, 200);
	},function(){
		$(this).stop().animate({'width' : '15px'});
	});
	window.setTimeout(function(){
		$("#flashMessage:visible").slideUp();
	},5500);	
	
});

