/*Site Magics videos*/
function fnAdicionaFavoritos(){
	str_titulo = "Magics Vídeo";
	str_url = "http://www.magicsvideo.com.br";
	if(window.sidebar){ window.sidebar.addPanel(str_titulo,str_url,""); }
	else if(window.external){ window.external.AddFavorite(str_url,str_titulo); }
	else if(window.opera && window.print){ return true; }
}
function mostra(campo){ document.getElementById(campo).style.display=''; }
function oculta(campo){ document.getElementById(campo).style.display='none'; }
function AbrePopUp(url,titulo,largura,altura,scrollbar){
	window.open(url,titulo,'width='+largura+',height='+altura+',scrollbars='+scrollbar+',toolbar=no,location=no,status=yes,menubar=no,resizable=no,left=10,top=10');
}
function verificaCesta(){
	if(document.getElementById('quantidade').value == ""){
		alert("Atenção!\nO campo QUANTIDADE deve ser preenchido!");
		document.getElementById('quantidade').focus();
		return false;
	}
	return true;
}
function onOff(id){
	esconder = (document.getElementById(id).style.display == 'block');
	divs = document.getElementsByTagName('DIV');
	for(d=0; d<divs.length; d++){
		_div = divs[d];
		if(_div.className == 'titulo'){
			id_link = 'titulo_'+(_div.id);
			_link = document.getElementById(id_link);
			if(_div.id != id){ _div.style.display = 'none'; }
			else{ _div.style.display = esconder ? 'none' : 'block'; }
		}
	}
}
function onOffCategoria(id){
	esconder = (document.getElementById(id).style.display == 'block');
	divs = document.getElementsByTagName('DIV');
	for(d=0; d<divs.length; d++){
		_div = divs[d];
		if(_div.className == 'submenu'){
			id_link = 'submenu_'+(_div.id);
			_link = document.getElementById(id_link);
			if(_div.id != id){ _div.style.display = 'none'; }
			else{ _div.style.display = esconder ? 'none' : 'block'; }
		}
	}
}
function Aparece(){
	on = document.getElementById('departamento_busca').style.display;
	if(on == "" || on == "none"){ document.getElementById('departamento_busca').style.display="block"; }
	else{ document.getElementById('departamento_busca').style.display="none"; }
}
function ValidaForm_News(form){
	if(form.nome.value.length<=1){
		alert("O campo Nome deve estar preenchido corretamente.");
		form.nome.focus();
		return false;
	}
	var str_email = form.email.value;
    if((str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)||(str_email == 'Email:')){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.email.focus();
    	return false;
	}

}
function ValidaForm_Busca(form){
	if(form.busca.value.length<=1){
		alert("O campo Busca deve estar preenchido corretamente.");
		form.busca.focus();
		return false;
	}
}
function ValidaForm_Contato(form){
	if(form.nome.value.length<=1){
		alert("O campo Nome deve estar preenchido corretamente.");
		form.nome.focus();
		return false;
	}
	var str_email = form.email.value;
    if((str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)||(str_email == 'Email:')){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.email.focus();
    	return false;
	}
	if(form.telefone.value.length<=1){
		alert("O campo Telefone deve estar preenchido corretamente.");
		form.telefone.focus();
		return false;
	}
	if(form.cidade.value.length<=1){
		alert("O campo Cidade deve estar preenchido corretamente.");
		form.cidade.focus();
		return false;
	}
	if(form.estado.value.length<=1){
		alert("O campo Estado deve estar selecionado corretamente.");
		form.estado.focus();
		return false;
	}
	if(form.mensagem.value.length<=1){
		alert("O campo Mensagem deve estar preenchido corretamente.");
		form.mensagem.focus();
		return false;
	}
	if(form.cod.value.length<=1){
		alert("O campo Código de Segurança deve estar preenchido corretamente.");
		form.cod.focus();
		return false;
	}
}
function fnMascara(objeto,evt,mask){ 
	var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var LetrasL = 'abcdefghijklmnopqrstuvwxyz';
	var Letras = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';	
	var Numeros = '0123456789';
	var Fixos = '().-:/ ';
	var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_/`abcdefghijklmnopqrstuvwxyz{|}~";
	evt = (evt) ? evt : (window.event) ? window.event : "";
	var value = objeto.value;
	if(evt){
		var ntecla = (evt.which) ? evt.which : evt.keyCode;
		tecla = Charset.substr(ntecla - 32, 1);
		if(ntecla < 32) return true;
		var tamanho = value.length;
		if(tamanho >= mask.length) return false;
		var pos = mask.substr(tamanho,1);
		while(Fixos.indexOf(pos) != -1){
 	 		value += pos;
 	 		tamanho = value.length;
 	 		if(tamanho >= mask.length) return false;
 	 		pos = mask.substr(tamanho,1);
		}
		switch(pos){
   			case '#': if(Numeros.indexOf(tecla) == -1) return false; break;
   			case 'A': if(LetrasU.indexOf(tecla) == -1) return false; break;
   			case 'a': if(LetrasL.indexOf(tecla) == -1) return false; break;
   			case 'Z': if(Letras.indexOf(tecla) == -1) return false; break;
   			case '*': objeto.value = value; return true; break;
   			default: return false; break;
 		}
	}
	objeto.value = value;
	return true;
}
function fnImagemPopUp(titulo,largura,altura,imagem,alt){
	var janela;
	janela = window.open("","popFoto","width="+largura+",height="+altura+",scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left=300,top=300'");
	janela.document.write('<html><head><title>'+titulo+'</title></head>');
	janela.document.write('<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	janela.document.write('<a href="javascript:window.close();"><img src="'+imagem+'" alt="'+alt+'" border="0" /></a>');
	janela.document.write('</body></html>');
}
function MM_openBrWindow(theURL,winName,features){
	var myWin = window.open(theURL,winName,features);
	myWin.focus();
}
function ValidaForm_IndiqueAmigo(form) {	
	if(form.nome.value==""){
		alert("O campo Seu nome deve ser preenchido corretamente.");
		form.nome.focus();
		return false;
	}
	var str_email = form.email.value;
    if(str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
    	alert("O campo Seu E-mail deve ser preenchido corretamente.");
    	form.email.focus();
    	return false;
	}
	var str_email = form.emailamigo.value;
    if(str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
    	alert("O campo E-mail do Destinatário deve ser preenchido corretamente.");
    	form.emailamigo.focus();
    	return false;
	}
}
function ValidaForm_login(form){
	var str_email = form.email.value;
    if((str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)||(str_email == 'Email:')){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.email.focus();
    	return false;
	}
	if(form.senha.value.length<=1){
		alert("O campo Senha deve estar preenchido corretamente.");
		form.senha.focus();
		return false;
	}
}
function fn_seleciona_tipo_pessoa(tipo){
	if(tipo == "fisica"){
		document.getElementById('oculta_empresa').style.display = 'none';
		document.getElementById('oculta_empresaa').style.display = 'none';
		document.getElementById('oculta_dado').style.display = '';
		document.getElementById('oculta_nome').style.display = '';
	}
	if(tipo == "juridica"){
		document.getElementById('oculta_empresa').style.display = '';
		document.getElementById('oculta_empresaa').style.display = '';
		document.getElementById('oculta_dado').style.display = 'none';
		document.getElementById('oculta_nome').style.display = 'none';
	}
}
function verificaCadastro(formCadastro){
	if((document.getElementById('pessoa_f').checked == false)&&(document.getElementById('pessoa_j').checked == false)){
		alert("Atenção!\nO campo PESSOA deve ser preenchido.");
		return false;
	}
	if(document.getElementById('pessoa_j').checked == true){
		if(formCadastro.empresa.value == ''){
			alert("O campo EMPRESA deve ser preenchido.");
			formCadastro.empresa.focus();
			return false;
		}
		if(formCadastro.cnpj.value == ''){
			alert("O campo CNPJ deve ser preenchido.");
			formCadastro.cnpj.focus();
			return false;
		}
	}
	if(document.getElementById('pessoa_f').checked == true){
		if(formCadastro.nome.value == ''){
			alert("O campo NOME deve ser preenchido.");
			formCadastro.nome.focus();
			return false;
		}
	}
	if(formCadastro.rg.value == ''){
		alert("O campo RG deve ser preenchido.");
		formCadastro.rg.focus();
		return false;
	}
	if(formCadastro.cpf.value == ''){
		alert("O campo CPF deve ser preenchido.");
		formCadastro.cpf.focus();
		return false;
	}
	if(formCadastro.email.value == ''){
		alert("O campo EMAIL deve ser preenchido.");
		formCadastro.email.focus();
		return false;
	}
	if(formCadastro.email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
		alert("Atenção!\nO campo E-MAIL deve ser preenchido corretamente.");
		formCadastro.email.value = ('');
		formCadastro.email.focus();
		return false;
 	}
	if(formCadastro.telefone.value == ''){
		alert("O campo TELEFONE deve ser preenchido.");
		formCadastro.telefone.focus();
		return false;
	}
	if(formCadastro.endereco.value == ''){
		alert("O campo ENDEREÇO deve ser preenchido.");
		formCadastro.endereco.focus();
		return false;
	}
	if(formCadastro.bairro.value == ''){
		alert("O campo BAIRRO deve ser preenchido.");
		formCadastro.bairro.focus();
		return false;
	}
	if(formCadastro.cidade.value == ''){
		alert("O campo CIDADE deve ser preenchido.");
		formCadastro.cidade.focus();
		return false;
	}
    if(formCadastro.estado.value == ''){
		alert("O campo ESTADO deve ser preenchido.");
		formCadastro.estado.focus();
		return false;
	}
	if(formCadastro.loginn.value == ''){
		alert("O campo LOGIN deve ser preenchido.");
		formCadastro.loginn.focus();
		return false;
	}
	if(formCadastro.senha.value == ''){
		alert("O campo SENHA deve ser preenchido.");
		formCadastro.senha.focus();
		return false;
	}
}
function fun_toggle_produto_info(tipo){
	img = document.getElementById('barra_produtos');
	src = img.src;
	src_base = src.substring(0, src.lastIndexOf('/'));
	switch(tipo){
		case 'D':
			document.getElementById('div_descricao').style.display = 'block';
			document.getElementById('div_esp').style.display = 'none';
			img.src = src_base+'/img_desc_especificacoes2.jpg';
			break;
		case 'E':
			document.getElementById('div_descricao').style.display = 'none';
			document.getElementById('div_esp').style.display = 'block';
			img.src = src_base+'/desc_especificacoes.jpg';
			break;
		default:
			document.getElementById('div_descricao').style.display = 'block';
			document.getElementById('div_esp').style.display = 'none';
			img.src = src_base+'/desc_especificacoes.jpg';
			break;
	}
}
function fnFlash(str_url, int_largura, int_altura)
{
	document.writeln('<object type="application/x-shockwave-flash" data="' + str_url + '" width="' + int_largura + '" height="' + int_altura + '">');
	document.writeln('<param name="movie" value="' + str_url + '">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('</object>');
}
