function Asignar(valor,destino){
	var destino;
	document.getElementById(destino).value = valor;
}

function submit(){
	
	document.form2.submit();
}


function GoToUrl(url,id,forma,destino){
	if(id!=""){
		 document.getElementById(destino).value = id;
	}
	var forma;
	document.getElementById(forma).action = url;
	document.getElementById(forma).submit();
}

function Ventana(url,video){
	window.open(url,'Video','width= 400 ,height= 450');
}

function Presentation(url,video){
	window.open(url,'Video','width= 850 ,height= 700, resizable=1,location=0');
}


	/************************SELECCIONAR TODOS LOS CHECKBOX DE UN FORM**************/
function seleccion(form)
{
	if(document.getElementById('todos').checked==true)
		seleccionar_todo(form);
	if(document.getElementById('todos').checked==false)
		deseleccionar_todo(form);
}

function seleccionar_todo(form){ 
   for (i=0;i<document.form1.elements.length;i++) 
      if(document.form1.elements[i].type == "checkbox" && document.form1.elements[i].id != "todos") 
         document.form1.elements[i].checked=1 
} 
function deseleccionar_todo(form){ 
   for (i=0;i<document.form1.elements.length;i++) 
      if(document.form1.elements[i].type == "checkbox"  && document.form1.elements[i].id != "todos") 
         document.form1.elements[i].checked=0
} 
	
	
	/************************* Funciones para validar los campos de texto **************************/
	
	function esNumero(e){//valida que sean numeros enteros y  decimales
		var ascii;
		if(navigator.appName == "Netscape")	//Esto sirve por si estoy usando Firefox o Explorer
			ascii = e.which;		//Para leer el código de la tecla que se presiono
		else
			ascii = e.keyCode;		//Lo mismo que WHICH
		status = ascii
		if(ascii > 31 && (ascii < 48 || ascii > 57) && ascii != 46){	//Esto sirve para comparar que la tecla presionada sea un número
			alert("Este campo solo acepta números.");
			return false;
		}else{
			return true;
		}
	}

	function esNumEnt(e,campo){//valida que los numeros sean enteros
		var ascii;
		if(navigator.appName == "Netscape")	//Esto sirve por si estoy usando Firefox o Explorer
			ascii = e.which;		//Para leer el código de la tecla que se presiono
		else
			ascii = e.keyCode;		//Lo mismo que WHICH
		status = ascii
		if(ascii > 31 && (ascii < 48 || ascii > 57)){	//Esto sirve para comparar que la tecla presionada sea un número
			alert("Este campo solo acepta números enteros.");
			campo.value="";
			return false;
		}else{
			return true;
		}
	}
	
function Disable(objeto){
	 var a=document.getElementById(objeto);
  	a.checked = false;	
}
/*****mostrar y ocultar divs ***/
function mostrar(div)//muestra seccion de plan b
{
	 var a=document.getElementById(div);
  	a.style.visibility='visible';
	a.style.display='block';
	
}
function ocultar(div)//oculta seccion de plan b
{
  var a=document.getElementById(div);
  a.style.visibility='hidden';	
  a.style.display='none';
}

function ConvertirMayus(campo)
{
	var Primera;
	var Resto = campo.value;
	Primera =Resto.substr(0,1);	
	Primera = Primera.toUpperCase();
	Resto = Resto.substr(1);
	Resto = Resto.toLowerCase();
	campo.value = Primera + Resto;
	
}
function Mayusculas(campo)
{
	
	campo.value = campo.value.toUpperCase();
	
}

/**** VALIDAR MAIL DE CORREO *****/
function ValidaEmail(email){
  invalidChars=" /:,;";
  if(email==""){
    return false;
  }
  for(i=0;i < invalidChars.length;i++){
    badChar=invalidChars.charAt(i);
    if(email.indexOf(badChar,0)>-1){
      return false;
    }
  }
  atPos=email.indexOf("@",1);
  if(atPos==-1){
    return false;
  }
  if(email.indexOf("@",atPos+1)!=-1){
    return false;
  }
  periodPos=email.indexOf(".",atPos);
  if(periodPos==-1){
    return false;
  }
  if(periodPos+3>email.length){
    return false;
  }
  return true;
}

/********** VALIDAR RFC *********/
function RFC(cual)
{
mensaje = "Debes poner un formato LLLL999999XXX"
pat = /[a-z]|[A-Z]/
pat2 = /[a-z]|[A-Z]|[0-9]/
val0 = cual.substr(0,3);
val1 = cual.substr(4,6);
val2 = cual.substr(10,3);
	if(val0.length == 4){
		if(!comp(val0,pat)){
			alert(mensaje)
			cual.focus();
			return false
			}
		}
	if(val1.length == 6){
		if(isNaN(val1)){
			alert('no es un numero')
			cual.focus();
			return false
			}
		}	
	if(val2.length == 3){
		if(!comp(val2,pat2)){
			alert(mensaje)
			cual.focus();
			return false
			}
		}

return true
}
function comp(cual,pa){
	for(m=0;m<cual.length;m++)
	{
		if(!pa.test(cual.charAt(m)))
		{
			return false
			break
		}
	}
	return true
}

function ValidaFecha(cadena)//yyyy-mm-dd
{
	var Fecha= new String(cadena)
	var RealFecha= new Date()
	var Dia= new String(Fecha.substring(Fecha.lastIndexOf("-")+1,Fecha.length))
	var Mes= new String(Fecha.substring(Fecha.indexOf("-")+1,Fecha.lastIndexOf("-")))
	var Ano= new String(Fecha.substring(0,Fecha.indexOf("-")))

	if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900){      
		return false
	}
	if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12){		
		return false
	}
	if (isNaN(Dia) || parseFloat(Dia)<1 || parseFloat(Dia)>31){		
		return false
	}
	if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {
		if (Mes==2 && Dia > 29 || Dia>30) {		
			return false
		}
	}
	return true;
}