﻿// JScript File
/*----------------------------------------------+
| Projeto:   SiteBasico (Beez)                  |
| Autor:     Edvin Markstein Zimmermann         |
| Criado em: Março/2009                         |
| Versao:    1.20090301                         |
| Descricao: Funcoes auxiliares genericas       |
| Linguagem: JavaScript                         |
+-----------------------------------------------+
+---------------------------------------------------------------------------------------------------------------+
+---------------------------------------------------------------------------------------------------------------+
|          I N D I C E      D E      F U N C O E S      -     O R D E M       A L F A B E T  I C A              |
+---------------------------------------------------------------------------------------------------------------+
+---------------------------------------------------------------------------------------------------------------+
|	jAguarde( lHidden, sMessage )
|		- cria um layer com uma imagem com a informacao "aguarde"
+---------------------------------------------------------------------------------------------------------------+
|	jAjax( )
|		- cria objeto para conexão
+---------------------------------------------------------------------------------------------------------------+
|	jCalendarClose( sId )
|		- Fecha um objeto tipo calendario criado pela funcao jGenerateCalendar
+---------------------------------------------------------------------------------------------------------------+
|	jCheckRadio( oFrm )
|		- Verifica se um radio de um formulario foi checado
+---------------------------------------------------------------------------------------------------------------+
|	jCreateCalendar( sId, sFocus )
|		-cria um calendario
+---------------------------------------------------------------------------------------------------------------+
|	jEditorBold( oEditor )
|		-editor HTML - negrito
+---------------------------------------------------------------------------------------------------------------+
|	jEditorCopyToText( oEditor , sEditorText )
|		-editor HTML - copia do iframe do editor para um campo tipo text
+---------------------------------------------------------------------------------------------------------------+
|	jEditorItalic( oEditor )
|		-editor HTML - itálico
+---------------------------------------------------------------------------------------------------------------+
|	jEditorListBullets(oEditor )
|		-editor HTML - lista com marcadores
+---------------------------------------------------------------------------------------------------------------+
|	jEditorListNumbers( oEditor )
|		-editor HTML - lista com números
+---------------------------------------------------------------------------------------------------------------+
|	jEditorUnderline( oEditor )
|		-editor HTML - sublinhado
+---------------------------------------------------------------------------------------------------------------+
|	jGebi( sName )
|		- Retorna um objeto do documento
+---------------------------------------------------------------------------------------------------------------+
|	jGenerateCalendar( sId, sFocus, iAno, iMes, iDia, sEstiloBorda, sEstiloTopo, sEstiloFundo, sEstiloDia, sEstiloDiaHoje, sEstiloFonte )
|		- Desenha um calendario
+---------------------------------------------------------------------------------------------------------------+
|	jGetAbsPosition( oObj )
|		- Recupera a posição de um objeto (x e y)
+---------------------------------------------------------------------------------------------------------------+
|	jGetRadio( oFrm )
|		- Recupera um valor de um radio de um formulario
+---------------------------------------------------------------------------------------------------------------+
|	jHSCalend( cDia , cMes , cAno , cIdDiv, sFocus )
|		- Recebe a data selecionada pelo objeto criado pela funcao jGenerateCalendar e envia para funcao javascript ou objeto de um formulario                                                   |
+---------------------------------------------------------------------------------------------------------------+
|	jIsBrowseIE()
|		- Informa se um browse e Internet Explorer ou outro tipo (true ou false)
+---------------------------------------------------------------------------------------------------------------+
|	function jIsEmail(campo)
|		- valida um e-mail
+---------------------------------------------------------------------------------------------------------------+
|	jIsNumero( oObj )
|		- permite digitar apenas numeros
+---------------------------------------------------------------------------------------------------------------+
|	jPopup( sUrl, sNome , nLargura , nAltura , bScroll )
|		- Cria uma instancia do navegador do tipo popup, centralizado na tela
+---------------------------------------------------------------------------------------------------------------+
|	jResizePopup( nLargura , nAltura )
|		- Redimensiona um popup (ou uma janela)) e centraliza na tela
+---------------------------------------------------------------------------------------------------------------+
|	jStringToDate( sDate )
|		- Transforma uma data escrita no tipo string num objeto do tipo date
+---------------------------------------------------------------------------------------------------------------+
|	jValidaCaracteres( sLista , sValor )
|		- Valida apenas digitacao de caracteres informados (onformado em slista)
+--------------------------------------------------------------------------------------------------------------*/

