function open_popup_FAQ(screen, name) {
	popupfaq = window.open(screen, name, 'toolbar=no, width=500,height=524')
	}
	
function open_popup_juego(screen, name) {
	popupfaq = window.open(screen, name, 'toolbar=no, width=500,height=550,scrollbars=no')
	}	

function open_popup_Oca(screen, name) {
	popupfaq = window.open(screen, name, 'toolbar=no, width=500,height=550')
	}	

function open_popup_Contrato(screen, name) {
	popupfaq = window.open(screen, name, 'scrollbars=yes, toolbar=no, width=560,height=550')
	}

function open_popup_Convenio(screen, name) {
	Convenio = window.open(screen, name, 'toolbar=no, width=270,height=524')
	}	

function open_popup_link_ansesCuil() {
	window.open('http://servicioswww.anses.gov.ar/ConstanciadeCuil2/Inicio.aspx', '', 'scrollbars=yes, toolbar=no, width=800,height=630')
	}
	
function open_popup_link_sucursalesRapipago() {
	window.open('http://www.rapipago.com.ar/SiteController.php?action=ViewPage&shortname=SUCURSALES_MAPA_ARGENTINA', '', 'scrollbars=yes, toolbar=no, width=800,height=630')
	}	
	
function open_popup_image(screen,ancho,alto) {
	Convenio = window.open(screen, 'Elementos promocionales', 'resizable=1, toolbar=no, width='+ancho+', height='+alto)
	}	
	
function open_popup_planPagos(screen) {
	window.open(screen, 'planPagos', 'toolbar=no, width=635, scrollbars=yes')
}		

