var discovery = {


	init: function() {
	    markMenu('nav-concept');
	    markSubmenuConcept('nav-4');
		$("div#sidebar ul li a").neoHover();
		$('#discovery > ol > li').neoHighlight();
		discovery.faq();
	},



	faq: function()
	{
		var items = $('#discovery > ol > li');
		var filename;


		$(items).fadeTo(0, 0);
		$('#fulltext').fadeTo(0, 0).hide();
		$.each(items, function(i, obj)
		{
			k = i + 1;
			filename = (k < 10) ? k = '0' + k : k;
			$(obj).addClass('item-' + k);
			$(obj).css('background-image', 'url(static/img/shared/concept/discovery/' + filename + '.png)');

			$(obj).bind('click', function()
			{
				var itemNumber = $(this).attr('class').split(' ')[0].split('-')[1];
				var html = '';
				var line = 0;
				html += '<h5 style="background-image:url(static/img/shared/concept/discovery/black_' + itemNumber + '.png)">' + itemNumber + '</h5>';
				html += '<h4>' + $(this).find('dt').html() + '</h4>';
				html += '<div class="text">' + $(this).find('dd').html() + '</div>';
				html += '<a class="bt-close">fechar</a>';

				
				
				$('#fulltext').animate({ opacity: 0 }, { queue: false, duration: 300, easing: 'easeOutQuad', complete: function()
				{




					$('#fulltext').html(html);
					$('#fulltext').css('display', 'block').animate({ opacity: 1 }, { duration: 300, easing: 'easeOutQuad' });

					var pos = Math.round(itemNumber);

					switch (pos)
					{
						case 1:
						case 4:
						case 7:
						case 10:
						case 13:
						case 16:
							$('#fulltext').css('right', 'auto');
							$('#fulltext').css('left', '0');
							break;

						case 2:
						case 5:
						case 8:
						case 11:
						case 14:
						case 17:
							$('#fulltext').css('right', 'auto');
							$('#fulltext').css('left', '243px');
							break;

						case 3:
						case 6:
						case 9:
						case 12:
						case 15:
							$('#fulltext').css('left', 'auto');
							$('#fulltext').css('right', '21px');
							break;

						default:
							break;
					}

					line = Math.floor((pos - 1) / 3);
					//alert('itemNumber: ' + itemNumber + '\npos: ' + pos + '\nline: ' + line);
					if (line == 0)
					{
						$('#fulltext').css('top', '0');

					} else if (line < 4)
					{
						var posY = ((line * 132) + ((line) * 20)) + 'px';
						$('#fulltext').css('top', posY);
					} else
					{
						var posY = (((line - 2) * 132) + (((line - 2)) * 20)) + 'px';
						$('#fulltext').css('top', posY);

					}




					//scroll--------------------------------------------------
					var targetOffset = $('#fulltext').offset().top;
					$('html,body').animate({ scrollTop: targetOffset }, 900);
					//--------------------------------------------------------
					


				}
				});
			});

			$('#fulltext .bt-close').live('click', function()
			{
				$('#fulltext').animate({ opacity: 0 }, { queue: false, duration: 300, easing: 'easeOutQuad', complete: function()
				{
					$(this).css('display', 'none');
				}
				});
			});

			/*$('a[href*=#]').click(function()
			{

				if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname)
				{

					var $target = $(this.hash);

					$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');

					if ($target.length)
					{

						var targetOffset = $target.offset().top;

						$('html,body').animate({ scrollTop: targetOffset }, 1000);

						return false;

					}

				}

			});*/

		});


		//animation

		$.each(items, function(i, obj)
		{
			$(obj).show();
			$(obj).animate({ foo: 1 }, { queue: true, duration: 350 + (200 * i), easing: 'easeOutQuad', complete: function()
			{
				$(obj).animate({ height: 92, width: 193, opacity: 1 }, { duration: 200, easing: 'easeOutQuad' });
			}
			});
		});


	}




};
