function verifyLogin(status)
{
	if(status == "fail")
		alert('E-mail ou senha incorretos.\nTente novamente.');
	else if(status == "0")
		alert("Sua conta ainda não foi ativada.");
}

function verifyLoginIngl(status)
{
	if(status == "fail")
		alert('E-mail or password incorrects.\nTry again.');
	else if(status == "0")
		alert("Your account still has not been activated.");
}

function verifyCad(resp)
{
	if(resp == "existe")
		alert('O e-mail informado j\u00E1 se encontra cadastrado em nosso sistema! Utilize outro e-mail.');
}

function verifyCadIngl(resp)
{
	if(resp == "existe")
		alert('The e-mail address that you supplied is already in use in our system! Please select another email address.');
}

function verifyRecoverIngl(bol, mail)
{
	if(bol == "true")
		alert('Your password to the Heat Transfer Calculation Program was sent to your registered e-mail.');
	else if(bol == "false")
		alert("The informed e-mail is not registered in our system.");
}

function verifyRecover(bol, mail)
{
	if(bol == "true")
		alert("'Sua senha de acesso ao Software de C\u00E1lculo de Transf\u00EArecia de Calor foi enviada para o e-mail '" + mail + "'");
	else if(bol == "false")
		alert("O e-mail '" + mail + "' informado n\u00E3o se encontra cadastrado em nosso sistema.");
}

function validaMD5()
{
	with(document.formlogin)
	{
		if(login.value == "")
		{
			alert('Entre com seu login!');
			login.focus();
			
			return false;
		}
		else if(pass.value == "")
		{
			alert('Entre com sua senha');
			pass.focus();
			
			return false;
		}
		else
		{
			login.value = hex_md5(login.value);
			pass.value = hex_md5(pass.value);
		}
	}
	
	return true;
}

function verifyMask(obj, func)
{
	v_obj = obj;
    v_fun = func;
	
    setTimeout("execMask()", 1);
}

function execMask()
{
    v_obj.value = v_fun(v_obj.value);
}

function vData(v)
{
	v = v.replace(/\//g, "-");
	
	if(v.length < 3)
		v = v.replace(/(\d{2})/g, "$1-");
	else if(v.length >= 3 && v.length < 6)
		v = v.replace(/(\d{2})-(\d{2})/g, "$1-$2-");
	else if(v.length > 10)
		v = v.slice(0, 10);
	
	return v;
}

function vVal(v)
{
	v = v.replace(/,/g, ".");
	
	return v;
}

function validaBusca()
{
	with(formsearch)
	{
		if(busca.value == "" && dataini.value == "" && dataend.value == "" && valini.value == "" && valend.value == "")
		{
			alert('Entre com parametros para busca.');
			busca.focus();
			
			return false;
		}
		else if(dataini.value.length < 10)
		{
			alert('Verifique a data inserida!');
			dataini.focus();
			
			return false;
		}
		else if(dataend.value != "")
			if(dataend.value.length < 10)
			{
				alert('Verifique a data inserida!');
				dataend.focus();
				
				return false;
			}
	}
	
	return true;
}

function setPromo(flagpromo)
{
	var targ = document.getElementById('divfloat');
	
	if(flagpromo)
	{
		if(document.all)
			targ.style.left = (screen.width / 2);
		else
			targ.style.left = (screen.width / 2) - 460;
		targ.style.display = "block";
		flagpromo = false;
	}
	else
	{
		targ.style.display = "none";
		flagpromo = true;
	}
}

function setPromoIndex(flagpromo)
{
	var targ = document.getElementById('divfloat');
	
	if(flagpromo)
	{
		targ.style.left = (screen.width / 2) - 460;
		targ.style.display = "block";
		flagpromo = false;
	}
	else
	{
		targ.style.display = "none";
		flagpromo = true;
	}
}

function openCalc()
{
	var width = (window.screen.width / 2) - 231;
	var height = (window.screen.height / 2) - 140;
	
	var parameters = 'location=no,scrollbars=no,status=no,resizable=no,maximize=no,width=462,height=280,left=' + width + ',top=' + height;
	
	window.open('calculadora.html', 'calc', parameters);
}

function openConv()
{
	var width = (window.screen.width / 2) - 275;
	var height = (window.screen.height / 2) - 215;
	
	var parameters = 'location=no,scrollbars=no,status=no,resizable=no,maximize=no,width=570,height=430,left=' + width + ',top=' + height;
	
	window.open('http://www.ipem.sp.gov.br/5mt/cv2/index.htm', 'conv', parameters);
}

