function mail_subscribe()
{
	var email=document.getElementById("textfield").value;
		if(email == "" || email == "Email" )
		{
      alert("Please enter the email id");
			return false;

		}
		if(email.length!=0)
		{
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)))
			{
				alert("Invalid email id");
				return false;
			}
		}
 //alert(email);
	jQuery.ajax({
							  
			type: "POST",
			url: "admin/mail.php",
			data:{
				"type":"email",
				"email_sub" : email
					},
				 
			success: function(msg){	
				//alert(msg);
				if(msg == 1)
				{
				//alert("Your News subscribe Sent to your mail id...");
				alert("Your mail id has been successfully subscribed...");
				$("#textfield").val('Email');
				}
				
			}
		});      
		return false;	
}

function validation()
{
	 var name = document.newletters.name.value.replace(/^[\s]+/g,"");
		if(name=="")
    {
        alert("Please enter the name");
        document.newletters.name.focus();
        return false;
    }

	var mail = document.newletters.email.value.replace(/^[\s]+/g,"");;
   if(mail=="")
    {
        alert("Please enter the email id");
        document.newletters.email.focus();
        return false;
    }
	
		if(mail.length!=0)
		{
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)))
			{
				alert("Invalid email id");
				return false;
			}
		}

	var contactno = document.newletters.contactno.value.replace(/^[\s]+/g,"");;
   if(contactno=="")
    {
        alert("Please enter the contact number");
        document.newletters.contactno.focus();
        return false;
    }

		var phonePattern = /^[0-9]/;
		if(!(phonePattern.test(contactno)))
		{
				alert("Invalid contact number");
				return false;
		}
 
}

function email_name()
{
	$("#textfield").val('');
}
function email_display()
{
	var emails = $("#textfield").val();
	if(emails == '')
	{
		$("#textfield").val('Email');
	}
}



function comment_validation()
{
	
	 var mail = document.comments.email.value.replace(/^[\s]+/g,"");;
   if(mail=="")
    {
        alert("Please enter the email id");
        document.comments.email.focus();
        return false;
    }
	
		if(mail.length!=0)
		{
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)))
			{
				alert("Invalid email id");
				return false;
			}
		}

}
