
function intOnly(i) {
      if(i.value.length>0) {
            i.value = i.value.replace(/[^\d]+/g, ''); 
      }
}

function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function vista(url){
	myWindow = window.open(url, "tinyWindow", "location=1,status=1,titlebar=1,menubar=1,toolbar=1,scrollbars=1,resizable=1,width=650,height=500,left=20,top=20");
}

function checkNumeric(objName,minval, maxval,comma,period,hyphen)
{
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(sfr){
	var ixcv;
    for (ixcv = 0; ixcv < sfr.length; ixcv++){   
        // Check that current character is number.
        var caq = sfr.charAt(ixcv);
        if (((caq < "0") || (caq > "9"))) return false;
    }
    return true;
}

function isDate(dtStr, formato){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	
	if (formato == "dd/mm/aa" || formato == "dd/mm/aaaa"){
		var strDay=dtStr.substring(0,pos1)
		var strMonth=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
	}
	else {
		var strMonth=dtStr.substring(0,pos1)
		var strDay=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
	}
	
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("El formato de fecha debe ser: " + formato);
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Por favor capture un mes valido")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Por favor capture un dia valido")
		return false
	}
	if (formato == 'dd/mm/aaaa') {
		if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
			alert("Por favor capture un aņo valido de 4 digitos entre "+minYear+" y "+maxYear)
			return false
		}
	}
	if (formato == 'dd/mm/aa'){
		if (strYear.length != 2 || year==0 || year<minYear || year>maxYear){
			alert("Por favor capture un aņo valido de 2 digitos entre "+minYear+" y "+maxYear)
			return false
		}
	}
	
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Por favor capture una fecha valida")
		return false
	}
return true
}

function newWindow(url, titulo, height, width) {
nameW='feature'
 if (navigator.appVersion.indexOf('4') != -1) {
 xTop = (screen.width - width)/2;
 yTop = (screen.height - height)/2;
 window.open(url, titulo, 'scrollbars=yes,resizable=yes,height='+height+',width='+width+',menubar=0,toolbar=0,status=0,location=0,directories=0,left=' + xTop + ',top=' + yTop + '');
 } else {
 window.open(url, titulo, 'scrollbars=yes,resizable=yes,height='+height+',width='+width+',menubar=0,toolbar=0,status=0,location=0,directories=0,left=150,top=200');
 }
}

function cambio_idioma(objeto,IntMenu) {
	var indice = objeto.selectedIndex;
	var valor = objeto.options[indice].value;
	//alert(replace(location.href,'&','-'));
	var url = 'ad-abrecuenta.asp?idioma=' + valor + '&IntMenu=' + IntMenu + '&pagReturn=' + location.href;
	//alert ('url:' + url);
	window.location.href = url;
	return true;
}

function cambio_usuario(objeto){
	
	var indice = objeto.selectedIndex;
	var valor = objeto.options[indice].value;

	objIdUsuario = document.getElementById("hdnUsuario");
	objIdUsuario.value = valor;
	document.adminForm.submit();
}
