function validaContato(frm){
	if (frm.nome.value.length < 1){
		alert("Preencha o campo 'Nome'.");
		frm.nome.focus();
		return (false);
	}
	if (frm.empresa.value.length < 1){
		alert("Preencha o campo 'Empresa'.");
		frm.empresa.focus();
		return (false);
	}
	if (frm.email.value.length < 1){
		alert("Preencha o campo 'E-mail'.");
		frm.email.focus();
		return (false);
	}
	if (frm.end.value.length < 1){
		alert("Preencha o campo 'Endereço'.");
		frm.end.focus();
		return (false);
	}
	if (frm.cidade.value.length < 1){
		alert("Preencha o campo 'Cidade'.");
		frm.cidade.focus();
		return (false);
	}
	if (frm.estado.value.length < 1){
		alert("Preencha o campo 'Estado'.");
		frm.estado.focus();
		return (false);
	}
	if (frm.pais.value.length < 1){
		alert("Preencha o campo 'País'.");
		frm.pais.focus();
		return (false);
	}
	if (frm.ddd.value.length < 1){
		alert("Preencha o campo 'DDD'.");
		frm.ddd.focus();
		return (false);
	}
	if (frm.telefone.value.length < 1){
		alert("Preencha o campo 'Telefone'.");
		frm.telefone.focus();
		return (false);
	}
	if (frm.msg.value.length < 1){
		alert("Preencha o campo 'Mensagem'.");
		frm.msg.focus();
		return (false);
	}
	return (true);
}

function validaNews(frm){
	if (frm.nome.value.length < 1){
		alert("Preencha o campo 'Nome'.");
		frm.nome.focus();
		return (false);
	}
	if (frm.email.value.length < 1){
		alert("Preencha o campo 'E-mail'.");
		frm.email.focus();
		return (false);
	}
	return (true);
}

function validaIndique(frm){
	if (frm.nome.value.length < 1){
		alert("Preencha o campo 'Seu Nome'.");
		frm.nome.focus();
		return (false);
	}
	if (frm.email.value.length < 1){
		alert("Preencha o campo 'Seu E-mail'.");
		frm.email.focus();
		return (false);
	}
	if (frm.nome_des.value.length < 1){
		alert("Preencha o campo 'Nome destino'.");
		frm.nome_des.focus();
		return (false);
	}
	if (frm.email_des.value.length < 1){
		alert("Preencha o campo 'E-mail destino'.");
		frm.email_des.focus();
		return (false);
	}
	return (true);
}

function validaTrabalhe(frm){
	if (frm.curr1_nom.value.length < 1){
		alert("Preencha o campo 'Nome'.");
		frm.curr1_nom.focus();
		return (false);
	}
	if (frm.curr1_car.value.length < 1){
		alert("Preencha o campo 'Cargo'.");
		frm.curr1_car.focus();
		return (false);
	}
	return (true);
}

function validaRepresentante(frm){
	if (frm.resi1_nom.value.length < 1){
		alert("Preencha o campo 'Nome'.");
		frm.resi1_nom.focus();
		return(false);
	}
	if (frm.resi1_pai.value.length < 1){
		alert("Preencha o campo 'País'.");
		frm.resi1_pai.focus();
		return(false);
	}
	if (frm.resi1_reg.value.length < 1){
		alert("Preencha o campo 'Região'.");
		frm.resi1_reg.focus();
		return(false);
	}
	if (frm.resi1_ema.value.length < 1){
		alert("Preencha o campo 'E-mail'.");
		frm.resi1_ema.focus();
		return(false);
	}
	if (frm.resi1_tel.value.length < 1){
		alert("Preencha o campo 'Telefone'.");
		frm.resi1_tel.focus();
		return(false);
	}
	return (true);
}

function validaFornecedor(frm){
	if (frm.forn1_nom.value.length < 1){
		alert("Preencha o campo 'Empresa'.");
		frm.forn1_nom.focus();
		return(false);
	}
	if (frm.forn1_cid.value.length < 1){
		alert("Preencha o campo 'Cidade'.");
		frm.forn1_cid.focus();
		return(false);
	}
	if (frm.forn1_ema.value.length < 1){
		alert("Preencha o campo 'E-mail'.");
		frm.forn1_ema.focus();
		return(false);
	}
	if (frm.forn1_tel.value.length < 1){
		alert("Preencha o campo 'Telefone'.");
		frm.forn1_tel.focus();
		return(false);
	}
	if (frm.forn1_pro.value.length < 1){
		alert("Preencha o campo 'Produto'.");
		frm.forn1_pro.focus();
		return(false);
	}
	return (true);
}

