﻿
$(document).ready(function() {
	//hideProductName
	var pn=$("#hideProductName").val();
	
   var hideProName=$("#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!");
     	var messageAlert = $("#hideAlertMessage").val();
			alert(messageAlert);
			message.focus();
			return;
		}
		if (name.val() == "") {
		//alert("Please fill in the names of!");
			var nameAlert = $("#hideAlertName").val();
			alert(nameAlert);
			name.focus();
			return;
		}
		if (email.val() == "") {
	var emailalert = $("#hideAlertEmail").val();
				alert(emailalert);
//		alert("Please fill in the e-mail!");
			
			email.focus();
			return;
		}
		if (hidetype == "1" || hidetype == "0") {
			//如果是产品留言或者是信息留言
		
			var language=$("#hidelanguage").val();
			var proid ;
 if(hidetype=="1")
 {
 		proid= $("#hideProduct").val();
 }
  if( hidetype=="0")
  {
      	proid= $("#hideProductid").val();
  }
			$.ajax({
				type: "POST",
				url: "../handler/XMLHttpSaveFeedback.ashx",
				data: "subject=" + subject.val() + "&language=" + language +"&message=" + message.val() + "&name=" + name.val() + "&email=" + email.val() + "&companyName=" + companyName.val() + "&phone=" + phone.val() + "&fax=" + fax.val() + "&address=" + address.val() + "&engine=0&pid=" + proid + "&type=" + hidetype + "",
				success: function(msg) {
					if (msg == "1") {
					    var success=$("#hidesuccess").val();
						alert(success);
						$(".clearValue").val("");
					}
					else {
						var sorry=$("#hidesorry").val();
						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() - 70,
						killSwitch: 'exampleLink',
						onText: 'Disable Follow',
						offText: 'Enable Follow'
					}
				);
				

	$("#SendMsgImage").click(function() {
	    $("#hideType").val("1");
		$("#MessageBox").fadeIn("1000");   
    	$("#proTitle").hide();    
    	$("#msgTitle").show();    
    	$("#mpn").hide();    
    	$("#hs").show();    
        $("#txtSubject").val("");

	});

	$("#CloseMsgImage").click(function() {
		//location.href=top.location.href;
		location.href = "?#";
		//$("#SendMessage").hide();				
	});
	$("#CloseDiv").click(function() {
		$("#MessageBox").fadeOut("2000");
	});
      
      
	$("#ShowDialog").click(function() {
	$("#hideType").val("0");
		$("#MessageBox").fadeIn("1000");
        $("#msgTitle").hide();
		$("#proTitle").show();
		$("#hs").hide();   
	    $("#mpn").show();    
		$("#txtSubject").val(pn);

	})
	
		$("#ShowBigImage").click(function() {
				$("#overlay").show(); 

		
		$("#lightbox").fadeIn("1000");

	})
		$("#bottomNavClose").click(function() {
				$("#overlay").hide(); 

				$("#lightbox").fadeOut("1000");

		
	});
	
	$("#SendSupply").click(function() {
		$("#CompanyBox").fadeIn("1000");
	})

	$("#CnSendSupply").click(function() {
		$("#CompanyBox").fadeIn("1000");
	})

	$("#CClose").click(function() {
		$("#CompanyBox").fadeOut("2000");
	});





});
