function submitCotiz(){
	var codPos = $('#postal').val();
	var tipAut = $('#vehiculo').val();
	var pageDest = "https://autos.segurosbanamex.com.mx";
	if ((codPos == '') || (codPos > '99999')) {
		jAlert("Por favor, ingrese un c&oacute;digo postal.");
		return false;
	} else {
		if (codPos.length < 4) {
			jAlert("El c&oacute;digo postal debe tener entre 4 y 5 d&iacute;gitos.<br/>Por favor, ingr&eacute;selo nuevamente.");
			return false;
		}
		if (tipAut == 0){
			jAlert("Por favor, seleccione un tipo de veh&iacute;culo.");
			return false;
		}
	}
	var newLoc = pageDest + "?cp=" + codPos + "&tv=" + tipAut;
	var newWindow = window.open(newLoc,'_blank');
	newWindow.focus();
}

function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val();
	var textlength = text.length;
	if(textlength > limit)
	{
		//$('#' + infodiv).html('You cannot write more then '+limit+' characters!');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
		{
			//$('#' + infodiv).html('You have '+ (limit - textlength) +' characters left.');
			return true;
		}
	}

$(document).ready(function(){
	$('input#postal').clearingInput();

	$("#postal").keydown(function(event) {
		if ( event.keyCode == 46 || event.keyCode == 8 ) {
		}
		else {
			if ((event.keyCode < 48 || event.keyCode > 57 ) && (event.keyCode < 96 || event.keyCode > 105 )) {
				event.preventDefault();
			}
		}
	});
	
	$('#postal').keyup(function(){
		limitChars('postal', 5, '');
	})

	$("#ingreso").validate();

	if ($("#btnContinuar").length > 0 ) {
		$("#btnContinuar").click(function(){submitCotiz(); return false;})
	};
});
