
  function isValidZip(num) { return (/^\d{5}$/.test(num)); }
	function showMessage() 	 { alert("Please enter a valid zip code."); }

	// Assigns ID's for Inline QBs 
	jQuery(document).ready(function() {
		jQuery('form').each(function(i, e) {
			var form 			= '#form-inline';
			var zip				= '#zip-inline';
			var submit 		= '#submit-inline';
			var over65_1	= '#is_over65_1-inline';
			var over65_0	= '#is_over65_0-inline';

			jQuery(form).each(function(e) 		{ jQuery(this).attr('id', "form-"+i) });
			jQuery(zip).each(function(e)  		{ jQuery(this).attr('id', "zip-"+i) });
			jQuery(submit).each(function(e) 	{ jQuery(this).attr('id', "submit-"+i) });
			jQuery(over65_1).each(function(e) { jQuery(this).attr('id', "is_over65_1-"+i) });
			jQuery(over65_0).each(function(e) { jQuery(this).attr('id', "is_over65_0-"+i) });			
  	});
  });

	// Invalid Zip Checker
	jQuery(document).ready(function() {	
		jQuery('form').each(function(i, e) {
			jQuery(e).submit(function(e) {
				var formUsed  =  '#' + this.id;			// Uses Form Information From Corresponding Submit
				var zip   		=  jQuery(formUsed + ' [name="zip"]').val();	
				var senior    =  jQuery(formUsed + ' [name="over65"]:checked').val();
			  var urltogoto =  jQuery(formUsed + ' [name="urltogoto"]').val();
			  var sid       =  jQuery(formUsed + ' [name="sid"]').val();
				if(!isValidZip(zip)){ showMessage(); return false; } else {
				  var params  	=  "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,status=yes,";
				  	  params    += "width=" + screen.width;
				  	  params    += ",height=" + screen.height;
				  	  params    += ",fullscreen=yes";
				  var pops    	=  "popup_handler.php" + "?zip=" + zip + "&over65=" + senior;
			  	window.open(pops, "", params).blur();
			  	window.focus();
				}				
			});
		});
	});
	
	// Replaces "Enter Zip" From Title to Value
	jQuery(document).ready(function() {
		/* on focus restore */
		jQuery(".default_value").each(function() {
			jQuery(this).val(jQuery(this).attr('title'));
	    jQuery(this).addClass('placeholder');
		  var default_value = jQuery(this).attr('title');
		
		  jQuery(this).focus(function() {
		  	if(this.value == default_value) {
		    	jQuery(this).val("");
	        jQuery(this).removeClass('placeholder');
				}
			});
	  	jQuery(this).blur(function() {
	    	if(this.value == "") {
	      	jQuery(this).val(default_value);
	        jQuery(this).addClass('placeholder');
	    	}
	    });
		});
	});
	
