function MontaFlash(arquivo, largura, altura, variaveis, transparente)
{
  document.write('<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+'">\n');
  document.write('<param name="movie" value="'+arquivo+'" />\n');
  document.write('<param name="quality" value="high" />\n');
  if(transparente)
  {
	document.write('<param name="wmode" value="transparent" />\n');
  }
  document.write('<param name="flashvars" value="'+variaveis+'">\n');
  document.write('<embed src="'+arquivo+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'" wmode="transparent" flashvars="'+variaveis+'"></embed>\n');
  document.write('</object>\n');
}

function testavalor(foto,campo,flag)
{  
      if(foto.checked == 0 && campo.value != ''){alert("Foto não permitida pois o campo FOTO? não está selecionado!");return false;}
	  if(foto.checked == 1 && campo.value == ''){alert("Procure a imagem para ser vinculada ao anúncio");return false;}
	 
      return true;	  
}


function preco(texto, fot, foto, countfield, semana) {

if(semana.value == '0'){semana.value=1;}
if (fot.checked == 0) 
		countfield.value = parseFloat(texto.value) * parseFloat(semana.value);
else 
		countfield.value = (parseFloat(foto.value) + parseFloat(texto.value)) * parseFloat(semana.value);
}



/*function ContarCampo(formu, Campo, limite) {
var Elemento, Len, Array
    Elemento = formu.elements;
	Len = Elemento.length;
	Array = Campos.split( '?' , Len*2 );
   
if (Elemento[1].value.length > limite)
		Elemento[1].value = Elemento[1].value.substring(0, limite);	
else 
		Elemento[2].value = limite - Elemento[2].value.length;

}*/



function ContarCampo(campo, contador, limite) {
if (campo.value.length > limite)
		campo.value = campo.value.substring(0, limite);	
else 
		contador.value = limite - contador.value.length;
}

<!--

// Valida o formulario antes de envia-lo 
// Verifica Campos Nulos e suas Formatacoes(Tipo)
// Tipo E-Mail - Tipo texto - Tipo Numerico - Tipo AlfaNumerico
// VFrom = formulario a ser verificado
// Objs = nomes de objetos do form que nao sao necessarios
function ValidForm( VForm , Objs )
	{
	var Array, Msg, Len, Element, i, ix
	Msg = '';
	Element = VForm.elements;
	
	Len = Element.length;
	Array = Objs.split( '?' , Len*2 );
	for(ix=0; ix < Array.length ;ix++)
		for(i=0; i < Len ;i++)
			if( Array[ix] == Element[i].name )
				switch( Element[i].id )
					{
					case 'text' :
						if( Element[i].value == '' || IsLetter(Element[i].value) != -1 )
							{
							Element[i].select();
							Element[i].focus();

							Msg = 'Preencha o campo ' + Element[i].param;
							i	= Len;
							ix	= Array.length;
							}
						break;
						
              case 'cpf'	:
                 if (! checaCPF(Element[i].value)){
                     Msg = Element[i].param;
							Element[i].select();
							Element[i].focus();
                 }
                 break;
				 
              case 'cnpj'	:
                 if (! checaCNPJ(Element[i].value)){
                     Msg = Element[i].param;
							Element[i].select();
							Element[i].focus();
                 }
                 break;
               
   			   case 'alfa' :
						if( Element[i].value == '' || IsAlfaNum(Element[i].value) != -1 )
							{
								Element[i].select();
								Element[i].focus();
								Msg = 'Preencha o campo ' + Element[i].param;
								i	= Len;
								ix	= Array.length;
							}
						break;
					case 'user' :
						if( Element[i].value == '' || IsUser(Element[i].value) != -1 )
							{
								Element[i].select();
								Element[i].focus();
								Msg = 'Preencha o campo ' + Element[i].param;
								i	= Len;
								ix	= Array.length;
							}
						break;
					case 'num' :
						if( Element[i].value == '' || IsNumber(Element[i].value) != -1 )
								{
							Element[i].select();
							Element[i].focus();
							Msg = 'Preencha o campo '+ Element[i].param;
							i	= Len;
							ix	= Array.length;
							}
						break;
	 				   
					case 'dinh' :
						if( Element[i].value == '' || IsGrana(Element[i].value) != -1 )
								{
							Element[i].select();
							Element[i].focus();
							Msg = 'Preencha o campo '+ Element[i].param;
							i	= Len;
							ix	= Array.length;
							}
						break;
	
					case 'data' :
						if( Element[i].value == '' || IsData(Element[i].value) != -1 || Verificadata(Element[i].value) != -1)
							{
							Element[i].select();
							Element[i].focus();
							Msg = 'Preencha o campo '+ Element[i].param +' corretamente!';
							i	= Len;
							ix	= Array.length;
							}
						break;
						
					case 'mail' :
						if(! IsValidEmail(Element[i].value))
							{
							Element[i].select();
							Element[i].focus();
							Msg = 'E-Mail inválido.';
							i	= Len;
							ix	= Array.length;
							}
						break;
					case 'pswd2' :
						if( Element[i].value == '' )
							{
							Element[i].select();
							Element[i].focus();
							Msg = 'Preencha o campo senha.';
							i	= Len;
							ix	= Array.length;
							}
						break;
					case 'pswd' :
						if((Element[i].value != Element[i+1].value && Element[i+1].type == 'password') )					
//						if( Element[i].value == '' || (Element[i].value != Element[i+1].value && Element[i+1].type == 'password') )
							{
							Element[i+1].value = '';
							Element[i].select();
							Element[i].focus();
							Msg = 'Senha e Confirmação de Senha não conferem.';
							i	= Len;
							ix	= Array.length;
							}
						break;
					case 'null' :
						if( Element[i].value == '' )
							{
							Element[i].select();
							Element[i].focus();
							Msg = 'Preencha o campo '+ Element[i].param;
							i	= Len;
							ix	= Array.length;
							}
						break;
					case 'sel' :
						if( Element[i].value == '' || Element[i].value == 'XX' )
							{
							Element[i].focus();
							Msg = 'Selecione uma opção.';
							i	= Len;
							ix	= Array.length;
							}
						break;

					default :
							i	= Len;
					}

	if( Msg != '' )
		{
		alert(Msg);
		return false;
		}
	return true;
	}


function ValidFormRadio( RadioName ) {

	//validacao de radio buttons sem saber quantos sao
	marcado = -1
	for (i=0; i < RadioName.length; i++) {
		if (RadioName[i].checked) {
			marcado = i
			resposta = RadioName[i].value
			RadioName[i].focus();
		}
	}
	
	if (marcado == -1) {
		alert("Selecione uma resposta.");
		RadioName[0].focus();
		return false;
	} else { 
		return true; 
	} 

}

// A cada tecla solta verifica o campo ativo
function SeeKeys()
	{
	var Obj, KeyCode, Point, Indx, Str
	KeyCode = window.event.keyCode;
	Obj = event.srcElement;

	if( KeyCode == 13 )
		{
		blnGerarTab = true;
		window.event.returnValue = false;
		return false
		}
	else if( KeyCode > 47 )
		switch( Obj.id )
			{
			case 'text' :
				Str		= Obj.value;
				for(Indx=0; Indx < Str.length ;Indx++)
					{
					Point	= IsLetter(Obj.value);
					if( Point != -1 )
						Obj.value = CutCharPoint( Obj.value , Point );
					}
				break;

			case 'num'	:
				Str		= Obj.value;
				for(Indx=0; Indx < Str.length ;Indx++)
					{
					Point	= IsNumber(Obj.value);
					if( Point != -1 )
						Obj.value = CutCharPoint( Obj.value , Point );
					}
				break;

			case 'dinh'	:
				Str		= Obj.value;
				for(Indx=0; Indx < Str.length ;Indx++)
					{
					Point	= IsGrana(Obj.value);
					if( Point != -1 )
						Obj.value = CutCharPoint( Obj.value , Point );
					}
  			    break;

			case 'user'	:
				Str		= Obj.value;
				for(Indx=0; Indx < Str.length ;Indx++)
					{
					Point	= IsUser(Obj.value);
					if( Point != -1 )
						Obj.value = CutCharPoint( Obj.value , Point );
					}
				break;
			case 'data'	:
				Str		= Obj.value;
				for(Indx=0; Indx < Str.length ;Indx++)
					{
					Point	= IsData(Obj.value);
					
					if( Point != -1 ){
						Obj.value = CutCharPoint( Obj.value , Point );}
					else
					{
					   if (Str.length == 2) 
					   { 
     						 Str = Str + '/'; 
						     Obj.value = Str; 
   						} 
						if (Str.length == 5) 
						{ 
						      Str = Str + '/'; 
						      Obj.value = Str; 
	 				    } 
					}
				}	
				break;

			case 'alfa'	:
				Str		= Obj.value;
				for(Indx=0; Indx < Str.length ;Indx++)
					{
					Point	= IsAlfaNum(Obj.value);
					if( Point != -1 )
						Obj.value = CutCharPoint( Obj.value , Point );
					}
				break;
            
         case 'cpf' :
				Str		= Obj.value;
				for(Indx=0; Indx < Str.length ;Indx++)
					{
					Point	= IsNumber(Obj.value);
					if( Point != -1 )
						Obj.value = CutCharPoint( Obj.value , Point );
					}

			case 'mail' :
				Str		= Obj.value;
				for(Indx=0; Indx < Str.length ;Indx++)
					{
					Point	= IsEmail(Obj.value);
					if( Point != -1 )
						Obj.value = CutCharPoint( Obj.value , Point );
					}
				break;
			}
	}

// Verifica formatação a@b.c
// Não permite caracteres especiais
// Retorna true se o Obj for um E-Mail
// Retorna false se o Obj nao for um E-Mail
function IsValidEmail( Value )
	{
	var i, Current, Tmp
	var Array = Value.split( '@' , 3 );
   
	
	// Se tiver mais ou menos que 1 Arroba ou nao tiver nada antes ou apos o Arroba
	if( Array.length != 2 || Array[0] == '' || Array[1] == '' )
		return false;

	Tmp = Array[0];
	// Se contiver caracteres especiais antes do Arroba
	for(i=0; i < Tmp.length ;i++)
		{
		Current =  Tmp.charAt(i);
		if( (Current == ' ') && (Current < '0' || Current > '9') && (Current < 'A' || Current > 'Z') && (Current < 'a' || Current > 'z') && Current != '_' && Current != '-' && Current != '.' )
			return false;
		}

	Tmp = Array[1];
	// Se contiver caracteres especiais depois do Arroba
	for(i=0; i < Tmp.length ;i++)
		{
		Current =  Tmp.charAt(i);
		if( (Current < '0' || Current > '9') && (Current < 'A' || Current > 'Z') && (Current < 'a' || Current > 'z') && Current != '.' )
			return false;
		}
	
	Tmp = Tmp.split( '.' , 4 );
	// Se depois do arroba existir menos de 2 ou mais de 3 pontos
	if( Tmp.length != 2 && Tmp.length != 3 )
		return false;

	// Se depois do arroba existir menos de 2 ou mais de 3 pontos
	if( Tmp.length == 2 && (Tmp[0] == '' || Tmp[1] == '') )
		return false;

	// Se depois do arroba existir menos de 2 ou mais de 3 pontos
	if( Tmp.length == 3 && (Tmp[0] == '' || Tmp[1] == '' || Tmp[2] == '') )
		return false;

	return true
	}

// Procura por "Chars" em "Str"
// Retorna -1 se nao encontar os "Chars"
// Retorna a posicao do Chars em Str se o encontar
function LookChars( Str, Chars )
	{
	var Count, Indx
	for(Count=0; Count < Str.length ;Count++)
		for(Indx=0; Indx < Chars.length ;Indx++)
			if( Str.charAt(Count) == Chars.charAt(Indx) )
				return Count;

	return -1
	}

// Remove de Str o caracter localizado na posicao Pnt
// Retorna o Str sem o caracter apontado por Pnt
function CutCharPoint( Str, Pnt )
	{
	var Count, Result
	Result = '';
	for(Count=0; Count < Str.length ;Count++)
		if( Count != Pnt )
			Result = Result + Str.charAt(Count);

	return Result
	}

// Verifica se Str contem caracteres invalidos em E-Mails
// Retorna -1 se nao contiver
// Retorna Posicao do Caracter Invalido em Str
function IsEmail( Str )
	{
	var Count, Current
	for(Count=0; Count < Str.length ;Count++)
		{
		Current =  Str.charAt(Count);
		if( (Current < '0' || Current > '9') && (Current < 'A' || Current > 'Z') && (Current < 'a' || Current > 'z') && Current != '_' && Current != '-' && Current != '.' && Current != '@' )
			return Count
		}

	return -1
	}

// Verifica se Str contem caracteres invalidos para User name
// Retorna -1 se nao contiver
// Retorna Posicao do Caracter Invalido em Str
function IsUser( Str )
	{
	var Count, Current
	for(Count=0; Count < Str.length ;Count++)
		{
		Current =  Str.charAt(Count);
		if((Current < '0' || Current > '9') && (Current < 'A' || Current > 'Z') && (Current < 'a' || Current > 'z') && Current != '_' && Current != '-' && Current != '.' && Current != '@' )
			return Count
		}

	return -1
	}

	
	
// Verifica se Str contem apenas Letras entre A e Z
// Retorna -1 se Str contiver apenas Letras entre A-Z
// Retorna Posicao do Caracter que for uma Letra entre A-Z
function IsLetter( Str )
	{
	var Count, Current
	for(Count=0; Count < Str.length ;Count++)
		{
		Current =  Str.charAt(Count);
		if( (Current < 'A' || Current > 'Z') && (Current < 'a' || Current > 'z') && IsNotAcent(Current) )
			return Count
		}

	return -1
	}

// Verifica se o Chr é acentuado
// Retorna true se o Chr nao for acentuado
// Retorna false se o Chr for acentuado
function IsNotAcent( Chr )
	{
	if( Chr=='á' || Chr=='é' || Chr=='í' || Chr=='ó' || Chr=='ú' || Chr=='Á' || Chr=='É' || Chr=='Í' || Chr=='Ó' || Chr=='Ú' )
		return false;
	if( Chr=='à' || Chr=='è' || Chr=='ì' || Chr=='ò' || Chr=='ù' || Chr=='À' || Chr=='È' || Chr=='Ì' || Chr=='Ò' || Chr=='Ù' )
		return false;
	if( Chr=='â' || Chr=='ê' || Chr=='î' || Chr=='ô' || Chr=='û' || Chr=='Â' || Chr=='Ê' || Chr=='Î' || Chr=='Ô' || Chr=='Û' )
		return false;
	if( Chr=='ä' || Chr=='ë' || Chr=='ï' || Chr=='ö' || Chr=='ü' || Chr=='Ä' || Chr=='Ë' || Chr=='Ï' || Chr=='Ö' || Chr=='Ü' )
		return false;
	if( Chr=='ã' || Chr=='õ' || Chr=='Ã' || Chr=='Õ' || Chr=='ñ' || Chr=='Ñ' || Chr=='ç' || Chr=='Ç' || Chr==' ')
		return false;

	return true;	
	}

// Verifica se Num contem apenas Numeros entre 0 e 9
// Retorna -1 se o Num contiver apenas Numeros entre 0 e 9
// Retorna Posicao do Caracter nao Numerico se o encontrar
function IsNumber( Num )
	{
	var Count, Current
	for(Count=0; Count < Num.length ;Count++)
		{
		Current = Num.charAt(Count);
		if(( Current < '0' || Current > '9' ))
			return Count
		}

	return -1
	}



// Verifica se Num contem apenas Numeros entre 0 e 9 e ','
// Retorna -1 se o Num contiver apenas Numeros entre 0 e 9  e ','
// Retorna Posicao do Caracter nao Numerico se o encontrar
function IsGrana( din )
	{
	var Count, Current, virg
	virg = 0
	for(Count=0; Count < din.length ;Count++)
		{
		Current = din.charAt(Count);

		if(( Current < '0' || Current > '9') && Current != ',' ){
			return Count
			}
		else{
			if(Current ==  ','){virg = virg+1;}
			if(virg > 1){return -1;}
	        }
		}
	return -1
	}
	
	
//  Verifica data aceitando barra
	function IsData( Num )
	{
	var Count, Current
	for(Count=0; Count < Num.length ;Count++)
		{
		Current = Num.charAt(Count);
		if((Current < '0' || Current > '9') && Current != '/')
			return Count

		}

	return -1
	}

	
// Verifica se Str contem contem caracteres AlfaNumericos
// Retorna -1 se Str contiver apenas caracteres AlfaNumericos
// Retorna Posicao do Caracter nao AlfaNumerico
function IsAlfaNum( Str )
	{
	var Count, Current
	for(Count=0; Count < Str.length ;Count++)
		{
		Current =  Str.charAt(Count);
		if( (Current < '0' || Current > '9') && (Current < 'A' || Current > 'Z') && (Current < 'a' || Current > 'z') && IsNotAcent(Current) && Current != '_' && Current != '-' && Current != '.' )
			return Count
		}

	return -1
	}
	
	
function Verificadata(data){
var Date = new String(data);
    Dia = "";
    Mes = "";
    Ano = "";
    i = 0;

    for (i=0;(i<Date.length) && (Date.charAt(i) != '/');i++)
           Dia = Dia + Date.charAt(i);
    i++;

   for (;(i<Date.length) && (Date.charAt(i) != '/');i++)
        Mes = Mes + Date.charAt(i);
   i++;

   for (;(i<Date.length);i++)
      Ano = Ano + Date.charAt(i);
	  
	  
   if (eval(Mes) > 12){
		 return 0}
		 
   if (eval(Dia) > 31){
        return 0}
		
    if(eval(Ano) < 1850) {
        return 0;}
		
	if((eval(Mes)==2) && (eval(Dia)>29)){
	    return 0}	
		
return -1
}

function checaCPF (CPF) {
   if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
	  CPF == "22222222222" ||	CPF == "33333333333" || CPF == "44444444444" ||
     CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
     CPF == "88888888888" || CPF == "99999999999")
     return false;
   soma = 0;
   for (i=0; i < 9; i ++)
     soma += parseInt(CPF.charAt(i)) * (10 - i);

   resto = 11 - (soma % 11);
   if (resto == 10 || resto == 11)
      resto = 0;
  
  if (resto != parseInt(CPF.charAt(9)))
     return false;

  soma = 0;
  
  for (i = 0; i < 10; i ++)
     soma += parseInt(CPF.charAt(i)) * (11 - i);
  resto = 11 - (soma % 11);

  if (resto == 10 || resto == 11)
     resto = 0;
  
  if (resto != parseInt(CPF.charAt(10)))
    return false;
  
  return true;
} 

