function ConteudoFlash(swf,largura,altura,VSpace,HSpace){
	STRFlash = '<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="'+largura+'" height="'+altura+'" vspace="'+VSpace+'" hspace="'+HSpace+'">'
	STRFlash += '<param name="movie" value="'+swf+'" />'
    STRFlash += '<param name="quality" value="high" />'
    STRFlash += '<param name="wmode" value="transparent" />'
	STRFlash += '<embed src="'+swf+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'" wmode="transparent" vspace="'+VSpace+'" hspace="'+HSpace+'"></embed>'
	STRFlash += '</object>'
	document.write(STRFlash);
}

function AbreJanela(link,x,y,s) {
	var t = (screen.height - y) / 2;
	var e = (screen.width - x) / 2;

	window.open(link,x+y,'width=' + x + ',height=' + y + ',scrollbars=' + s + ',toolbar=0,location=0,status=0,menubar=0,resizable=0,left=' + e + ',top=' + t + '');
}

var PopUp = null
function FocaJanela(){
	if (PopUp!=null && !PopUp.closed){
		PopUp.focus();
	}
}

function Fecha(Tipo){
	if(Tipo=='C'){
		if(confirm('Deseja cancelar esta operação?')){
			window.close()
			window.opener.location.reload();
		}else{
			return false;
		}
	}else if(Tipo=='F'){
		window.close()
		window.opener.location.reload();
	}else{
		window.close();
	}
}

function PageLoad(){
	window.opener.location.reload();
}

function Voltar(){
	history.back(0);
}

// ******************************************************
// *********** mostra determinada area ************
// ******************************************************
function ShowHide(IdObjeto){
	if (document.getElementById(IdObjeto).style.display == 'block'){
		document.getElementById(IdObjeto).style.display = 'none';
	} else {
		document.getElementById(IdObjeto).style.display = 'block';
	}
}
function Show(IdObjeto){
	document.getElementById(IdObjeto).style.display = '';
}
function Hide(IdObjeto){
	document.getElementById(IdObjeto).style.display = 'none';
}

function Confirma(Msg,Url){
	if(confirm(Msg)){
		location.href = Url
		return false;
	}else{
		return false;
	}
}


function ExibeImg(Valor,ObjDestino){
	document.getElementById(ObjDestino).src = Valor;
}
function FrmEnvia(Confirma,Msg,ObjId){
	if(Confirma==1){
		if(confirm(Msg)){
			document.getElementById(ObjId).submit();
		}
	}else{
		document.getElementById(ObjId).submit();
	}
	return false;
}

function GridFoto(NomeClass,IdObj,idCheck){
	var CheckBox = document.getElementById(idCheck).checked;
	if(CheckBox == false){
		document.getElementById(IdObj).className = NomeClass;
	}
}
function ClicaFoto(IdObj,idCheck){
	CheckBox = document.getElementById(idCheck).checked;
	if(CheckBox == false){
		document.getElementById(idCheck).checked = true;
		document.getElementById(IdObj).className = 'FotoC';
	}else{
		document.getElementById(idCheck).checked = false;
		document.getElementById(IdObj).className = 'FotoA';
	}
	//alert(document.getElementById(idCheck).checked);
}

function GridCategoria(NomeClass,IdObj,idCheck){
	var CheckBox = document.getElementById(idCheck).checked;
	if(CheckBox == false){
		document.getElementById(IdObj).className = NomeClass;
	}
}
function ClicaCategoria(IdObj,idCheck){
	CheckBox = document.getElementById(idCheck).checked;
	if(CheckBox == false){
		document.getElementById(idCheck).checked = true;
		document.getElementById(IdObj).className = 'CategoriaC';
	}else{
		document.getElementById(idCheck).checked = false;
		document.getElementById(IdObj).className = 'CategoriaA';
	}
	//alert(document.getElementById(idCheck).checked);
}











function GridSelecionar(){
	CheckBox = document.getElementsByTagName('input');
	for (var i=0;i<CheckBox.length;i++){
		if(CheckBox[i].type=='checkbox'){
			CheckBox[i].checked = true;
		}
	}
}

function Base(){
	document.getElementById('Base').style.bottom = '0px';

}
//window.onresize = Base;

function WSize(W,H){
	window.resizeTo(W,H)
	
	var t = (screen.height - H) / 2;
	var e = (screen.width - W) / 2;
	
	window.moveTo(e,t);
}
function GID(ObjId){
	return document.getElementById(ObjId)
}

