//FLASH
function flash(versao, largura, altura, nome, modo, cor)
{
	/*
	versao = 8 .................. <- Versão do player
	largura = 200px ............. <- Largura do SWF
	altura = 200px .............. <- Altura do SWF
	id = nome ................... <- ID do arquivo
	nome = arquivo.swf .......... <- Caminho do SWF, essa opção não pode ser vazia
	modo = transparent/opaque ... <- Flash transparente ou opaco / pode ser vazia
	cor = #ffffff ............... <- Cor de fundo
	*/
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="'+versao+',0,0,0" width="'+largura+'" height="'+altura+'">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="../../includes/'+nome+'" />\n');
	document.write('<param name="wmode" value="'+modo+'" />\n');
	document.write('<param name="bgcolor" value="'+cor+'" />\n');
	document.write('<embed src="../../includes/'+nome+'" wmode="'+modo+'" bgcolor="'+cor+'" width="'+largura+'" height="'+altura+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>\n');
}
//
function validaInscricao(){
	frm=document.Form1;
	
	if(frm.txtNome.value == ""){
		alert('Digite o nome!');
		frm.txtNome.focus();
		return false;
	}
	
	if(frm.txtNomeCracha.value == ""){
		alert('Digite o nome do Cracha!');
		frm.txtNomeCracha.focus();
		return false;
	}
	
	
	if(valida_CPF(frm.txtCPF) == false ){
		alert('CPF e invalido!');
		frm.txtCPF.focus();
		return false;
	}
	
	/*if(frm.txtCRM.value == ""){
		alert('Digite o CRM!');
		frm.txtCRM.focus();
		return false;
	}*/
	
	if(frm.txtRG.value == ""){
		alert("Digite o RG!");
		frm.txtRG.focus();
		return false;
	}
	
	if(frm.txtEmail.value == ""){
		alert('Digite o E-mail!');
		frm.txtEmail.focus();
		return false;
	}
	
	if(frm.txtEmail.value != frm.txtConfirmacao.value){
		alert('Confirmacao do E-mail esta incorreta!!');
		frm.txtConfirmacao.focus();
		return false;
	}
	
	/*if(frm.drpCategoria.value == "0"){
		alert('Selecione uma categoria!!');
		return false;
	}*/
	
//	if((document.getElementById("optListCatNaoSocioSocio").SelectedValue != "Sócio") && (document.getElementById("optListCatNaoSocioSocio").SelectedValue != "Nâo Sócio")){
//	    alert(document.getElementById("optListCatNaoSocioSocio").SelectedValue);
//	    
//	    alert('Selecione um tipo de categoria; Sócio ou Não Sócio!!!');
//	    return false;	
//	}
	/*if((document.getElementById("optListCatProfissionalEstudante").SelectedValue != "Profissional") &&(document.getElementById("optListCatProfissionalEstudante").SelectedValue != "Estudante")){
	    alert('Selecione um tipo de categoria; Profissional ou Estudante!!!');
	    return false;	
	}
	if((document.getElementById("optListCatTelaoPressencial").SelectedValue != "Presencial") &&(document.getElementById("optListCatTelaoPressencial").SelectedValue != "Telão")){
	    alert('Selecione um tipo de categoria; Presencial ou Telão!!!');
	    return false;	
	}*/
	
	document.Form1.acao.value = "Confirmar";

	frm.submit();
}

function execSubmit(page, acao)
{
	frm=document.form1;
	frm.action=page;
	frm.acao.value=acao;	
	frm.submit();
}


function mascCep(fild, e){
	var valor=fild.value;
	if(fild.value.length == 05){
		fild.value = fild.value + '-';
	}
	return IsNumeric(fild, e);
}

function mascTel(fild, e){
	var valor=fild.value;
	if(fild.value.length == 03){
		fild.value = fild.value + '-';
	}
	return IsNumeric(fild, e);
}

function IsNumeric(fild, e) 
{
	var strCheck = '0123456789,';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	key = String.fromCharCode(whichCode);
	if (strCheck.indexOf(key) == -1) return false;
}



function limita(obj,n)
{
	var tamanho = obj.value.length;
	var tex=obj.value;
	if (tamanho>=n) {
		obj.value=tex.substring(0,n-1);
	}
	return true;
}

/***************************************/
/* 		LIMPA O CAMPO                  
//**************************************/

function limpa_string(S){
// Deixa só os digitos no numero
var Digitos = "0123456789";
var temp = "";
var digito = "";
    for (var i=0; i<S.length; i++){
      digito = S.charAt(i);
      if (Digitos.indexOf(digito)>=0){
		  temp=temp+digito
	  }
    }
    return temp;
}

/***************************************/
/* 		MÁSCARA TELEFONE
//**************************************/

function mascara_fone(fone)
{
    var myfone = '';
    myfone = myfone + fone;
    if (myfone.length == 02) {
        myfone = myfone + '-';
        document.forms[0].fone.value = myfone;
		
    }    
    if (myfone.length == 11) {
	}
	
	return true;
}

/***************************************/
/* 			MÁSCARA CNPJ
/***************************************/
function valida_CNPJ(s)
{
	var i;
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0)
		return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}

