$(document).ready(function(){var a={success:showResponse,resetForm:true};$("#uploadForm").ajaxForm(a)});function showResponse(f,g){if(isSend==true){if(f.indexOf("Upload Files Length Error")>-1){alert("Your upload file must be less than 150KB.");$("#uploadImg").attr("disabled",false);$("#sendImg").attr("disabled",false);isSend=false;filecount--}else{if(fileArray.length==0){fileArray[1]=f.substring(f.lastIndexOf(":")+2,f.lastIndexOf("'"))}else{if(fileArray[1]==null){fileArray[1]=f.substring(f.lastIndexOf(":")+2,f.lastIndexOf("'"))}else{if(fileArray[2]==null){fileArray[2]=f.substring(f.lastIndexOf(":")+2,f.lastIndexOf("'"))}else{if(fileArray[3]==null){fileArray[3]=f.substring(f.lastIndexOf(":")+2,f.lastIndexOf("'"))}else{if(fileArray[4]==null){fileArray[4]=f.substring(f.lastIndexOf(":")+2,f.lastIndexOf("'"))}}}}}var e="";if(fileArray.length>0){for(var d=0;d<fileArray.length;d++){if(fileArray[d]!=null){e+=$.trim(fileArray[d])+","}}}$("#hdNewFiles").val(e);var c=$("#txtName").val();var b=$("#txtEmail").val();var h=$("#txtContent").val();$("#sendImg").attr("disabled",true);$("#uploadImg").attr("disabled",true);$.ajax({type:"POST",url:"/Action/ProductQuestion.ashx",data:{txtName:c,txtEmail:$.trim(b),txtContent:h,hdNewFiles:$("#hdNewFiles").val()},dataType:"json",cache:false,timeout:15000,success:function(j){if(j[0].Result.indexOf("Success")>-1){alert("Thanks for your qustions!");window.location=window.location}},error:function(){alert("webpage is invalid.");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false)}})}}else{$("#uploadImg").attr("disabled",false);if(f.indexOf("Upload Files Length Error")>-1){alert("Your upload file must be less than 150KB");filecount--}else{if(fileArray.length==0){fileArray[1]=f.substring(f.lastIndexOf(":")+2,f.lastIndexOf("'"));var a=fileArray[1].split(";");$(".linkcolor3",$("#li_file1")).html(a[0]);$("#li_file1").css("display","")}else{if(fileArray[1]==null){fileArray[1]=f.substring(f.lastIndexOf(":")+2,f.lastIndexOf("'"));var a=fileArray[1].split(";");$(".linkcolor3",$("#li_file1")).html(a[0]);$("#li_file1").css("display","")}else{if(fileArray[2]==null){fileArray[2]=f.substring(f.lastIndexOf(":")+2,f.lastIndexOf("'"));var a=fileArray[2].split(";");$(".linkcolor3",$("#li_file2")).html(a[0]);$("#li_file2").css("display","")}else{if(fileArray[3]==null){fileArray[3]=f.substring(f.lastIndexOf(":")+2,f.lastIndexOf("'"));var a=fileArray[3].split(";");$(".linkcolor3",$("#li_file3")).html(a[0]);$("#li_file3").css("display","")}else{if(fileArray[4]==null){fileArray[4]=f.substring(f.lastIndexOf(":")+2,f.lastIndexOf("'"));var a=fileArray[4].split(";");$(".linkcolor3",$("#li_file4")).html(a[0]);$("#li_file4").css("display","")}}}}}}}}var filecount=0;var filetype=[".gif",".png",".jpeg",".jpg",".bmp",".pdf"];var fileArray=new Array();var isSend=false;function displayUpload(){$("#li_upload").css("display","");$("#li_uploadMsg").css("display","");$("#spAttachFile").css("display","none")}function submitUploadFile(){$("#uploadImg").attr("disabled",true);var d=$("#txtFilePath").val();var c=d.substring(d.lastIndexOf("."),d.length);var a=0;for(var b=0;b<filetype.length;b++){if(c.toLowerCase()==filetype[b]){break}a++}if(a>=6){alert("The format of upload file is invalid.");$("#uploadImg").attr("disabled",false);return}if(filecount>=4){alert("You may submit four attachments only.");$("#uploadImg").attr("disabled",false);return}filecount++;$("#uploadForm").submit()}function removeFile(a){if(confirm("Make sure you would like to remove this file?")){fileArray[a]=null;$(".linkcolor3",$("#li_file"+a)).html("");$("#li_file"+a).css("display","none");filecount--}}function submitSend(){isSend=true;$("#sendImg").attr("disabled",true);$("#uploadImg").attr("disabled",true);var b=$("#txtName").val();var f=$("#txtEmail").val();var h=$("#txtContent").val();var d="";var j=false;if($.trim(b)==""){if(j==false){$("#txtName").focus();j=true}$("#spName").html("&nbsp;&nbsp;Your name is required.");$("#spName").css("display","");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false);isSend=false}else{if(b.length>100){if(j==false){$("#txtName").focus();j=true}$("#spName").html("&nbsp;&nbsp;Your name must be 100 characters.");$("#spName").css("display","");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false);isSend=false}else{$("#spName").html("");$("#spName").css("display","none")}}if($.trim(f)==""){if(j==false){$("#txtEmail").focus();j=true}$("#spEmail").html("&nbsp;&nbsp;Please input your contact E-mail.");$("#spEmail").css("display","");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false);isSend=false}else{if(f.length>200){if(j==false){$("#txtEmail").focus();j=true}$("#spEmail").html("&nbsp;&nbsp;Your E-mail must be 200 characters.");$("#spEmail").css("display","");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false);isSend=false}else{if(!isEmail(f)){if(j==false){$("#txtEmail").focus();j=true}$("#spEmail").html("&nbsp;&nbsp;Your E-mail format is wrong, please re-check it.");$("#spEmail").css("display","");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false);isSend=false}else{$("#spEmail").html("");$("#spEmail").css("display","none")}}}if($.trim(h)==""){if(j==false){$("#txtContent").focus();j=true}$("#spContent").html("&nbsp;&nbsp;Sorry, your inquery contect canot be empty.");$("#spContent").css("display","");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false);isSend=false}else{if(!isValidString(h)){if(j==false){$("#txtContent").focus();j=true}$("#spContent").html("&nbsp;&nbsp;Format of Input contect is invalid.");$("#spContent").css("display","");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false);isSend=false}else{if(h.length>2000){if(j==false){$("#txtContent").focus();j=true}$("#spContent").html("&nbsp;&nbsp;Your content must be less than 2000 characters.");$("#spContent").css("display","");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false);isSend=false}else{$("#spContent").html("");$("#spContent").css("display","none")}}}var g=$("#txtFilePath").val();if(g.length>0){var a=g.substring(g.lastIndexOf("."),g.length);var e=0;for(var c=0;c<filetype.length;c++){if(a.toLowerCase()==filetype[c]){break}e++}if(e>=6){alert("The format of upload file is invalid.");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false);isSend=false;return}if(filecount>=4){alert("You may submit four attachments only.");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false);isSend=false;return}filecount++;if(isSend==true){$("#uploadForm").submit()}}else{if(fileArray.length>0){for(var c=0;c<fileArray.length;c++){if(fileArray[c]!=null){d+=$.trim(fileArray[c])+","}}}$("#hdNewFiles").val(d);if(isSend==true){$("#sendImg").attr("disabled",true);$("#uploadImg").attr("disabled",true);$.ajax({type:"POST",url:"/Action/ProductQuestion.ashx",data:{txtName:b,txtEmail:$.trim(f),txtContent:h,hdNewFiles:$("#hdNewFiles").val()},dataType:"json",cache:false,timeout:15000,success:function(k){if(k[0].Result.indexOf("Success")>-1){alert("Thanks for your qustions!");window.location=window.location}},error:function(){alert("webpage is invalid.");$("#sendImg").attr("disabled",false);$("#uploadImg").attr("disabled",false)}})}}}function isValidString(b){var a='"><';for(i=0;i<a.length;i++){aChar=a.substring(i,i+1);if(b.indexOf(aChar)>-1){return false}}return true}function isEmail(b){var a=/^\s*[-_A-Za-z0-9]+(\.[-_A-Za-z0-9]+)*@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}\s*$/;if(a.test(b)){return true}return false}function displayContactDiv(){$("#contactDiv").css("display","")};