function FormataValor(objeto,teclapres,tammax,decimais){
	var tecla			= teclapres.keyCode;
	var tamanhoObjeto	= objeto.value.length;
	if ((tecla == 8) && (tamanhoObjeto == tammax))
	{
		tamanhoObjeto = tamanhoObjeto - 1 ;
	}
    if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) && ((tamanhoObjeto+1) <= tammax))
	{
		vr	= objeto.value;
		vr	= vr.replace( "/", "" );
		vr	= vr.replace( "/", "" );
		vr	= vr.replace( ",", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		tam	= vr.length;
		if (tam < tammax && tecla != 8)
		{
			tam = vr.length + 1 ;
		}
		if ((tecla == 8) && (tam > 1))
		{
			tam = tam - 1 ;
			vr = objeto.value;
			vr = vr.replace( "/", "" );
			vr = vr.replace( "/", "" );
			vr = vr.replace( ",", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
		}
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
		{
			if (decimais > 0)
			{
				if ( (tam <= decimais) )
				{ 
					objeto.value = ("0," + vr) ;
				}
				if( (tam == (decimais + 1)) && (tecla == 8))
				{
					objeto.value = vr.substr( 0, (tam - decimais)) + ',' + vr.substr( tam - (decimais), tam ) ;	
				}
				if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) &&  ((vr.substr(0,1)) == "0"))
				{
					objeto.value = vr.substr( 1, (tam - (decimais+1))) + ',' + vr.substr( tam - (decimais), tam ) ;
				}
				if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) &&  ((vr.substr(0,1)) != "0"))
				{
				    objeto.value = vr.substr( 0, tam - decimais ) + ',' + vr.substr( tam - decimais, tam ) ; 
				}
				if ( (tam >= (decimais + 4)) && (tam <= (decimais + 6)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 3) ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
			 	if ( (tam >= (decimais + 7)) && (tam <= (decimais + 9)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 6) ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
				if ( (tam >= (decimais + 10)) && (tam <= (decimais + 12)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 9) ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
				if ( (tam >= (decimais + 13)) && (tam <= (decimais + 15)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 12) ) + '.' + vr.substr( tam - (decimais + 12), 3 ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
			}
			else if(decimais == 0)
			{
				if ( tam <= 3 )
				{ 
			 		objeto.value = vr ;
				}
				if ( (tam >= 4) && (tam <= 6) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr(0, tam - 3) + '.' + vr.substr( tam - 3, 3 ); 
				}
				if ( (tam >= 7) && (tam <= 9) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 6 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); 
				}
				if ( (tam >= 10) && (tam <= 12) )
				{
			 		if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); 
				}

				if ( (tam >= 13) && (tam <= 15) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ) ;
				}			
			}
		}
	}
	else if((window.event.keyCode != 8) && (window.event.keyCode != 9) && (window.event.keyCode != 13) && (window.event.keyCode != 35) && (window.event.keyCode != 36) && (window.event.keyCode != 46))
		{
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
}

//Valida email
function IsEmail(pVal){
	var reTipo = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	return reTipo.test(pVal);
}

