function openPopup(URL,iWidth, iHeight) {
	var top = (screen.height / 2) - (iHeight / 2);
	var left = (screen.width / 2) - (iWidth / 2);
	window.open(URL,"j1","scrollbars=yes,toolbar=no,menubar=no,status=no,width=" + iWidth + ",height="+iHeight+",left="+left+",top=" + top);
	return false;
}
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
window.addEvent('domready', function(){
	
	montarSubMenu();
	
	newDiv = document.createElement("div");
	newDiv.setAttribute("id", "avisoManu_1");
	document.body.insertBefore(newDiv, document.getElementById("geral"));
	
	newDiv1 = document.createElement("div");
	newDiv1.setAttribute("id", "avisoManu_");
	newDiv1.innerHTML = "<p style='font:bold 12px Arial; color:#fff; text-align:right; cursor:pointer;' onclick='escondeManu();'>fechar</p><img id='imgManu_' />";
	document.body.insertBefore(newDiv1, document.getElementById("geral"));
	
	newP = document.createElement("div");
	newP.setAttribute("id", "menuSSL");
	newP.innerHTML = "<a href='http://www.instantssl.com' target='_blank'><img src='http://www.vetoreditora.com.br/site/img/cot_evssl.gif'></a>";
	document.body.insertBefore(newP, document.getElementById("geral"));
	
	document.getElementById("avisoManu_").style.display = "none";
	document.getElementById("avisoManu_1").style.display = "none";
});

