﻿
$(document).ready(function() {
	var pname = $("#hideProName").val();
	var pn=$("#ChangeProductName").val();
	$("#btnSend").click(function() {
		var hidetype = $("#hideType").val();
		//alert(hidetype.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;
		}
	var proid;

		if(hidetype=="0")
		{		  	
			 		 proid = $("#hideProductID").val();
		}
		else
		{
				 	proid = $("#hideProduct").val();

		}
		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'
					}
				);
									$('#EmailBox').scrollFollow(
					{
						speed: 500,
						offset: $(window).height() - 196,
						killSwitch: 'exampleLink',
						onText: 'Disable Follow',
						offText: 'Enable Follow'
					}
				);				
	$("#SendMsgImage").click(function() {
		$("#MessageBox").fadeIn("1000");
		$("#ChangeName").text("Subject:");
		$("#txtSubject").val("Inquiry about Guli locks Co.,Ltd");
		$("#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("Product Name:");
		$("#txtSubject").val(pn);
		$("#hideType").val("0");
	})

	$("#CloseMsgImage").click(function() {
		location.href = "?#";
	});
	$("#CloseDiv").click(function() {
		$("#MessageBox").fadeOut("2000");
	});
	$("#SendSupply").click(function() {
		$("#CompanyBox").fadeIn("1000");
	})

	$("#CClose").click(function() {
		$("#CompanyBox").fadeOut("2000");
	});

});
