function doDownload(str_arquivo, chk)
{
	if(document.getElementById('id_select_down'))
	{
		document.getElementById('id_select_down').style.display='none';
	}
	
	if(str_arquivo == "")
	{
		for(it=0; it<document.down_mail.sc_download.length; it++)
		{
			if(document.down_mail.sc_download[it].checked == true)
			{
				str_arquivo = document.down_mail.sc_download[it].value;
				break;
			}
		}
	}
	
	if(str_arquivo != "")
	{
		ok = true;
		if (typeof(chk) != "undefined")
		{
			ok = checkMail();
		}
		
		if (ok)
		{
			if(document.getElementById('id_down_lang'))
			{
				str_lang = document.getElementById('id_down_lang');
				if(str_lang.options[str_lang.selectedIndex])
				{
					str_lang = str_lang.options[str_lang.selectedIndex].value;
					str_arquivo = str_arquivo.replace("{str_lang}", str_lang);
				}
			}

			document.down.dl_file.value = str_arquivo;
			document.down.submit();
			
			if(document.down_mail.trial)
			{
				document.down_mail.trial.checked = false;
			}
			if(document.down.email)
			{
				document.down.email.value = "";
			}
		}
	}else
	{
		document.getElementById('id_select_down').style.display='';
	}
}

function checkMail()
{
	var x = document.down.email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if(document.down_mail.trial.checked && x == "")
	{
		alert(str_lang_js_error_empty_email);
		return false;
	} else if (document.down_mail.trial.checked && !filter.test(x))
	{
		alert(str_lang_js_error_invalid_email);
		return false;
	} else
	{
		return true;
	}
}

function mostraMsg()
{
	for(it=0; it<document.down_mail.sc_download.length; it++)
	{
		if(document.down_mail.sc_download[it].checked == true)
		{
			if(document.getElementById('id_sc_download' + it))
			{
				document.getElementById('id_sc_download' + it).style.display='';
			}
		}else
		{
			if(document.getElementById('id_sc_download' + it))
			{
				document.getElementById('id_sc_download' + it).style.display='none';
			}
		}
	}
}
