function verificaNews(form){
	var email = form.email.value;
    if((email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)||(email == '::Digite seu e-mail::')){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.email.focus();
    	return false;
	}
}
////////////////////////////////////////////////////////////////////////////////////////////
// FUNÇÃO PARA DESCADASTRAR DA NEWSLETTER
function fnDescadastrar(){
	var email = document.getElementById('email').value;
    if((email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)||(email == '::Digite seu e-mail::')){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	document.getElementById('email').focus();
    	return false;
	}
	location.href='descadastrar.php?email='+email;
}
function fnAdicionaFavoritos(){
	str_titulo = "Dahruj Veiculos";
	str_url = "http://www.dahrujveiculos.com.br";
	try{
		if(window.external){window.external.AddFavorite(str_url,str_titulo); }
	}
	catch(e)
	{
		try{
			if(window.sidebar){ window.sidebar.addPanel(str_titulo,str_url,""); }
		}
		catch(ee)
		{
			if(window.opera && window.print){ return true; }
		}
	}
}

//Funcao de popup
function MM_openBrWindow(theURL,winName,features){
	var myWin =  window.open(theURL,winName,features);
	myWin.focus();
}

function fnFlash(str_url, int_largura, int_altura)
{
	document.writeln('<object type="application/x-shockwave-flash" data="' + str_url + '" width="' + int_largura + '" height="' + int_altura + '">');
	document.writeln('<param name="movie" value="' + str_url + '">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('</object>');
}

function verificaBusca(form){
	if((form.busca.value.length <= 2)||(form.busca.value == "Produto::")){
		alert("Preencha a Busca corretamente para obter suas informações.");
		form.busca.focus();
		return false;
	}
}

function verificaLogin(form){
	var email = form.emaill.value;
    if((email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)||(email == 'E-mail:')){
    	alert("O campo Email deve ser preenchido corretamente");
    	form.emaill.focus();
    	return false;
	}
	if((form.senha.value.length <= 5)||(form.senha.value == "Senha:")){
		alert("Preencha a Senha corretamente para obter suas informações.");
		form.senha.focus();
		return false;
	}
}
function ValidaForm_senha(form){
	var str_email = form.emailsenha.value ;
    if (( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) || ( str_email == 'Email:' )){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.emailsenha.focus();
    	return false;
	}

}
//funcao para o (mostrar e ocultar)
function onOff(id){
	esconder = (document.getElementById(id).style.display == 'block');
	/*if ( visivel == "" || visivel == "none" ) { document.getElementById(id).style.display = "block" }
	else{ document.getElementById(id).style.display = "none"; }*/
	divs = document.getElementsByTagName('DIV');
	for(d=0; d<divs.length; d++){
		_div = divs[d];
		if (_div.className == 'titulo'){
			id_link = 'titulo_'+(_div.id);
			_link = document.getElementById(id_link);
			if(_div.id != id){ _div.style.display = 'none'; }
			else{ _div.style.display = esconder ? 'none' : 'block'; }
		}
	}
}
//mostra e oculta (menu)
function mostra(campo){
    document.getElementById(campo).style.display='' ;
}

function oculta(campo){
    document.getElementById(campo).style.display='none' ;
}

// TIRA O CHECK DOS CAMPOS DA BUSCA
function fnTiraCheck(tipo){
	if((tipo != 'M')&&(document.getElementById('okmm').checked == true)&&(document.getElementById('seminovos').checked == true)){
		document.getElementById('motos').checked = false;
		document.getElementById('li_1').style.display = 'none';
		document.getElementById('li_2').style.display = 'none';
		document.getElementById('li_3').style.display = 'none';
		document.getElementById('li_4').style.display = 'none';
		document.getElementById('li_5').style.display = '';
	}
	else if((tipo != 'M')&&(document.getElementById('okmm').checked == true)&&(document.getElementById('seminovos').checked == false)){
		document.getElementById('motos').checked = false;
		document.getElementById('li_1').style.display = 'none';
		document.getElementById('li_2').style.display = '';
		document.getElementById('li_3').style.display = 'none';
		document.getElementById('li_4').style.display = 'none';
		document.getElementById('li_5').style.display = 'none';
	}
	else if((tipo != 'M')&&(document.getElementById('okmm').checked == false)&&(document.getElementById('seminovos').checked == true)){
		document.getElementById('motos').checked = false;
		document.getElementById('li_1').style.display = 'none';
		document.getElementById('li_2').style.display = 'none';
		document.getElementById('li_3').style.display = '';
		document.getElementById('li_4').style.display = 'none';
		document.getElementById('li_5').style.display = 'none';
	}
	else if((tipo == 'M')&&(document.getElementById('motos').checked == true)){
		document.getElementById('okmm').checked = false;
		document.getElementById('seminovos').checked = false;
		document.getElementById('li_1').style.display = 'none';
		document.getElementById('li_2').style.display = 'none';
		document.getElementById('li_3').style.display = 'none';
		document.getElementById('li_4').style.display = '';
		document.getElementById('li_5').style.display = 'none';
	}
	else if((document.getElementById('okmm').checked == false)&&(document.getElementById('seminovos').checked == false)&&(document.getElementById('motos').checked == false)){
		document.getElementById('li_1').style.display = '';
		document.getElementById('li_2').style.display = 'none';
		document.getElementById('li_3').style.display = 'none';
		document.getElementById('li_4').style.display = 'none';
		document.getElementById('li_5').style.display = 'none';
	}
}

function pesquisar_dados(valor,pagina,campo,selecionado){
	extensao = 1;
	for(cont_string=0; cont_string<pagina.length; cont_string++){
		if(pagina.charAt(cont_string) == '.'){ extensao = 0; }
	}
	if(extensao != 0){ pagina = pagina+'.php?'; }
	else{ pagina = pagina+'&'; }
	http.open("GET",pagina+"id="+valor,true);
	http.onreadystatechange = function(){ handleHttpResponse(campo,selecionado); };
	http.send(null);
}

function handleHttpResponse(campo,selecionado){
	campo_select = document.getElementById(campo);
	if(http.readyState == 4){
		campo_select.options.length = 0;
		results = http.responseText.split(",");
		for(i=0; i<(parseInt(results.length)-1); i++){
			string = results[i].split("|");
			if(string[0] != ''){
				campo_select.options[i] = new Option(string[0],string[1]);
				if(selecionado == string[1]){ campo_select.options[i].selected = true; }
			}
			if(selecionado == ''){ campo_select.options[0].selected = true; }
		}
	}
}

function getHTTPObject(){
	if(typeof ActiveXObject == "undefined" && typeof XMLHttpRequest == "undefined") return null;
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5){
		try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e){
			try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (E){ xmlhttp = false; }
		}
	}
	@else xmlhttp = null;
	@end @*/
	if(xmlhttp == null && typeof XMLHttpRequest != 'undefined'){
		try{ xmlhttp = new XMLHttpRequest(); }
		catch(e){ xmlhttp = null; }
	}
	return xmlhttp;
}
var http = getHTTPObject();
