$(document).ready(function() {
      $("#promocode").bind("keypress", function(evt) 
      { 
	    var charCode = (evt.which) ? evt.which : window.event.keyCode;  
       
                  if (charCode <= 13) 
		  { 
		        return true; 
		  } 
               
		  else 
		  { 
		        var keyChar = String.fromCharCode(charCode); 
		        var re = /[a-zA-Z0-9 ]/ ;
		        return re.test(keyChar); 

		  } 
	    });
	
	      $('#subm').click(function(){
                  
                  $('.myLoader').remove();
                  
                 var scree = $('<div id="block" style="position:fixed; top: 0;left: 0;background-color:black;height:100%;width:100%;opacity: 0.8;filter:alpha(opacity=80);-moz-opacity:0.8;-khtml-opacity: 0.8;z-index:100;"></div>');
                 $('#wrap').append(scree);
                 scree.fadeIn(700);
                                  var overlay_panel = $('<div id="overlay-panel" style="text-align:center;position:relative;margin: 20% auto 0 auto;filter:alpha(opacity=100);-moz-opacity:1;-khtml-opacity:1;opacity:1;"></div>').appendTo('#block');


                  $('#overlay-panel').append("<img class='myLoader' src='http://www.ieplexus.com/wp-content/plugins/pricing/2.gif'>");
	          var promocode = $('#promocode').val();
 var pg_id = $('#pg_id').val();
		  var subm = $('#subm').val();

		

		  
		  
		  
		  $.ajax({
	                url: "http://www.ieplexus.com/",
	                type: 'GET',
	                data: "promocode=" + promocode + "&pg_id=" + pg_id + "&subm=" + subm,
		            		    
	                success: function(result) {
	                			$('#block').fadeOut();
	                			$('#overlay-panel').fadeOut();
                        $('.myLoader').remove();
                        $('.myFormResponse').remove();
	                      $('#ajaxResponse').append(result);
	                      $('#block').remove();
	                      if(result != "<p class='myFormResponse'><font color='red'>Wrong code!</font></p>" && result != "<p class='myFormResponse'><font color='red'>You did not enter the code!</font></p>")
	                      {  
	                      	$('#myForm').hide();
	                      }
                 }
	       });
	      return false;
      });
});