function valida_CPF (field) 
{ 
	CPF= field.value.replace(".","");
	CPF= CPF.replace(".","");
	CPF= CPF.replace("-","");
	CPF= CPF.replace("-","");
	//CPF=field.value;
   Ok=true; 
	if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
		CPF == "22222222222" ||	CPF == "33333333333" || CPF == "44444444444" ||
		CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
		CPF == "88888888888" || CPF == "99999999999")
		Ok=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)))
		Ok=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)))
		Ok=false;

   return(Ok);
 }


function mascara_cpf(cpf, e)
{
	frm=document.Form1;

	if (cpf.value.length == 3) {
        cpf.value = cpf.value+'.';
    }
    if (cpf.value.length == 7) {
        cpf.value = cpf.value+'.';
    }
    if (cpf.value.length == 11) {
        cpf.value = cpf.value+ '-';
    }
    if (cpf.value.length == 14) {
    }
		return IsNumeric(cpf, e);

}

function maskDT(field, e) {
	if(field.value.length == 2){
		field.value = field.value + "/";
	}
	if(field.value.length == 5 ){
		field.value = field.value + "/";
	}
	
	return IsNumeric(field, e);
}


// DATA - ÍNICIO
function data() {
	mdata = new Date();
	mhora = mdata.getHours();
	mminuto = mdata.getMinutes();
	msegundos = mdata.getSeconds();
	mdia = mdata.getDate();
	mdiasemana = mdata.getDay();
	mmes = mdata.getMonth();
	mano = mdata.getFullYear();
	if (mdiasemana == 0) {
		document.write("'Domingo, ");
	} else if (mdiasemana == 1) {
		document.write("Segunda-feira, ");
	} else if (mdiasemana == 2) {
		document.write("Ter&ccedil;a-feira, ");
	} else if (mdiasemana == 3) {
		document.write("Quarta-feira, ");
	} else if (mdiasemana == 4) {
		document.write("Quinta-feira, ");
	} else if (mdiasemana == 5) {
		document.write("Sexta-feira, ");
	} else if (mdiasemana == 6) {
		document.write("S&aacute;bado, ");
	}
	document.write(+mdia+' de ');
	if (mmes == 0) {
		document.write("janeiro de ");
	} else if (mmes == 1) {
		document.write("fevereiro de ");
	} else if (mmes == 2) {
		document.write("mar&ccedil;o de ");
	} else if (mmes == 3) {
		document.write("abril de ");
	} else if (mmes == 4) {
		document.write("maio de ");
	} else if (mmes == 5) {
		document.write("junho de ");
	} else if (mmes == 6) {
		document.write("julho de ");
	} else if (mmes == 7) {
		document.write("agosto de ");
	} else if (mmes == 8) {
		document.write("setembro de ");
	} else if (mmes == 9) {
		document.write("outubro de ");
	} else if (mmes == 10) {
		document.write("novembro de ");
	} else if (mmes == 11) {
		document.write("dezembro de ");
	}
	document.write(mano);
}
// DATA - FIM
function mudaLabel(obj,name){
	//alert('oi');
	//alert(obj.id);
	//alert(document.getElementById(name).style.display);
	if (document.getElementById(name).style.display=="block"){
		obj.innerHTML="Mostrar";
		document.getElementById(name).style.display="none";
	}
	else{
		obj.innerHTML="Oculta";
		document.getElementById(name).style.display="block";
	}
}

function exibeImagem(url){
	//document.getElementById('lblImagemGrande').innerHTML = "<image src='" + url + "' width='180' height='180'>";
	document.getElementById("imgGrande").src=url;
}