/********** PRODUTOS ***********/
function abaProduto(obj){
	obj_name = 'item'+obj;
	
	document.getElementById('item1').className = 'off';
	document.getElementById('item2').className = 'off';
	document.getElementById('item3').className = 'off';
	document.getElementById('item4').className = 'off';
	document.getElementById(obj_name).className = 'on';
}

function abaProdutoDet(obj){
	obj_name = 'item'+obj;
	obj_name_det = 'item'+obj+'_det';
	
	document.getElementById('item1').className = 'off';
	document.getElementById('item2').className = 'off';
	document.getElementById('item3').className = 'off';
	document.getElementById('item4').className = 'off';
	document.getElementById('item5').className = 'off';
	document.getElementById(obj_name).className = 'on';
	
	document.getElementById('item1_det').style.display = 'none';
	document.getElementById('item2_det').style.display = 'none';
	document.getElementById('item3_det').style.display = 'none';
	document.getElementById('item4_det').style.display = 'none';
	document.getElementById('item5_det').style.display = 'none';
	document.getElementById(obj_name_det).style.display = 'block';
}

function abaTrabalhe(obj){
	obj_name = 'item'+obj;
	obj_name_det = 'item'+obj+'_det';
	
	document.getElementById('item1').className = 'off';
	document.getElementById('item2').className = 'off';
	document.getElementById('item3').className = 'off';
	document.getElementById(obj_name).className = 'on';
	
	document.getElementById('item1_det').style.display = 'none';
	document.getElementById('item2_det').style.display = 'none';
	document.getElementById('item3_det').style.display = 'none';
	document.getElementById(obj_name_det).style.display = 'block';
}

function abreVideo(vid){
	window.open('video_'+vid+'.php','Video','width=500,height=470,scrollbars=no,statusbar=no,left=150,top=50');
}

function changeProduto(url){
	document.getElementById('lista_produtos').innerHTML = 'Carregando...';
	document.getElementById('hdarea').value = url;
	
	// VERIFICA A ABA QUE ESTÁ ABERTA
	if (document.getElementById('item1').className == 'on'){
		aba = 1;
	}
	if (document.getElementById('item2').className == 'on'){
		aba = 2;
	}
	if (document.getElementById('item3').className == 'on'){
		aba = 3;
	}
	if (document.getElementById('item4').className == 'on'){
		aba = 4;
	}
	
	url = url + "&aba="+aba+"&url="+url+"&cache=" + new Date().getTime();
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState == 4) {
			if (xmlhttp.status == 200) {
				var retorno = url_decode(xmlhttp.responseText);
				var divCampo = document.getElementById("lista_produtos");
				divCampo.innerHTML = "";
				
				if (retorno.length > 0){
					divCampo.innerHTML = retorno;
					initLytebox();
					//reloadMilkbox();
				}
			}
		}
	};
	xmlhttp.send(null);
}

function reloadMilkbox(){
	milkbox.reloadGalleries();
}

function filtroProdutos(){
	document.getElementById('lista_produtos').innerHTML = 'Carregando...';
	a = document.getElementById('hdarea').value;
	query = document.getElementById('q').value;
	
	url = a + "&q="+query;
	url = url + "&cache=" + new Date().getTime();

	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState == 4) {
			if (xmlhttp.status == 200) {
				var retorno = url_decode(xmlhttp.responseText);
				var divCampo = document.getElementById("lista_produtos");
				divCampo.innerHTML = "";
				
				if (retorno.length > 0){
					divCampo.innerHTML = retorno;
					initLytebox();
				}
			}
		}
	};
	xmlhttp.send(null);
	
}

function filtroProdutosKey(a){
	var Key = a.keyCode || a.which;
	if(Key == "13"){
		filtroProdutos();
	}
}
