// JavaScript Document
	$(document).ready(function() 
	{

			/* Javascript para validar Formularios */

			$("#formPaso3").bind("submit", function(e)
			{
				/******************
				 *Config***********
				 ******************/
				
				
				var bgcolor = $(this).find('input[id=_bgcolor]').attr('value');
				if (bgcolor == null)
				{
					bgcolor = "#FAA109";
				}
				
				var fontcolor = $(this).find('input[id=_fontcolor]').attr('value');
				if (fontcolor == null)
				{
					fontcolor = "#FFFFFF";
				}

				/******************
				 *Filtros**********
				 ******************/
				var filtros = 
				{
					obligatorio:function(el) 
							   	{
									return ($(el).val() != '' && $(el).val() != -1);
							   	},
					numerico: function(el)
								{
									if (/^[0-9]*$/.test($(el).val()) && $(el).val() != "")
									{
										return true;
									}
									else
									{
										return false;
									}
								}
				}
				
				/******************
				 *CORE*************
				 ******************/
				 
				var aux = true;
				checkSeleccionado = $(this).find("input[name=idtipocupon]:checked").attr('value');
				switch (checkSeleccionado)
				{
					case '1':
						if ( !filtros['obligatorio']( $('#tipo_1_valor') ) )
						{
							$('#tipo_1_valor').css({"background":bgcolor, "color":fontcolor});
							aux = false;
							$('#tipo_1_valor').focus(function()
							{
									$(this).removeAttr("style");
							});
						}
						break;
					case '2':
						if (!filtros['numerico']($('#tipo_2_valor1')))
						{
							$('#tipo_2_valor1').css({"background":bgcolor, "color":fontcolor});
							aux = false;
							$('#tipo_2_valor1').focus(function()
							{
									$(this).removeAttr("style");
									$(this).unbind('focus');
							});
						}
						if (!filtros['numerico']($('#tipo_2_valor2')))
						{
							$('#tipo_2_valor2').css({"background":bgcolor, "color":fontcolor});
							aux = false;
							$('#tipo_2_valor2').focus(function()
							{
									$(this).removeAttr("style");
									$(this).unbind('focus');
							});
						}
						break;
					case '3':
						if ( !filtros['obligatorio']( $('#tipo_3_valor') ) )
						{
							$('#tipo_3_valor').css({"background":bgcolor, "color":fontcolor});
							aux = false;
							$('#tipo_3_valor').focus(function()
							{
									$(this).removeAttr("style");
									$(this).unbind('focus');
							});
						}
						break;
					default:
						aux = false;
						break;
				}
				var cantidad = new Number($('#cantidad').val());
				if (cantidad < 10 || cantidad > 100)
				{
					$('#cantidad').css({"background":bgcolor, "color":fontcolor});
					$('#cantidad').val('Min. 10 Max. 100');
					$('#cantidad').focus(function()
					{
							if ($('#cantidad').val() == 'Min. 10 Max. 100')
							{
								$('#cantidad').val('');
							}
							$(this).removeAttr("style");
							$(this).unbind('focus');
					});
					aux = false;
				}
				
				/*Si aux es false quiere decir que un filtro dio false*/
				if (!aux)
				{
					/*Paro el evento submit*/
					e.preventDefault();
					e.stopPropagation();
					return false;
				}
			});
			
			$(this).find("input[name=idtipocupon]").bind('change',function()
			{
				$('#tipo_1_valor').removeAttr("style");
				$('#tipo_2_valor1').removeAttr("style");
				$('#tipo_2_valor2').removeAttr("style");
				$('#tipo_3_valor').removeAttr("style");
			});
		/*-------------------*/
		
		
	});
