﻿  function ValidarBusqueda(url)
{
	txtBusc=document.getElementById("txtBusqueda").value;
	sBus=document.getElementById("sBusqueda").value;
	sNo=document.getElementById("sNoRegistros").value;	
	sTipo=document.getElementById("sTipoBusqueda").value;
	aBus=sBus.split("-");
	
	err="";
	if(aBus[0]=="S")
	{
		if(txtBusc=="")
			err="Se necesita un valor de busqueda";
		
		if(sTipo!=" like ")
			txtBusc="'"+txtBusc+"'";
	}else if(aBus[0]=="I")
	{
		if(!IsNumeric(txtBusc) ||  txtBusc=="")
			err="Se necesita un número";
		if(sTipo==" like ")
			sTipo="=";
	}else if(aBus[0]=="B")
	{
		if(txtBusc!="0" && txtBusc!="1")
			err="0- falso;  1- verdadero";
		if(sTipo!="=")
			sTipo="=";
	}else if(aBus[0]=="D")
	{
		if(!Isfecha(txtBusc))
			err="No es un formato de fecha valido. (dd/mm/aaaa)";
		else
		{
			afecha=txtBusc.split("/");
			txtBusc="'"+afecha[2]+"-"+afecha[1]+"-"+afecha[0]+"'";
			if(sTipo==" like ")
				sTipo="=";
		}
	}
	
	if(err=="")
	{
		//txtBusc=Utf8.encode(txtBusc);
		txtBusc=encodeURIComponent(txtBusc);
		showHint(url+"?TB="+txtBusc+"&C="+aBus[1]+"&TR="+sNo+"&ST="+sTipo+"&CA="+aBus[2]);
	}else
	{
		alert(err);
	}
	
}
function consultaGrafica(url){
	window.open(url,"name","height=800,width=800,left=100,top=100,toolbar=no,directories=no,status=no,continued from previous linemenubar=no,scrollbars=Yes,resizable=no ,modal=yes");
	
}
	function remplazaTodos(cadena, bloque, remplazo) {
		while (cadena.indexOf(bloque, 0)>-1) {
			var aux = cadena.substr(cadena.indexOf(bloque, 0)+bloque.length, cadena.length);
			cadena = cadena.substr(0, cadena.indexOf(bloque, 0));
			cadena += remplazo+aux;
		}
		return cadena;
	}
	
function IsTipoArchivo(nA,tipo) {
	//alert(tipo);
	tipo=tipo.toUpperCase();
	nA=nA.toUpperCase();
	if (nA != "" && nA.indexOf("."+tipo)!=-1)
	{
		p=nA.indexOf("."+tipo);
		if(nA.substr(p+1,nA.length-(p+1))==tipo)
			return true;
	}
    return false;
}

function openModal(url1,id,url2,name,tipo,w,h)
{
	if (window.showModalDialog) {
		window.showModalDialog(url1+"?TIP="+encodeURIComponent(tipo)+"&ID="+id+"&NAME="+name,"name","dialogWidth:"+w+"px;dialogHeight:"+h+"px; status=no; scroll=yes; resizable=no; center=yes;help=no;");
		
		
	} else {
		window.open(url1+"?TIP="+encodeURIComponent(tipo)+"&ID="+id,"name","height="+h+",width="+w+",left=100,top=100,toolbar=no,directories=no,status=no,continued from previous linemenubar=no,scrollbars=Yes,resizable=no ,modal=yes");
	}
	if(tipo!="Ver")
		showHint(url2);

}

function BorrarRegistro(cadena)
{
	if(confirm("Seguro quiere borrar el registro"))
		showHint(cadena);
}
function ActivarPeriodo(cadena)
{
	if(confirm("Seguro desea seleccionar este periodo"))
		showHint(cadena);
}
function ActConfig()
{
	
	vsMN=document.getElementById("sMN").value;	
	vsMRM=document.getElementById("sMRM").value;	
	vsNRD=document.getElementById("sNRD").value;	
	vsGB=document.getElementById("sGB").value;
	vsVI=document.getElementById("sVI").value;
	showHint("includes/Admin/ActConfiguracion.asp?sMN="+vsMN+"&sMRM="+vsMRM+"&sNRD="+vsNRD+"&sGB="+vsGB+"&sVI="+vsVI);
}
function ActConfigAE()
{
	
	vsEfoto=document.getElementById("sEfoto").value;	
	vsEOfic=document.getElementById("sEOfic").value;	
	vsTxTOfi=document.getElementById("txtOficios").value;
	showHint("includes/AdminEsc/ActConfiguracion.asp?sEfoto="+vsEfoto+"&sEOfic="+vsEOfic+"&sTxTOfi="+vsTxTOfi);
}

