function getLanguage() { return(0); } String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } function showMessage(p_msgHash) { alert(p_msgHash[getLanguage()]); } function afterSubmit(p_status, p_consumer, p_request, p_curRptContentDivId) { disableFormField(false); if (p_status < 200 || p_status > 299) { //alert("Submit request failed!"); showMessage( {0 : "Submit request failed!" , 1 : "\u63d0\u4ea4\u8acb\u6c42\u5931\u6557\u0021" } ); return; } var xmlDoc = p_request.responseXML; var result = xmlDoc.getElementsByTagName("result")[0].childNodes[0].nodeValue; if (result == "OK") { resetSubmit(); //alert("Message sent."); showMessage( {0 : "Message sent." , 1 : "\u4fe1\u606f\u5df2\u7d93\u767c\u9001\u002e" } ); } else { //alert("Message sent failed."); showMessage( {0 : "Message sent failed." , 1 : "\u4fe1\u606f\u767c\u9001\u5931\u6557\u0021" } ); } } function triggerSubmit(p_event, p_fromPage) { if (validateUserInput()) { /* //cleanPostForm("/winecave/cleanContactUs.jsp?fromPage="+p_fromPage, document.sellWineForm, null, afterSubmit, null); var url = "/winecave/cleanContactUs.jsp?" +"fromPage="+urlencode(p_fromPage) +"&contactName="+urlencode(document.sellWineForm.contactName.value) +"&contactEmail="+urlencode(document.sellWineForm.contactEmail.value) +"&enquiryDetails="+urlencode(document.sellWineForm.enquiryDetails.value) ; disableFormField(true); cleanGetUrl(url, null, afterSubmit, null); */ cleanPostForm("/winecave/cleanContactUs.jsp?fromPage="+p_fromPage, document.sellWineForm, null, afterSubmit, null); } } function disableFormField(p_disable) { document.sellWineForm.contactName.disabled = p_disable; document.sellWineForm.contactEmail.disabled = p_disable; document.sellWineForm.enquiryDetails.disabled = p_disable; document.sellWineForm.Submit.disabled = p_disable; document.sellWineForm.Submit2.disabled = p_disable; } function resetSubmit() { document.sellWineForm.contactName.value = ""; document.sellWineForm.contactEmail.value = ""; document.sellWineForm.enquiryDetails.value = ""; } function validateEmail(p_emailAddr) { var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if(reg.test(p_emailAddr) == false) { alert("Invalid Email Address!"); return(false); } else { return(true); } } function validateUserInput() { if (document.sellWineForm.contactName.value.trim() == "") { //alert("Contact Name is required!"); showMessage( {0 : "Contact Name is required!" , 1 : "\u806f\u7d61\u59d3\u540d\u4e0d\u80fd\u70ba\u7a7a\u0021" } ); return(false); } if (document.sellWineForm.contactEmail.value.trim() == "") { //alert("Contact Email is required!"); showMessage( {0 : "Contact Email is required!" , 1 : "\u806f\u7d61\u96fb\u90f5\u4e0d\u80fd\u70ba\u7a7a\u0021" } ); return(false); } var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if (reg.test(document.sellWineForm.contactEmail.value.trim()) == false) { //alert("Invalid Conatct Email address!"); showMessage( {0 : "Invalid Conatct Email address!" , 1 : "\u806f\u7d61\u96fb\u90f5\u683c\u5f0f\u4e0d\u6b63\u78ba\u0021" } ); return false; } if (document.sellWineForm.enquiryDetails.value.trim() == "") { //alert("Enquiry Details is required!"); showMessage( {0 : "Enquiry Details is required!" , 1 : "\u67e5\u8a62\u5167\u5bb9\u4e0d\u80fd\u70ba\u7a7a\u0021" } ); return false; } return(true); } function DrawImage(ImgD,w,h){ var flag=false; var image=new Image(); image.src=ImgD.src; if(image.width>0 && image.height>0){ flag=true; if(image.width/image.height>= w/h){ if(image.width>w){ ImgD.width=w; ImgD.height=(image.height*w)/image.width; }else{ ImgD.width=image.width; ImgD.height=image.height; } }else{ if(image.height>h){ ImgD.height=h; ImgD.width=(image.width*h)/image.height; }else{ ImgD.width=image.width; ImgD.height=image.height; } } } } function DrawImage1(ImgD, image,w,h){ if(image.width>0 && image.height>0){ flag=true; if(image.width/image.height>= w/h){ if(image.width>w){ ImgD.width=w; ImgD.height=(image.height*w)/image.width; }else{ ImgD.width=image.width; ImgD.height=image.height; } } else { if(image.height>h){ ImgD.height=h; ImgD.width=(image.width*h)/image.height; }else{ ImgD.width=image.width; ImgD.height=image.height; } } } } function DrawImageDetail(ImgD,w,h){ var flag=false; //var oldSrc = ImgD.src; var image=new Image(); //ImgD.src="xxxx"; image.src = ImgD.src; if (image.complete) { // ImgD.src=oldSrc; DrawImage1(ImgD, image,w,h); // alert("haha1"); } else { image.onload = function(){ DrawImage1(ImgD, image,w,h); // alert("haha0"); } } } function getXmlNodeValue(p_xmlDoc, p_nodeName) { var value = ""; var nodeEls = p_xmlDoc.getElementsByTagName(p_nodeName); if (nodeEls != null && nodeEls.length > 0) { if (nodeEls[0].childNodes != null && nodeEls[0].childNodes.length > 0) { value = nodeEls[0].childNodes[0].nodeValue; } } return(value); }