var error_msg_245 = "";
function validate_email_245(mail)
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail))
{
return (true);
}
error_msg_245 = "ИмÑйл хаÑгаа зөв оруулна уу";
return (false);
}
function getCookie_245(cname) {
var name_245 = cname + "=";
var decodedCookie_245 = decodeURIComponent(document.cookie);
var ca_245 = decodedCookie_245.split(';');
for(var i = 0; i < ca_245.length; i++) {
var c_245 = ca_245[i];
while (c_245.charAt(0) == ' ') {
c_245 = c_245.substring(1);
}
if (c_245.indexOf(name_245) == 0) {
return c_245.substring(name_245.length, c_245.length);
}
}
return "";
}
function subscribe_submit_245(){
var form_245 = document.querySelector('#subscribe-form-245');
var data_245 = new FormData(form_245);
var url_245 = "/api.php/subscription/save?site_id=418&id=245"
+ '&cookie_id=' + getCookie_245("cookie_id") + '&short_cookie_id=' + getCookie_245("short_cookie_id");
var xhr_245 = new XMLHttpRequest();
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
var xhr_245 = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
var xhr_245 = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr_245.open('POST', url_245, true);
xhr_245.onload = function () {
/* do something to response */
console.log(this.responseText);
document.getElementById("subscription-form-container-245").innerHTML = this.responseText;
};
var valid_245 = 1;
if(form_245.querySelector('input[name="subscriber[name]"]')){
if(form_245.querySelector('input[name="subscriber[name]"]').value.trim().length > 0){
}else{
valid_245 = 0;
form_245.querySelector('input[name="subscriber[name]"]').setAttribute("style", "border-color: red;");
}
}
if(form_245.querySelector('input[name="subscriber[email]"]')){
if(form_245.querySelector('input[name="subscriber[email]"]').value.trim().length > 0){
}else{
valid_245 = 0;
form_245.querySelector('input[name="subscriber[email]"]').setAttribute("style", "border-color: red;");
}
}
if(form_245.querySelector('input[name="subscriber[phone]"]')){
if(form_245.querySelector('input[name="subscriber[phone]"]').value.trim().length > 0){
}else{
valid_245 = 0;
form_245.querySelector('input[name="subscriber[phone]"]').setAttribute("style", "border-color: red;");
}
}
if(form_245.querySelector('input[name="subscription[company_name]"]')){
if(form_245.querySelector('input[name="subscription[company_name]"]').value.trim().length > 0){
}else{
valid_245 = 0;
form_245.querySelector('input[name="subscription[company_name]"]').setAttribute("style", "border-color: red;");
}
}
if(form_245.querySelector('input[name="subscription[company_position]"]')){
if(form_245.querySelector('input[name="subscription[company_position]"]').value.trim().length > 0){
}else{
valid_245 = 0;
form_245.querySelector('input[name="subscription[company_position]"]').setAttribute("style", "border-color: red;");
}
}
if(form_245.querySelector('input[name="subscription[title]"]')){
if(form_245.querySelector('input[name="subscription[title]"]').value.trim().length > 0){
}else{
valid_245 = 0;
form_245.querySelector('input[name="subscription[title]"]').setAttribute("style", "border-color: red;");
}
}
if(form_245.querySelector('textarea[name="subscription[body]"]')){
if(form_245.querySelector('textarea[name="subscription[body]"]').value.trim().length > 0){
}else{
valid_245 = 0;
form_245.querySelector('textarea[name="subscription[body]"]').setAttribute("style", "border-color: red;");
}
}
if(valid_245 == 0){
error_msg_245 = "Талбаруудыг бүрÑн бөглөнө Ò¯Ò¯!";
}
if(!validate_email_245(form_245.querySelector('input[name="subscriber[email]"]').value)){
form_245.querySelector('input[name="subscriber[email]"]').style="border-color: red;";
valid_245 = 0;
}else{
}
if(valid_245){
document.querySelector('#subscribe-form-245').style.display = "none";
document.querySelector('#subscription-form-loading-245').style.display = "inline";
xhr_245.send(data_245);
}else{
alert(error_msg_245);
}
}
//
function postRequest_245(strURL) {
var xmlHttp_245;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
var xmlHttp_245 = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
var xmlHttp_245 = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp_245.open('POST', strURL, true);
xmlHttp_245.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp_245.onreadystatechange = function() {
if (xmlHttp_245.readyState == 4) {
updatepage_245(xmlHttp_245.responseText);
}
}
xmlHttp_245.send(strURL);
}
//
function updatepage_245(str){
document.getElementById("subscription-form-container-245").innerHTML = str;
}
//'//chatsargana.mn' +
var get_url_245 =
'/api.php/subscription/renderform?site_id=418' +
'&id=245' +
'' ;
postRequest_245(get_url_245);