﻿
$(document).ready(function() {
    var pname = $("#hideProName").val();
    $("#btnSend").click(function() {
        var hidetype = $("#hideType").val();
        //alert(hidetype.val());
        var proid = $("#hideProduct").val();
        var subject = $("#txtSubject");

        var message = $("#txtMessage");
        var name = $("#txtName");
        var email = $("#txtEmail");
        var companyName = $("#txtCompanyName");
        var phone = $("#txtPhone");
        var fax = $("#txtFax");
        var address = $("#txtAddress");
        if (message.val() == "") {
            alert("Please fill in the information!");
            message.focus();
            return;
        }
        if (name.val() == "") {
            alert("Please fill in the names of!");
            name.focus();
            return;
        }
        if (email.val() == "") {
            alert("Please fill in the e-mail!");
            email.focus();
            return;
        }
        if (hidetype == "1" || hidetype == "0") {
            //如果是产品留言或者是信息留言
            $.ajax({
                type: "POST",
                url: "../handler/XMLHttpSaveFeedback.ashx",
                data: "subject=" + subject.val() + "&message=" + message.val() + "&name=" + name.val() + "&email=" + email.val() + "&companyName=" + companyName.val() + "&phone=" + phone.val() + "&fax=" + fax.val() + "&address=" + address.val() + "&engine=0&productID=" + proid + "&type=" + hidetype + "",
                success: function(msg) {
                    if (msg == "1") {
                        alert("success!");
                        $(".clearValue").val("");
                    }
                    else {
                        alert("sorry!");
                    }

                }
            });
        }

    });

    $("#btnReset").click(function() {

        $(".clearValue").val("");

    });


    $('#MessageBox').scrollFollow(
					{
					    speed: 1000,
					    offset: 0,
					    killSwitch: 'exampleLink',
					    onText: 'Disable Follow',
					    offText: 'Enable Follow'
					}
				);
    $('#SendMessage').scrollFollow(
					{
					    speed: 500,
					    offset: $(window).height() - 50,
					    killSwitch: 'exampleLink',
					    onText: 'Disable Follow',
					    offText: 'Enable Follow'
					}
				);
    $("#SendMsgImage").click(function() {
        $("#MessageBox").fadeIn("1000");
        $("#ChangeName").text("Subject:");
        var subject = $("#hideNavProduct").val();
        $("#txtSubject").val(subject);
        $("#msgTitle").text("We will deal with your message in 24 hours");
        $("#hideType").val("1");
    });
    $("#ShowDialog").click(function() {
        $("#MessageBox").fadeIn("1000");
        $("#msgTitle").text("Consulting Products Information");
        $("#ChangeName").text("ProductName:");
        $("#txtSubject").val(pname);
        //		   alert(pname);
        $("#hideType").val("0");
    })

    $("#CloseMsgImage").click(function() {
        location.href = top.location.href;
        //$("#SendMessage").hide();				
    });
    $("#CloseDiv").click(function() {
        $("#MessageBox").fadeOut("2000");
    });


});