// JavaScript Document
function faq(idFaq, idMostrar) {
	asDuvidas = document.getElementById(idFaq).getElementsByTagName("dd").length;

	for(i=0; i<asDuvidas; i++) {
		
		if(document.getElementById(idFaq).getElementsByTagName("dd")[i].id != 'faq_' + idMostrar) {
			document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display = 'none';
			document.getElementById(idFaq).getElementsByTagName("dt")[i].getElementsByTagName("a")[0].className = '';
		}
		else {
		
			if(document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display != 'block') {
				document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display = 'block';
				document.getElementById(idFaq).getElementsByTagName("dt")[i].getElementsByTagName("a")[0].className = 'ativo';
			}
			else {
				document.getElementById(idFaq).getElementsByTagName("dd")[i].style.display = 'none';
				document.getElementById(idFaq).getElementsByTagName("dt")[i].getElementsByTagName("a")[0].className = '';
			}
			
		}
	}
}

$(document).ready(function () {
   var h = $('ul.lstMapaSite li.botijao ul li.meio').height()
   if($('ul.lstMapaSite li.ultra ul li.meio').height() > h) h = $('ul.lstMapaSite li.ultra').height()
   if($('ul.lstMapaSite li.revendedores ul li.meio').height() > h) h = $('ul.lstMapaSite li.revendedores').height();

   $('ul.lstMapaSite li.botijao ul li.meio').height(h);
   $('ul.lstMapaSite li.ultra ul li.meio').height(h);
   $('ul.lstMapaSite li.revendedores ul li.meio').height(h);
   
   var h2 = $('ul.lstMapaSite2 li.mapa:eq(0)').height();
   if($('ul.lstMapaSite2 li.mapa:eq(1)').height() > h2) h2 = $('ul.lstMapaSite2 li.mapa:eq(1)').height();
   if($('ul.lstMapaSite2 li.mapa:eq(2)').height() > h2) h2 = $('ul.lstMapaSite2 li.mapa:eq(2)').height();
   if($('ul.lstMapaSite2 li.mapa:eq(3)').height() > h2) h2 = $('ul.lstMapaSite2 li.mapa:eq(3)').height();


   $('ul.lstMapaSite2 li.mapa:eq(0)').height(h2);
   $('ul.lstMapaSite2 li.mapa:eq(1)').height(h2);
   $('ul.lstMapaSite2 li.mapa:eq(2)').height(h2);
   $('ul.lstMapaSite2 li.mapa:eq(3)').height(h2);

   $(".lightbox").lightbox();
  
	$('.btHover').mouseover(function(){
		$(this).find('.divSubArea').each(function() {
			$(this).show();

		});
		$(this).find('img').each(function() {
			$(this).attr('src', $(this).attr('src').replace('_off', '_on'));
		});
		
		return false;
	});
	$('.btHover').mouseout(function(){
		$(this).find('.divSubArea').each(function() {
			$(this).hide();	

		});
		$(this).find('img').each(function() {
			$(this).attr('src', $(this).attr('src').replace('_on','_off'));
		});
		
		return false;
	});
	
	$('.boxMenuPrincipal ul li').mouseover(function(){
		if($(this).parent().attr("class") != 'sub') {
			$(this).addClass('ativo');
			$(this).find('.divSubMenu').each(function() {
				$(this).width($(document).width()).show();
			});
			return false;
		}
	});
	$('.boxMenuPrincipal ul li').mouseout(function(){
		if($(this).parent().attr("class") != 'sub') {
			$(this).removeClass('ativo');
			$(this).find('.divSubMenu').each(function() {
				$(this).hide();
			});
			return false;
		}
	});

});

function abrePop(u) {
	var w = (window.screen.width)/2 - 230;
	var h = (window.screen.height)/2 - 220;
	window.open(u, '_blank', 'top='+h+',left='+w+',width=460,height=420,toolbar=no,status=yes,menubar=no,scrollbars=no,location=no,resizable=no');
}

function selectChange(obj) {
    var destination = obj.options[obj.selectedIndex].value;
    var tgt = obj.options[obj.selectedIndex].getAttribute('tgt');

    if (destination) {
    	if (tgt) {
    		window.open(destination, tgt);
    	} else {
	    	location.href = destination;
    	}
    }
}

function aplicaFlash(swf, width, height, wmode, cache) {
	var noCache = "";
	if (cache == undefined || cache == '') {var noCache = "?" + new Date();}
	if (wmode != "opaque" && wmode != "transparent") {wmode = "transparent";}
	var monta_swf = "";
	monta_swf += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+ width +"' height='"+ height +"' title=''>";
	monta_swf += "<param name='movie' value='"+ swf + noCache +"'>";
	monta_swf += "<param name='quality' value='high'>";
	monta_swf += "<param name='menu' value='0'>";
	monta_swf += "<param name='wmode' value='"+ wmode +"'>";
	monta_swf += "<embed src='"+ swf + noCache +"' quality='high' wmode='"+ wmode +"' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+ width +"' height='"+ height +"'></embed>";
	monta_swf += "</object>";
	document.write(monta_swf);
}

var r={
'special':/[\W]/g,
'quotes':/['\''&'\"']/g,
'notnumbers':/[^\d]/g,
'onlynumbers':/[^0-9.,]/g
}

function valid(o,w){
  o.value = o.value.replace(r[w],'');
}