$(document).ready(function(){

    setTimeout(function(){ 
        $(".with-errors").delay(1000).fadeOut(300);
               }, 3000);

	//Home Subscribe
$('#Subscribe_submit').click(function(event) {
        event.preventDefault();
        var email = $("#Subscribe_email").val();
        console.log(email);
        var pattrnemail = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;        
        if(email == '')
        {
            $(".form-Error").text("Subscribe Email field is Required...");
             setTimeout(function(){ 
                            $(".form-Error").hide(0);
                             }, 3000);
            return false;
        } 
        if(!email.match(pattrnemail)) 
        {
             $(".form-Error").text("Please enter a valid Subscribe email address....");
              setTimeout(function(){ 
                            $(".form-Error").hide(0);
                             }, 3000);
            return false;
        }
        else
        {
             $.ajax({
                method: "POST",
                url: "captcha/mailsend.php",
                data: {subscribe_form:1,email:email},
                success: function(html) {
                    if(html == "Newsletter Not Send!!!")
                    {
                        
                       $(".form-success").text(html);
                        setTimeout(function(){ 
                            $(".form-success").hide(0);
                             }, 3000);
                       document.getElementById("Subscribe_form").reset();
                    }
                    else
                    {
                        //alert(html);
                        $(".form-Error").text(html);
                        setTimeout(function(){ 
                            $(".form-Error").hide(0);
                             }, 3000);
                        //document.getElementById("Subscribe_form").reset();
                    }
                }
            });
        }
        

    });

///Home Index

//Contact. Home.........
    $('#button_contact').click(function(event) {
        event.preventDefault();
        var name = $("#name").val();
        //var name = fname.concat(lname);
        //console.log(name);
        
        var email = $("#email").val();       
        var phone = $("#phone").val();
        var message = $("#message").val();
        var type = $("#type").val();
        var enq_con = $("#enq_con").val();
        
        var pattrnname = /^[a-zA-z\s]{3,100}$/;
        var pattrnemail = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
        var patternmobile = /^[\d]{10}$/;

        if(name == '')
        {

            alert("Name Field is Required...");
            return false;
        }
        if(email == '')
        {

            alert("Email field is Required...");
            return false;
        }
        if(!email.match(pattrnemail)) 
        {
            alert("Please enter a valid email address...");
            return false;
        }        
        if(!phone.match(patternmobile))
        {
            alert("Mobile Number is Require Enter only 10 digit number...");
            return false;
        }
         if(message == '')
        {
            alert("Message Field is Required...");
            return false;
        }                      
        else
        {
           $.ajax({
                method: "POST",
                url: "captcha/mailsend.php",
                data: {contact_form:1,name:name,email:email,message:message,phone:phone,enq_con:enq_con,type:type},
                success: function(html) {
                    if(html == "Mail Not Send!!!")
                    {
                        $(".form-Error").html(html);
                         setTimeout(function(){ 
                            $(".form-Error").delay(1000).fadeOut(300);
                             }, 3000);
                        document.getElementById("myForm_contact").reset();
                    }
                    else
                    {                        
                        $(".form-success").html(html);
                         setTimeout(function(){ 
                            $(".form-success").delay(1000).fadeOut(300);
                             }, 3000);
                        document.getElementById("myForm_contact").reset();
                    }
                }
            });
        }
    });
//Contact..........
    $('#button_contact_con_enq').click(function(event) {
        event.preventDefault();
        var Fname = $("#Fname").val();
        var Lname = $("#Lname").val();
        var email = $("#email").val(); 
        var phone = $("#phone").val();
        var Service = $("#Service").val();      
        var subject = $("#subject").val();
        var message = $("#message").val();
        var enq_con = $("#enq_con").val();
        var pattrnname = /^[a-zA-z\s]{3,100}$/;
        var pattrnemail = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
        var patternmobile = /^[\d]{10}$/;

        if(Fname == '')        {
            $("#fname_msg").text("First Name Field is Required...");
           
            return false;
        }
        if(Lname == '')
        {
            $("#lname_msg").text("Last name Field is Required...");
            //alert("Name Field is Required...");
            return false;
        }
        if(email == '')
        {
            $("#email_msg").text("Email Field is Required...");
            return false;
        }
        if(!email.match(pattrnemail)) 
        {
            $("#email_msg").text("Name Field is Required...");
            return false;
        }
        if(!phone.match(patternmobile))
        {
            $("#phone_msg").text("Mobile Number is Require Enter only 10 digit number...");
            return false;
        }
        if(Service == '')
        {
            $("#ser_msg").text("Service Field is Required...");
            return false;
        }
        if(subject == '')
        {
            $("#sub_msg").text("Name Field is Required...");
            return false;
        }
        if(message == '')
        {
            $("#mess_msg").text("message Field is Required...");
            return false;
        }               
        else
        {
           $.ajax({
                method: "POST",
                url: "captcha/mailsend.php",
                data: {contact_form_rr:1,Fname:Fname,Lname:Lname,email:email,phone:phone,Service:Service,subject:subject,message:message,enq_con:enq_con},
                success: function(html) {
                    if(html == "Mail Not Send!!!")
                    {
                        //alert(html);
                        $("#form_msg").html(html);
                         setTimeout(function(){ 
                            $("#form_msg").hide(0);
                             }, 3000);
                        document.getElementById("myForm_contact").reset();
                    }
                    else
                    {
                        $("#form_msg").html(html);
                         setTimeout(function(){ 
                            $("#form_msg").delay(1000).fadeOut(300);
                             }, 3000);
                        //alert(html);
                       // document.getElementById("myForm_contact").reset();
                    }
                }
            });
        }
        

    });




	});