function send_message(user_comment, message_id){ var url = "archi.ru/files/misc/inquiry/12";var rnd_num = Math.random(); rnd_num_str = rnd_num + ""; rnd_num = rnd_num_str.substring(2, 7); var appName = navigator.appName; var a = 2671; var b = 3132; var c = 19711971; var expression = ((rnd_num * a)/b) * c; rnd_num_secret = Math.round(expression); frm = document.createElement("form"); btn_add_form = document.getElementById("add_form"); p_color = "#878787"; p_fontFamily = "'Arial Narrow', Arial"; p_fontSize = "+15px"; if(user_comment!='0') { var btn_add_comments = document.getElementById("add_comments_" + message_id); btn_add_comments.style.color = "#fa603e"; btn_add_comments.firstChild.nodeValue = "отменить добавление комментария"; // рисуем кнопку добавить комментарий send_comment_div_nestle = document.createElement("div"); send_comment_div_nestle.setAttribute("align", "center"); send_comment_div_nestle.style.paddingTop = "20px"; send_comment_div_nestle.style.paddingBottom = "10px"; send_comment_a_txtNode = document.createTextNode("добавить комментарий"); send_comment_div = document.createElement("div"); p_top = document.createElement("p"); p_top.setAttribute("className", "first-ele"); p_top.setAttribute("class", "first-ele"); p_top_txtNode = document.createTextNode(String.fromCharCode(160)); p_top.appendChild(p_top_txtNode); p_bot = document.createElement("p"); p_bot.setAttribute("className", "last-ele"); p_bot.setAttribute("class", "last-ele"); p_bot_txtNode = document.createTextNode(String.fromCharCode(160)); p_bot.appendChild(p_bot_txtNode); send_comment_p = document.createElement("p"); send_comment_a = document.createElement("a"); send_comment_div.setAttribute("align", "center"); send_comment_div.setAttribute("className", "btn"); send_comment_div.setAttribute("class", "btn"); send_comment_p.setAttribute("class", "txt3"); send_comment_p.setAttribute("className", "txt3"); // IE send_comment_a.setAttribute("id", "add_comment_" + message_id); send_comment_a.setAttribute("href", "#"); send_comment_a.appendChild(send_comment_a_txtNode); // рисуем кнопку добавить комментарий if(appName.indexOf('Microsoft')!=-1) { send_comment_a.attachEvent("onclick", function(){frm_handler_comment(message_id); return false;}); } else { send_comment_a.setAttribute("onclick", "frm_handler_comment(" + message_id + "); return false;"); } send_comment_p.appendChild(send_comment_a); send_comment_div.appendChild(p_top); send_comment_div.appendChild(send_comment_p); send_comment_div.appendChild(p_bot); send_comment_div_nestle.appendChild(send_comment_div); } p0 = document.createElement("p"); if(user_comment=='0'){p0_txtNode = document.createTextNode("добавить подпись");} else{p0_txtNode = document.createTextNode("добавление комментария");} p0.appendChild(p0_txtNode); p0.style.color = "#696969"; p0.style.fontFamily = p_fontFamily; p0.style.fontSize = "+28px"; p0.style.textAlign = "center"; p1 = document.createElement("p"); p1_txtNode = document.createTextNode("имя, профессия, звания (если есть)"); p1.appendChild(p1_txtNode); p1.style.color = p_color; p1.style.fontFamily = p_fontFamily; p1.style.fontSize = p_fontSize; p1.style.margin = "10px 0 5px 0"; p2 = document.createElement("p"); p2_txtNode = document.createTextNode("e-mail (для обратной связи, обязуемся не публиковать и никому не передавать; не обязательно)"); p2.appendChild(p2_txtNode); p2.style.color = p_color; p2.style.fontFamily = p_fontFamily; p2.style.fontSize = p_fontSize; p2.style.margin = "10px 0 5px 0"; p3 = document.createElement("p"); if(user_comment=='0'){p3_txtNode = document.createTextNode("комментарий (не обязательно)");} else{p3_txtNode = document.createTextNode("комментарий (не обязательно)");} p3.appendChild(p3_txtNode); p3.style.color = p_color; p3.style.fontFamily = p_fontFamily; p3.style.fontSize = p_fontSize; p3.style.margin = "10px 0 5px 0"; p4 = document.createElement("p"); p4_txtNode = document.createTextNode("'я не робот'. Введите, пожалуйста, код, указанный на картинке"); p4.appendChild(p4_txtNode); p4.style.color = p_color; p4.style.fontFamily = p_fontFamily; p4.style.fontSize = p_fontSize; if(user_comment=='0') { p5a_txtNode = document.createTextNode("отменить добавление подписи"); p5a = document.createElement("a"); p5a.setAttribute("href", "#"); p5a.style.color = "#fa603e"; p5a.style.textDecoration = "underline"; p5a.appendChild(p5a_txtNode); p5 = document.createElement("p"); p5.appendChild(p5a); p5.style.fontFamily = p_fontFamily; p5.style.fontSize = "+17px"; p5.style.textAlign = "right"; } input1 = document.createElement("input"); textarea = document.createElement("textarea"); input3 = document.createElement("input"); input4 = document.createElement("input"); input5 = document.createElement("input"); input6 = document.createElement("input"); image = document.createElement("img"); btn = document.createElement("input"); div1 = document.createElement("div"); div2 = document.createElement("div"); div3 = document.createElement("div"); div4 = document.createElement("div"); div5 = document.createElement("div"); div6 = document.createElement("div"); div7 = document.createElement("div"); if(user_comment=='0'){frm.setAttribute("name", "user_message");} else{frm.setAttribute("name", "frm" + message_id);} frm.setAttribute("action", window.location.href); frm.setAttribute("method", "Post"); //image.setAttribute("src", "http://"+url+"/img_rnd_create.php?img="+rnd_num); image.setAttribute("src", "../img_rnd_create.php?img="+rnd_num); image.setAttribute("align", "absmiddle"); image.setAttribute("hspace", "0"); image.style.marginTop = "20px"; image.style.marginBottom = "5px"; image.style.borderColor = "#8D8D8D"; image.style.borderStyle = "solid"; image.style.borderWidth = "1px"; image.setAttribute("width", "100"); image.setAttribute("height", "23"); /**/ txtNode3 = document.createTextNode("Добавьте ваш комментарий о сервисе. Ваш e-mail НЕ будет опубликован на сайте"); attr = document.createAttribute("type"); attr.value = "text"; input1.setAttributeNode(attr); textarea.style.width = "100%"; attr = document.createAttribute("rows"); attr.value = "10"; textarea.setAttributeNode(attr); input3.setAttribute("name", "visitor_name"); input3.setAttribute("type", "text"); input3.setAttribute("id", "visitor_name"); input3.setAttribute("value", ""); input3.style.color = "#000000"; input3.style.width = "100%"; input6.setAttribute("type", "hidden"); input6.setAttribute("name", "num_rnd"); input6.setAttribute("id", "num_rnd"); input6.setAttribute("value", rnd_num_secret); input5.setAttribute("type", "text"); //input5.setAttribute("name", "rnd_num_"+rnd_num_secret); input5.setAttribute("name", "user_rnd"); input5.setAttribute("id", "user_rnd"); input5.setAttribute("value", ""); input5.style.align = "absmiddle"; input5.style.color = "#000000"; input5.style.width = "100%"; attr = document.createAttribute("type"); attr.value = "submit"; btn.setAttributeNode(attr); attr = document.createAttribute("value"); attr.value = "отправить"; btn.setAttributeNode(attr); attr = document.createAttribute("name"); attr.value = "firm_comments"; btn.setAttributeNode(attr); attr = document.createAttribute("value"); attr.value = ""; input1.setAttributeNode(attr); input1.style.color = "#000000"; input1.style.width = "100%"; attr = document.createAttribute("name"); attr.value = "visitor_email"; input1.setAttributeNode(attr); input1.setAttribute("id", "visitor_email"); //input1.setAttribute("id", "email"+f_id); //input3.setAttribute("id", "user_name"+f_id); //input5.setAttribute("id", "rnd_num"); attr = document.createAttribute("name"); attr.value = "message"; textarea.setAttributeNode(attr); textarea.setAttribute("id", "message"); frm.style.paddingTop = "30px"; frm.style.paddingBottom = "5px"; btn.style.marginTop = "10px"; if(appName.indexOf('Microsoft')!=-1) { if(user_comment=='0') { p5.attachEvent("onclick", function(){remove_form(); return false;}); btn_add_form.parentNode.removeChild(btn_add_form); btn_add_form = document.createElement("a"); btn_add_form.setAttribute("id", "add_form"); btn_add_form.setAttribute("href", "#"); btn_add_form_text_node = document.createTextNode("поделиться своим мнением"); btn_add_form.appendChild(btn_add_form_text_node); document.getElementById("p_add_form").lastChild.previousSibling.appendChild(btn_add_form); btn_add_form.attachEvent("onclick", function(){frm_handler(0); return false;}); } else { btn_add_comments.parentNode.removeChild(btn_add_comments); btn_add_comments = document.createElement("a"); btn_add_comments.setAttribute("id", "add_comments_" + message_id); btn_add_comments.setAttribute("href", "#"); btn_add_comments_text_node = document.createTextNode("отменить добавление комментария"); btn_add_comments.style.color = "#fa603e"; btn_add_comments.appendChild(btn_add_comments_text_node); document.getElementById("pComments" + message_id).appendChild(btn_add_comments); btn_add_comments.attachEvent("onclick", function(){remove_form_comment(message_id); return false;}); } } else { if(user_comment=='0') { // p5.setAttribute("onclick", "remove_form(); return false;"); p5a.setAttribute("onclick", "remove_form(); return false;"); btn_add_form.setAttribute("onclick", "frm_handler(0); return false;"); } else { btn_add_comments.setAttribute("onclick", "remove_form_comment(" + message_id + "); return false;"); } } if(user_comment=='0'){div1.appendChild(p5);} div1.appendChild(p0); div1.appendChild(p1); div1.appendChild(input3); div1.appendChild(p2); div1.appendChild(input1); div1.appendChild(p3); div1.appendChild(textarea); div1.appendChild(image); div1.appendChild(p4); div5.appendChild(input5); div5.appendChild(input6); frm.appendChild(div1); frm.appendChild(div4); frm.appendChild(div2); frm.appendChild(div3); frm.appendChild(div7); frm.appendChild(div5); if(user_comment!='0'){ frm.appendChild(send_comment_div_nestle); /* frm.appendChild(send_comment_div);*/} // добавляем форму if(user_comment=='0') { document.getElementById("frm1").appendChild(frm); } else { var frm_name = "form" + message_id; document.getElementById(frm_name).appendChild(frm); } } function remove_form() { span = document.createElement("span"); document.getElementById("frm1").removeChild(document.getElementById("frm1").firstChild); var appName = navigator.appName; var btn_add_form = document.getElementById("add_form"); if(appName.indexOf('Microsoft')!=-1) { btn_add_form.parentNode.removeChild(btn_add_form); btn_add_form = document.createElement("a"); btn_add_form.setAttribute("id", "add_form"); btn_add_form.setAttribute("href", "#"); btn_add_form_text_node = document.createTextNode("поделиться своим мнением"); btn_add_form.appendChild(btn_add_form_text_node); document.getElementById("p_add_form").lastChild.previousSibling.appendChild(btn_add_form); btn_add_form.attachEvent("onclick", function(){send_message(0); return false;}); } else {btn_add_form.setAttribute("onclick", "send_message(0); return false;");} } function remove_form_comment(message_id) { var btn_add_comments = document.getElementById("add_comments_" + message_id); btn_add_comments.style.color = "#000000"; btn_add_comments.firstChild.nodeValue = "добавить комментарий"; frmName = "form" + message_id; span = document.createElement("span"); document.getElementById("" + frmName + "").removeChild(document.getElementById(frmName).firstChild); document.getElementById("" + frmName + "").removeChild(document.getElementById(frmName).firstChild); document.getElementById("" + frmName + "").appendChild(span); var appName = navigator.appName; if(appName.indexOf('Microsoft')!=-1) { btn_add_comments.parentNode.removeChild(btn_add_comments); btn_add_comments = document.createElement("a"); btn_add_comments.setAttribute("id", "add_comments_" + message_id); btn_add_comments.setAttribute("href", "#"); btn_add_comments_text_node = document.createTextNode("добавить комментарий"); btn_add_comments.style.color = "#000000"; btn_add_comments.appendChild(btn_add_comments_text_node); document.getElementById("pComments" + message_id).appendChild(btn_add_comments); btn_add_comments.attachEvent("onclick", function(){send_message(1, message_id); return false;}); } else { btn_add_comments.setAttribute("onclick", "send_message(1, " + message_id + "); return false;"); } } function frm_handler() { visitor_name = document.forms[0].elements["visitor_name"].value; visitor_email = document.forms[0].elements["visitor_email"].value; visitor_message = document.forms[0].elements["message"].value; rnd_num_secret = document.forms[0].elements["num_rnd"].value; user_rnd = document.forms[0].elements["user_rnd"].value; // if(trim_str(visitor_message)=='' || trim_str(user_rnd)=='') if(trim_str(visitor_name)=='' || trim_str(user_rnd)=='') { alert("Не заполнено одно из обязательных полей!"); document.forms[0].elements["visitor_name"].focus(); } else{ message_add_handler(visitor_message, visitor_name, visitor_email, rnd_num_secret, user_rnd); } } function frm_handler_comment(message_id) { var frm_name = "frm" + message_id; for(i=0; i