$.validator.setDefaults({
	submitHandler: function() { 
		$.post("salva.asp",$("#salva").serialize());
		$('#campos').fadeOut('fast',function(){ 
			$('#msg').fadeIn('fast',function(){
				//pageTracker._trackPageview('/90a/sucesso');
			});
		})
	}
});

$(function(){
	
	//limitando textarea
	$('textarea.limited').maxlength({
		'feedback' : '.restantes' // note: looks within the current form
	});
	
	$('input[name="conteudo"]').click(function(){
		$('#conteudourl').removeAttr('disabled').focus();
	});
	
	$('input[name="canal"]').click(function(){
		$('#canalurl').removeAttr('disabled').focus();
	});
	
	$("#salva").validate({
		
		rules: {
			
			nome: "required",
			historia: "required",
			ano: "required",
			conteudourl: {
				required: function(element) {
					return $("input[name=conteudo]:checked").val() != null;
				}
			},
			canalurl: {
				required: function(element) {
					return $("input[name=canal]:checked").val() != null;
				}
			}
		},
		messages: {
			nome: "",
			historia: "",
			ano: "",
			conteudourl: "",
			canalurl: ""
		}
	});
	
	
	
	
});


function mostraextras(){
	showextras();
}

function showform(){
	//window.location.href = "#/seucitroen";
	tb_show(null, '#TB_inline?height=480&width=560&inlineId=form-cnt', null);	
}
function showextras(){
	//window.location.href = "#/download";
	tb_show(null, '#TB_inline?height=380&width=540&inlineId=extras-cnt', null);	
}

function showreserve(){
	//window.location.href = "#/reserve";
	tb_show(null, 'http://www.citroen.com.br/contato/vendas/?ReserveAgora=1&KeepThis=true&TB_iframe=true&height=500&width=640', null);	
}
function promocheers(){
	//window.location.href = "#/cheers";
	tb_show(null, 'promo_cheers.asp?KeepThis=true&TB_iframe=true&height=500&width=830', null);	
}
function promoviagemparis(){
	//window.location.href = "#/viagem_paris";
	tb_show(null, 'promo_viagem-paris/index.html?KeepThis=true&TB_iframe=true&height=605&width=840', null);	
}
function showreservepromoviagemparis(){
	//window.location.href = "#/reserve";
	tb_show(null, 'http://www.citroen.com.br/contato/vendas/?ComprouGanhou=1&KeepThis=true&TB_iframe=true&height=500&width=640', null);	
}