Form
function initCss(id, href) { if (!document.getElementById(id)) { var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.id = id; link.rel = 'stylesheet'; link.type = 'text/css'; link.href = href; link.media = 'all'; head.appendChild(link); } };
initCss("iconMG", "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css");
function MGCRM_sendRequest_4(){
var url = 'https://crm.afternet.gr/webform/CRMWebFormProcess.php';
var params = '';
var form = document.getElementById('MGCRM_WebForm_4');
for(var i=0; i < form.length; i++)
{
if(form[i].type === 'checkbox'){
params += form[i].name.split('').map( function (a) {return a.charCodeAt(0);}).join("_") +'='+form[i].checked+'&';
}else
{
params += form[i].name.split('').map( function (a) {return a.charCodeAt(0);}).join("_") +'='+form[i].value+'&';
}
}
var request = new XMLHttpRequest();
request.open('POST', url, true);
request.onreadystatechange = function()
{
if(request.readyState == 4 && request.status == 200) {
var json = JSON.parse(request.responseText);
if(json.status === 'success')
{
document.getElementById('MGCRM_WebForm_ErrorMessage_4').style.display = 'none';
var message = document.getElementById('MGCRM_WebForm_AfterSendMessage_4');
slideUp(form, 0.1, 0, function(){
slideDown(message, 1, 60, function(){});
});
}
else
{
document.getElementById('MGCRM_WebForm_ErrorMessage_4').style.display = 'block';
document.getElementById('MGCRM_WebForm_ErrorMessage_4').innerHTML = json.msg;
}
//if server returns status 500
}else if(request.response !== undefined){
try {
var json = JSON.parse(request.responseText);
} catch (e) {
}
if (json && json.msg){
document.getElementById('MGCRM_WebForm_ErrorMessage_4').style.display = 'block';
document.getElementById('MGCRM_WebForm_ErrorMessage_4').innerHTML = json.msg;
} else {
document.getElementById('MGCRM_WebForm_ErrorMessage_4').style.display = 'block';
document.getElementById('MGCRM_WebForm_ErrorMessage_4').innerHTML = 'Something went wrong. Please contact the administrator.';
}
};
};
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
request.send(params);
}
function slideDown (element, duration, finalheight, callback) {
var s = element.style;
s.height = '0px';
var y = 0;
var framerate = 10;
var one_second = 1000;
var interval = one_second*duration/framerate;
var totalframes = one_second*duration/interval;
var heightincrement = finalheight/totalframes;
var tween = function () {
y += heightincrement;
s.height = y+'px';
if (y