function Isfecha(valor) 
{
	if (valor.indexOf("/")>-1)
	{
		aJecha=valor.split("/");
		if (aJecha.length==3)
		{
			var dia=aJecha[0];
			var mes=aJecha[1];
			var ano=aJecha[2];
			if (IsNumeric(ano) && IsNumeric(mes) && IsNumeric(dia) && ano!="" && aJecha[1].length==2 && aJecha[0].length==2)
			{ 
				ano=parseInt(ano,10);
				mes=parseInt(mes,10);
				dia=parseInt(dia,10);
				if ((ano==0) || (ano<1900) || (ano>2100)) 
					{return false; }
				if (mes ==2) 
				{ 
					if ((ano%4 == 0) && (dia<=29) && (dia>0)) 
						{return true;}
					else if((dia<=28) && (dia>0))
						{return true;}
					else
						{return false; }
				} 
				else if (((mes==1) || (mes==3) || (mes==5) || (mes==7) || (mes==8) || (mes==10) || (mes==12)) && (dia<=31) && (dia>0)) 
				{return true; } 
				else if (((mes==4) || (mes==6) || (mes==9) || (mes==11)) && (dia<=30) && (dia>0)) 
				{return true; }
				else 
					{return false; }
			} 
			else 
				{return false; } 
		}
		else 
			{return false; }
	}else 
		{return false; }
}


function IsNumeric(valor) 
{ 
	var log=valor.length; var sw="S"; 
	for (x=0; x<log; x++) 
	{ 
		v1=valor.substr(x,1); 
		v2 = parseInt(v1); 
		//Compruebo si es un valor numérico 
		if (isNaN(v2)) { sw= "N";} 
	} 
	if (sw=="S") 
		{return true;} 
	else 
		{return false; } 
} 



var primerslap=false; 
var segundoslap=false; 
function formateafecha(fecha) 
{ 
	var long = fecha.length; 
	var dia; 
	var mes; 
	var ano; 
	if ((long>=2) && (primerslap==false)) 
	{ 
		dia=fecha.substr(0,2); 
		if ((IsNumeric(dia)==true) && (dia<=31) && (dia!="00")) 
		{ 
			fecha=fecha.substr(0,2)+"/"+fecha.substr(3,7); 
			primerslap=true;
		} 
		else { 
			fecha=""; 
			primerslap=false;
		} 
	} 
	else 
	{ 
		dia=fecha.substr(0,1); 
		if (IsNumeric(dia)==false) 
			{fecha="";} 
		if ((long<=2) && (primerslap=true)) 
		{
			fecha=fecha.substr(0,1); primerslap=false;
		} 
	} 
	if ((long>=5) && (segundoslap==false)) 
	{ 
			mes=fecha.substr(3,2); 
			if ((IsNumeric(mes)==true) &&(mes<=12) && (mes!="00")) 
				{ 
					fecha=fecha.substr(0,5)+"/"+fecha.substr(6,4); segundoslap=true; 
				} 
			else { fecha=fecha.substr(0,3);; segundoslap=false;} 
	} 
	else 
	{ 
		if ((long<=5) && (segundoslap=true)) 
		{	
			fecha=fecha.substr(0,4); segundoslap=false;
		} 
	} 
	if (long>=7) 
	{
		ano=fecha.substr(6,4); 
		if (IsNumeric(ano)==false) 
		{ 
			fecha=fecha.substr(0,6); 
		} 
		else 
		{ 
			if (long==10)
			{ 
				if ((ano==0) || (ano<1900) || (ano>2100)) 
				{ 
					fecha=fecha.substr(0,6); 
				} 
			} 
		} 
	} 
	if (long>=10) 
	{ 
		fecha=fecha.substr(0,10); 
		dia=fecha.substr(0,2); 
		mes=fecha.substr(3,2); 
		ano=fecha.substr(6,4); 
		// Año no viciesto y es febrero y el dia es mayor a 28 
		if ( (ano%4 != 0) && (mes ==02) && (dia > 28) ) { fecha=fecha.substr(0,2)+"/"; } 
	} 
	return (fecha); 
}



