function ValidarBlancos(form)
{
	var sw = true;
		
	for (i=0; i<form.elements.length; i++ ) 
	{ 
		if (form.elements[i].value == "" && form.elements[i].type == "text") 
		{ 
			sw = false;	break;
		} 
  	}
	return sw;
}
function ValidarSelect(form)
{
	var sw = true;
		
	for (i=0; i<form.elements.length; i++ ) 
	{ 
		if (form.elements[i].selectedIndex == 0 && form.elements[i].type == "select-one") 
		{ 
			sw = false;	break;
		} 
  	}
	return sw;
}
function validarFormaPrueba(form,varLocation)
{
	var forma = form;
	var swBlanco = ValidarBlancos(forma);
	var swSelect = ValidarSelect(forma);	
	var swEmail = ValidarEmail(forma.email);
	var swEmailv = ValidarEmail(forma.emailv);	
	if(!swBlanco || !swSelect)
		alert("Error... Existen campos vacios. Por favor llenarlos.");
	else if(!swEmail || !swEmailv)
		alert("Error... Formato de email incorrecto.");			
	else if(forma.email.value != forma.emailv.value)
		alert("Error... Los campos de email no coinciden.");		
	else
	{
		forma.action = varLocation;;
		forma.submit();
	}
}
function validarForma(form) {
	var forma = form;
	var swBlanco = ValidarBlancos(forma);
	var swEmail = ValidarEmail(forma.e);
	if(!swBlanco) {
		alert("Error... Existen campos vacios. Por favor llenarlos.");
		return false;
	}
	else if(!swEmail) {
		alert("Error... Formato de email incorrecto.");			
		return false;
	}
	else
	{
		return true;
	}	
}
function ValidarEmail(campo) 
{ 
  var sw = true;
  if (campo.value.indexOf('@') == -1 || campo.value.indexOf('.') == -1 || campo.value.length<6) 
	sw=false;
  return sw; 
}

function BloqueoCaracter(e) 
{
	var isIE = document.all?true:false;
	var isNS = document.layers?true:false;
	var _ret = true;
	
	if (isIE) 
	{
		if (window.event.keyCode < 46 || window.event.keyCode > 57) 
		{
		  window.event.keyCode = 0;
		  _ret = false;
		}
	}
  	if (isNS) 
	{
		if (e.which < 46 || e.which > 57) 
		{
	  		e.which = 0;
	  		_ret = false;
		}
  	}
	return (_ret); 
}

function FormatoMoneda(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);
}