//Funcion de Envio de Formularios...
function enviar (formu){
	document.getElementById(formu).submit();		
}

//Asigna a un campo oculta el valor de un elemento seleccionado...
function asigletra(valorum,campoinf,forminf){
	document.getElementById(campoinf).value = valorum;
	enviar(forminf);
}

//Ubica campo al cargar la pagina..
function ubicar(campo){
	document.getElementById(campo).focus();						
}

//regresa el id del campo a asignar..
function GEBI(id){
		return document.getElementById(id);
	}

//AJAX para carga de procesos
var http_request = false;
var global_load_div = '';
function makePOSTRequest(url, parametros){
	http_request = false;  
	try { // Firefox, Opera 8.0+, Safari
	http_request =new XMLHttpRequest();
		if (http_request.overrideMimeType) {
		http_request.overrideMimeType('text/html');
		}
  	}
	catch (e){
		try {	// IE
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
		http_request = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
   
	if (!http_request) {
	alert('Your browser does not support AJAX!');
	return false;
	}
	
	http_request.onreadystatechange = alertContents;
	http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parametros.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parametros);
}
//<------ END AJAX BASIC FUNCTION ------>
	  
function alertContents() {
	if (http_request.readyState == 1) {
	GEBI(global_load_div).innerHTML = '<div align="center"><img src="'+urlimg+'images/loading.gif" align="absmiddle" width="16" height="16"/></div>';
	}

	if (http_request.readyState == 4) {
    	if (http_request.status == 200) {
        result = http_request.responseText;
		GEBI(global_load_div).innerHTML = result;		
		}
		else {
		alert('Your Internet connection is null or an abuse made in the system. \n Please try again');
		}
	}
}

//Validador de campos numericos
function numberValidate(e) {
	tecla = (document.all) ? e.keyCode : e.which;
	if (tecla==8 || tecla==0) return true; //Tecla de retroceso (para poder borrar)
		patron =/[0-9]/;
		te = String.fromCharCode(tecla);
		return patron.test(te);
};
//Validar Cambio de imagen de danderas.
function bande_cambio(rutaban,nomcampo,bande){
	if (document.getElementById(nomcampo).value != ''){
		//document.images.bande.src=rutaban+ document.getElementById(nomcampo).value;	
		document.getElementById(bande).src=rutaban+ document.getElementById(nomcampo).value;	
	}else{
		document.getElementById(bande).src='images/flag_white.gif';		
	}
}
//Envio de informacion para eliminar registros
function eli_info(textoinf,nombre,linkinf) {
	Boxy.confirm('>>> <strong>'+textoinf+': '+nombre+' ?</strong>', function() { window.location= linkinf; });
	//var eli_pagina = confirm('>>> '+textoinf+': '+nombre+' ?');
	/*if (eli_pagina == true) {
		window.location= linkinf;
	} */
}
//Asigna Referencia de letras iniciales
function asigrefphp(campoasig1,campoasig2,campoinf,exteninf){
	if(campoinf != '' && exteninf != ''){
		GEBI(campoasig2).value = campoinf+'_'+GEBI(campoasig1).value+'.'+exteninf;
	}else{
		GEBI(campoasig2).value = GEBI(campoasig1).value;		
	}	
}

//Asigna texto digitado en el lenguaje
function load_form(load_list,info_id) {
	var poststr = "link_id=" + info_id + "&link_traduc=" + document.getElementById(load_list).value;
	global_load_div = 'resultado_post';
	makePOSTRequest('language_info.php', poststr);
}

//Funcion de muestra de infomacion adicional en las tablas...
function mas_multi(idval,viewmas,viewmenos,viewmues,valucam) {
	var valor=new Array;	
	for(var i=0;i<=valucam;i++){
		valor[i] = i+viewmues+idval;		
	}
	var muestra = viewmenos+idval;	
	var oculta = viewmas+idval;		
	GEBI(muestra).style.display='';		
	for(var i=0;i<=valucam;i++){
		GEBI(valor[i]).style.display='';			
	}
	GEBI(oculta).style.display='none';				
}

//Funcion de ocultar la infomacion adicional en las tablas...
function menos_multi(idval,viewmas,viewmenos,viewmues,valucam) {
	var valor=new Array;
	for(var i=0;i<=valucam;i++){
		valor[i]= i+viewmues+idval;		
	}
	var muestra = viewmenos+idval;	
	var oculta = viewmas+idval;		
	for(var i=0;i<=valucam;i++){
		GEBI(valor[i]).style.display='none';			
	}		
	GEBI(muestra).style.display='none';	
	GEBI(oculta).style.display='';	
}	