function MM_validateForm() { //v4.0
  var val,i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve conter um endereço de e-mail válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve conter um número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' deve conter um número entre '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é de preenchimento obrigatório.\n'; }
  } if (errors) alert('O seguinte erro ocorreu:\n'+errors);
  return true;
}

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function remove_XS_whitespace(item)
{
  var tmp = "";
  var item_length = item.value.length;
  var item_length_minus_1 = item.value.length - 1;
  for (index = 0; index < item_length; index++)
  {
    if (item.value.charAt(index) != ' ')
    {
      tmp += item.value.charAt(index);
    }
    else
    {
      if (tmp.length > 0)
      {
        if (item.value.charAt(index+1) != ' ' && index != item_length_minus_1)
        {
          tmp += item.value.charAt(index);
        }
      }
    }
  }
  item.value = tmp;
}
//  End -->

function LimpaCampos(frm)
{
  remove_XS_whitespace(frm.Valor_Depositado);
  remove_XS_whitespace(frm.Data_do_Deposito);
  remove_XS_whitespace(frm.Agencia_de_Origem);
  remove_XS_whitespace(frm.Nome_Completo);
}

<!-- Original:  David Blackledge -->
<!-- Web Site:  http://David.Blackledge.com -->
<!-- Modificado:  Joao Rodrigo da Rosa -->
<!-- Begin
function checkRadios() {
// var el = document.forms[0].elements;
 var el = document.form1.elements;
 for(var i = 0 ; i < el.length ; ++i) 
  if(el[i].type == "radio") {
   var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
   var itemchecked = false;
   for(var j = 0 ; j < radiogroup.length ; ++j) {
    if(radiogroup[j].checked) {
	 itemchecked = true;
	 break;
	}
   }
   if(!itemchecked) return false;
  }
 return true;
} 
//  End -->

