
function redireciona(url)
{
	window.location=url;
}

function login()
{
	
	//Inicialização Ajax	
		var ajaxRequest;  // The variable that makes Ajax possible!	
		try
		{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} 	
		catch (e)
		{
		// Internet Explorer Browsers
			try
			{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e) 
			{
				try
				{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch (e)
				{
					// Something went wrong
					alert("Browser não compatível");
					return false;
				}
			}
		}		
		//Fim init ajax
		
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function()
		{			
			if(ajaxRequest.readyState < 4)
			{
				var ajaxDisplay = document.getElementById('status_login');
				//ajaxDisplay.innerHTML = '<img src="imagens/ajax-loader.gif" width="16" height="16"/>';
				//ajaxDisplay.innerHTML = 'Carregando...';
			}
	
			
			if(ajaxRequest.readyState == 4)
			{
				if(ajaxRequest.status==200)
				{					
					var ajaxDisplay = document.getElementById('status_login');						
					var resposta = ajaxRequest.responseText;					
					if(resposta=="1")	
					window.location="select_veiculo.php";					
					else
					ajaxDisplay.innerHTML = "Login ou Senha incorretos";					
				}
			}
		}
	
	
		var login = document.getElementById('login').value;	
		var senha = document.getElementById('senha').value;		
		var queryString = "login="+login + "&senha="+senha;
		ajaxRequest.open("POST", "checa_login.php", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");	
		ajaxRequest.setRequestHeader("Content-length", queryString.length); 
		ajaxRequest.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		ajaxRequest.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		ajaxRequest.setRequestHeader("Pragma", "no-cache");
		ajaxRequest.send(queryString);			
}	
	


function alterar_horario()
{
	
	//Inicialização Ajax	
		var ajaxRequest;  // The variable that makes Ajax possible!	
		try
		{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} 	
		catch (e)
		{
		// Internet Explorer Browsers
			try
			{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch (e) 
			{
				try
				{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} 
				catch (e)
				{
					// Something went wrong
					alert("Browser não compatível");
					return false;
				}
			}
		}		
		//Fim init ajax
		
		
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function()
		{			
			if(ajaxRequest.readyState < 4)
			{
				var ajaxDisplay = document.getElementById('status_horario');
				//ajaxDisplay.innerHTML = '<img src="imagens/ajax-loader.gif" width="16" height="16"/>';
				//ajaxDisplay.innerHTML = 'Carregando...';
			}
	
			
			if(ajaxRequest.readyState == 4)
			{
				if(ajaxRequest.status==200)
				{					
					var ajaxDisplay = document.getElementById('status_horario');	
					ajaxDisplay.innerHTML = ajaxRequest.responseText;						
				}
			}
		}
	
	
		var horario = document.getElementById('horario').value;	
	
		var queryString = "horario="+horario;
		ajaxRequest.open("POST", "altera_horario.php", true);
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");	
		ajaxRequest.setRequestHeader("Content-length", queryString.length); 
		ajaxRequest.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		ajaxRequest.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		ajaxRequest.setRequestHeader("Pragma", "no-cache");
		ajaxRequest.send(queryString);			
}



function ajaxNoHistory()
{
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try	{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} 
	catch (e)	{
		// Internet Explorer Browsers
		try		{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e){
				// Something went wrong
				alert("Browser não compatível");
				return false;
			}
		}
	}
		
	ajaxRequest.onreadystatechange = function()
	{
		/*if(ajaxRequest.readyState < 4)
		{
			var ajaxDisplay = document.getElementById('map');
			ajaxDisplay.innerHTML = "<div id=\"loading\" align=\"center\"><img src=\"history-loader.gif\" width=220 height=19 /></div>";
			//ajaxDisplay.innerHTML = "Carregando...";
		}*/
	
		if(ajaxRequest.readyState == 4)
		{		
			if (ajaxRequest.status ==200)	
			{				
				var map = new GMap2(document.getElementById("map"));				        	
				map.addControl(new GLargeMapControl());
				map.addControl(new GMapTypeControl());
				map.addControl(new GScaleControl());
				map.setCenter(new GLatLng(lat,lng), zoom_level);
				GEvent.addListener(map, "moveend",function() 
				{var zoom = map.getZoom();
				document.cookie = "zoom="+zoom;
				}); 
				
				
				var point = new GLatLng(lat,lng);
				
				if(cge=="A")
					var marker = new GMarker(point,iconGreen);	
				
				else if(cge=="H" || cge=="B")
					var marker = new GMarker(point,iconRed);	
				
				else
					var marker = new GMarker(point,iconOrange);
				map.addOverlay(marker);	
			}						
			
		}
	}
	
	ajaxRequest.open("GET", "mapa.php", true);	
	ajaxRequest.send(null);		
}


function ajaxHistory()
{
	var ajaxRequest;  // The variable that makes Ajax possible!	
	try	{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} 
	catch (e)	{
		// Internet Explorer Browsers
		try		{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e){
				// Something went wrong
				alert("Browser não compatível");
				return false;
			}
		}
	}
		
	ajaxRequest.onreadystatechange = function()
	{
		if(ajaxRequest.readyState < 4)
		{
			var ajaxDisplay = document.getElementById('map');
			ajaxDisplay.innerHTML = "<div id=\"loading\" align=\"center\"><img src=\"history-loader.gif\" width=220 height=19 /></div>";
			//ajaxDisplay.innerHTML = "Carregando...";
		}
	
		if(ajaxRequest.readyState == 4)
		{			
			if (ajaxRequest.status == 200)	
			{
				var map = new GMap2(document.getElementById("map"));				        	
				map.addControl(new GLargeMapControl());
				map.addControl(new GMapTypeControl());
				map.addControl(new GScaleControl());
				map.setCenter(new GLatLng(lat,lng), zoom_level);
				GEvent.addListener(map, "moveend",function() 
				{var zoom = map.getZoom();
				document.cookie = "zoom="+zoom;
				}); 				
			}			
		}			
				
	}
	
	ajaxRequest.open("GET", "mapa.php", true);	
	ajaxRequest.send(null);	
}