function montarSubMenu() {
	if($defined($('mM_Produtos'))) {
		$('mM_Produtos').addEvent('mousemove', function(){
			$('subProdutos').setStyle('display', '');
			this.setStyle('background', '#ede1d8');
			this.setStyle('marginBottom', '0px');
		});
	}
	if($defined($('mM_Produtos'))) {
		$('mM_Produtos').addEvent('mouseout', function(){
			$('subProdutos').setStyle('display', 'none');
			this.setStyle('background', '#f3efeb');
			this.setStyle('marginBottom', '2px');
		});
	}
	if($defined($('mM_Servicos'))) {
		$('mM_Servicos').addEvent('mousemove', function(){
			$('subServicos').setStyle('display', '');
			this.setStyle('background', '#ede1d8');
			this.setStyle('marginBottom', '0px');
		});
	}
	if($defined($('mM_Servicos'))) {
		$('mM_Servicos').addEvent('mouseout', function(){
			$('subServicos').setStyle('display', 'none');
			this.setStyle('background', '#f3efeb');
			this.setStyle('marginBottom', '2px');
		});
	}
	if($defined($('mM_VersaoEletronica'))) {
		$('mM_VersaoEletronica').addEvent('mousemove', function(){
			$('subVersaoEletronica').setStyle('display', '');
			this.setStyle('background', '#ede1d8');
			this.setStyle('marginBottom', '0px');
		});
	}
	if($defined($('mM_VersaoEletronica'))) {
		$('mM_VersaoEletronica').addEvent('mouseout', function(){
			$('subVersaoEletronica').setStyle('display', 'none');
			this.setStyle('background', '#f3efeb');
			this.setStyle('marginBottom', '2px');
		});
	}
	// -----------------------------------------------------------------
	if($defined($('subVersaoEletronica'))) {
		$('subVersaoEletronica').addEvent('mouseout', function(){
			this.setStyle('display', 'none');
			$('mM_VersaoEletronica').setStyle('background', '#f3efeb');
			$('mM_VersaoEletronica').setStyle('marginBottom', '2px');
		});
	}
	if($defined($('subVersaoEletronica'))) {
		$('subVersaoEletronica').addEvent('mousemove', function(){
			this.setStyle('display', '');
			$('mM_VersaoEletronica').setStyle('background', '#ede1d8');
			$('mM_VersaoEletronica').setStyle('marginBottom', '0px');
		});
	}
	if($defined($('subServicos'))) {
		$('subServicos').addEvent('mouseout', function(){
			this.setStyle('display', 'none');
			$('mM_Servicos').setStyle('background', '#f3efeb');
			$('mM_Servicos').setStyle('marginBottom', '2px');
		});
	}
	if($defined($('subServicos'))) {
		$('subServicos').addEvent('mousemove', function(){
			this.setStyle('display', '');
			$('mM_Servicos').setStyle('background', '#ede1d8');
			$('mM_Servicos').setStyle('marginBottom', '0px');
		});
	}
	if($defined($('subProdutos'))) {
		$('subProdutos').addEvent('mouseout', function(){
			this.setStyle('display', 'none');
			$('mM_Produtos').setStyle('background', '#f3efeb');
			$('mM_Produtos').setStyle('marginBottom', '2px');
		});
	}
	
	if($defined($('subProdutos'))) {
		$('subProdutos').addEvent('mousemove', function(){
			this.setStyle('display', '');
			$('mM_Produtos').setStyle('background', '#ede1d8');
			$('mM_Produtos').setStyle('marginBottom', '0px');
		});
	}
	
	if($defined($('txtNomeNews'))){
		$('txtNomeNews').addEvent('focus', function(){
			if(this.value == 'Nome'){
				this.value = '';
			}
		});
		
		$('txtNomeNews').addEvent('blur', function(){
			if(this.value == ''){
				this.value = 'Nome';
			}
		});
	}
	if($defined($('txtEmailNews'))){
		$('txtEmailNews').addEvent('focus', function(){
			if(this.value == 'E-mail'){
				this.value = '';
			}
		});
		
		$('txtEmailNews').addEvent('blur', function(){
			if(this.value == ''){
				this.value = 'E-mail';
			}
		});
	}
	
	if($defined($('cmbProfissaoNews'))) {
		$('cmbProfissaoNews').addEvent('change', function(){
			//alert(this.value);
			if(this.value == 'ASSESSORIA EM RH'){
				$("compNews").innerHTML = '';
				$("complementoNews").style.display = 'none';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'AUTOR'){
				$("compNews").innerHTML = '';
				$("complementoNews").style.display = 'none';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'CONSUMIDOR'){
				$("compNews").innerHTML = '';
				$("complementoNews").style.display = 'none';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'DISTRIBUIDOR AUTORIZADO VETOR'){
				$("compNews").innerHTML = 'Qual:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'DISTRIBUIDOR DE LIVROS'){
				$("compNews").innerHTML = 'Qual:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'ESTUDANTE'){
				$("compNews").innerHTML = 'Qual curso:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'IMPRENSA'){
				$("compNews").innerHTML = 'Qual Veículo:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'INSTITUICOES DE ENSINO'){
				$("compNews").innerHTML = 'Universidade/ Faculdade:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'LIVRARIA'){
				$("compNews").innerHTML = 'Qual:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'OUTROS'){
				$("compNews").innerHTML = 'Qual:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'PEDAGOGO'){
				$("compNews").innerHTML = 'Universidade/ Faculdade:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'PEDAGOGO E PROFESSOR'){
				$("compNews").innerHTML = 'Universidade/ Faculdade:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'PSICOLOGO'){
				$("compNews").innerHTML = 'CRP:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'PSICOLOGO E PROFESSOR'){
				$("compNews").innerHTML = 'CRP:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'PSICOPEDAGOGO'){
				$("compNews").innerHTML = '';
				$("complementoNews").style.display = 'none';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'PSICOPEDAGOGO E PROFESSOR'){
				$("compNews").innerHTML = 'Universidade/ Faculdade:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'PSICOPEDAGOGO E PSICOLOGO'){
				$("compNews").innerHTML = 'CRP:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}else if(this.value == 'PSICOTECNICO'){
				$("compNews").innerHTML = 'CRP:';
				$("complementoNews").style.display = '';
				$("txtComplementoNews").value = '';
			}
		});
	}
	
	if($defined($('txtCpf'))) {
		$('txtCpf').addEvent('keypress', function(){
			fnCpf(this);
			//this.set("maxlength", "20");//maxlength = 20;
			this.removeAttribute("maxlength");
		});
	}
	if($defined($('txtCnpj'))) {
		$('txtCnpj').addEvent('keypress', function(){
			fnCnpj(this);
			//this.set("maxlength", "20");//maxlength = 20;
			this.removeAttribute("maxlength");
		});
	}
}

