
	$(function(){
		// * Limpeza automatica dos inputs de newsletter
		$('#txNome').focus(function(){
			if ($('#hdIdioma').val() == 'pt') {
				if ($(this).val() == 'Digite seu nome...') {
					$(this).val('');
				}
			}
			else if ($('#hdIdioma').val() == 'en') {
				if ($(this).val() == 'Digit your name...') {
					$(this).val('');
				}
			}
		});
		$('#txNome').blur(function(){
			if ($('#hdIdioma').val() == 'pt') {
				if ($(this).val() == '') {
					$(this).val('Digite seu nome...');
				}
			}
			else if ($('#hdIdioma').val() == 'en') {
				if ($(this).val() == '') {
					$(this).val('Digit your name...');
				}
			}
		});
		$('#txEmail').focus(function(){
			if ($('#hdIdioma').val() == 'pt') {
				if ($(this).val() == 'Digite seu e-mail...') {
					$(this).val('');
				}
			}
			else if ($('#hdIdioma').val() == 'en') {
				if ($(this).val() == 'Digit your e-mail...') {
					$(this).val('');
				}
			}
		});
		$('#txEmail').blur(function(){
			if ($('#hdIdioma').val() == 'pt') {
				if ($(this).val() == '') {
					$(this).val('Digite seu e-mail...');
				}
			}
			else if ($('#hdIdioma').val() == 'en') {
				if ($(this).val() == '') {
					$(this).val('Digit your e-mail...');
				}
			}
		});
		
		// * Banner
		$('#banner').nivoSlider({
			effect: 'sliceUp',
			directionNav: false,
			pauseTime: 10000,
			captionOpacity : 0
		});
		
		// * Tipsy - Tooltip
		if($("a.tipsy")[0])
		{
			$("a.tipsy").tipsy({
				fade: 	true,
				gravity:'n'
			});
		}
		
		// * Facebox
		$("a[rel*=facebox]").facebox({
			loadingImage : "/site/layout/imagem/facebox/loading.gif",
			closeImage   : "/site/layout/imagem/facebox/closelabel.png"
		});
		
		// * Background randômico do Header
		$("header").css("visibility","hidden");
		var backgroundLista = ["topo-5.png"];
		var backgroundRandomico = backgroundLista[Math.floor(Math.random()*backgroundLista.length)];
		$("header").css("background","url(/site/layout/imagem/"+ backgroundRandomico +") no-repeat 460px 25px");
		$("header").css("visibility","visible");
		
		// * Alteração de CSS
		$("article section.coluna-3 ul li:last-child").css("border-bottom","none");
		$("article section.coluna-3 ul li:last-child").css("padding-bottom","0");
		$("article section.coluna-3 ul li:last-child").css("margin-bottom","0");
		$(".imagem li:last-child").css("margin-right","0");
		$("header nav#menu li ul:last-child").css("margin-right","0");
		$(".english header nav#menu li:last-child a").css("padding-right","20px");
		
		// * Tabela dos produtos
		$("article section.interno .produtoTexto table tbody tr:odd").addClass("linha-1");
		$("article section.interno .produtoTexto table tbody tr:even").addClass("linha-2");
		
		// * Cufon
        Cufon('section h2', { fontFamily: 'Dax-Light' });
        Cufon('article section.interno h2', { fontFamily: 'Dax-Medium' });
        Cufon('section h3', { fontFamily: 'Dax-Light' });
        Cufon('section h2 strong', { fontFamily: 'Dax-Medium' });
        Cufon('header nav#menu > ul > li > a', { fontFamily: 'Dax-Bold' });
        Cufon('footer #coluna-1 p a', { fontFamily: 'Dax-Light' });
        Cufon('footer #coluna-1 p strong', { fontFamily: 'Dax-Bold' });
		
		// * Mega Drop-down menu
        function megaHoverOver(){
            $(this).find(".sub").stop().fadeTo('fast',1).show();
			$(this).find(".sub").parent().children("a").addClass("ativo");
        }
        function megaHoverOut(){ 
			$(this).find(".sub").stop().fadeTo('fast',0,function() {
				$(this).parent().children("a").removeClass("ativo");
				$(this).hide();
			});
        }
        var config = {    
             sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
             interval: 100, // number = milliseconds for onMouseOver polling interval    
             timeout: 500, // number = milliseconds delay before onMouseOut 
             over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
             out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
        };
        $("header nav#menu li").hoverIntent(config);
		
		// * Corrige o bug z-index
		fix_flash();
		
	});
	
	// * Código que anula o bug do z-index
	function fix_flash() {
		var embeds = document.getElementsByTagName('embed');
		for (i = 0; i < embeds.length; i++) {
			embed = embeds[i];
			var new_embed;
			if (embed.outerHTML) {
				var html = embed.outerHTML;
				if (html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i))
					new_embed = html.replace(/wmode\s*=\s*('|")window('|")/i, "wmode='transparent'");
				else
					new_embed = html.replace(/<embed\s/i, "<embed wmode='transparent' ");
				embed.insertAdjacentHTML('beforeBegin', new_embed);
				embed.parentNode.removeChild(embed);
			} else {
				new_embed = embed.cloneNode(true);
				if (!new_embed.getAttribute('wmode') || new_embed.getAttribute('wmode').toLowerCase() == 'window')
					new_embed.setAttribute('wmode', 'transparent');
				embed.parentNode.replaceChild(new_embed, embed);
			}
		}
		var objects = document.getElementsByTagName('object');
		for (i = 0; i < objects.length; i++) {
			object = objects[i];
			var new_object;
			if (object.outerHTML) {
				var html = object.outerHTML;
				if (html.match(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")[a-zA-Z]+('|")\s*\/?\>/i))
					new_object = html.replace(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")window('|")\s*\/?\>/i, "<param name='wmode' value='transparent' />");
				else
					new_object = html.replace(/<\/object\>/i, "<param name='wmode' value='transparent' />\n</object>");
				var children = object.childNodes;
				for (j = 0; j < children.length; j++) {
					try {
						if (children[j] != null) {
							var theName = children[j].getAttribute('name');
							if (theName != null && theName.match(/flashvars/i)) {
								new_object = new_object.replace(/<param\s+name\s*=\s*('|")flashvars('|")\s+value\s*=\s*('|")[^'"]*('|")\s*\/?\>/i, "<param name='flashvars' value='" + children[j].getAttribute('value') + "' />");
							}
						}
					}
					catch (err) {
					}
				}
				object.insertAdjacentHTML('beforeBegin', new_object);
				object.parentNode.removeChild(object);
			}
		}
	}
