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 = 'block';
}
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);
}

//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;
}

function ValidaIndique(){
	Nome = document.getElementById('Nome');
	Email = document.getElementById('Email');
	NomeAmigo = document.getElementById('NomeAmigo');
	EmailAmigo = document.getElementById('EmailAmigo');
	
	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(NomeAmigo.value==''){
		alert('Informe o nome do seu amigo.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		NomeAmigo.focus();
		return false;
	}
	
	if(EmailAmigo.value==''){
		alert('Informe seu E-mail.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		EmailAmigo.focus();
		return false;
	}

	if(IsEmail(EmailAmigo.value)==false){
		alert('Seu E-mail é inválido.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		EmailAmigo.focus();
		return false;
	}
	
	return true;
}


function ValidaAvalia(){
	Endereco = document.getElementById('Endereco');
	Bairro = document.getElementById('Bairro');
	Cidade = document.getElementById('Cidade');
	Estado = document.getElementById('Estado');
	Nome = document.getElementById('Nome');
	Email = document.getElementById('Email');
	Telefone = document.getElementById('Telefone');
	
	if(Endereco.value==''){
		alert('Informe o campo endereço.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		Endereco.focus();
		return false;
	}

	if(Bairro.value==''){
		alert('Informe o campo bairro.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		Bairro.focus();
		return false;
	}

	if(Cidade.value==''){
		alert('Informe o campo cidade.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		Cidade.focus();
		return false;
	}

	if(Estado.value==''){
		alert('Informe o campo estado.');
		//SeuNome.style.backgroundColor = '#FFE6E6';
		Estado.focus();
		return false;
	}

	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;
	}
	
	return true;
}

function ValidaIdeal(){
	Nome = document.getElementById('Nome');
	Email = document.getElementById('Email');
	Telefone = document.getElementById('Telefone');
	
	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;
	}
	
	return true;
}
function IsDate(StrDate){
	var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
	var msgErro = 'Formato inválido (Ex.: 10/02/1982).';
	var vdt = new Date();
	var vdia = vdt.getDay();
	var vmes = vdt.getMonth();
	var vano = vdt.getYear();
	if ((StrDate.value.match(expReg)) && (StrDate.value!='')){
		var dia = StrDate.value.substring(0,2);
		var mes = StrDate.value.substring(3,5);
		var ano = StrDate.value.substring(6,10);
		if((mes==04 && dia > 30) || (mes==06 && dia > 30) || (mes==09 && dia > 30) || (mes==11 && dia > 30)){
			alert("Dia incorreto !!! O mês especificado contém no máximo 30 dias.");
			StrDate.focus();
			return false;
		} else{ //1
			if(ano%4!=0 && mes==2 && dia>28){
				alert("Data incorreta!! O mês especificado contém no máximo 28 dias.");
				StrDate.focus();
				return false;
			} else{ //2
				if(ano%4==0 && mes==2 && dia>29){
					alert("Data incorreta!! O mês especificado contém no máximo 29 dias.");
					StrDate.focus();
					return false;
				} else{ //3
					return true;
				} //3-else
			}//2-else
		}//1-else                       
	} else { //5
		alert(msgErro);
		StrDate.focus();
		return false;
	} //5-else
}

function IsCpf(idObj){
	var i;
	s = idObj.value;
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++){
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0){
		alert("CPF Invalido")
		idObj.focus();
		return false;
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9){
		d1 = 0;
	}
	if (dv.charAt(0) != d1){
		alert("CPF Invalido")
		idObj.focus()
		return false;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++){
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9){
		d1 = 0;
	}
	if (dv.charAt(1) != d1){
		alert("CPF Invalido")
		idObj.focus();
		return false;
	}
	return true;
}