// a função principal de validação 
var isNS4 = (navigator.appName=="Netscape")?1:0;
function validar(obj) { // recebe um objeto 
    var s = (obj.value).replace(/\D/g,''); 
    var tam=(s).length; // removendo os caracteres não numéricos 
//    if (!(tam==11 || tam==14)){ // validando o tamanho 
    if (!(tam==14)){ // validando o tamanho 
//        alert("'"+s+"' Não é um CPF ou um CNPJ válido!" ); // tamanho inválido
		obj.value='CNPJ inválido';
		//obj.focus(); 
        //alert("'"+s+"' Não é um CNPJ válido!" ); // tamanho inválido
		//obj.select();
        return false; 
    } 
     
// se for CPF 
//    if (tam==11 ){ 
//        if (!validaCPF(s)){ // chama a função que valida o CPF 
//            alert("'"+s+"' Não é um CPF válido!" ); // se quiser mostrar o erro 
//            obj.select();  // se quiser selecionar o campo em questão 
//            return false; 
//        } 
//        //alert("'"+s+"' É um CPF válido!" ); // se quiser mostrar que validou         
//        obj.value=maskCPF(s);    // se validou o CPF mascaramos corretamente 
//        return true; 
//    } 
     
// se for CNPJ             
    if (tam==14){ 
        if(!validaCNPJ(s)){ // chama a função que valida o CNPJ 
			obj.value='CNPJ inválido';
//            alert("'"+s+"' Não é um CNPJ válido!" ); // se quiser mostrar o erro 
//            obj.select();    // se quiser selecionar o campo enviado 
            return false;             
        } 
        //alert("'"+s+"' É um CNPJ válido!" ); // se quiser mostrar que validou                 
        //obj.value=maskCNPJ(s);    // se validou o CNPJ mascaramos corretamente 
        return true; 
    } 
} 
// fim da funcao validar() 

