var structure = {

	init: function() {
		structure.rolloverMainNav.init();
		structure.navProducts.init();
		structure.bing.init();
	},

	/**
	* Rollover do menu principal
	**/
	rolloverMainNav: {


		init: function() {

			$('#main-nav').css({ backgroundPosition: "250px -136px" });

			$('#main-nav ul li a').hover(
				function(e) {
					var widthBg = 128;
					var xMouse = $(this).offset().left;
					var xHolder = $(this).parent().parent().offset().left;
					var pos = Math.round(xMouse - xHolder + ((($(this).width() + 60) / 2) - (widthBg / 2)) + 2);
					$('#main-nav').animate({ backgroundPosition: "(" + pos + "px -78px)" }, { queue: false, duration: 200, easing: "easeInOutQuad" });
					if (!$.browser.msie) { $(this).animate({ marginTop: -30, opacity: 0 }, { queue: false, duration: 150, easing: "easeInOutQuad", complete: function() { $(this).css("margin-top", "-52px").animate({ marginTop: -40, opacity: 1 }, { queue: false, duration: 150, easing: "easeInOutQuad" }) } }); }
				},
				function(e) {
					var widthBg = 128;
					var xMouse = $(this).offset().left;
					var xHolder = $(this).parent().parent().offset().left;
					var pos = Math.round(xMouse - xHolder + ((($(this).width() + 60) / 2) - (widthBg / 2)) + 2);
					$('#main-nav').animate({ backgroundPosition: "(" + pos + "px -136px)" }, { queue: false, duration: 200, easing: "easeInOutQuad" });
				}
			);
		}


	},

	/**
	* Acoes da combobox de produtos
	**/
	navProducts: {

		init: function() {

			var time;
			$('#header #combobox-products').click(function() {
				
				$("#combobox-products #combobox-button img").attr('src', 'http://www.windowslive.com.br/static/img/structure/seta_up_combo_products.png');
				if ($('#header #combobox-list').is(':hidden')) {
					clearTimeout(time);
					$('#header #combobox-list').slideDown(500);
					dpc_omniture_pageview('hotsite|geral|Menu Windows Live|Expandir Menu de Produtos', 'Menu Windows Live', '', '', '', '', '', false,false);
					$('#header #combobox-list > ul > li').attr('href',$(this).find('> a').attr('href'));
					$('#header #combobox-list > ul > li').click(function() {
						//window.location = $(this).find('> a').attr('href');
					});
				
				
				
					$('#header #combobox-list > ul > li').hover(function() {
					
						$(this).animate({ backgroundColor: "#bcbcbc", paddingLeft: 10 }, { queue: false, duration: 200 });
						$(this).find('> ul').animate({ width: 188, opacity: 1 }, { queue: false, duration: 200, easing: "easeInOutQuad" });
				
						$(this).find( '> ul.submenu li' ).click(function() {
							//window.location = $(this).find('> a').attr('href');
						});							   
						
					}, function() {
						$(this).animate({ backgroundColor: "#f6f6f6", paddingLeft: 15 }, { queue: false, duration: 200 });
						$(this).find('> ul').animate({ width: 0, opacity: 0 }, { queue: false, duration: 200, easing: "easeInOutQuad" });
					});
				
				} else {
				
					$('#header #combobox-list').slideUp(400);
					$("#combobox-products #combobox-button img").attr('src', 'http://www.windowslive.com.br/static/img/structure/seta_down_combo_products.png');
				
				}
				
				
				
				$('#header #combobox-products').hover(
					function() {
						clearTimeout(time);
					}, function() {
						clearTimeout(time);
						time = setInterval(function() {
							$('#header #combobox-list').slideUp(400);
							$("#combobox-products #combobox-button img").attr('src', 'http://www.windowslive.com.br/static/img/structure/seta_down_combo_products.png');
							}, 500);
					}
				);
			});


		}

	},

	/**
	* Blur e Focus do campo de texto do Bing
	**/
	bing: {

		init: function() {

			$('#form-bing #query').blur(function() {
				if (this.value == '') {
					this.value = 'encontre aqui';
				}
			});

			$('#form-bing #query').focus(function() {
				this.value = '';
			});

		}

	}
};

$(document).ready(function(){
	structure.init();
});