function num_aleatorio(inicio, fin)
{
    return Math.round((fin-inicio)*Math.random()) + inicio;
}	


function num_aleatDif(Inicio, Fin, Diferente) 
{
	var resultado = Inicio + parseInt((Fin-Inicio+1)*Math.random(),10); 
	while (resultado == Diferente) 
	{
		resultado = Inicio+ parseInt((Fin-Inicio+1)*Math.random(),10); 
	}
	return resultado;
}
	
function xnum_aleatorioD(inicio, fin, Diferente) {
	
		var resultado = Math.round((fin-inicio)*Math.random()) + inicio;
		while (resultado == Diferente) {
			resultado = Math.round((fin-inicio)*Math.random()) + inicio;
		}
		return resultado;
	}
	function xnum_aleatorioD2(inicio, fin, Diferente,diferente2) {
	
		var resultado = Math.round((fin-inicio)*Math.random()) + inicio;
		while (resultado == Diferente || resultado == diferente2) {
			resultado = Math.round((fin-inicio)*Math.random()) + inicio;
		}
		return resultado;
	}
	function Ordena(Algo)
{
	var NArr = Algo;
	for(var i = 1; i< NArr.length; i++)
	{
		for (var j=0; j < i; j++)
			if (NArr[i] < NArr[j])
			{
				var Cmd = NArr[i];
				for (var k=i; k>= j+1; k--)
					NArr[k] = NArr[k-1];
				NArr[j] = Cmd;
			}
	}
	return NArr; 
}
function mayuscula1ra(texto,indice) 
{
	var aux=(texto.substr(indice, 1)).toUpperCase()+texto.substr((indice+1), texto.length);
//	alert(texto.substr(1, 1).toUpperCase());

	return (aux);
}
function modo_moneda(cadena1) 
{
	var cadena = cadena1+"";
	var pos=0;
	if (cadena.indexOf(".", 0) == -1) {
		pos = cadena.length;
		cadena += ".00";
	} else {
		pos = cadena.indexOf(".", 0);
		 var tlong = cadena.length;
		var temp=2-(tlong-(pos+1));
		if (temp>=0) {
			for (var c = 0; c<2-(tlong-(pos+1)); c++) {
				cadena += "0";
			}
		} else {
			cadena = cadena.substr(0, pos+3);
		}
	}
	var apunto = "";
	var tlong = cadena.length-3;
	var dpunto = cadena.substr(pos, cadena.length);
	for (var xc = 0; xc<tlong; xc++) {
		apunto += cadena.substr(xc, 1);
		if ((tlong-(xc+1))%3 == 0 && xc != (tlong-1)) {
			apunto += "*";
		}
	}
	return (apunto+""+dpunto);
}

function Desordena(Arr)
{
	var Desorden = new Array();

	var Temp = GeneArrALea(Arr.length,0,Arr.length-1);
	for (var i=0; i<Arr.length; i++)
	{
		Desorden[i] = Arr[Temp[i]];
	}
	return Desorden;
}

function GeneArrALea(Dimension,Inicio,Fin)
{   

	var NumRnd = Inicio + parseInt((Fin-Inicio+1)*Math.random(),10); 		
	var xArreglo = new Array();
	for(var i = 0; i < Dimension; i++)
	{
		while (Pertenece(NumRnd,xArreglo))	
		{
			NumRnd = Inicio + parseInt((Fin-Inicio+1)*Math.random(),10); 
		}
		xArreglo[i] = NumRnd;
		NumRnd = Inicio + parseInt((Fin-Inicio+1)*Math.random(),10); 
	}
	return xArreglo;  
}

