function News(){
	$.ajax({
		url: '/api/marketing/',
		success: function(html){
			$("body").append(html);
			$("#marketing").fadeIn(function(){
				$(this).css({"display":"block"});
			});
			$("#close").click(function(){
				$("#marketing").fadeOut(function(){
					$(this).css({"display":"none"});
					$(this).remove();
				});
			});
			$("#submit").click(function(){
				var email = $("#email").val(),
					nome  = $("#nome").val();
				$.ajax({
					url: '/api/marketing/'+nome+'/'+email+'/',
					success: function(result){
						$("#status").append('<span>'+result+'</span>');
						$("#submit").replaceWith('<div id="voltar">Voltar</div>');
						$("#voltar").click(function(){
							$("#marketing").remove();
							News();
						});
					}
				});
			});
		}
	});
}
function swf(video,pasta){
	$.ajax({
		url: '/api/homevideos/?dir='+pasta+'&i='+video,
		success: function(html){
			$("#video object").remove();
			$("#video").append(html);
		}
	});
}
function alertBox(texto,largura){
	var html = '';
		html+= '';
		html+= '';
		html+= '';
	
}
function lojas(loja){
	$("#mapas").remove();
	$.ajax({
		url: '/api/mapas/'+loja,
		success: function(html){
			$("body").append(html);
			$("#mapas").fadeIn(360,function(){
				$(this).css({"display":"block"});
			});
			$("#close").click(function(){
				$("#mapas").fadeOut(360,function(){
					$(this).css({"display":"none"});
					$(this).remove();
				});
			});
		}
	});
}
function SelectVendedor(){
	var vendedor = $("#select-cidade").val();
	location='/?change='+vendedor;
	return false;
}
function models(id){
	$("#_detalhes").stop(true,true).fadeOut(300).remove();
	$.ajax({
		url: '/novos/get/'+id+'/',
		success: function(html){
			$("#_get").append(html);
			$("#_detalhes").fadeIn(300,function(){
				$(this).css({"display":"block"});
			});
		}
	});
		
}

function novosFoto(src){
	var html = '<div id="novosFoto"><img src="/img/carros/novos/fotos/'+ src +'" alt="" /></div>';
	$("body").append(html);
	$("#novosFoto").fadeIn(350);
	$("#novosFoto").click(function(){
		$(this).remove();	
	});
}
function validation(action,ids){
	var colorErro = '#c83434',
		colorReturn = '#494949',
		form = '#form',
		method = 'post',
		result = '.erro',
		status = true;
	$.each(ids,function(index,value){
		if($(value).val()==""){
			status = false;
			$("input"+value).ready(function(){
				$(value).css({"border-color":colorErro,"-moz-box-shadow":"0px 0px 5px "+colorErro,"-webkit-box-shadow":"0px 0px 5px "+colorErro,"box-shadow":"0px 0px 5px "+colorErro});
				$(value).keypress(function(){
					$(this).css({"border-color":colorReturn,"-moz-box-shadow":"0px 0px 0px "+colorErro,"-webkit-box-shadow":"0px 0px 0px "+colorErro,"box-shadow":"0px 0px 0px "+colorErro});
				});
			});
			$("select"+value).ready(function(){
				$(value).css({"border-color":colorErro,"-moz-box-shadow":"0px 0px 5px "+colorErro,"-webkit-box-shadow":"0px 0px 5px "+colorErro,"box-shadow":"0px 0px 5px "+colorErro});
				$(value).change(function(){
					$(this).css({"border-color":colorReturn,"-moz-box-shadow":"0px 0px 0px "+colorErro,"-webkit-box-shadow":"0px 0px 0px "+colorErro,"box-shadow":"0px 0px 0px "+colorErro});
				});
			});
		}
	});
	if(status){
		$(form).attr({"action":action,"method":method});
		$(form).submit();
	} else {
		$("#_erro_texto").remove();
		$(result).append('<div id="_erro_texto">Preencha todos os campos grifados em vermelho</div>');	
	}
}

