/**********************************************************************************
 - Función que pasa el valor de un elemento a un campo tipo hidden -
**********************************************************************************/
function setGroupValue(hdnID, valueToSet){
	
	var hdnToSet = document.getElementById(hdnID);
	hdnToSet.value = valueToSet;
	//alert(hdnToSet.value);
}
/*********************************************************************************/

/**********************************************************************************
 - Begin PopUp Generic -
**********************************************************************************/
function openPopup(url,wWidth,wHight,wLeftP,wTopP,wResize,scrl){
	var newWindow = window.open(url,"_blank","width="+wWidth+", height="+wHight+", left="+wLeftP+", top="+wTopP+", scrollbars="+scrl+", resizable="+wResize);
}
/*********************************************************************************/

/**********************************************************************************
 - Función que solo permite caracteres numericos -
**********************************************************************************/
function justVarchar(fieldName, fieldType){
	
	//Definimos que tipo de caracteres aceptara
	if(fieldType == "num"){ 
		var allowedKeys = "0123456789";
	}else if(fieldType == "char"){
		var allowedKeys = ".0123456789ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyz@-_";	
	}else if(fieldType == "url"){
		var allowedKeys = ".0123456789ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyz ";	
	}
	//////////////////////////////////////////
	
	var contentArray = new Array();
	var finalArray = new Array();
	var fieldContent = fieldName.value;
	var cont = 0;
	var filteredContent = "";
	
	// Creación de un arreglo con los caracteres del campo de texto
	for(i=0; i<=fieldContent.length; i++){
		contentArray[i] = fieldContent.substring(i,i+1);
	}
	
	for(j=0; j<=contentArray.length; j++){
		for(x=0; x<=allowedKeys.length; x++){
			if(contentArray[j] == allowedKeys.charAt(x)){
				finalArray[cont] = contentArray[j];
				cont++;
			}
		}
	}

	for(z=0; z<=finalArray.length-2; z++){
		filteredContent += finalArray[z];
	}
	fieldName.value = filteredContent;
}
/*********************************************************************************/