function Pertenece(NumRnd, xArreglo) 
{	
	var Pertenece = false;
	for(var i=0; i < xArreglo.length; i++) if (xArreglo[i] == NumRnd) Pertenece = true;
	return Pertenece;
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) 
  {
    d=parent.frames[n.substring(p+1)].document; 
	n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
	x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) 
	x=d.getElementById(n); 
  return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es un campo obligatorio.\n'; }
  } if (errors) alert('Los siguientes campos no están completados correctamente:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}





function showHint(url)
{
	
	if (url.length==0)
	{
		document.getElementById("hintCuerpo").innerHTML="";
		//$("hintCuerpo").html="";
		return;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("El navegador no soporta AJAX!");
		return;
	}
	xmlHttp.onreadystatechange=stateChanged;
	
	xmlHttp.open("get",url,true);
	xmlHttp.send(null);
}
function SetContainerHTML(id,html,processScripts)
{
	mydiv = document.getElementById(id);
	mydiv.innerHTML = html;
	if(processScripts!=false)
	{
		
		var elementos = mydiv.getElementsByTagName('script');
		
		for(i=0;i<elementos.length;i++) 
		{
			var elemento = elementos[i];
			nuevoScript = document.createElement('script');
			nuevoScript.text = elemento.innerHTML;
			if(elemento.src!=null && elemento.src.length>0)
			{
				nuevoScript.src = elemento.src;
			}
			elemento.parentNode.replaceChild(nuevoScript,elemento);
		}
	}
}

function stateChanged()
{	
	if (xmlHttp.readyState==1)	
	{
		document.getElementById("hintCuerpo").innerHTML="Cargando... por favor espere."
	}
	if (xmlHttp.readyState==4)
	{
		
		//SetContainerHTML("hintCuerpo",xmlHttp.responseText,true);
		//alert(xmlHttp.responseText);
		document.getElementById("hintCuerpo").innerHTML=xmlHttp.responseText;
		//$("#hintCuerpo").html(xmlHttp.responseText);
		
		$(function() {
	
	cargar_paises();
	$("#estado").change(function(){dependencia_estado("#estado","#municipio","municipio");});
	$("#municipio").change(function(){dependencia_ciudad("#estado","#municipio","#localidad","localidad");});
	$("#municipio").attr("disabled",true);
	$("#localidad").attr("disabled",true);	
	
	$("#estadoD").change(function(){dependencia_estado("#estadoD","#municipioD","municipioD");});
	$("#municipioD").change(function(){dependencia_ciudad("#estadoD","#municipioD","#localidadD","localidadD");});
	$("#municipioD").attr("disabled",true);
	$("#localidadD").attr("disabled",true);	
	
	$("#estadoE").change(function(){dependencia_estado("#estadoE","#municipioE","municipioE");});
	$("#municipioE").change(function(){dependencia_ciudad("#estadoE","#municipioE","#localidadE","localidadE");});
	$("#municipioE").attr("disabled",true);
	$("#localidadE").attr("disabled",true);	
	
	$("#estadoT").change(function(){dependencia_estado("#estadoT","#municipioT","municipioT");});
	$("#municipioT").change(function(){dependencia_ciudad("#estadoT","#municipioT","#localidadT","localidadT");});
	$("#municipioT").attr("disabled",true);
	$("#localidadT").attr("disabled",true);	
  
   $("input[name=chx]").change(
			function(){
				
			if ($(this).is(':checked'))	
				{
					
					var valor = $(this).val();
					var return_value= $.ajax({ 
					type: "POST", 
					url: "../DB/AsistenciaDB.asp",
					data: "Mtr="+encodeURIComponent(valor)+"&Che=Si",
					dataType: "html",
					async: false }).responseText;		
					
				} else{
					var valor = $(this).val();
					
					var return_value= $.ajax({ 
					type: "POST", 
					url: "../DB/AsistenciaDB.asp",
					data: "Mtr="+encodeURIComponent(valor)+"&Che=No",
					dataType: "html",
					async: false }).responseText;		
				}
			}
	);
    
   /***********************************************textos de calificaciones****************************************/
    $(".Selector").change(
			function(){
			var nombre= $(this).attr("name");
   			var nom = "#txt"+nombre;
			if ($(this).val()==10)	
				{
					  $(nom).removeAttr("disabled");
					$(nom).removeClass("quitarA");
				} else if($(this).val()==0){
					$(nom).removeAttr("disabled");
					$(nom).removeClass("quitarA");
				}else{
				   	$(nom).attr("disabled","disabled");
					$(nom).addClass("quitarA");
				}
			}
	);
	 /****************************************Guardado de Asistencias********************************************/
	 $("#GuardarAsis").click(
		function(){
			if ($("#probare").val() == "Guardar" ){
	   			$("INPUT[type='checkbox']").attr("disabled","disabled");
				$(this).attr("disabled","disabled");
				var valor= $(this).attr("name");
				var return_value= $.ajax({ 
					type: "POST", 
					url: "../DB/AsistenciaDB.asp",
					data: "Mtr="+encodeURIComponent(valor)+"&Che=Up",
					dataType: "html",
					async: false }).responseText;
			alert(return_value);
	 		}else {
	  			$("#probare").val('')
	 			 alert("Escribe correctamente lo que se te pide en la caja de textp"); 
	 		};
		});
	  /****************************************Guardado de Horario********************************************/
	 $("#GuardarHorario").click(
		function(){
			if ($("#probare").val() == "Guardar" ){
	   			
				$(this).attr("disabled","disabled");
				var valor= $(this).attr("name");
				var return_value= $.ajax({ 
					type: "POST", 
					url: "../ADB/GuardarHorario.asp",
					data: "Cla="+encodeURIComponent(valor),
					dataType: "html",
					async: false }).responseText;
			  showHint(return_value)
			}else {
	  			$("#probare").val('')
	 			 alert("Escribe correctamente lo que se te pide en la caja de texto"); 
	 		};
		});
	 /*********************************************Guardado de acta******************/
	$("#GuardarActa").click(
		function(){
			var valor= $(this).attr("name");
			/*$("#GuardarActa").addClass("quitarA");*/
			$("#result").append("Guardando por favor espere");	
		});		
	 
	 /*************************************/
    $.metadata.setType("attr", "validate");
    $("#FormEvento").validate();
	$('#EventosPicker').datepick(
		{
			minDate:'07/01/2010', 
       		maxDate:'31/12/2010',
			firstDay: 1, 
			multiSelect: 999,
			numberOfMonths:3,
			multiSeparator:', ',
			dateFormat:'dd/mm/yy'
		});	
	$("#PassOpen").click(
			function(){ 
				$("#PassClose").removeClass("Desaparecer");
				$("#PassClose").addClass("Etiquetas2");
			},
			function(){ 
				$("#PassClose").removeClass("Desaparecer"); 
			}
		);	
		$("#Botoncito").hover(
			function(){ 
				$(this).addClass("ui-state-hover"); 
			},
			function(){ 
				$(this).removeClass("ui-state-hover"); 
			}
		);
		$("#Botoncito").mousedown(function(){
			$(this).addClass("ui-state-active"); 
		});
		$("#Botoncito").mouseup(function(){
				$(this).removeClass("ui-state-active");
		});
		
		
		$("#envioForm").validate({
				submitHandler: function(envioForm) {
					jQuery(envioForm).ajaxSubmit({
						target: "#result"
					});
				}
		});
		$("#ActaCal").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					beforeSubmit: showRequest,
					success: showResponse,
					target: "#result"
				});
			}
		});
		$("#GuardarHorario").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					beforeSubmit: showRequest,
					success: showResponse,
					target: "#result"
				});
			}
		});
		$("#datosGenerales").validate({
				submitHandler: function(envioForm) {
					jQuery(envioForm).ajaxSubmit({
						target: "#result"
					});
				}
		});
		$(".ui-datepicker-trigger").datepick({
			showOtherMonths: true, selectOtherMonths: true,
			dateFormat:'dd/mm/yy',
			changeMonth: true,
			changeYear: true,
			yearRange: '-50:+10'
			
		});
		$("#txtFechaN").datepick({showOtherMonths: true, selectOtherMonths: true,firstDay: 1, showOn: 'both'});

		$("#txtPassword2").blur(function() {
		$("#txtConfirm_password").valid();});
			
			$("#tablesorter")
			.tablesorter({widthFixed: true, widgets: ['zebra']})
			.tablesorterPager({container: $("#pager")});
		});
	
	
	}/*else
	{
		document.getElementById("hintCuerpo").innerHTML="<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"img/loading-p2.gif\"/>&nbsp;&nbsp;&nbsp;<p class=\"Estilo6\">Cargando....<br/>";
	}*/
}

