﻿function validarddl(source,arguments)
{
	if(arguments.Value == "0")
	{
		arguments.IsValid = false;
	}
	else
	{
		arguments.IsValid = true;
	}
}

function vcorreo(source,arguments)
{
    //expresion regular
    var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/            
    //devuelve verdadero si validacion OK, y falso en caso contrario
    if(! b.test(arguments.Value)){
    arguments.IsValid = false;
    }
    else{
    arguments.IsValid = true;
    }	
}

function validarckbterminos(source,arguments)
{
		arguments.IsValid =document.aspnetForm.ctl00_ContentPlaceHolder1_ckbbterminoscondiciones.checked; 
		
}

function numerosdecimales(source,arguments) {
theValue = arguments.Value;
arguments.IsValid = false;
rx = /[^0-9.]/;
if(rx.test(theValue)) {
arguments.IsValid = false;
}
if(theValue.indexOf(".") != -1) {
theValue = theValue.substring(0,(theValue.indexOf(".") + 3));
}
lnt = theValue.length;
if(lnt > 11) {
    if(theValue.indexOf(".") == -1) {
    theValue = theValue.substring(0,11);
    }
    else {
    theValue = theValue.substring(0,12);
    }
lnt = theValue.length;
}
if(lnt > 9 && theValue.indexOf(".") == -1) {
first = theValue.substring(0,9);
second = theValue.substring(9);
theValue = first + "." + second;
}
arguments.Value = theValue;
arguments.IsValid = true;
} 

function validarckbestadisticas(source,arguments)
{
var chkbox1=document.aspnetForm.ctl00_ContentPlaceHolder1_ckbbamigo.checked; 
var chkbox2=document.aspnetForm.ctl00_ContentPlaceHolder1_ckbbmedios.checked; 
var chkbox3=document.aspnetForm.ctl00_ContentPlaceHolder1_ckbbtelevision.checked; 
var chkbox4=document.aspnetForm.ctl00_ContentPlaceHolder1_ckbbinternet.checked; 

    if (chkbox1!=true && chkbox2!=true && chkbox3!=true && chkbox4!=true){
	arguments.IsValid = false;
	}
	else{
	arguments.IsValid = true;
	}		
	
}

function solonumeros(num)
{
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') +  num + '.' + cents);
}

function covernumeros(num)
{
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "1";
return num;
}


function numerosmayoresdecero(source,arguments)
{
    var micampo = arguments.Value;
    if(micampo <= 0 ){
       arguments.IsValid = false;
       return;
    }else if(micampo != 0 ){
       if(!isNaN(parseInt(micampo))){
        arguments.IsValid = true;
      }
    }
}