function open_popup_Veraz(url) {
	window.open(url, '_blank', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=770,height=500');
}

		
function closeWindow() {
	window.close();
}


function isNumber(sText){
   	var ValidChars = "0123456789.-";
	var IsNumber=true;
	var Char;
 
   	for (i = 0; i < sText.length && IsNumber == true; i++){ 
	    Char = sText.charAt(i); 
    	if (ValidChars.indexOf(Char) == -1){
		       IsNumber = false;
        }
     }
   	return IsNumber;
}

function isNumberPositivo(sText){
   	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
 
   	for (i = 0; i < sText.length && IsNumber == true; i++){ 
	    Char = sText.charAt(i); 
    	if (ValidChars.indexOf(Char) == -1){
		       IsNumber = false;
        }
     }
   	return IsNumber;
}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function




function validaYpostea(cantEnteros, cantDecimales) {
    var msg;
    var i=0;
	while(i<document.forms[0].elements.length) {
	    if (document.forms[0].elements[i].type=="text") {
	        if (document.forms[0].elements[i].value=='' || !isNumber(document.forms[0].elements[i].value)) {
		        document.forms[0].elements[i].focus();
		        msg = "Ingrese un valor num?rico v?lido para la apuesta.";
		        alert(msg);
		        return false;
	        }
	        var valorIngresado = trim(document.forms[0].elements[i].value);
	        var posPunto = valorIngresado.indexOf('.');
	        var lastposPunto = valorIngresado.lastIndexOf('.');
	        var posNeg = valorIngresado.indexOf('-');
	        var lastposNeg = valorIngresado.lastIndexOf('-');
	        if ((posPunto != lastposPunto) || (posNeg != lastposNeg)) {
	        	msg = "Ingrese un valor num?rico v?lido para la apuesta.";
		        alert(msg);
		        return false;
	        }
	        
	        if (cantDecimales != 0) {
		        if (posPunto != -1) {
		        	var parteEntera = valorIngresado.substring(0,posPunto);
		        	if (parteEntera.charAt(0)=='-') {
		        		if (((parteEntera.length-1) > cantEnteros) || ((parteEntera.length-1) == 0)) {
								msg = "La parte entera debe tener entre 1 y "+cantEnteros+" d?gitos.";
			        			alert(msg);
			        			return false;
						}
		        	} else {
		        		if ((parteEntera.length > cantEnteros) || (parteEntera.length == 0)) {
								msg = "La parte entera debe tener entre 1 y "+cantEnteros+" d?gitos.";
			        			alert(msg);
			        			return false;
						}
		        	}
		        	var parteDecimal = valorIngresado.substring(posPunto+1,valorIngresado.length)
		        	if (parteDecimal.length != cantDecimales) {
		        		msg = "La parte decimal debe tener exactamente "+cantDecimales+" d?gitos.";
			        	alert(msg);
			        	return false;
		        	}
		     
		        } else {
		        	msg = "La parte decimal debe tener exactamente "+cantDecimales+" d?gitos despu?s del punto.";
			        alert(msg);
			        return false;
		        }
	        } else {
	        	if (posPunto == -1) {
		        	var parteEntera = valorIngresado;
		        	if (parteEntera.charAt(0)=='-') {
		        		if (((parteEntera.length-1) > cantEnteros) || ((parteEntera.length()-1) == 0)) {
								msg = "La parte entera debe tener entre 1 y "+cantEnteros+" d?gitos.";
			        			alert(msg);
			        			return false;
						}
		        	} else {
		        		if ((parteEntera.length > cantEnteros) || (parteEntera.length == 0)) {
								msg = "La parte entera debe tener entre 1 y "+cantEnteros+" d?gitos.";
			        			alert(msg);
			        			return false;
						}
		        	}
	        	} else {
	        		msg = "El valor ingresado no puede tener parte decimal.";
			        alert(msg);
			        return false;
	        	}
	        }
	    } 
    i++;
    }
    document.forms[0].submit(); 
} 


function validaYposteaSC(paramEnteros, paramDecimales) {
    var msg;
    var cantEnteros=0;
    var cantDecimales=0;
	var nroCifras=document.forms[0].elements[4].value;
	var apuesta=document.forms[0].elements[5].value;
	
    if (apuesta=='' || !isNumberPositivo(apuesta)) {
        document.forms[0].elements[5].focus();
        msg = "Ingrese un valor num?rico v?lido para la apuesta.";
        alert(msg);
        return false;
    }
    var valorIngresado = trim(apuesta);
    var posPunto = valorIngresado.indexOf('.');
    var lastposPunto = valorIngresado.lastIndexOf('.');
    
    if (posPunto != lastposPunto) {
    	msg = "Ingrese un valor num?rico v?lido para la apuesta.";
        alert(msg);
        return false;
    }
    
    if (nroCifras <= paramDecimales) {
    	cantEnteros = nroCifras;
    } else {
    	cantEnteros = nroCifras - paramDecimales;
    	cantDecimales = paramDecimales; 
    }
    
    if (cantDecimales != 0) {
        if (posPunto != -1) {
        	var parteEntera = valorIngresado.substring(0,posPunto);
    		if ((parteEntera.length != cantEnteros) || (parteEntera.length == 0)) {
					msg = "La parte entera debe tener exactamente "+cantEnteros+" d?gitos.";
        			alert(msg);
        			return false;
			}
        	var parteDecimal = valorIngresado.substring(posPunto+1,valorIngresado.length)
        	if (parteDecimal.length != cantDecimales) {
        		msg = "La parte decimal debe tener exactamente "+cantDecimales+" d?gitos.";
	        	alert(msg);
	        	return false;
        	}
        } else {
        	msg = "La parte decimal debe tener exactamente "+cantDecimales+" d?gitos despu?s del punto.";
	        alert(msg);
	        return false;
        }
    } else {
    	if (posPunto == -1) {
        	var parteEntera = valorIngresado;
    		if ((parteEntera.length != cantEnteros) || (parteEntera.length == 0)) {
					msg = "La parte entera debe tener exactamente "+cantEnteros+" d?gitos.";
        			alert(msg);
        			return false;
			}
    	} else {
    		msg = "El valor ingresado no puede tener parte decimal.";
	        alert(msg);
	        return false;
    	}
    } 
    document.forms[0].submit(); 
} 


