// JavaScript Document


//FUNCION Q PERMITE CREAR UN OBJETO AJAX PARA SER USADO AL CARGAR LOS COMBOS
function nuevoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false;
	try
	{
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			// Creacion del objet AJAX para IE
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E)
		{
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
		}
	}
	return xmlhttp; 
}


//SELECCIONAR TODOS LOS CHECKBOX
	function seleccionar_todo(){ 
	   for (i=0;i<document.frmmantproducto.elements.length;i++) 
		  if(document.frmmantproducto.elements[i].type == "checkbox") 
			 document.frmmantproducto.elements[i].checked=1 
	} 

	//QUITA LA SELCCION DE LOS CHQCKBOX
	function deseleccionar_todo(){ 
   for (i=0;i<document.frmmantproducto.elements.length;i++) 
		  if(document.frmmantproducto.elements[i].type == "checkbox") 
			 document.frmmantproducto.elements[i].checked=0 
	}
	
	
	
	//FUNCION Q PERMITE TRAER LA CODIFICACION DEL TELEFONO DEPENDIENDO DEL PAIS
	function cargacentrocosto(codagencia,usuario)
	{
			var fecha = new Date();
			var ajax=nuevoAjax();
			//llama a una pagina q permite mostrar la codificación del país
			ajax.open("GET", "muestracombos.php?codagencia="+codagencia+"&usuario="+usuario+"&fecha="+fecha, true);
			ajax.onreadystatechange=function() 
			{ 
				//si terminó de ejecutarse el ajax
				if (ajax.readyState==4)
				{
					//cargando la codificacion del pais seleccionado
					//selectDestino.parentNode.innerHTML=ajax.responseText;
					document.getElementById("centrocosto").innerHTML = ajax.responseText;
					//alert(ajax.responseText);
					//document.getElementById("txtcodifica")= ajax.responseText;
				} 
			}
			ajax.send(null);
	}


	function cargacentrocostologin(codagencia,usuario,opt)
	{
			var fecha = new Date();
			var ajax=nuevoAjax();
			//llama a una pagina q permite mostrar la codificación del país
			ajax.open("GET", "muestracombos.php?codagencia="+codagencia+"&usuario="+usuario+"&opt="+opt+"&fecha="+fecha, true);
			ajax.onreadystatechange=function() 
			{ 
				//si terminó de ejecutarse el ajax
				if (ajax.readyState==4)
				{
					//cargando la codificacion del pais seleccionado
					//selectDestino.parentNode.innerHTML=ajax.responseText;
					document.getElementById("centrocosto").innerHTML = ajax.responseText;
					//alert(ajax.responseText);
					//document.getElementById("txtcodifica")= ajax.responseText;
				} 
			}
			ajax.send(null);
	}