//////////////////////////////////////////////////////////////////////////////
//VARIÁVEIS PARA TODOS OS SCRIPTS
	oImgAguarde = new Image();
	oImgAguarde.src = "img/loading.gif";

//////////////////////////////////////////////////////////////////////////////
function jAguarde( lHidden, sMessage )
{
	if(document.getElementById("layerAguarde") == null)
	{
		oDiv = document.createElement("DIV");
		oDiv.id = "layerAguarde";
		oDiv.style.position = "absolute";
		oDiv.style.left = "0px";
		oDiv.style.top = "0px";
		oDiv.style.width = "100%";
		oDiv.style.height = "100%";
		oDiv.style.zIndex = 1;
		oDiv.style.visibility = "hidden";
		document.body.appendChild(oDiv);

		sHtml = '<table class="transparente" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">';
		sHtml += '<tr>';
		sHtml += '<td align="center" valign="middle">';
		sHtml += '<table width="100" height="100" class="EMZAguarde" style="background-color: #FFFFFF; border: 1px solid #000000;">';
		sHtml += '<tr>';
		sHtml += '<td>';
		sHtml += '<p>';
		sHtml += '<img src="img/loading.gif"><br>';
		sHtml += sMessage == null ? 'aguarde...' : sMessage;
		sHtml += '</p>'
		sHtml += '</td>';
		sHtml += '</tr>';
		sHtml += '</table>';
		sHtml += '</td>';
		sHtml += '</tr>';
		sHtml += '</table>';
		oDiv.innerHTML = sHtml;
	}
	oLayer = document.getElementById("layerAguarde");	
	oLayer.style.visibility = (lHidden ? "hidden" : "visible" );
	//Posicionando...
	oLayer.style.top = f_scrollTop() + "px";
	return;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel))){
		n_result = n_docel;
	}
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

function jAjax(){
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}catch (e){
		// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){
				sAjaxMsg = "Seu navegador não suporta AJAX!";
				return false;
			}
		}
	}
	return true;
}

//////////////////////////////////////////////////////////////////////////////
function jCalendarClose( cIdDiv )
{
	//FECHA LAYER
	//var oObj = document.getElementById( cIdDiv + "Calend" );
	var oObj = document.getElementById( "Calendario" );
	document.body.removeChild(oObj);
	
	//oObj = document.getElementById( "ifr_" + cIdDiv );
	oObj = document.getElementById( "ifr_Calendario" );
	document.body.removeChild(oObj);

	return;
}
//////////////////////////////////////////////////////////////////////////////

function jCheckRadio( oFrm )
{
	lRet = false
	for( var npos=0;npos<oFrm.elements.length; npos++ ){
		if(oFrm.elements[npos].type=='radio'){
			if ( oFrm.elements[npos].checked ){
				lRet = true
			} 
		} 
	} 
	return lRet;
}

//////////////////////////////////////////////////////////////////////////////
function jGebi( sName )
{
	return document.getElementById(sName);
}

