$(function() {
	
$("#submit_subscribe").click(function()
	{
		var siteurl = $("#sitelink").attr('surl');
		$("#msgbox").expose({closeOnClick: false});
		$("#msgbox").removeClass().addClass('messagebox').html('<div class="formmember" align="center" style="width:200px;"><div class="loadingbox">Sending data...</div></div>').fadeIn(100).delay(1000);
		
		$.post(siteurl+"index.php/home/enews",{ EmailName:$('#Email').val() } ,function(data) {
		  if(data=='yes') //if correct login detail
		  {
			  	  $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('<div class="formmember" align="center" style="width:200px;"><div class="completebox">Complete </div></div>').addClass('messageboxok').fadeTo(100,1).delay(1000).fadeOut(100);
$.mask.close(2000);
			  /*$("#bodypage").delay(1000).fadeTo(1000,1);*/
			});
			  
			
		  }
		  else if(data=="no")
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('<div class="formmember" align="center" style="width:200px;"><div class="errorbox">Email has already exist!</div></div>').addClass('messageboxok').fadeTo(100,1).delay(1000).fadeOut(100);
			  $.mask.close(2000);
				/*$("#bodypage").delay(1000).fadeTo(1000,1);*/
			});		
          }
		  else
		 {
		 	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('<div class="formmember" align="center" style="width:200px;"><div class="errorbox">Email not Empty!</div></div>').addClass('messageboxok').fadeTo(100,1).delay(1000).fadeOut(100);
			  $.mask.close(2000);

				/*$("#bodypage").delay(1000).fadeTo(1000,1);*/
			});	
		 }
				
        });
 		return false; 
		
	});

	
});