function JR_validate_ExtraFields(form2valid) { 
  var erros='';
  if (TotalCompra == 0) erros+='Você deve escolher um dos Cursos, Vídeo-Aulas ou E-books!\n';
  if (!checkRadios()) erros+='Preencha corretamente a informação sobre o depósito bancário!\nInforme em qual dos Bancos foi feito o pagamento ou a transferência.\n';
  if (!form2valid.Agencia_de_Origem.value) erros+='Em Agência de Origem, informe a Agência pagadora da sua cidade.\nCaso o pagamento tenha sido feito via envelope, informe o nº do envelope.\n';
  if (erros) alert('Atente para o ocorrido abaixo:\n'+erros);
  if (document.MM_returnValue) document.MM_returnValue = (erros == '');
}
//-->
var TotalCompra = 0;
function ProcessaCursos() {
	ValorTotalCursos = 0;
	ValorTotalTekno = 0;
	var TotalCursos = 0;
	var TotalEbooks = 0;
	var TotalVideo = 0;
	var TotalTekno = 0;
	var Texto = new Array();
	document.form1.TamanhoTotal.value = 0;
	document.form1.PaginasTotal.value = 0;
	document.getElementById("ProdutosTexto").innerHTML = "";
	for (var i = 0; i < document.form1.cursos.length; i++) {
		if (eval("document.form1.cursos[" + i + "].checked")) {
			TotalCursos += 1;
			document.form1.TamanhoTotal.value = document.form1.TamanhoTotal.value / 1 + eval("document.form1." + eval("document.form1.cursos[" + i + "].value") + "mb.value") / 1;
			document.form1.PaginasTotal.value = document.form1.PaginasTotal.value / 1 + eval("document.form1." + eval("document.form1.cursos[" + i + "].value") + "pag.value") / 1;
			Texto.push(eval("document.form1." + eval("document.form1.cursos[" + i + "].value") + "nm.value"));
		}
	}
	ValorTotalCursos = TotalCursos * 15;
	for (var i = 0; i < document.form1.video.length; i++) {
		if (eval("document.form1.video[" + i + "].checked")) {
		TotalVideo += 1;
		document.form1.TamanhoTotal.value = document.form1.TamanhoTotal.value / 1 + eval("document.form1.v" + eval("document.form1.video[" + i + "].value") + "mb.value") / 1;
		Texto.push(eval("document.form1.v" + eval("document.form1.video[" + i + "].value") + "nm.value"));
		}
	}
	ValorTotalVideo = TotalVideo * 32;
	// Exceçoes
	if (document.form1.video[0].checked) // dvd_convformatos
		ValorTotalVideo += 8;
	if (document.form1.video[1].checked) // dvd_falandoempublico
		ValorTotalVideo += 28;
	if (document.form1.video[2].checked) // videohardware
		ValorTotalVideo += 13;
	if (document.form1.video[7].checked) // videodremphpmysql
		ValorTotalVideo += 33;
	if (document.form1.video[8].checked) // jailtonloja
		ValorTotalVideo += 88;
	if (document.form1.video[15].checked) // videoxpbaserico
		ValorTotalVideo += 5;
	if (document.form1.video[19].checked) // videoexcel2007basico
		ValorTotalVideo += 3;
	if (document.form1.video[21].checked) // vidflashcs3basico
		ValorTotalVideo += 18;
	if (document.form1.video[25].checked) // jailtonlogica
		ValorTotalVideo += 67;
	if (document.form1.video[26].checked) // jailtonlogvbnet
		ValorTotalVideo += 38;
	if (document.form1.video[27].checked) // videomatfinanceira
		ValorTotalVideo += 3;
	if (document.form1.video[28].checked) // jailtonmysql
		ValorTotalVideo += 57;
	if (document.form1.video[30].checked) // jailtonphp
		ValorTotalVideo += 67;
	if (document.form1.video[32].checked) // videograficosnoexcel
		ValorTotalVideo += 2;
	if (document.form1.video[33].checked) // jailtonwindowsxp
		ValorTotalVideo += 18;
	if (document.form1.video[35].checked) // vidinterativotabdinex2003
		ValorTotalVideo += 2;
	if (document.form1.video[36].checked) // videosql2005rs
		ValorTotalVideo += 4;
	for (var i = 0; i < document.form1.tekno.length; i++) {
		if (eval("document.form1.tekno[" + i + "].checked")) {
			TotalTekno += 1;
			document.form1.TamanhoTotal.value = document.form1.TamanhoTotal.value / 1 + eval("document.form1.t" + eval("document.form1.tekno[" + i + "].value") + "mb.value") / 1;
			Texto.push(eval("document.form1.t" + eval("document.form1.tekno[" + i + "].value") + "nm.value"));
		}
	}
	if (document.form1.tekno[0].checked) // Autocad 2D
		ValorTotalTekno += 40;
	if (document.form1.tekno[1].checked) // Autocad 3D
		ValorTotalTekno += 40;
	if (document.form1.tekno[2].checked) // Microinformática Prática
		ValorTotalTekno += 35;
	if (document.form1.tekno[3].checked) // Teoria Musical
		ValorTotalTekno += 47;
	if (document.form1.tekno[4].checked) // Profissional Photoshop
		ValorTotalTekno += 44;
	// Verificacao se existe Video selecionada
	if (TotalVideo > 0 || TotalTekno > 0) {
//		if (document.form1.TipoEnvio[0].checked) {
//			alert("Video-aulas só podem ser enviadas através de CD!");
//		}
	// Troca para CD
		document.form1.TipoEnvio[0].checked = false;
		document.form1.TipoEnvio[1].checked = true;
		document.form1.TipoEnvio[0].disabled = 'DISABLED';
	// Desconta 10 agora pra somar 10 download 
		ValorTotalCursos -= 10;
	}
	else {
		document.form1.TipoEnvio[0].disabled = '';
	}
	for (var i = 0; i < document.form1.ebooks.length; i++) {
		if (eval("document.form1.ebooks[" + i + "].checked")) {
		TotalEbooks += 1;
		document.form1.TamanhoTotal.value = document.form1.TamanhoTotal.value / 1 + eval("document.form1.e" + eval("document.form1.ebooks[" + i + "].value") + "mb.value") / 1;
		document.form1.PaginasTotal.value = document.form1.PaginasTotal.value / 1 + eval("document.form1.e" + eval("document.form1.ebooks[" + i + "].value") + "pag.value") / 1;
		Texto.push(eval("document.form1.e" + eval("document.form1.ebooks[" + i + "].value") + "nm.value"));	
		}
	}
	ValorTotalEbooks = TotalEbooks * 20;
	// Exceçoes
	if (document.form1.ebooks[1].checked) // accessavancado
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[5].checked) // accessrelatorios
		ValorTotalEbooks += -5;
	if (document.form1.ebooks[8].checked) // excelavancado
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[9].checked) // excelvba
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[19].checked) // ex2003vstoformsbas
		ValorTotalEbooks += -5;
	if (document.form1.ebooks[23].checked) // wrd2007basico
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[24].checked) // wrd2007ribbon
		ValorTotalEbooks += -5;
	if (document.form1.ebooks[27].checked) // itilv2
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[32].checked) // 70270
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[33].checked) // 70271
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[34].checked) // 70272
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[35].checked) // 70290
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[36].checked) // 70291
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[37].checked) // 70620
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[38].checked) // sp170291
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[48].checked) // s70648
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[49].checked) // s70649
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[50].checked) // passarconcursos
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[51].checked) // contabilidadecomercial
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[52].checked) // contfolhaspagamento
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[53].checked) // conbas
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[54].checked) // diradmin
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[55].checked) // dircivil
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[56].checked) // dircom
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[57].checked) // dirconst
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[58].checked) // dirprcivil
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[59].checked) // dirtribut
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[66].checked) // isa2006bas
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[77].checked) // axcelassdig
		ValorTotalEbooks += -5;
	if (document.form1.ebooks[82].checked) // delphi6cc
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[85].checked) // delphi7cc
		ValorTotalEbooks += 15;
	if (document.form1.ebooks[86].checked) // delphi8cc
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[91].checked) // progrphp
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[96].checked) // digeratiadmemprproject
		ValorTotalEbooks += -5;
	if (document.form1.ebooks[104].checked) // ciditaliana
		ValorTotalEbooks += 25;
	if (document.form1.ebooks[105].checked) // copasmundo 
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[107].checked) // crmalex
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[114].checked) // intavancada
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[117].checked) // secrerec 
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[123].checked) // empreendedorismo
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[124].checked) // digeratiempreentreinexec
		ValorTotalEbooks += -5;
	if (document.form1.ebooks[125].checked) // digeratisucprof
		ValorTotalEbooks += -5;
	if (document.form1.ebooks[129].checked) // frontxp
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[130].checked) // gerproj
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[131].checked) // gerprojav
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[132].checked) // gervendasav
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[133].checked) // gerfinanceira
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[135].checked) // digeratineginf
		ValorTotalEbooks += -5;
	if (document.form1.ebooks[138].checked) // digeratitemarketing
		ValorTotalEbooks += -5;
	if (document.form1.ebooks[140].checked) // msproject2007
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[142].checked) // nata
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[144].checked) // oracle9i 
		ValorTotalEbooks += 10;
	if (document.form1.ebooks[147].checked) // osmlu
		ValorTotalEbooks += 5;
	if (document.form1.ebooks[161].checked) // sql2005 
		ValorTotalEbooks += 17;
	if (document.form1.ebooks[164].checked) // digerativendasaten 
		ValorTotalEbooks += -5;
	ValorTotalCursos += ValorTotalEbooks;
	ValorTotalCursos += ValorTotalVideo;
	ValorTotalCursos += ValorTotalTekno;
	document.form1.TotalCompra.value = "R$ " + (ValorTotalCursos) + ",00";
	document.form1.ValorDepositado.value = "R$ " + (ValorTotalCursos) + ",00";
	TotalCompra = ValorTotalCursos;
	ProcessaEnvio();
	document.floatbox.TamanhoTotal.value = document.form1.TamanhoTotal.value;
	document.floatbox.PaginasTotal.value = document.form1.PaginasTotal.value;
	Texto.sort();
	var LinhaOrdem = "a";
	for (var i = 0; i < Texto.length; i++) {
		Texto[i]="<li class="+LinhaOrdem+">"+Texto[i]+"</li>";
		if (LinhaOrdem == "a") LinhaOrdem = "b"; 
		else LinhaOrdem = "a";
	}		 
	document.getElementById("ProdutosTexto").innerHTML = "<ul>" + Texto.join("") + "</ul>";
}
function ProcessaEnvio() {
	ValorTotal = TotalCompra;
	for (var i = 0; i < document.form1.TipoEnvio.length; i++) {
		if (eval("document.form1.TipoEnvio[" + i + "].checked")) {
			if (eval("document.form1.TipoEnvio[" + i + "].value") == "CD") {
				if (ValorTotal > 0) {
					ValorTotal += 10;
						if (document.form1.ebooks[128].checked) // sql2005 
							ValorTotal -= 2;
				}
			}
			document.form1.EnvioTexto.value = eval("document.form1.TipoEnvio[" + i + "].value");
		}
	}
	document.form1.TotalCompra.value = "R$ " + ValorTotal + ",00";
	document.form1.ValorDepositado.value = "R$ " + ValorTotal + ",00";
	document.floatbox.TotalCompra.value = document.form1.TotalCompra.value;
	document.floatbox.EnvioTexto.value = document.form1.EnvioTexto.value;
}