window.addEvent('domready', function(){
	var TipsHelp = new Tips($$('.TipsHelp'), {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
});

function openAba(idA){
	if(idA == 'abaFicha'){
		$("abaFicha").style.backgroundImage = 'url(../../../img/abaOut.png)';
		$("abaResenha").style.backgroundImage = 'url(../../../img/abaOver.png)';
		$("abaComentario").style.backgroundImage = 'url(../../../img/abaOver.png)';
		
		$("AfichaTecnica").style.display = '';
		$("Aresenha").style.display = 'none';
		$("Acomentario").style.display = 'none';
	}
	
	if(idA == 'abaResenha'){
		$("abaFicha").style.backgroundImage = 'url(../../../img/abaOver.png)';
		$("abaResenha").style.backgroundImage = 'url(../../../img/abaOut.png)';
		$("abaComentario").style.backgroundImage = 'url(../../../img/abaOver.png)';
		
		$("AfichaTecnica").style.display = 'none';
		$("Aresenha").style.display = '';
		$("Acomentario").style.display = 'none';
	}
	
	if(idA == 'abaComentario'){
		$("abaFicha").style.backgroundImage = 'url(../../../img/abaOver.png)';
		$("abaResenha").style.backgroundImage = 'url(../../../img/abaOver.png)';
		$("abaComentario").style.backgroundImage = 'url(../../../img/abaOut.png)';
		
		$("AfichaTecnica").style.display = 'none';
		$("Aresenha").style.display = 'none';
		$("Acomentario").style.display = '';
	}
}
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function formNews(){
	var msgErro = "";
	var param = "";
	if($("txtNomeNews").value == "" || $("txtNomeNews").value == 'Nome'){
		msgErro += "Preencha o campo Nome.<br>";
	}else{
		param += "?nome=" + $("txtNomeNews").value;
	}
	// ------------------------------------------------------------
	if($("txtEmailNews").value == '' || $("txtEmailNews").value == 'E-mail'){
		msgErro += 'Preencha o campo E-mail.<br>';
	}else if($('txtEmailNews').value.indexOf('@') == -1 || $('txtEmailNews').value.indexOf('.') == -1){
		msgErro += 'E-mail inválido.<br>';
	}else{
		param += "&email=" + $("txtEmailNews").value;
	}
	// ------------------------------------------------------------
	param += "&profissao=" + $("cmbProfissaoNews").value + "&complemento=" + $("txtComplementoNews").value;
	if(msgErro == ""){
		var ajax = opaAjax();
		ajax.open('GET', 'http://www.vetoreditora.com.br/site/includes/news.asp' + param, true);
		ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.status == 200) {
					
					$('txtNomeNews').value = 'Nome';
					$('txtEmailNews').value = 'E-mail';
					$("cmbProfissaoNews").value = 'AUTOR';
					$("cmbEstadoNews").value = 'SP';
					$("compNews").innerHTML = '';
					$("complementoNews").style.display = 'none';
					$("txtComplementoNews").value = '';
					$('erroNews').innerHTML = 'Seus dados foram enviados<br>com sucesso.';
				}
			}
		}
		ajax.send(null);
		return false;
	}else{
		$('erroNews').innerHTML = msgErro;
		return false;
	}
}
function opaAjax() {
	var ajax;
	try {
		ajax = new XMLHttpRequest();
	} catch(ee) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				ajax = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(E) {
				alert('Seu Browser não suporta Ajax.')
				ajax = false;
			}
		}
	}
	return ajax;
}
function fnCpf(cpf){
	var tecla=(window.event)?event.keyCode:e.which;
	if((tecla > 47 && tecla < 58) || tecla == 8){
		if(cpf.value.length == 3) cpf.value = cpf.value + '.';
		if(cpf.value.length == 7) cpf.value = cpf.value + '.';
		if(cpf.value.length == 11) cpf.value = cpf.value + '-';
		if(cpf.value.length >= 14) cpf.value = cpf.value.substring(0, cpf.value.length - 1);
	}else{
		cpf.value = cpf.value.substring(0, cpf.value.length - 1);
	}
}
// ###########################################################################

/**
* 
* 
**/
function fnCnpj(cnpj){
	var tecla=(window.event)?event.keyCode:e.which;
	if((tecla > 47 && tecla < 58) || tecla == 8){
		if(cnpj.value.length == 2) cnpj.value = cnpj.value + '.';
		if(cnpj.value.length == 6) cnpj.value = cnpj.value + '.';
		if(cnpj.value.length == 10) cnpj.value = cnpj.value + '/';
		if(cnpj.value.length == 15) cnpj.value = cnpj.value + '-';
		if(cnpj.value.length >= 18) cnpj.value = cnpj.value.substring(0, cnpj.value.length - 1);
	}else{
		cnpj.value = cnpj.value.substring(0, cnpj.value.length - 1);
	}
}

function mostraDHTML(imagem, wid){
	var versionindex = navigator.userAgent.indexOf("MSIE")+5;
	var versao = parseInt(navigator.userAgent.charAt(versionindex));
	
	var leftMargin = (1000 - wid) / 2;
	if(navigator.appName == "Microsoft Internet Explorer" && versao <= 7){
		$("imgManu_").src = imagem;
		$("avisoManu_1").style.display = "";
		$("avisoManu_").style.marginLeft = leftMargin+"px";
		$("avisoManu_").style.display = "";
	}else{
		$("imgManu_1_").src = imagem;
		$("avisoManu").style.display = "";
		$("avisoManu_1_").style.marginLeft = leftMargin+"px";
		$("avisoManu_1_").style.display = "";
	}
}

function escondeManu(){
	$("imgManu_").src = "";
	$("imgManu_1_").src = "";
	$("avisoManu_1").style.display = "none";
	$("avisoManu").style.display = "none";
	$("avisoManu_").style.display = "none";
	$("avisoManu_1_").style.display = "none";
}