// função que valida CPF 
// O algorítimo de validação de CPF é baseado em cálculos 
// para o dígito verificador (os dois últimos) 
//function validaCPF(s) { 
//    var c = s.substr(0,9); 
//    var dv = s.substr(9,2); 
//    var d1 = 0; 
//    for (var i=0; i<9; i++) { 
//        d1 += c.charAt(i)*(10-i); 
//     } 
//    if (d1 == 0) return false; 
//    d1 = 11 - (d1 % 11); 
//    if (d1 > 9) d1 = 0; 
//    if (dv.charAt(0) != d1){ 
//        return false; 
//    } 
//    d1 *= 2; 
//    for (var 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){ 
//        return false; 
//    } 
//    return true; 
//} 

// Função que valida CNPJ 
// O algorítimo de validação de CNPJ é baseado em cálculos 
// para o dígito verificador (os dois últimos) 
function validaCNPJ(CNPJ) { 
    var a = new Array(); 
    var b = new Number; 
    var c = [6,5,4,3,2,9,8,7,6,5,4,3,2]; 
    for (i=0; i<12; i++){ 
        a[i] = CNPJ.charAt(i); 
        b += a[i] * c[i+1]; 
    } 
    if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
    b = 0; 
    for (y=0; y<13; y++) { 
        b += (a[y] * c[y]); 
    } 
    if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; } 
    if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){ 
        return false; 
    } 
    return true; 
} 


