////// FUNCION PARA MOSTRAR LAS CAPAS LENTAMENTE ////////
var alturaMaxima=0;//datos originales 401
var velocidad=25; //pixels por vez. alturaMaxima-cantidad tiene que ser múltiplo de velocidad.   20
var espera=20; //Tiempo de espera entre cada movimiento  100
var anchura=200;	

var prorrata=anchura/alturaMaxima;
var cantidad=1;	
var cantidad2=1;
var num_enter=0,keypress=null;

function deslizar(esto,divs,altura)
{
	alturaMaxima=altura;
	div=document.getElementById(esto);
	
	if((alturaMaxima-cantidad)%25)
		alturaMaxima+=25-((alturaMaxima-cantidad)%25);// para cumplir la regla: alturaMaxima-cantidad tiene que ser múltiplo de velocidad.
	
	var clase="titulos2";
	
	if(document.getElementById(divs).className!=clase)
	{
		document.getElementById(divs).className=clase;
	}
	else
	{
		document.getElementById(divs).className='titulos';
		cantidad=alturaMaxima;
	}
	
	if(document.getElementById('conocimiento').style.height!='' && document.getElementById('conocimiento').style.height!='1px' && esto!='conocimiento')
	{
		document.getElementById('conocimiento').style.height="1px";
		cantidad=1;
	}
	
	if(document.getElementById('habilidades').style.height!='' && document.getElementById('habilidades').style.height!='1px' && esto!='habilidades')
	{
		document.getElementById('habilidades').style.height="1px";
		cantidad = 1;
	}
	if(document.getElementById('actitud').style.height!='' && document.getElementById('actitud').style.height!='1px' && esto!='actitud')
	{
		document.getElementById('actitud').style.height="1px";
		cantidad = 1;
	}
	
	mostrar(esto);
}

function mostrar(pe)
{	
	if(cantidad==1 || cantidad==alturaMaxima)
	{
		incremento=(cantidad==1) ? velocidad : -velocidad;
		tope=(cantidad==1) ? alturaMaxima : 1;
	}	
	es=document.getElementById(pe);
	
	cantidad+=incremento;
	es.style.height=cantidad+"px";
	//es.style.width=parseInt(prorrata*cantidad)+"px"; PARA ANCHO LO DEJE EL QUE SE LE PONE PREDETERMINADO
	
	if(cantidad!=tope)
	{
		setTimeout("mostrar('"+pe+"')",espera);
	}
}

function email(s) 
{
  // Remove leading spaces and carriage returns
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }
  // Remove trailing spaces and carriage returns
  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function valtelefono(f)
{
	var key;
	if (navigator.appName == "Netscape")//código te tecla netscape
		key=f.which;
	else                                //IE
	key=f.keyCode;
	if ((key>46)&&(key<58))//valida que este entre el rango del 0-9
		return true;
	else//si no son numeros valida que sea el guion, y si no retorna un false
		if(key==8||key==0||key==45)
			return true;
		else
			return false;
}

function valnumeros(f)
{
	var key;
	if (navigator.appName == "Netscape")//código te tecla netscape
		key=f.which;
	else                                //IE
	key=f.keyCode;
	if ((key>47)&&(key<58))//valida que este entre el rango del 0-9
		return true;
	else//si no son numeros valida que sea el guion, y si no retorna un false
		if(key==8||key==0)
			return true;
		else
			return false;
}

function calendario(campo,boton)
{
	Zapatec.Calendar.setup({
        firstDay          : 1,
        step              : 1,
        weekNumbers       : true,
        electric          : false,
        inputField        : campo,//ID edit
        button            : boton,//ID boton
        ifFormat          : "%d/%m/%Y",
        daFormat          : "%d/%m/%Y"
      });
}


//--------------------------------------------------------------------------
function redireccionAuto(dir)
{
  relojRegresivo();
  setTimeout("redireccion('"+dir+"')",5000);
  return;
}
function redireccion(dir)
{
  
  if(dir=='')
  dir='./';
  
  document.location.href=dir;
}

SegundosTotal='06'
function relojRegresivo()//función de segundero
{ 
	/* Capturamos los Segundos */ 
	Segundos = parseFloat(SegundosTotal);
	
	/*temenos que ir descontando cada segundo*/
	Segundos=Segundos-1
	
	/* Si la Hora, los Minutos o los Segundos 
	Son Menores o igual a 9, le añadimos un 0 */ 
	if (Segundos<=9) 
	Segundos = "0" + Segundos 
	
	SegundosTotal=Segundos
	
	document.getElementById('RelojRegresivo').innerHTML = SegundosTotal 
	
	/* Indicamos que nos refresque el Reloj cada 1 segundo */ 
	setTimeout("relojRegresivo()",1000) 
} 
//--------------------------------------------------------------------------------


