var global_location = "/modustpl/_secureXMLReq.php"; var global_url = ""; function company_profile(a, b) { if(a) { divShowIsShown = false; divShowWaitStop(); divShowWaitMask.style.display = "none"; divShowIframe.style.display = "none"; if(b == "0") { // blacklisted IP address, blacklisted words or phrases, missing, invalid or maxlength fields var error_message = req.responseXML.getElementsByTagName("error_message")[0].firstChild.data; var error_field = req.responseXML.getElementsByTagName("error_field")[0].firstChild.data; alert(error_message); document.getElementById(error_field).focus(); document.getElementById('cp_submit').disabled = false; } else if(b == "1") { // success alert("Your request more information form has been submitted."); document.getElementById("cp_submit").disabled = false; } else if(b == "2") { // email failed, requires confirmation var error_message = req.responseXML.getElementsByTagName("error_message")[0].firstChild.data; var error_field = req.responseXML.getElementsByTagName("error_field")[0].firstChild.data; var yes = confirm(error_message); if(yes) { divShowIsShown = true; divShowWaitStart(); var url_tmp = global_url + "&email_verify=1"; lXML(global_location, url_tmp); } else { document.getElementById(error_field).focus(); document.getElementById('cp_submit').disabled = false; } } } else { divShowIsShown = true; document.getElementById("cp_submit").disabled = true; var return_flag = true; var focus_flag = true; var url = "pid=6"; var error_message = "A problem with the fields listed below was encountered:\n\n"; if(document.getElementById("cp_legalCompanyName").value.length > 0) { url += "&cp_legalCompanyName=" + encodeURIComponent(document.getElementById("cp_legalCompanyName").value); } else { if(focus_flag) { focus_flag = false; document.getElementById("cp_legalCompanyName").focus(); } error_message += "'Company Legal Name' field missing content.\n"; return_flag = false; } if(document.getElementById("cp_primaryContact").value.length > 0) { url += "&cp_primaryContact=" + encodeURIComponent(document.getElementById("cp_primaryContact").value); } else { if(focus_flag) { focus_flag = false; document.getElementById("cp_primaryContact").focus(); } error_message += "'Primary Contact' field missing content.\n"; return_flag = false; } if(document.getElementById("cp_phone").value.length > 0) { url += "&cp_phone=" + encodeURIComponent(document.getElementById("cp_phone").value); } else { if(focus_flag) { focus_flag = false; document.getElementById("cp_phone").focus(); } error_message += "'Phone' field missing content.\n"; return_flag = false; } if(document.getElementById("cp_generalCompanyEmail").value.length > 0) { if((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/.test(document.getElementById("cp_generalCompanyEmail").value))) { url += "&cp_generalCompanyEmail=" + encodeURIComponent(document.getElementById("cp_generalCompanyEmail").value); } else { if(focus_flag) { focus_flag = false; document.getElementById("cp_generalCompanyEmail").focus(); } error_message += "\'Email\' field invalid.\n"; return_flag = false; } } else { if(focus_flag) { focus_flag = false; document.getElementById("cp_generalCompanyEmail").focus(); } error_message += "'Email' field missing content.\n"; return_flag = false; } if(ismaxlength(document.getElementById("cp_otherInformation").value, 1024)) { url += "&cp_otherInformation=" + encodeURIComponent(document.getElementById("cp_otherInformation").value); } else { if(focus_flag) { focus_flag = false; document.getElementById("cp_otherInformation").focus(); } error_message += "'Other Information' field exceeded its maximum length of 1024 characters.\n"; return_flag = false; } if(!return_flag) { alert(error_message); document.getElementById("cp_submit").disabled = false; return false; } else { url += "&cp_dBA=" + encodeURIComponent(document.getElementById("cp_dBA").value); url += "&cp_address=" + encodeURIComponent(document.getElementById("cp_address").value); url += "&cp_fax=" + encodeURIComponent(document.getElementById("cp_fax").value); url += "&cp_travelPlannersName=" + encodeURIComponent(document.getElementById("cp_travelPlannersName").value); url += "&cp_contacts=" + encodeURIComponent(document.getElementById("cp_contacts").value); global_url = url; var url_tmp = global_url + "&emailVerify=0"; divShowWaitStart(); //lXML(global_location, url_tmp); $.ajax({ type: "POST", async: false, data: url_tmp, url: "/moduslib/bis/company_profile_submit.php", success: function (dat) { alert(dat); } }); divShowWaitStop(); } } }