function IsDate( sDate ) {
		// Check string's length
		if ( sDate.length < 6 || sDate.length > 10 ) { 
			return "";
		}
	
		// Get / position
		var lPos1 = sDate.indexOf( "/", 0 )
		if ( lPos1 < 1 || lPos1 > 2 ) {
			return "";
		}
		
		// MODIFICADO PABLO
		// Get Day
		var sDay = sDate.substring(0, lPos1)
	
		// Get / Position
		var lPos2 = sDate.indexOf( "/", lPos1+1 )
		if ( lPos2 < lPos1+2 || lPos2 > lPos1+3 ) {
			return "";
		} 
	
		// Get Month
		var sMonth = sDate.substring(lPos1+1, lPos2)
	
		// Get Year
		var sYear = sDate.substring(lPos2+1, sDate.length)

		// Format Year
		if ( sYear.length == 1 || sYear.length == 3 ) {
			return "";
		}
		if ( sYear.length == 2 ) {
			if ( parseInt( sYear ) > 29 ) {
				sYear = "19" + sYear
			} else {
				sYear = "20" + sYear
			}
		}

		// Check Month 
		if ( sMonth < 1 || sMonth >12 ) {
			return "";
		}
	
		// Check Day
		if ( sDay < 1 || sDay >31) {
			return "";
		}
	
		// Check Day and Month
		if ( (sMonth==4 || sMonth==6 || sMonth==9 || sMonth==11) && (sDay == 31 ) ) {
			return "";
		}
	
		// Check February	
		if ( sMonth==2 ){
			if ( sDay > 29 ) {
				return "";
			}
			if ( ( sYear / 4 == parseInt( sYear / 4 ) )  
			     && ! ( ( sYear / 100 == parseInt( sYear / 100 ) ) 
		                     && ( sYear / 400 != parseInt( sYear / 400 ) ) ) ) {
				var bLeapYear = true;
			} else {
				var bLeapYear = false;
			}
			if ( ! bLeapYear && sDay==29 ) {
				return "";
			}
		}
	
		// Day format
		if ( sDay.length == 1 ) { sDay = "0" + sDay; }
	
		// Month format
		if ( sMonth.length == 1 ) { sMonth = "0" + sMonth; }
	
	
		// Date format
		return ( sDay + "/" + sMonth + "/" + sYear );
	
}

function IsNumeric( sNumber ) {

	// Check String contains just numeric values
	for ( lPos = 0; lPos < sNumber.length; lPos++ ) {
		var sChar = sNumber.charAt( lPos );
		if ( isNaN( parseInt( sChar ) ) 
		     && sChar != "+"
		     && sChar != "."
		     && sChar != "," ) {
			return "";
		}
	}
	return sNumber;
}

function IsMailAddress( str ) {
   //var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
   //var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+$/;
   //return filter.test(sMail);
   
   		var at="@"
   		var dot="."
   		var lat=str.indexOf(at)
   		var lstr=str.length
   		var ldot=str.indexOf(dot)
   		if (str.indexOf(at)==-1){
   		   //alert("Invalid E-mail ID")
   		   return false
   		}
   
   		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
   		   //alert("Invalid E-mail ID")
   		   return false
   		}
   
   		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
   		    //alert("Invalid E-mail ID")
   		    return false
   		}
   
   		 if (str.indexOf(at,(lat+1))!=-1){
   		    //alert("Invalid E-mail ID")
   		    return false
   		 }
   
   		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
   		    //alert("Invalid E-mail ID")
   		    return false
   		 }
   
   		 if (str.indexOf(dot,(lat+2))==-1){
   		    //alert("Invalid E-mail ID")
   		    return false
   		 }
   		
   		 if (str.indexOf(" ")!=-1){
   		    //alert("Invalid E-mail ID")
   		    return false
   		 }
   
    		 return true					

}

function GetSelectionCombo(pSelect) 
{
	if (pSelect.selectedIndex != -1) 
	{
		// Recuperamos el valor
		return pSelect.options[pSelect.selectedIndex].value;
	} 
	else 
	{
		return "-1";
	}
}

function GetCheckOptionRadioGroup (RadioGroup) 
{
		var nNumElements = 0;
		var i = 0;
		var bEncontrado = false;
		
		nNumElements = RadioGroup.length;
		
		while(!bEncontrado && i < nNumElements) {
			 if (RadioGroup[i].checked == true) {
				bEncontrado = true;
			 } else {
				i++;
			 }
		}
		return bEncontrado;		
}

function replaceDots(entry) {
	out = "."; // replace this
	add = ","; // with this
	temp = "" + entry; // temporary holder
	
	while (temp.indexOf(out)>-1) {
	pos= temp.indexOf(out);
	temp = "" + (temp.substring(0, pos) + add + 
	temp.substring((pos + out.length), temp.length));
	}
	return temp;
}

function replaceCommas(entry) {
	out = ","; // replace this
	add = "."; // with this
	temp = "" + entry; // temporary holder
	
	while (temp.indexOf(out)>-1) {
	pos= temp.indexOf(out);
	temp = "" + (temp.substring(0, pos) + add + 
	temp.substring((pos + out.length), temp.length));
	}
	return temp;
}