function marcaEstrela(obj, num){
	alert(num);
	for (x=0;x<5;x++){
		obj[x].checked=false;
	}
	obj[num-1].checked=true;
}

function verificaData(field){
	var checkstr = "0123456789";
	var DateField = field;
	var Datevalue = "";
	var DateTemp = "";
	var seperator = "/";
	var day;
	var month;
	var year;
	var leap = 0;
	var err = 0;
	var i;
	err = 0;
	
	DateValue = DateField.value;
	
	/* Delete all chars except 0..9 */
	for (i = 0; i < DateValue.length; i++)
	{
    	if (checkstr.indexOf(DateValue.substr(i,1)) >= 0){   
			DateTemp = DateTemp + DateValue.substr(i,1);
		}
		else{ //Converte data d/m/yyyy para dd/mm/yyyy
			if (DateTemp.length==1) DateTemp='0'+DateTemp;
			else if (DateTemp.length==3) DateTemp=DateTemp.substr(0,2)+'0'+DateTemp.substr(2,1);
		}
	}

	DateValue = DateTemp;

	/* Always change date to 8 digits - string*/
	/* if year is entered as 2-digit / always assume 20xx */
	if (DateValue.length == 6){
		DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2);
	}
	if (DateValue.length != 8){
		err = 19;
	}
		
	/* year is wrong if year = 0000 */
	year = DateValue.substr(4,4);
	if ((year == 0) || (year < 1900)){
		err = 20;
	}
	
	/* Validation of month*/
	month = DateValue.substr(2,2);
	if ((month < 1) || (month > 12)){
		err = 21;
	}
	
	/* Validation of day*/
	day = DateValue.substr(0,2);
	if (day < 1){
		err = 22;
	}
	
	/* Validation leap-year / february / day */
	if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
		leap = 1;
	}
	if ((month == 2) && (leap == 1) && (day > 29)) {
		err = 23;
	}
	if ((month == 2) && (leap != 1) && (day > 28)) {
		err = 24;
	}
		
	/* Validation of other months */
	if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
		err = 25;
	}
	if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
		err = 26;
	}
	
	/* if 00 ist entered, no error, deleting the entry */
	if ((day == 0) && (month == 0) && (year == 00)){
		err = 0; day = ""; month = ""; year = ""; seperator = "";
	}
	
	/* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
	
	if 	(DateValue=='' || DateValue=='00000000'){
		err = 27;
	}

	if (err == 0) {
		DateField.value = day + seperator + month + seperator + year;
	}
	/* Error-message if err != 0 */
	else{
		alert("A data está incorreta, favor verificar novamente.");
		DateField.select();
		DateField.focus();
		return false;
	}
	return true;	
}

function popup(theURL, width, height, features) { 
	if(window.screen){
		per_ancho=(width/screen.width)*100;
		per_alto=(height/width)*100;
		win_ancho=(screen.width*per_ancho)/100;
		win_alto=(win_ancho*per_alto)/100;
		x=(screen.width-win_ancho)/2;
		y=(screen.height-win_alto)/2;
	}else{
		x=0;
		y=0;
		win_ancho=w;
		win_alto=y;
	}
	winfeatures=("top="+y+",left="+x+",width="+win_ancho+",height="+win_alto+","+features);
	window.open(theURL, 'popup', winfeatures);
}
//FLASH
function flash(versao, largura, altura, nome, modo, cor)
{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="'+versao+',0,0,0" width="'+largura+'" height="'+altura+'>\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="'+nome+'" />\n');
	document.write('<param name="wmode" value="'+modo+'" />\n');
	document.write('<param name="bgcolor" value="'+cor+'" />\n');
	document.write('<embed src="'+nome+'" wmode="'+modo+'" bgcolor="'+cor+'" width="'+largura+'" height="'+altura+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>\n');
}
/*
versao = 8 .................. <- Versão do player
largura = 200px ............. <- Largura do SWF
altura = 200px .............. <- Altura do SWF
nome = arquivo.swf .......... <- Caminho do SWF, essa opção não pode ser vazia
modo = transparent/opaque ... <- Flash transparente ou opaco / pode ser vazia
cor = #ffffff ............... <- Cor de fundo
*/


function HabDesParcelas(valor){
    if (valor=="h"){
        document.getElementById("ddlParcelasAmex").disabled=false;
    }
    else{
        document.getElementById("ddlParcelasAmex").disabled=true;
    }
}