tinyMCE.init({mode:"textareas",theme:"simple"});function CheckProfile(enquiryForm){var telnum=/[\d\D]+$/;var doc=document.enquiryForm;var strsecuritycode=doc.email_securitycode.value;var strEmail=doc.email_from.value;var strCC=doc.email_cc.value;var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(strEmail!=""&&strFirstName!=""&&strLastName!=""&&strMessage!=""&&strsecuritycode!=""){var testresults=true;if(!telnum.test(strsecuritycode)){alert("Security Code does not match!");testresults=false;}
if(!filter.test(strEmail)){alert("Invalid Email Address. Please try again!");testresults=false;}
if(!filter.test(strEmail)){alert("Invalid Email Address. Please try again!");testresults=false;}}else{var strAlert="Please fill infomation in the blank field";if(strsecuritycode==""){strAlert=strAlert+" - Security Code";}
if(!doc){strAlert=strAlert+"Unable to find form: '"+enquiryForm+"'\n";}
if(doc.email_fname.value==""){strAlert=strAlert+"Please enter your first name\n";document.getElementById('fnlabel').style.color='red';}
if(doc.email_lname.value==""){strAlert=strAlert+"Please enter your last name\n";document.getElementById('lnlabel').style.color='red';}
if(doc.email_from.value==""){strAlert=strAlert+"Please enter your email address\n";document.getElementById('elabel').style.color='red';}
if(doc.email_subject.value==""){strAlert=strAlert+"Please enter a subject\n";document.getElementById('sublabel').style.color='red';}
if(doc.email_enquiry.value==""){strAlert=strAlert+"Please provide a comment\n";document.getElementById('msglabel').style.color='red';}
if(doc.email_securitycode.value==""){strAlert=strAlert+"Please enter the security code\n";document.getElementById('seclabel').style.color='red';}
alert(strAlert);testresults=false;}
return(testresults);}
function divScroll(divId,value)
{var element=document.getElementById(divId);element.scrollTop+=value;}
function divScrollTop(divId,value)
{var element=document.getElementById(divId);element.scrollTop-=value;}
function sendMailToAgent(elementId)
{var mailReceiver=document.getElementById("mailMe_receiverInput_"+elementId);var mailSender=document.getElementById("mailMe_emailInput_"+elementId);var mailSubject=document.getElementById("mailMe_subjectInput_"+elementId);var mailMessage=document.getElementById("mailMe_messageInput_"+elementId);var mailSecurityCode=document.getElementById("mailMe_securityCodeInput_"+elementId);var mailSecurityCodeImage=document.getElementById("mailMe_securityCodeImage_"+elementId);var formData=new FormData();formData.append("mailReceiver",mailReceiver.value);formData.append("mailSender",mailSender.value);formData.append("mailSubject",mailSubject.value);formData.append("mailMessage",mailMessage.innerHTML);formData.append("mailSecurityCode",mailSecurityCode.value);formData.append("mailSecurityCodeImage",mailSecurityCodeImage.value);var oXHR=new XMLHttpRequest();oXHR.open("POST","http://www.siam-property.com/send_mail.php");oXHR.onreadystatechange=function(oEvent)
{if(oXHR.readyState===4)
{if(oXHR.status===200)
{if(oXHR.responseText=="mail-success")
{document.getElementById('mailMe_mailFormContainer_'+elementId).innerHTML='<div style="margin:0; padding:0; border:0; background:transparent; font-size:22px; margin-top:100px; width:230px; text-align:center;">Message has been sent successfully.</div>';}
else if(oXHR.responseText=="verification-error")
{document.getElementById('mailMe_mailFormContainer_'+elementId).innerHTML='<div style="margin:0; padding:0; border:0; background:transparent; font-size:22px; margin-top:100px; width:230px; text-align:center; color:#FF0000;">The entered Security Code did not match the picture.</div>';}
else
{document.getElementById('mailMe_mailFormContainer_'+elementId).innerHTML='<div style="margin:0; padding:0; border:0; background:transparent; font-size:22px; margin-top:100px; width:230px; text-align:center; color:#FF0000;">An error occured while sending the message. Please Retry Later.</div>';}}}}
oXHR.send(formData);}
function getMailParameter(elementId)
{var mailReceiver=document.getElementById("mailMe_receiverInput_"+elementId);var mailSender=document.getElementById("mailMe_emailInput_"+elementId);var mailSubject=document.getElementById("mailMe_subjectInput_"+elementId);var mailMessage=document.getElementById("mailMe_messageInput_"+elementId);var mailSecurityCode=document.getElementById("mailMe_securityCodeInput_"+elementId);var mailSecurityCodeImage=document.getElementById("mailMe_securityCodeImage_"+elementId);mailSender.style.border="";mailSender.style.color="";mailSender.style.backgroundColor="";mailSender.style.padding="";mailSubject.style.border="";mailSubject.style.color="";mailSubject.style.backgroundColor="";mailSubject.style.padding="";mailMessage.style.border="";mailMessage.style.color="";mailMessage.style.backgroundColor="";mailMessage.style.padding="";mailSecurityCode.style.border="";mailSecurityCode.style.color="";mailSecurityCode.style.backgroundColor="";mailSecurityCode.style.padding="";if(mailSender.value==""||mailSender.value=="Your Email")
{mailSender.style.border="1px solid #FF0000";mailSender.style.color="#FF0000";mailSender.style.backgroundColor="#EEE";mailSender.style.padding="1px";}
if(mailSubject.value==""||mailSubject.value=="Subject")
{mailSubject.style.border="1px solid #FF0000";mailSubject.style.color="#FF0000";mailSubject.style.backgroundColor="#EEE";mailSubject.style.padding="1px";}
if(mailMessage.value==""||mailMessage.value=="Message")
{mailMessage.style.border="1px solid #FF0000";mailMessage.style.color="#FF0000";mailMessage.style.backgroundColor="#EEE";mailMessage.style.padding="1px";}
if(mailSecurityCode.value==""||mailSecurityCode.value=="Enter Security Code")
{mailSecurityCode.style.border="1px solid #FF0000";mailSecurityCode.style.color="#FF0000";mailSecurityCode.style.backgroundColor="#EEE";mailSecurityCode.style.padding="1px";}
if(mailSender.value!=""&&mailSender.value!="Your Email"&&mailSubject.value!=""&&mailSubject.value!="Subject"&&mailMessage.value!=""&&mailMessage.value!="Message"&&mailSecurityCode.value!=""&&mailSecurityCode.value!="Enter Security Code")
{sendMailToAgent(elementId);}}