mascarauniversal = function(f, m){
	function mask(e){
		var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
			rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
		function accept(c, rule){
			for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
				if(r & i && patterns[i].test(c))
					break;
				return i <= r || c == rule;
		}
		var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
		(!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
			r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
			: (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
			r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
	}
	for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
		addEvent(f, i, mask);
};




addEvent = function(o, e, f, s)
{
var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
r[r.length] = [f, s || o], o[e] = function(e){
try{
(e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
e.target || (e.target = e.srcElement || null);
e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
}catch(f){}
for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
return e = null, !!d;
}
};

removeEvent = function(o, e, f, s){
for(var i = (e = o["_on" + e] || []).length; i;)
if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
return delete e[i];
return false;
};


//CANTIDADES CON COMA
function formatNumber(num,prefix,decimales)
{
    prefix = prefix || ''; //simbolo antes de la cantidad
	decimales = decimales || ''; //si la cantidad no tiene decimales, es la cantidad que pondra por defecto
    num += '';
    var splitStr = num.split('.');
    var splitLeft = splitStr[0];
    var splitRight = splitStr.length > 1 ? '.' + splitStr[1] : decimales;
    var regx = /(\d+)(\d{3})/;
    while (regx.test(splitLeft)) 
	{
    	splitLeft = splitLeft.replace(regx, '$1' + ',' + '$2');
    }
    return prefix + splitLeft + splitRight;
}

function unformatNumber(num) 
{
    return num.replace(/([^0-9\.\-])/g,'')*1;
} 

function formatoPrecio(elemento)
{
	var cadena=elemento.value.split('.');
		
	if(cadena.length>2)//valida que nada mas ponga un punto
	{
		elemento.value=cadena[0]+"."+cadena[1];
		//deja la primera cifra antes del punto	
	}
	
	//alert(elemento.value+' '+cadena[1]);
	if(cadena.length > 1) //determina si la cadena tiene punto o si se acaba de agregar
	{
		if(cadena[1]=='')
		{
			elemento.value = formatNumber(unformatNumber(elemento.value)+'.');
		}
		else
		{
			if(cadena[1]!='0')
			elemento.value = formatNumber(unformatNumber(elemento.value));
		}
	}
	else
	{
		elemento.value=formatNumber(unformatNumber(elemento.value));
	}
}


function validatecla (e, valor)
{
	if (navigator.appName == "Netscape")//código te tecla netscape
	  key=e.which
	else                                //IE
	  key=e.keyCode
	
	keypress=key;
}

function formatomoneda(elemento)//marca de dinero
{
	if (((keypress>45)&&(keypress<58)&&(keypress!=47))||(keypress==13))//valida que este entre el rango del 0-9, sea '.' ó enter
	{
		var cadena=elemento.value.split('.');
		
		if(cadena.length>2)//valida que nada mas ponga un punto
		{
			elemento.value=cadena[0]+"."+cadena[1];
			//deja la primera cifra antes del punto	
		}
		
		//alert(elemento.value+' '+cadena[1]);
		if(cadena.length > 1) //determina si la cadena tiene punto o si se acaba de agregar
		{
			if(cadena[1]=='')
			{
				elemento.value = formatNumber(unformatNumber(elemento.value)+'.');
			}
			else
			{
				if(cadena[1]!='0')
				elemento.value = formatNumber(unformatNumber(elemento.value));
			}
		}
		else
		{
			elemento.value=formatNumber(unformatNumber(elemento.value));
		}
	}
	keypress=null;
}


function validabanner(campo)//verifica que el archivo que se seleccionó en el file sea de la extension correcta
{
	var contenido='',contenido2='';
	var longitud=0;
	
	contenido = campo.value;
	if(contenido!='')
	{
		longitud=parseInt(contenido.length);
		if(longitud>3)
		{
			contenido2=contenido.substring(longitud-3,longitud);
			if((contenido2!='JPG')&&(contenido2!='jpg')&&(contenido2!='swf')&&(contenido2!='SWF')&&(contenido2!='gif')&&(contenido2!='GIF'))
			{
				alert("Formato de archivo incorrecto, sólo *.jpg , *.swf y *.gif");
				campo.value='';
				return;
			}
		}
		else
		{
			alert("Formato de archivo incorrecto, sólo *.jpg , *.swf y *.gif");
			campo.value='';
			return;
		}
	}
	else
		return;
}

function validatemario(campo)//verifica que el archivo que se seleccionó en el file sea de la extension correcta
{
	var contenido='',contenido2='';
	var longitud=0;
	
	contenido=campo.value;
	if(contenido!='')
	{
		longitud=parseInt(contenido.length);
		if(longitud>3)
		{
			contenido2=contenido.substring(longitud-3,longitud);
			if((contenido2!='JPG')&&(contenido2!='jpg')&&(contenido2!='PDF')&&(contenido2!='pdf')&&(contenido2!='GIF')&&(contenido2!='gif'))
			{
				alert("Formato de archivo incorrecto, sólo *.jpg, *.gif  y *.pdf");
				campo.value='';
				return;
			}
		}
		else
		{
			alert("Formato de archivo incorrecto, sólo *.jpg, *.gif  y *.pdf");
			campo.value='';
			return;
		}
	}
	else
		return;
}


function obtieneimagen(extension)
{
	switch(extension)
	{
		case 'pdf':
			return "pdf.gif";
		break;
		case 'txt':
		case 'doc':
		case 'docx':
		case 'TXT':
		case 'DOC':
		case 'DOCX':
		case 'rtf':
			return "doc.gif";
		break;
		case 'xls':
			return "xls.gif";
		break;
		case 'zip':
		case 'rar':
		case 'tar':
		case 'ZIP':
		case 'RAR':
		case 'TAR':
			return "zip.gif";
		break;
		case 'jpg':
		case 'jpeg':
		case 'tif':
		case 'tiff':
		case 'png':
		case 'bmp':
		case 'gif':
		case 'JPG':
		case 'JPEG':
		case 'TIF':
		case 'TIFF':
		case 'PNG':
		case 'BMP':
		case 'GIF':
			return "image.gif";
		break;
		case 'ppt':
		case 'pps':
		case 'PPT':
		case 'PPS':
			return 'ppt.gif';
		break;
		case 'avi':
		case 'ram':
		case 'mpg':
		case 'mov':
		case 'qt':
		case 'mp3':
		case 'aiff':
		case 'aif':
		case 'au':
		case 'wav':
		case 'ra':
		case 'wma':
		case 'midi':
		case 'wmv':
		case 'mpe':
		case 'mpeg':
		case 'AVI':
		case 'RAM':
		case 'MPG':
		case 'MOV':
		case 'QT':
		case 'MP3':
		case 'AIFF':
		case 'AIF':
		case 'AU':
		case 'WAV':
		case 'RA':
		case 'WMA':
		case 'MIDI':
		case 'WMV':
		case 'MPE':
		case 'MPEG':
			return "wmp.gif";
		break;
		default:
			return "default.gif";
		break;
	}
}

function obtieneextension(archivo)
{
	//Obtiene solo el nombre del archivo
	ar = archivo.split(".");
	archivo = ar[ar.length-1];
	return archivo;
}

function obtienenombre(archivo)
{
	//Obtiene solo el nombre del archivo
	ar = archivo.split("\\");
	archivo = ar[ar.length-1];
	return archivo;
}


function aumentahora(thora,tminutos,hhora)//hace la funcion de los botones de sibir y bajar la hora
{
	var hora=0;
	var minutos=0;
	var concatena='0';
	var val='';
	
	if(thora.value=='')
		thora.value='00';
	
	if(tminutos.value=='')
		tminutos.value='00';
	
	if(hhora.value=='1')
	{
		val=thora.value;
		if(val.charAt(0)=='0')
			hora=parseInt(val.charAt(1));
		else
			hora=parseInt(val);
		
		
		hora++;
		if(hora>=24)
		hora=0;
		
		
		if(hora<10)
		{
			concatena+=hora;
			hora=concatena;
			
		}
		
		thora.value=hora;
		thora.select();
	}
	
	if(hhora.value=='2')
	{
		val=tminutos.value;
		if(val.charAt(0)=='0')
			minutos=parseInt(val.charAt(1));
		else
			minutos=parseInt(val);
			
		
		minutos++;
		if(minutos>=60)
		minutos=0;
		
		if(minutos<10)
		{
			concatena+=minutos;
			minutos=concatena;
		}
		
		tminutos.value=minutos;
		tminutos.select();
	}
}

function disminuyehora(thora,tminutos,hhora)//hace la funcion de los botones de sibir y bajar la hora
{
	var hora=0;
	var minutos=0;
	var concatena='0';
	var val='';
	
	if(thora.value=='')
		thora.value='00';
	
	if(tminutos.value=='')
		tminutos.value='00';
	
	if(hhora.value=='1')
	{
		val=thora.value;
		if(val.charAt(0)=='0')
			hora=parseInt(val.charAt(1));
		else
			hora=parseInt(val);
		
		
		hora--;
		if(hora<0)
		hora=23;
		
		
		if(hora<10)
		{
			concatena+=hora;
			hora=concatena;
		}
		
		thora.value=hora;
		thora.select();
	}
	
	if(hhora.value=='2')
	{
		val=tminutos.value;
		if(val.charAt(0)=='0')
			minutos=parseInt(val.charAt(1));
		else
			minutos=parseInt(val);
			
		
		minutos--;
		if(minutos<0)
		minutos=59;
		
		if(minutos<10)
		{
			concatena+=minutos;
			minutos=concatena;
		}
		
		tminutos.value=minutos;
		tminutos.select();
	}
}

function val_hora(hora)
{
	if(parseInt(hora.value)>=24)
	hora.value='23';
	if(hora.value=='')
	hora.value='00';
}

function val_minutos(minutos)
{
	if(parseInt(minutos.value)>=60)
	minutos.value='59';
	if(minutos.value=='')
	minutos.value='00';
}
//--------------------------------------------------------------------------