
var i			= 1;	// contador das imgs (índice)
/*# passa as imagens q estão declaradas na array 'ar_img' */
function slideShow(vc_diretorio){

	if (document.getElementById('slide')) {
		//Recupera no form os valores e monta uma array
		ar_img			= document.getElementById("imagensVC").value.split(",");
		
		if (!document.images.slide) return;	// caso ñ haja imagens, sai da função
		
		document.images.slide.src		= 'imagens/'+vc_diretorio+'/'+ar_img[i];	// insere próxima imagem
		 
		// verifica se chegou no fim das imagens p/ zerar o contador
		if (i < ar_img.length - 1)
			i++;
		else
			i	= 1;
			
		setTimeout("slideShow('"+vc_diretorio+"')",2000);	// muda a foto a cada 3 segundos
	}
}


/*# CONTA CARACTER #*/
function contaCaracter(it_caracter,it_limite,vc_campo) {
	if (vc_campo.value.length > it_limite) {
		vc_campo.value		= vc_campo.value.substring(0,it_limite);
	} else {
		it_caracter.value	= it_limite - vc_campo.value.length;
	}
}


/*# VALIDA E-MAIL [expressão regular] */
function verficaEmail(campo) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(campo)) {
		return	'';
	}
	return '- O E-MAIL digitado é inválido.\n';
}

/*# MASCARA */
function mascarar(vc_campo,vc_mascara) {
	var i		= vc_campo.value.length;
	var x		= vc_mascara.substring(0,1);
	var y		= vc_mascara.substring(i);
	
	if (y.substring(0,1) != x) {
		vc_campo.value += y.substring(0,1);
	}
}

/*# VERIFICA DATA #*/
function verificaData(vc_campo) { 
	if (vc_campo.value.length > 0) {  
		it_dia		= (vc_campo.value.substring(0,2)); 
		it_mes		= (vc_campo.value.substring(3,5)); 
		it_ano		= (vc_campo.value.substring(6,10)); 
		it_erro		= 0; 
		
		if ((it_dia < 01) || (it_dia < 01 || it_dia > 30) && (it_mes == 04 || it_mes == 06 || it_mes == 09 || it_mes == 11 ) || it_dia > 31) { 
			it_erro	= 1; 
		} 

		if (it_mes < 01 || it_mes > 12 ) { 
			it_erro	= 1; 
		} 

		if (it_mes == 2 && (it_dia < 01 || it_dia > 29 || (it_dia > 28 && (parseInt(it_ano / 4) != it_ano / 4)))) { 
			it_erro	= 1; 
		} 

		if ((it_ano < 1900) || (it_ano>2078)){
			it_erro	= 1;
		}
		
		if (it_erro == 1) { 
			alert("Por favor, preencha uma data válida!"); 
			vc_campo.value	= '';
			vc_campo.focus(); 
		}
	} 
}

/*# aceita só números digitados num campo */
function soNumero(evtKeyPress) {
	var nTecla;
	nTecla = (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;
	
	if((nTecla > 47 && nTecla < 58) || nTecla == 8 || nTecla == 9)
		return true;
	else
		return false;
}

/* MÁSCARA PARA TELEFONE */
function MascaraTelefone(obj,evtKeyPress) {

	var nTecla	= (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;

	if(nTecla == 45 || nTecla == 47 || nTecla == 42 || nTecla == 46 || nTecla == 44 || nTecla == 43) 
	{
		return false;
	}	
	if(obj.value.length == 2) {
		obj.value = obj.value + '-';
	} else if (obj.value.length == 7) {
		obj.value = obj.value + '.';	
	}
	
}

/*# TRIM - Função que verifica se há espaços no início e fim de uma string, semelhante ao trim #*/
function trim(vc_string) {
 
  //Remove os espaços do Inicio
  while ((vc_string.substring(0,1) == ' ') || (vc_string.substring(0,1) == '\n') || (vc_string.substring(0,1) == '\r')) {
    vc_string = vc_string.substring(1,vc_string.length);
  }
 
  //Remove os espaços do Final
  while ((vc_string.substring(vc_string.length-1,vc_string.length) == ' ') || (vc_string.substring(vc_string.length-1,vc_string.length) == '\n') || (vc_string.substring(vc_string.length-1,vc_string.length) == '\r')) {
    vc_string = vc_string.substring(0,vc_string.length-1);
  }
 
 return vc_string;
}

/*# iFrame virtual [ crossBrowser ] #*/
function iframeVirtual(vc_url) {
	// pega iframeVirtual pelo ID ou cria um iframeVirtual caso ñ exista
	var tempIFrame = (document.getElementById('iframe_virtual')) ? document.getElementById('iframe_virtual') : document.createElement('iframe');
	
	tempIFrame.style.border		= '0px';
	tempIFrame.style.width		= '0px';
	tempIFrame.style.height		= '0px';
	
	tempIFrame.setAttribute('id','iframe_virtual');
	tempIFrame.setAttribute('name','iframe_virtual');
	tempIFrame.setAttribute('src',vc_url);
	
	IFrameObj		= document.body.appendChild(tempIFrame);
}


/*# Desenvolvido por André Luiz
ToDo				 -> Pega o HTML gerado pelo FCKEditor 
@vc_instancia:String -> Nome da isntancia do FCKEditor

A função retorna uma string c/ o HTmL gerado pelo editor */
function getHTML(vc_instancia) {
	var oEditor  = FCKeditorAPI.GetInstance(vc_instancia);
	return oEditor.GetXHTML();
}

/*# SAIR - Efetua o logoff #*/
function sair(){
	self.location.href	= 'codigos/logoff.asp';
}

/*# AMPLIAR - Abre Popup para ampliação da Imagem #*/
function ampliar(vc_imagem){
	window.open('temp/ampliar.asp?imagemVC='+vc_imagem,'','toolbar=no,directories=no,menubar=no,status=no,scrollbars=no,resizable=no, width=400,height=400,left=200,top=200');
}


/*# VIDEO - Abre Popup para Exibição do Vídeo #*/
function video(vc_arquivo){
	window.open('temp/video.asp?arquivoVC='+vc_arquivo,'','toolbar=no,directories=no,menubar=no,status=no,scrollbars=no,resizable=no, width=314,height=255,left=200,top=200');
}

/*# REPLACE GERAL - Função replace que substitui todos e não só um como a padrão #*/
function replaceGeral(vc_texto, vc_str_1, vc_str_2){
/*----------------------------------------------------  
	vc_texto 	= String onde será procurado o valor
   	vc_str_1 	= Valor que deve ser substituido.
   	vc_str_2 	= Valor por qual deve ser substituido  
------------------------------------------------------*/
	while (vc_texto.indexOf(vc_str_1) > 0){
  	vc_texto = vc_texto.replace(vc_str_1,vc_str_2);
 	}
 
 	return vc_texto;
}

/*# abre popUp */
function popUp(vc_url, W, H,titulo) {
	var W	= (W) ? parseInt(W) : parseInt(window.screen.width * 0.7);
	var H	= (H) ? parseInt(H) : parseInt(window.screen.height * 0.7);
	var X	= Math.ceil((window.screen.height - H) / 2);
	var Y	= Math.ceil((window.screen.width - W) / 2);
	
	window.open(vc_url, 'ap_select', 'width='+W+',height='+H+',top='+X+',left='+Y+',location=no,status=yes,menubar=no,scrollbars=no,resizable=no,directories=no,toolbar=no').focus();
}

function fecharFloater()
{
	document.getElementById('floater').style.display = 'none';	
}