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


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


$(function(){
	
	$('a[rel="blank"]').click(function(){
		window.open(this.href);
		return false;
	});
	
	$('#cformsform label').each(function(){
		$(this).html($(this).text());
	});
	
	$('#cf_uploadfile-3').attr('size', '78').parent().append('<span class="file-upload">Anexar currículo</span>');
	
	$('.magic-label').each(function(){
		var self		= $(this);
		var self_id		= self.attr('id');
		var self_label	= $('label[for='+self_id+']').hide();
		
		self_label.next('br').hide();
		
		var reset_value = function(){
			if (self.val() == '')
				self.val(self_label.html());
		}
		
		reset_value();
		
		self.focus(function(){
			if (self.val() == self_label.html())
				self.val('');
		}).blur(reset_value);
	
		self.parents('form').submit(function()
		{
			self.focus();
		});
	});
	
	$('div#top > div > div.menu').append('<div class="bg-motion"></div>');
	$('div#top > div > div.menu > ul > li > a').hover(function(){
		var menu = $(this).parent().attr('class');
		
		if(menu == 'menu-grupo-santana')
		{
			$('.bg-motion').css({
				'width' : ($(this).width() + 20)+'px',
				'left' : '-5px'
			}, 200);
		}
		
		else if(menu == 'menu-produtos')
		{
			$('.bg-motion').css({
				'width' : ($(this).width() + 20)+'px',
				'left' : ($(this).parent().parent().find('li:eq(0)').width() + 25) + 'px'
			}, 200);
		}
		else if(menu == 'menu-favoritos')
		{
			$('.bg-motion').css({
				'width' : ($(this).width() + 20)+'px',
				'left' : ($(this).parent().parent().find('li:eq(0)').width() + 30 + $(this).parent().parent().find('li:eq(1)').width() + 25) + 'px'
			}, 200);
		}
		else if(menu == 'menu-blog')
		{
			$('.bg-motion').css({
				'width' : ($(this).width() + 20)+'px',
				'left' : ($(this).parent().parent().find('li:eq(0)').width() + 30 + $(this).parent().parent().find('li:eq(1)').width() + 30 + $(this).parent().parent().find('li:eq(2)').width() + 25) + 'px'
			}, 200);
		}
		
		else if(menu == 'menu-perguntas-frequentes')
		{
			$('.bg-motion').css({
				'width' : ($(this).width() + 20)+'px',
				'left' : ($(this).parent().parent().find('li:eq(0)').width() + 30 + $(this).parent().parent().find('li:eq(1)').width() + 30 + $(this).parent().parent().find('li:eq(2)').width() + 30 + $(this).parent().parent().find('li:eq(3)').width() + 25) + 'px'
			}, 200);
		}
		
		else if(menu == 'menu-contato')
		{
			$('.bg-motion').css({
				'width' : ($(this).width() + 20)+'px',
				'left' : ($(this).parent().parent().find('li:eq(0)').width() + 30 + $(this).parent().parent().find('li:eq(1)').width() + 30 + $(this).parent().parent().find('li:eq(2)').width() + 30 + $(this).parent().parent().find('li:eq(3)').width() + 30 + $(this).parent().parent().find('li:eq(4)').width() + 25) + 'px'
			}, 200);
		}
		else
		{
			$('.bg-motion').animate({
				'width' : '0px',
				'left' : '0px'
			}, 200);
		}
		
		//$(this).parent().parent().find('li a').removeClass('menu-hover');
		$(this).addClass('menu-hover');
		
	},function(){
		//$('.bg-motion').animate({
		//	'width' : '0px',
		//	'left' : '0px'
		//}, 200);
		//$(this).removeClass('menu-hover');
		$('.bg-motion').css({
			'width' : '0px',
			'left' : '0px'
		}, 200);
		$(this).removeClass('menu-hover');
	});
	
	
	var i		= 0;
	var total	= $('ul#produtos-lista > li').length;
	
	$('ul#produtos-lista > li:eq(0)').addClass('padding-top-none').css({'min-height' : '240px'});
	$('ul#produtos-lista > li:eq(1)').addClass('padding-top-none').css({'min-height' : '240px'});
	$('ul#produtos-lista > li:eq(2)').addClass('padding-top-none').css({'min-height' : '240px'});
	
	$('ul#produtos-lista > li').each(function(e){
		e%3 ? $(this).addClass('padding-left-35') : '';
	});
	
	$('div#destaque').css({ 'background-image' : 'url('+$('img', this).attr('src')+')' }).html('<a href="javascript:;"></a>');
	
	$('div#business > ul > li').each(function(){
		$('a', this).append('<span></span>');
	});
	
	$('div#business > ul > li').hover(function(){
		$('img', this).animate({		'top'		: '0px'		}, 100);
		//$('strong', this).animate({		'bottom'	: '5px'		}, 100);
		$('span:last', this).animate({	'bottom'	: '60px'	}, 100);
	},function(){
		$('img', this).animate({		'top'		: '10px'	}, 300);
		//$('strong', this).animate({		'bottom'	: '0px'		}, 300);
		$('span:last', this).animate({	'bottom'	: '65px'	}, 300);
	});
	
	
	
	
	//ie bug
	$('div#top > div > div.menu > ul > li:last').css({ 'margin-right' : '0' });
	$('div#footer-top > div.menu > ul > li:last').css({ 'margin-right' : '0' });
	$('div#business > ul > li:last').css({ 'margin-right' : '0' });
	
	$('#cf_uploadfile-3').change(function(e){
		$in = $(this);
		
		$('li#li--3 span.file-upload').html($in.val());
	});
	
	$('div#usermessagea').html('<div id="msg-bg"></div><div id="msg-erro">Currículo enviado com sucesso!</div>');
	
	if(window.location.hash == '#usermessagea')
	{
		setTimeout(function(){
			$("div#usermessagea").fadeOut("slow", function(){
				$("div#usermessagea").remove();
			});
		}, 3000);
	}else{
		$("div#usermessagea").remove();
	}
	
});