//////////////////////////////////////////////////////////////////////////////
function jCreateCalendar( sId, sFocus )
{
	jGenerateCalendar( sId , sFocus )
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jEditorBold( oEditor ){
	oEditor.document.execCommand('bold', false, null);
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jEditorCopyToText( oEditor , sEditorText )
{
	oEditor = frames.txtEditorHTML;
	oValorEditor = document.getElementById( sEditorText );
	oValorEditor.value = oEditor.document.body.innerHTML;
	oValorEditor.value = oValorEditor.value == "<P>&nbsp;</P>" ? "" : oValorEditor.value;
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jEditorItalic( oEditor ){
	oEditor.document.execCommand('italic', false, null);
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jEditorListBullets(oEditor ){
	oEditor.document.execCommand('insertunorderedlist', false, null);
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jEditorLink( oEditor ){
    if( prompt("Informe o link") ){
    }
    oEditor.document.execCommand('insertunorderedlist', false, null);
    return;

    
    function getEl(sTag,start){
        while ((start!=null) && (start.tagName!=sTag))
            start = start.parentElement;
        return start;
    }
    
    var isA = getEl("A",textEdit.document.selection.createRange().parentElement())
var str=prompt("Para qual URL você quer criar o link? (ex.: http:\/\/www.nome.com.br\/)",isA ? isA.href : "http:\/\/")
if ((str!=null) && (str!="http://")) {
if ((textEdit.document.selection.type=="None") && (!isA)) {
var strNome=prompt("Que texto você quer que seja o link?",isA ? isA.href : "texto")
var sel=textEdit.document.selection.createRange()
sel.pasteHTML("<A HREF=\""+str+"\">"+strNome+"</A> ")
sel.select()
}
else
doFormat("CreateLink",str)
}
else
textEdit.focus()
}

//////////////////////////////////////////////////////////////////////////////
function jEditorListNumbers( oEditor ){
	oEditor.document.execCommand('insertorderedlist', false, null);
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jEditorUnderline( oEditor ){
	oEditor.document.execCommand('underline', false, null);
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jGenerateCalendar( sId, sFocus, iAno, iMes, iDia, sEstiloBorda , sEstiloTopo , sEstiloFundo , sEstiloDia , sEstiloDiaHoje, sEstiloFonte )
{
	//VALORES PADRÃO PARA CALENDARIO
	iAno = (iAno != null ? iAno : 0 );
	iMes = (iMes != null ? iMes : 0 );
	iDia = (iDia != null ? iDia : 0 );
	sEstiloBorda = (sEstiloBorda != null ? sEstiloBorda : "calendarioBorda");
	sEstiloTopo = (sEstiloTopo != null ? sEstiloTopo : "agendaSemanaTitulo");
	sEstiloFundo = (sEstiloFundo != null ? sEstiloFundo : "calendarioFundo");
	sEstiloDia = (sEstiloFundo != null ? sEstiloFundo : "calendarioMes");
	sEstiloDiaHoje = (sEstiloDiaHoje != null ? sEstiloDiaHoje : "calendarioHoje");
	sEstiloFonte = (sEstiloFonte != null ? sEstiloFonte : "calendarioDias");

	//Encontrando posicao da imagem/link
	var oObj = document.getElementById(sId);

	//var oDiv = document.getElementById(sId + "Calend");
	//var oIfrm = document.getElementById("ifr_" + sId);

	var oDiv = document.getElementById("Calendario");
	var oIfrm = document.getElementById("ifr_Calendario");

	if( oDiv != null ){
		document.body.removeChild(oDiv);
    }
	if( oIfrm != null ){
		document.body.removeChild(oIfrm);
    }


//	if ( oDiv == null )
//	{
		oIfrm = document.createElement( "IFRAME" );
		oIfrm.id = "ifr_" + sId;
		oIfrm.scrolling = 'no';
		oIfrm.frameborder = '0';
		oIfrm.style.position = "absolute";
		oIfrm.style.top = "0px";
		oIfrm.style.left = "0px";
		oIfrm.style.width = "0px";
		oIfrm.style.height = "0px";
		oIfrm.style.visibility = "hidden";
		document.body.appendChild(oIfrm);
		oDiv = document.createElement("DIV");
		document.body.appendChild(oDiv);
		oDiv.id = "Calendario";
		//oDiv.id = sId + "Calend";
		oDiv.style.position = "absolute";
		oDiv.style.width= "201px";
		oDiv.style.height= "125px";
//	}
	if( iAno == 0 && iMes == 0 && iDia == 0 )
	{
		var dData = new Date();
		iAno = ( jIsBrowseIE() ) ? dData.getYear() : eval(dData.getFullYear().toString());
		iMes = dData.getMonth();
		iDia = dData.getDate();
	}
	else
		var dData = new Date( iAno, iMes, iDia );

	var dDataHoje = new Date();
	var iAnoHoje  = ( jIsBrowseIE() ) ? dDataHoje.getYear() : eval(dDataHoje.getFullYear().toString());
	var iMesHoje  = dDataHoje.getMonth();
	
	var iNAno = 0;
	var iNMes = 0;
	var iPAno = 0;
	var iPMes = 0;

	if( iMes == 0 )
	{	
		iNAno = iAno;
		iNMes = 1;
		iPAno = iAno-1;
		iPMes = 11;
	}
	else if( iMes == 11 )
	{
		iNAno = iAno+1;
		iNMes = 0;
		iPAno = iAno;
		iPMes = 10;
	}
	else
	{
		iNAno = iAno;
		iNMes = iMes+1;
		iPAno = iAno;
		iPMes = iMes-1;
	}

	var aMeses 	   = [ "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" ];
	var DiasPorMes = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
	
	var Ano  = eval(dData.getFullYear().toString());
	var Hoje = dData.getDate();

	if( ( (Ano % 4 == 0) && (Ano % 100 != 0) ) || (Ano % 400 == 0) )
		DiasPorMes[ 1 ] = 29; 

	NDias = DiasPorMes[ dData.getMonth() ];

	TmpData = dData;
	TmpData.setDate(1);
	PrimDia = TmpData.getDay();
	
	var sRet = "";

	//cabeçalho
	sRet += "<link href='css/calendario.css' rel='stylesheet' type='text/css'>";

	sRet += "<table width='200' class='calendarioBorda' cellspacing='0' cellpadding='0' >";
	sRet += "<tr>";
	sRet += "<td>";
    sRet += "<table width='100%' border='0' align='center' cellspacing='1' cellpadding='1' class='" + sEstiloTopo + "'>";
	sRet += "<tr align='center'>" ;
	sRet += "<td width='50' align='left'><a class='" + sEstiloTopo + "' href='javascript:jGenerateCalendar( \"" + sId + "\" , \"" + sFocus + "\" , " + iPAno + " , " + iPMes + " , " + iDia + " )'><img src='img/icons/resultset_previous.png' alt='mês anterior' border='0' align='middle'></a></td>";
	sRet += "<td >" + aMeses[ dData.getMonth() ] + " " + Ano + "</td>";
	sRet += "<td width='50' align='right'>";
	sRet += "<a class='" + sEstiloTopo + "' href='#' onclick='jCalendarClose(\"" + sId + "\")'><img src='img/icons/cross.png' alt='fechar calendário' width='16' height='16' border='0' align='middle'></a>";
	sRet += " <a class='" + sEstiloTopo + "' href='javascript:jGenerateCalendar( \"" + sId + "\" , \"" + sFocus + "\" , " + iNAno + " , " + iNMes + " , " + iDia + " )'><img src='img/icons/resultset_next.png' alt='próximo mês' border='0' align='middle'></a>";
	sRet += "</td>";
	sRet += "</tr></table>";
	//corpo
	sRet += "<table width='200' border='0' align='center' class='" + sEstiloFundo + "'><tr align='center' class='calendarioDias'>";
		//dias da semana
	sRet += "<td width='20'><b>D</b></td>";
	sRet += "<td width='20'><b>S</b></td>";
	sRet += "<td width='20'><b>T</b></td>";
	sRet += "<td width='20'><b>Q</b></td>";
	sRet += "<td width='20'><b>Q</b></td>";
	sRet += "<td width='20'><b>S</b></td>";
	sRet += "<td width='20'><b>S</b></td>";
	sRet += "</tr>";
	// Celulas em branco
	var coluna = 0;
	var totalDias = 1;
	var fimDias = 1;
	for (var i = 0; i < 6; i++)
	{
		sRet += "<tr align='center'>";
		
		for(var x = 0; x < 7; x++)
		{
			if ( i == 0 && x < PrimDia) {
				if (iMes == 0)
					sRet += "<td class='" + sEstiloFonte + "'><a href='javascript:jHSCalend( " + '"' + (DiasPorMes[11] - PrimDia + x) + '"' + ' , "' + (iPMes+1) + '"' + ' , "' + iPAno + '" , ' + '"' + sId + '"' + ", " + '"' + sFocus + '"' + " )' class='" + sEstiloFonte + "'>" + (DiasPorMes[11] - PrimDia + x) + "</a></td>";
				else
					sRet += "<td class='" + sEstiloFonte + "'><a href='javascript:jHSCalend( " + '"' + (DiasPorMes[11] - PrimDia + x) + '"' + ' , "' + (iPMes+1) + '"' + ' , "' + iPAno + '" , ' + '"' + sId + '"' + ", " + '"' + sFocus + '"' + " )' class='" + sEstiloFonte + "'>" + (DiasPorMes[iMes-1] - PrimDia + x) + "</a></td>";
				continue;
			}
			else if ( totalDias > DiasPorMes[iMes] )
			{
				sRet += "<td class='" + sEstiloFonte + "'><a href='javascript:jHSCalend( " + '"' + fimDias + '"' + ' , "' + (iNMes+1) + '"' + ' , "' + iNAno + '" , ' + '"' + sId + '"' + ", " + '"' + sFocus + '"' + " )' class='" + sEstiloFonte + "'>" + (fimDias++) + "</a></td>";
				continue;				
			}
			
			if( totalDias == Hoje && iMesHoje == iMes && iAnoHoje == iAno )
				sRet += "<td class='" + sEstiloDiaHoje + "'><a href='javascript:jHSCalend( " + '"' + totalDias + '"' + ' , "' + (iMes+1) + '"' + ' , "' + iAno + '" , ' + '"' + sId + '"' + ", " + '"' + sFocus + '"' + " )' class='" + sEstiloFonte + "'>" + totalDias + "</a></td>"; //dia corrente
			else
				sRet += "<td class='" + sEstiloDia + "'><a href='javascript:jHSCalend( " + '"' + totalDias + '"' + ' , "' + (iMes+1) + '"' + ' , "' + iAno + '" , ' + '"' + sId + '"' + ", " + '"' + sFocus + '"' + " )' class='" + sEstiloFonte + "'>" + totalDias + "</a></td>"; //outros dias

			totalDias++;
		}
		
		sRet += "</tr>";
	}
	sRet += "</table>";

	sRet += "</tr>";
	sRet += "</td>";
	sRet += "</table>";

	oPosition = jGetAbsPosition(oObj);
	iTop = oPosition.Top;
	iLeft = oPosition.Left;

	oDiv.style.top   = iTop + "px";
	oDiv.style.left  = iLeft + "px";
	oDiv.style.zIndex = "2";

	oIfrm.style.top = iTop + "px";
	oIfrm.style.left = iLeft + "px";
	oIfrm.style.zIndex = "1";

	oDiv.innerHTML = sRet;
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jGetAbsPosition( oObj ) {
	var position = new Object;
	position.Left = 0;
	position.Top = 0;
	if( oObj ) {
		position.Left = oObj.offsetLeft;
		position.Top = oObj.offsetTop;
		if( oObj.offsetParent ) {
			var parentpos = jGetAbsPosition(oObj.offsetParent);
			position.Left += parentpos.Left;//x
			position.Top += parentpos.Top;//y
		}
	}
	return position;
}

//////////////////////////////////////////////////////////////////////////////
function jGetRadio( oFrm )
{
	for( var npos=0;npos<oFrm.elements.length; npos++ ){
		if(oFrm.elements[npos].type=='radio'){
			if ( oFrm.elements[npos].checked ){
				return oFrm.elements[npos].value;
			} 
		} 
	} 
	return null;
}

//////////////////////////////////////////////////////////////////////////////
function jHSCalend( cDia , cMes , cAno , cIdDiv, sFocus )
{
	var myFunc
	var cMyDia
	var cMyMes

	//TRATANDO A DATA (ACRESCENTANDO 0)
	cMyDia = (cDia.length == 1)? "0" + cDia : cDia;
	cMyMes = (cMes.length == 1)? "0" + cMes : cMes;
	//criando variável para "macroexecutar"
	var sData = cMyDia + "/" + cMyMes + "/" + cAno

	//FECHA LAYER
//	var oObj = document.getElementById( cIdDiv + "Calend" );
    var oObj = document.getElementById( "Calendario" );
	document.body.removeChild(oObj);
	
//	oObj = document.getElementById( "ifr_" + cIdDiv );
//    oObj = document.getElementById( "ifr_Calendario" );
//	document.body.removeChild(oObj);

	//VERIFICA SE E UMA FUNCAO OU UM INPUT
	iPos = sFocus.indexOf( "()" );
	if( iPos == -1 )
	{
		oFocus = document.getElementById( sFocus );
		oFocus.value = sData;
	}else{
		myFunc = sFocus.substr(0, sFocus.length - 2);
		myFunc = myFunc + "('" + sData + "')";
		eval(myFunc);
		myFunc;
	}
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jIsBrowseIE()
{
	return navigator.appName == "Microsoft Internet Explorer";
}

//////////////////////////////////////////////////////////////////////////////
function jIsEmail(campo) {
	if(campo.value == "")
	{
		alert("Preencha o campo e-mail");
		campo.focus();
		return false;
	}
	var iAt = campo.value.indexOf('@');
	var iPoint = 0;
	for(i = 0; i < campo.value.length;i++ )
	{
		if(campo.value.substr(i,1) == ".")
		iPoint = i;
	}
	if(iAt<0 || iPoint < 0 || iPoint < iAt)
	{
		alert("Preencha o campo com um e-mail válido.")
		campo.focus();		
		return false;
	}
	if(iPoint >= (campo.value.length - 1))
	{
		alert("Preencha o campo com um e-mail válido.")
		campo.focus();		
		return false;
	}
	return true;
}

//////////////////////////////////////////////////////////////////////////////
function jIsNumero( oObj )
{
	sValor = oObj.value.substring(oObj.value.length-1);
	if(!jValidaCaracteres( '0123456789' , sValor ))
	{
		oObj.value = oObj.value.substr(0,oObj.value.length-1);
	}
	return
}

//////////////////////////////////////////////////////////////////////////////
function jPopup( sUrl, sNome , nLargura , nAltura , bScroll )
{
	if (!jIsBrowseIE())
	{
		nAltura += 16;
		nLargura += 15;
	}
	var winl = (screen.width - nLargura) / 2;
	var wint = (screen.height - nAltura) / 2;
	var sScroll = 'yes';
	window.open( sUrl,'PMS_' + sNome , 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + sScroll + ',resizable=yes,width=' + nLargura + ',height=' + nAltura + ',top=' + wint + ',left=' + winl );
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jResizePopup( nLargura , nAltura )
{
	this.resizeTo( nLargura , nAltura );
	if (!jIsBrowseIE())
	{
		nLargura = ((screen.width - nLargura + 16)) / 2;
		nAltura = ((screen.height  - nAltura + 16)) / 2;
	}else{
		nLargura = (screen.width - nLargura) / 2;
		nAltura = (screen.height  - nAltura) / 2;
	}
	this.moveTo(nLargura , nAltura)
	return;
}

//////////////////////////////////////////////////////////////////////////////
function jStringToDate(sDate)
{
	iDia = eval(sDate.substr(0,2));
	iMes = eval(sDate.substr(3,2)) - 1;
	iAno = eval(sDate.substr(6,4));
	return new Date( iAno, iMes, iDia );
}

//////////////////////////////////////////////////////////////////////////////
function jValidaCaracteres( sLista , sValor )
{
	iSize = sValor.length;
	for(i = 0 ; i < iSize ; i++)
	{
		if(sLista.indexOf( sValor.substr(i,1)) == -1 )
			return false;
	}
	return true;
}