function ValidaLembrarSenha(){
	UsuarioEmail = document.getElementById('UsuarioEmail');
	
	if(UsuarioEmail.value==''){
		alert('Informe seu E-mail.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		UsuarioEmail.focus();
		return false;
	}

	if(IsEmail(UsuarioEmail.value)==false){
		alert('Seu E-mail é inválido.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		UsuarioEmail.focus();
		return false;
	}
	return true;
}
//Valida formulario de contato em geral
function ValidaContato(){
	Nome = document.getElementById('Nome');
	Email = document.getElementById('Email');
	Telefone = document.getElementById('Telefone');
	Assunto = document.getElementById('Assunto');
	Mensagem = document.getElementById('Mensagem');
	
	if(Nome.value==''){
		alert('Informe seu nome.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		Nome.focus();
		return false;
	}
	
	if(Email.value==''){
		alert('Informe seu E-mail.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		Email.focus();
		return false;
	}

	if(IsEmail(Email.value)==false){
		alert('Seu E-mail é inválido.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		Email.focus();
		return false;
	}

	if(Telefone.value==''){
		alert('Informe seu telefone.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		Telefone.focus();
		return false;
	}

	if(Assunto.value==''){
		alert('Informe o assunto.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		Assunto.focus();
		return false;
	}
	
	if(Mensagem.value==''){
		alert('Informe a mensagem.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		Mensagem.focus();
		return false;
	}
	

	return true;
}


/*Catalogo*/
function IsDate(pObj) {
	var expReg = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/(19|20)?\d{2}$/;
	var aRet = true;
	if ((pObj) && (pObj.match(expReg)) && (pObj != '')) {
		var dia = pObj.substring(0,2);
		var mes = pObj.substring(3,5);
		var ano = pObj.substring(6,10);
		if ((mes == 4 || mes == 6 || mes == 9 || mes == 11 ) && dia > 30){
			aRet = false;
		}else{
			if ((ano % 4) != 0 && mes == 2 && dia > 28){
				aRet = false;
			}else{
				if ((ano%4) == 0 && mes == 2 && dia > 29){
					aRet = false;
				}
			}
		}
	}else{
		aRet = false;
	}
	
	return aRet;
}


function AtualizaQtd(ObjTxt,idItem){
	Qtd = document.getElementById(ObjTxt).value;
	if(Qtd==''){
		alert('Informe a quantidade de itens!')
	}else if(Qtd==0){
		alert('Informe um valor maior que 0!')
	}else if(isNaN(Qtd)){
		alert('Informe um valor numérico!')
	}else{
		//alert('ProdutoQtdCart.asp?idItem='+idItem+'&Qtd='+Qtd)
		location.href = 'CarrinhoQtd.asp?idItem='+idItem+'&Qtd='+Qtd
	}
}

function ValidaLogin(){
	Usuario = document.getElementById('Usuario');
	UsuarioSenha = document.getElementById('UsuarioSenha');
	
	if(Usuario.value==''){
		alert('Informe seu nome de Usuario.');
		Usuario.style.backgroundColor = '#FFE6E6';
		Usuario.focus();
		return false;
	}else{
		Usuario.style.backgroundColor = '#FFFFFF';
	}
	
	if(UsuarioSenha.value==''){
		alert('Informe sua Senha.');
		UsuarioSenha.style.backgroundColor = '#FFE6E6';
		UsuarioSenha.focus();
		return false;
	}else{
		UsuarioSenha.style.backgroundColor = '#FFFFFF';
	}
	return true;
}
function ValidaLogin2(){
	Usuario = document.getElementById('Usuario2');
	UsuarioSenha = document.getElementById('UsuarioSenha2');
	
	if(Usuario.value==''){
		alert('Informe seu nome de Usuario.');
		Usuario.style.backgroundColor = '#FFE6E6';
		Usuario.focus();
		return false;
	}else{
		Usuario.style.backgroundColor = '#FFFFFF';
	}
	
	if(UsuarioSenha.value==''){
		alert('Informe sua Senha.');
		UsuarioSenha.style.backgroundColor = '#FFE6E6';
		UsuarioSenha.focus();
		return false;
	}else{
		UsuarioSenha.style.backgroundColor = '#FFFFFF';
	}
	return true;
}

function ValidaCadastro(){
	UsuarioNome = document.getElementById('UsuarioNome');
	UsuarioDataNascimento = document.getElementById('UsuarioDataNascimento');
	UsuarioSexo = document.getElementById('UsuarioSexo');
	UsuarioTelefone = document.getElementById('UsuarioTelefone');
	UsuarioEmail = document.getElementById('UsuarioEmail');
	UsuarioCidade = document.getElementById('UsuarioCidade');
	UsuarioBairro = document.getElementById('UsuarioBairro');
	UsuarioRua = document.getElementById('UsuarioRua');
	UsuarioNumero = document.getElementById('UsuarioNumero');
	UsuarioEstado = document.getElementById('UsuarioEstado');
	UsuarioCep = document.getElementById('UsuarioCep');
	Usuario = document.getElementById('Usuario');
	UsuarioSenha = document.getElementById('UsuarioSenha');
	UsuarioSenhaC = document.getElementById('UsuarioSenhaC');
	
	if(UsuarioNome.value==''){
		alert('Informe seu nome.');
		UsuarioNome.style.backgroundColor = '#F4F3B6';
		UsuarioNome.focus();
		return false;
	}else{
		UsuarioNome.style.backgroundColor = '#FFFFFF';
	}

	if(UsuarioDataNascimento.value==''){
		alert('Informe sua data de nascimento.');
		UsuarioDataNascimento.style.backgroundColor = '#F4F3B6';
		UsuarioDataNascimento.focus();
		return false;
	}else if(IsDate(UsuarioDataNascimento.value)==false){
		alert('Informe data de nascimento válida.');
		UsuarioDataNascimento.style.backgroundColor = '#F4F3B6';
		UsuarioDataNascimento.focus();
		return false;
	}else{
		UsuarioDataNascimento.style.backgroundColor = '#FFFFFF';
	}
	
	if(UsuarioSexo.value=='X'){
		alert('Informe seu sexo.');
		UsuarioSexo.style.backgroundColor = '#F4F3B6';
		UsuarioSexo.focus();
		return false;
	}else{
		UsuarioSexo.style.backgroundColor = '#FFFFFF';
	}

	if(UsuarioTelefone.value==''){
		alert('Informe seu telefone.');
		UsuarioTelefone.style.backgroundColor = '#F4F3B6';
		UsuarioTelefone.focus();
		return false;
	}else{
		UsuarioTelefone.style.backgroundColor = '#FFFFFF';
	}

	if(UsuarioEmail.value==''){
		alert('Informe seu e-mail.');
		UsuarioEmail.style.backgroundColor = '#F4F3B6';
		UsuarioEmail.focus();
		return false;
	}else if(IsEmail(UsuarioEmail.value)==false){
		alert('Informe e-mail válido.');
		UsuarioEmail.style.backgroundColor = '#F4F3B6';
		UsuarioEmail.focus();
		return false;
	}else{
		UsuarioEmail.style.backgroundColor = '#FFFFFF';
	}

	if(UsuarioCidade.value==''){
		alert('Informe sua cidade.');
		UsuarioCidade.style.backgroundColor = '#F4F3B6';
		UsuarioCidade.focus();
		return false;
	}else{
		UsuarioCidade.style.backgroundColor = '#FFFFFF';
	}

	if(UsuarioBairro.value==''){
		alert('Informe seu bairro.');
		UsuarioBairro.style.backgroundColor = '#F4F3B6';
		UsuarioBairro.focus();
		return false;
	}else{
		UsuarioBairro.style.backgroundColor = '#FFFFFF';
	}

	if(UsuarioRua.value==''){
		alert('Informe sua rua.');
		UsuarioRua.style.backgroundColor = '#F4F3B6';
		UsuarioRua.focus();
		return false;
	}else{
		UsuarioRua.style.backgroundColor = '#FFFFFF';
	}

	if(UsuarioNumero.value==''){
		alert('Informe seu número.');
		UsuarioNumero.style.backgroundColor = '#F4F3B6';
		UsuarioNumero.focus();
		return false;
	}else if(isNaN(UsuarioNumero)==false){
		alert('Informe número válido.');
		UsuarioNumero.style.backgroundColor = '#F4F3B6';
		UsuarioNumero.focus();
		return false;
	}else{
		UsuarioNumero.style.backgroundColor = '#FFFFFF';
	}

	if(UsuarioEstado.value==''){
		alert('Informe seu estado.');
		UsuarioEstado.style.backgroundColor = '#F4F3B6';
		UsuarioEstado.focus();
		return false;
	}else{
		UsuarioEstado.style.backgroundColor = '#FFFFFF';
	}

	if(UsuarioCep.value==''){
		alert('Informe seu CEP.');
		UsuarioCep.style.backgroundColor = '#F4F3B6';
		UsuarioCep.focus();
		return false;
	}else{
		UsuarioCep.style.backgroundColor = '#FFFFFF';
	}

	if(Usuario.value==''){
		alert('Informe seu nome de usuário.');
		Usuario.style.backgroundColor = '#F4F3B6';
		Usuario.focus();
		return false;
	}else{
		Usuario.style.backgroundColor = '#FFFFFF';
	}

	if(UsuarioSenha.value==''){
		alert('Informe sua senha.');
		UsuarioSenha.style.backgroundColor = '#F4F3B6';
		UsuarioSenha.focus();
		return false;
	}else if(UsuarioSenhaC.value==''){
		alert('Confirme sua senha.');
		UsuarioSenhaC.style.backgroundColor = '#F4F3B6';
		UsuarioSenhaC.focus();
		return false;
	}else if(UsuarioSenhaC.value != UsuarioSenha.value){
		alert('Senhas não conferem.');
		UsuarioSenhaC.style.backgroundColor = '#F4F3B6';
		UsuarioSenha.style.backgroundColor = '#F4F3B6';
		UsuarioSenhaC.focus();
		return false;
	}else{
		UsuarioSenhaC.style.backgroundColor = '#FFFFFF';
		UsuarioSenha.style.backgroundColor = '#FFFFFF';
	}

	return true;
}

function ValidaCarrinhoEnderecoEntrega(){
	PedidoEstado = document.getElementById('PedidoEstado').value
	PedidoCidade = document.getElementById('PedidoCidade').value
	PedidoBairro = document.getElementById('PedidoBairro').value
	PedidoRua = document.getElementById('PedidoRua').value
	PedidoNumero = document.getElementById('PedidoNumero').value
	PedidoCep = document.getElementById('PedidoCep').value

	if(PedidoEstado=='' || PedidoCidade=='' || PedidoBairro=='' || PedidoRua=='' || PedidoNumero=='' || PedidoCep==''){
		alert('Preencha todos com campos com assinalados (*)')
		return false;
	}else if(isNaN(PedidoNumero)){
		alert('Campo número deve conter valores numéricos')
		return false;
	}else{
		return true;
	}
}

function ValidaMensagem(){
	Assunto = document.getElementById('Assunto').value
	Mensagem = document.getElementById('Mensagem').value

	if(Assunto=='' || Mensagem==''){
		alert('Preencha todos com campos com assinalados (*)')
		return false;
	}else{
		return true;
	}
}

function OpenUrl(Url){
	location.href = Url;
}
function Voltar(){
	history.back(1)
}