//===============================================================================
//= FUNÇÕES DE JQUERY =======================================================
//===============================================================================
$(document).ready(function(){
	 $("div#menu-esquerda dl dd").hide();
	 $("div#menu-esquerda dl dt a").click(function(){
			if(this.className.indexOf("selecionado") != -1) {
		  		$("div#menu-esquerda dl dd:visible").hide("normal");
				$(this).removeClass("selecionado");
		  } else{
				$("div#menu-esquerda dl dt a").removeClass();
				$(this).addClass("selecionado");
				$("div#menu-esquerda dl dd:visible").hide("normal");
				$(this).parent().next().show("normal");
		  }
		  return false;
	 });
});
//===============================================================================
//= FUNÇÕES DE FORMULÁRIO =======================================================
//===============================================================================
var tipo = 0;

function FaleConosco() {
	tipo = 1;
	document.form1.action = "mail.asp";
	document.form1.method = "post";
}

function Newsletter() {
	tipo = 2;
	document.form1.action = "newsletter-act.asp";
	document.form1.method = "post";
}

function Busca() {
	tipo = 3;
	document.form1.action = "busca.asp";
	document.form1.method = "get";
}

function EnviaFormulario() {
	switch(tipo) {
		case 1: return VFaleConosco(); break;
		case 2: return VNewsletter(); break;
		case 3: if (VBusca()) { document.location.href="busca.asp?busca=" + document.form1.busca.value; } break;
	}
	return false;
}


//===============================================================================
//= BUSCA =======================================================================
//===============================================================================
function VBusca() {
	if (!(document.form1.busca.value.length > 1)) { alert("Informe o texto a ser procurado."); document.form1.busca.focus(); return false; };
	return true;
}


//===============================================================================
//= FUNÇÃO DE EXIBIÇÃO DOS MENUS ================================================
//===============================================================================
function SHMenu(menu, linkMenu) {
	element = document.getElementById("menu" + menu);
	element.style.display = element.style.display != 'none' ? 'none' : '';
}

function EscondeCat(id) {
	document.getElementById(id).style.display = (document.getElementById(id).style.display == 'none') ? '' : 'none';
}

function NovaCategoria() {
	document.location.href = (document.form1.categoria.value != '-') ? 'index.asp?cat=' + document.form1.categoria.value : 'index.asp';
}

//===============================================================================
//= ABRE POP-UP CENTRALIZADO ====================================================
//===============================================================================
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
	LeftPosition = parseInt((screen.width) ? (screen.width-w)/2 : 0);
	TopPosition = parseInt((screen.height) ? (screen.height-h)/2 : 0);
	settings = 'width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',noresizable,status=yes'
	win = window.open(mypage,myname,settings)
}


//===============================================================================
//= REDIMENSIONA POP-UP =========================================================
//===============================================================================
function Redimensiona(w, h) {
	//Corrige o tamanho da janela
	if (navigator.appName == "Microsoft Internet Explorer") {
		w = parseInt(w) + 10;
		h = parseInt(h) + 60;
	} else {
		w = parseInt(w) + 6;
		h = parseInt(h) + 60;
	};
	// IE 7
	var nversao = navigator.userAgent;
	var nresult = nversao.search(/\bMSIE 7.0\b/g);
	if (nresult > 0) {
		h = parseInt(h) + 35;
	};
	//
	// IE 8
	var nversao = navigator.userAgent;
	var nresult = nversao.search(/\bMSIE 8.0\b/g);
	if (nresult > 0) {
		h = parseInt(h) + 85;
	};
	//
	// FIREFOX 3
	var nversao = navigator.userAgent;
	var nresult = nversao.search(/\bFirefox\/3\b/g);
	if (nresult > 0) {
		h = parseInt(h) + 115;
	};
	//
	// SAFARI / CHROME
	var nversao = navigator.userAgent;
	var nresult = nversao.search(/\bSafari\b/g);
	if (nresult > 0) {
		h = parseInt(h) + 15;
	};
	//
	window.resizeTo(w, h);
	LeftPosition =  parseInt((screen.width) ? (screen.width-w)/2 : 0);
	TopPosition =  parseInt((screen.height) ? (screen.height-h)/2 : 0);
	window.moveTo(LeftPosition,TopPosition);
	window.focus();
}


//===============================================================================
//= EXIBE FLASHS ================================================================
//===============================================================================
function ExibeFlash(movie,w,h,wmode,bg) {
	if(wmode == "transparent") { ftransp = true; wmode = "wmode='transparent'"; } else { ftransp = false; wmode = ""; };

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'">');
	if(ftransp) { document.write('<param name="wmode" value="transparent"/>'); };
	document.write('<param name="quality" value="high"/>');
	document.write('<param name="movie" value="'+movie+'"/>');
	document.write('<embed src="'+movie+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" '+wmode+' width="'+w+'" height="'+h+'"></embed>');
	document.write('</object>');
}


//===============================================================================
//= VERIFICA NAVEGADORES ========================================================
//===============================================================================
var ua = navigator.userAgent;
var ver = parseInt( navigator.appVersion );
var opera = /opera [56789]|opera\/[56789]/i.test(ua);
var ie = !opera && /MSIE/.test(ua);
var ie6 = ie && /MSIE [0123456]/.test(ua);
var ie7 = ie && /MSIE [789]/.test(ua);
var ieBox = ie && (document.compatMode == null || document.compatMode != "CSS1Compat");
var moz = !opera && /gecko/i.test(ua);
var nn6 = !opera && /netscape.*6\./i.test(ua);