/*********************************************************************************/
/**										**/
/**		Montagem:	Hudson Marinho (http://balaioideias.com.br/)	**/
/**		Contato: 	hudson@balaioideias.com.br			**/
/**		Ano:		Maio/2011				**/
/**										**/
/*********************************************************************************/


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


$(function(){
	
	$('a[rel="blank"]').click(function(){
		window.open(this.href);
		return false;
	});
	
	$('.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-main ul li a').append('<span class="menu-border"></span>');
	
	$('div#top-main ul li a, ul#footer-menu > li > a').append('<span class="menu-divisor"></span>');
	$('div#top-main ul li a:first, ul#footer-menu > li > a:first').addClass('padding-left-none');
	$('div#top-main ul li a:last span.menu-divisor, ul#footer-menu > li > a:last span.menu-divisor').remove();
	
	
	$('ul#slide > li').each(function(){
		$('a', this).css({ 'background-image' : 'url(' + $('img', this).attr('src') + ')' }).find('img').remove();
	});
	
	$('div#info-novidades ul li:first').css({ 'padding-top' : '0' , 'border-top' : 'none'});
	$('div#info-novidades ul li:last').css({ 'padding-bottom' : '0' , 'border-bottom' : 'none'});
	
	//$('#info-google-maps').each(function(){
	//	$(this).css({ 'background-image' : 'url(' + $('img', this).attr('src') + ')' }).find('img').remove();
	//});
	
	$('.text p:last').addClass('margin-bottom-none');
	
	
	$('.play-video > a.btn-play').click(function(){
		
		$('.img-play').fadeOut();
		
		$(this).animate({ 'width' : '550' }, 'normal', function(){
			$(this).animate({ 'height' : '330' }, 'normal', function(){
				$(this).fadeOut('normal');
			});
		});
		
		$(this).parent().animate({ 'width' : '550' }, 'normal', function(){
			$(this).animate({ 'height' : '330' }, 'normal', function(){
				$(this).find('.youtube').fadeIn('normal');
			});
		});
		
	});
	
	$('.youtube a.close-yt').click(function(){
		$(this).parent().fadeOut('normal');
		
		$(this).parent().parent().find('a.btn-play').fadeIn('normal', function(){
			$(this).parent().animate({ 'width' : '370px' }, 'normal', function(){
				$(this).animate({ 'height' : '240px' }, 'normal');
			});
			
			$(this).animate({ 'width' : '370px' }, 'normal', function(){
				$(this).animate({ 'height' : '240px' }, 'normal');
				
				$('.img-play').fadeIn();
			});
		});
	});
	
	
	$('ul#conheca-mais li:last').addClass('margin-right-none');
	$('ul#conheca-mais > li').each(function(){
		$('a', this).css({ 'background-image' : 'url(' + $('img', this).attr('src') + ')' }).find('img').remove();
	});
	
	
	$('div#produtos-right').append('<span class="no-border"></span>');
	
	
	$('.play-video').append('<span class="img-play"></span>');
	
	$('.img-play').css({ 'background' : 'url(' + $(this).find('img.imgVideo').attr('src') + ')' });
	$('.youtube').find('img.imgVideo').remove();
	
	
	$('.jCarousel').jcarousel({
		animation: 800,
		wrap: 'circular',
		scroll: 1
	});
	
});

