/*
   Script:					Checar.js

   Author:					Marcio Braga
							outsource
							
   Description:			    Generic validation routine.

   
*/


function notExist(Obj)
{
   return (typeof(Obj) == 'undefined');
}

function Exist(Obj)
{
   return  !(typeof(Obj) == 'undefined');
}

function strToInt(Obj)
{
  var valor = parseInt(Obj.value);
  if (isNaN(valor))
	  return 0
  else
	  return valor;

}

function goBack() {
	 
  if (navigator.appVersion.indexOf("MSIE") > 0)
    history.back(-1);
  else
    window.back();
}

function goLogin() { document.location.href = HOST+'/_login'}
function goAgendaCarro() {
   if (!temPlacaSelecionada())
 	 goMinhasAgendas()
    else
	  document.location.href = HOST + '/selagenda?PlacaID='+GLOBAL_PlacaID
	}
function goMinhasAgendas() {document.location.href = HOST + '/agendas'}
function goMeusDados() {document.location.href = HOST + '/usuario?$action='+taSEARCH}
function goAdicionarCarro() { document.location.href = HOST + '/mycar?$action='+taNEW_RECORD}
function temPlacaSelecionada() 
{
  if (GLOBAL_PlacaID == '')
	{
	  alert('Você deve selecionar um carro');
	  return false;
    }
	else
	  return true;
}
function goServicosRealizados() 
{     
	if (!temPlacaSelecionada())
        goMinhasAgendas()
     else
	   document.location.href = HOST + '/selagenda?$$filtro=1'
}
function goMeuCarro() 
	{
     if (!temPlacaSelecionada())
        goMinhasAgendas()
     else
    	document.location.href = HOST + '/mycar?$action='+taSEARCH+'&$_placa='+ GLOBAL_PlacaID
	}
function goMeuCarroPlaca(Placa)
{
  document.location.href = HOST + '/mycar?$action='+taSEARCH+'&$_placa='+ Placa;
}
function goAtualizarKm() 
	{

   if (!temPlacaSelecionada())
	 goMinhasAgendas()
   else
	document.location.href = HOST + '/atualiza' 
	}
function goServicos() {document.location.href = HOST + '/debug?&$pg=lstservicos' }
function goCadastrarServico() {document.location.href = HOST + '/servico?$action='+taNEW_RECORD}
function goAdicionarAgenda() 
 { 
   if (!temPlacaSelecionada())
	 goMinhasAgendas()
   else
     document.location.href = HOST + '/mycaragenda?$action='+taNEW_RECORD
 }