function formatearValor(dato)
{
		var i;
		var aux;
		var bConcatenar;
		var sDecimales;
		var sPrimero;
		var sSegundo;
		var sEntero;
		var sNumero;
		
		sDecimales="";
		sEntero="";
		sPrimero="0";
		sSegundo="0";
		sNumero="";
		
		aux=dato
		bConcatenar=-1;
		for (i = 0; i < aux.length; i++)
	    {   
	        // Check that current character isn't whitespace.
	        var c = aux.charAt(i);
			if(c=="," || c==".") 
			{
				bConcatenar=i;
			}
			else
			{
				if(bConcatenar==-1)
				{
					sEntero=sEntero+aux.charAt(i);
				}
			}
			if(bConcatenar!=-1 && bConcatenar!=i) sDecimales=sDecimales+aux.charAt(i);
	    }
		if(sDecimales.length > 2)
		{
			if(parseInt(sDecimales.charAt(2)) < 5)
			{
				sPrimero=sDecimales.charAt(0);
				sSegundo=sDecimales.charAt(1);
			}
			else
			{
				sPrimero=sDecimales.charAt(0);
				sSegundo=(String) (parseInt(sDecimales.charAt(1))+1);
				if(parseInt(sSegundo)>9)
				{
					sPrimero=(String) (parseInt(sDecimales.charAt(0))+1);
					sSegundo="0";
					if(parseInt(sPrimero)>9)
					{
						sPrimero="0";
						sEntero=(String) (parseInt(sEntero)+1)
					}
				}
				
			}
			
		}
		else
		{
			sPrimero=sDecimales.charAt(0);
			sSegundo=sDecimales.charAt(1);
		}
		if(sPrimero=="")sPrimero="0";
		if(sSegundo=="")sSegundo="0";
		if(sPrimero=="0" && sSegundo=="0"){
			sNumero = sEntero; 
		}else{
			sNumero = sEntero+","+sPrimero+sSegundo;
		}
		return sNumero;	
}

function formatearValor2(dato)
	{
		var i;
		var aux;
		var bConcatenar;
		var sDecimales;
		var sPrimero;
		var sSegundo;
		var sEntero;
		var sNumero;
		
		sDecimales="";
		sEntero="";
		sPrimero="0";
		sSegundo="0";
		sNumero="";
		
		aux=dato
		bConcatenar=-1;
		 for (i = 0; i < aux.length; i++)
	    {   
	        // Check that current character isn't whitespace.
	        var c = aux.charAt(i);
			if(c=="," || c==".") 
			{
				bConcatenar=i;
			}
			else
			{
				if(bConcatenar==-1)
				{
					sEntero=sEntero+aux.charAt(i);
				}
			}
			if(bConcatenar!=-1 && bConcatenar!=i) sDecimales=sDecimales+aux.charAt(i);
	    }
		if(sDecimales.length > 2)
		{
			if(parseInt(sDecimales.charAt(2))< 5)
			{
				sPrimero=sDecimales.charAt(0);
				sSegundo=sDecimales.charAt(1);
			}
			else
			{
				sPrimero=sDecimales.charAt(0);
				sSegundo=(String) (parseInt(sDecimales.charAt(1))+1);
				if(parseInt(sSegundo)>9)
				{
					sPrimero=(String) (parseInt(sDecimales.charAt(0))+1);
					sSegundo="0";
					if(parseInt(sPrimero)>9)
					{
						sPrimero="0";
						sEntero=(String) (parseInt(sEntero)+1)
					}
				}
				
			}
			
		}
		else
		{
			sPrimero=sDecimales.charAt(0);
			sSegundo=sDecimales.charAt(1);
		}
		if(sPrimero=="")sPrimero="0";
		if(sSegundo=="")sSegundo="0";
		if(sPrimero=="0" && sSegundo=="0"){
			sNumero = sEntero; 
		}else{
			sNumero = sEntero+","+sPrimero+sSegundo;
		}
		return sNumero;	
	}
	
	function mensaje()
	{
		alert('Debe estar registrado para enviar un cálculo.');
	}
	
	function formateaTexto(nompage) 
		{
		  caractere1 = "éêèëîïíàâáãùüûúóõôç'";
		  caractere2 = "éêèëîïíàâáãùüûúóõôç´";
		  //alphabet = "abcdefghijklmnopqrstuvwxyz0123456789-_:~\\/";
		// nompage = nompage.toLowerCase();
		 for (i=0; i<nompage.length; i++) 
		 {
			  pos = caractere1.indexOf(nompage.charAt(i));
			  if (pos != -1) 
			  {
				  nompage = nompage.substring(0, i) + caractere2.charAt(pos) + nompage.substring(i+1, nompage.length);
			  }
			/*  else {
				   pos = alphabet.indexOf(nompage.charAt(i));
				   if (pos == -1) nompage = nompage.substring(0, i) + '_' + nompage.substring(i+1, nompage.length());
			  }*/
		 }
		 //alert(nompage);
		 return nompage;
		}
	
	