function GetXmlHttpObject()
{
      var xmlHttp=null;
      try
        {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
      catch (e)
        {
        // Internet Explorer
        try
          {
          xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          }
        catch (e)
          {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
          }
        }
      return xmlHttp;
} 

function popitup(url,h,w)
{
	newwindow=window.open(url,'name','height='+h+',width='+w+',scrollbars = yes,left = 300,top = 300'); 
	if (window.focus) {newwindow.focus()}
	return false;
}

function DivMostrar(Div,Tipo)
{
	if (Tipo=="A"){
	document.getElementById(Div).style.display = "block";
	document.getElementById(Div+"A").style.display = "none";
	document.getElementById(Div+"B").style.display = "block";
	}
	if (Tipo=="B"){
	document.getElementById(Div).style.display = "none";
	document.getElementById(Div+"B").style.display = "none";
	document.getElementById(Div+"A").style.display = "block";
	}
	
}

/**********************************************************************************************************************/

function toggle_periodo(elemento) {
  if(elemento.value=="m") {
      document.getElementById("div_cuatrimestre").style.display = "block";
	   document.getElementById("div_semestre").style.display = "none";
   } else {
    document.getElementById("div_semestre").style.display = "block";
     document.getElementById("div_cuatrimestre").style.display = "none";
   }

}
function cambia_color(elemento,color) {
	    var c;
	for(c=1;c<=6;c++){
	document.getElementById("sub"+c).style.background= '#8BBD21';
	document.getElementById("sub"+c).style.color= '#FFFFFF';
	document.getElementById("sub"+c).value=0;
	}
	 document.getElementById(elemento).style.background= '#237217';
	 document.getElementById(elemento).style.color= '#FFFFFF';
	 document.getElementById(elemento).value=1;
}
function sobre_color(elemento,color) {
    var c,aux;
	for(c=1;c<=6;c++){
	aux=document.getElementById("sub"+c).value;
	if(aux==0)
		document.getElementById("sub"+c).style.background= '#8BBD21';
    }
	if(document.getElementById(elemento).value==0)
	document.getElementById(elemento).style.background= '#237217';
	
}
function quita_color() {
    var c,aux;
	for(c=1;c<=6;c++){
	aux=document.getElementById("sub"+c).value;
	if(aux==0)
		document.getElementById("sub"+c).style.background= '#8BBD21';
    }
}

function cambia_pais(elemento) {
if(elemento.value=="MEX"){
 document.getElementById("pmex1").style.display = "inline";
 document.getElementById("pmex2").style.display = "inline";
 document.getElementById("pmex3").style.display = "inline";
 document.getElementById("oestado").disabled = true;
  document.getElementById("omunicipio").disabled = true;
   document.getElementById("olocalidad").disabled = true;
     document.getElementById("opais1").style.display ="none";
 document.getElementById("opais2").style.display = "none";
 document.getElementById("opais3").style.display = "none";
  document.getElementById("estado").disabled = false;
  
 
 
}else{
if(elemento.value!=""){
 document.getElementById("pmex1").style.display = "none";
 document.getElementById("pmex2").style.display = "none";
 document.getElementById("pmex3").style.display = "none";
  document.getElementById("opais1").style.display ="inline";
 document.getElementById("opais2").style.display = "inline";
 document.getElementById("opais3").style.display = "inline";
  document.getElementById("oestado").disabled = false;
  document.getElementById("omunicipio").disabled = false;
   document.getElementById("olocalidad").disabled = false;
    document.getElementById("estado").disabled = true;
	 document.getElementById("municipio").disabled = true;
    document.getElementById("localidad").disabled = true;
 
   }
   else{
    document.getElementById("pmex1").style.display = "none";
 document.getElementById("pmex2").style.display = "none";
 document.getElementById("pmex3").style.display = "none";
      document.getElementById("opais1").style.display ="none";
 document.getElementById("opais2").style.display = "none";
 document.getElementById("opais3").style.display = "none";
   }
}
}

function cambia_pais2(elemento) {
if(elemento.value=="MEX"){
 document.getElementById("pmex1E").style.display = "inline";
 document.getElementById("pmex2E").style.display = "inline";
 document.getElementById("pmex3E").style.display = "inline";
 document.getElementById("oestadoE").disabled = true;
  document.getElementById("omunicipioE").disabled = true;
   document.getElementById("olocalidadE").disabled = true;
     document.getElementById("opais1E").style.display ="none";
 document.getElementById("opais2E").style.display = "none";
 document.getElementById("opais3E").style.display = "none";
 document.getElementById("estadoE").disabled = false;
  
 
}else{
if(elemento.value!=""){
 document.getElementById("pmex1E").style.display = "none";
 document.getElementById("pmex2E").style.display = "none";
 document.getElementById("pmex3E").style.display = "none";
  document.getElementById("opais1E").style.display ="inline";
 document.getElementById("opais2E").style.display = "inline";
 document.getElementById("opais3E").style.display = "inline";
  document.getElementById("oestadoE").disabled = false;
  document.getElementById("omunicipioE").disabled = false;
   document.getElementById("olocalidadE").disabled = false;
   document.getElementById("estadoE").disabled = true;
   document.getElementById("municipioE").disabled = true;
   document.getElementById("localidadE").disabled = true;
   }
   else{
    document.getElementById("pmex1E").style.display = "none";
 document.getElementById("pmex2E").style.display = "none";
 document.getElementById("pmex3E").style.display = "none";
      document.getElementById("opais1E").style.display ="none";
 document.getElementById("opais2E").style.display = "none";
 document.getElementById("opais3E").style.display = "none";
   }
}
}
function mostar_div(elemento) {
      document.getElementById("div_login").style.display = "block";
	   document.getElementById("div_login2").style.display = "none";
	  
}
function ocultar_div(elemento) {
      document.getElementById("div_login").style.display = "block";
}
/**************************************************************************************************/
function Alerta(Valor)
{
		alert(Valor);
	
}
function cargar_paises()
{
	$.get("../Prueba/scripts/AgregaEstados.asp", function(resultado){
		if(resultado == false)
		{
			alert("Error");
		}
		else
		
		{
			
			$('#estado').append(resultado);
			$('#estadoD').append(resultado);
			$('#estadoE').append(resultado);
			$('#estadoT').append(resultado);
			
						
		}
	});	
}
function dependencia_estado(idEstado,idMunicipio,nMunicipio)
{
	var code = $(idEstado).val();
	$.get("../Prueba/scripts/AgregaMunicipios.asp", { code: code },
		function(resultado)
		{
			if(resultado == false)
			{
				alert("Error");
			}
			else
			{			
						$(idMunicipio).attr("disabled",false);
						document.getElementById(nMunicipio).value="asdasda asda sdasdas";
						document.getElementById(nMunicipio).options.length=1;
						$(idMunicipio).append(resultado);	
										
			}
		}

	);
}

function dependencia_ciudad(idEstado,idMunicipio,idLocalidad,nLocalidad)
{
	var code = $(idEstado).val()+","+$(idMunicipio).val();
	$.get("../Prueba/scripts/AgregaLocalidad.asp", { code: code }, function(resultado){
		if(resultado == false)
		{
			alert("Error");
		}
		else
		{
			$(idLocalidad).attr("disabled",false);
			document.getElementById(nLocalidad).options.length=1;
			$(idLocalidad).append(resultado);			
		}
	});	
	
}

function showRequest(formData, jqForm, options) { 
   
     if ($("#probare").val() == "Guardar" ){
		 $("#result").append("Guardando porfavor espere");			
	   	$("#InpuActa").attr("disabled","disabled");
     return true; 
	 }else {
	  $("#probare").val('')
	  alert("Escribe correctamente lo que se te pide en la caja de texto"); 
	   return false;
	  };
} 
function showResponse(responseText, statusText, xhr, $form)  { 
    if ( responseText == "Error al guardar" ){
	 $("#InpuActa").removeAttr("disabled");
	 $("#probare").attr("value","");
	}
} 