helpstat = false; stprompt = false; basic = true; function thelp(swtch){ if (swtch == 1){ basic = false; stprompt = false; helpstat = true; } else if (swtch == 0) { helpstat = false; stprompt = false; basic = true; } else if (swtch == 2) { helpstat = false; basic = false; stprompt = true; } } function AddText(text) { var tarea = document.PostTopic.Message; if (typeof tarea.selectionStart != 'undefined'){ // if it supports DOM2 //alert ('Вошли в основной if'); start = tarea.selectionStart; end = tarea.selectionEnd; tarea.value = tarea.value.substr(0,tarea.selectionStart) + text + tarea.value.substr(tarea.selectionEnd); tarea.selectionStart = ((start - end) == 0) ? start + text.length : start; tarea.selectionEnd = start + text.length; // вычисляем новое значение положения курсора cursor = tarea.selectionStart + text.length + tarea.selectionEnd; // ставим курсор в текстовое поле сразу после вставленного текста tarea.selectionStart = tarea.selectionEnd = cursor; tarea.focus(); } else { //alert ('Вошли в else'); if (tarea.createTextRange && tarea.caretPos) { var caretPos = tarea.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; } else { tarea.value += text; } tarea.focus(caretPos); } } function bold() { var text = getText(); if (helpstat) { alert("Текст, заключенный между тегами , отображается жирным шрифтом.\nПример:"); } else if (basic) { AddTxt="" + text + ""; AddText(AddTxt); } else { if (text) { txt=prompt("Текст, отображается жирным шрифтом.",text); } else { txt=prompt("Текст, отображается жирным шрифтом.","Текст"); } if (txt!=null) { AddTxt=""+txt+""; AddText(AddTxt); } } } function italicize() { var text = getText(); if (helpstat) { alert("Текст, заключенный между тегами , отображается курсивом. \nПример:Курсив"); } else if (basic) { AddTxt="" + text + ""; AddText(AddTxt); } else { if (text) { txt=prompt("Текст, отображается курсивом",text); } else { txt=prompt("Текст, отображается курсивом","Текст"); } if (txt!=null) { AddTxt=""+txt+""; AddText(AddTxt); } } } function underline() { var text = getText(); if (helpstat) { alert("Текст, заключенный между тегами , подчеркивается.\nПример: Подчеркнутый текст"); } else if (basic) { AddTxt="" + text + ""; AddText(AddTxt); } else { if (text) { txt=prompt("Подчеркнутый текст.",text); } else { txt=prompt("Подчеркнутый текст.","Текст"); } if (txt!=null) { AddTxt=""+txt+""; AddText(AddTxt); } } } function strike() { var text = getText(); if (helpstat) { alert("Текст, заключенный между тегами , зачеркивается.\nПример: Зачеркнутый текст"); } else if (basic) { AddTxt="" + text + ""; AddText(AddTxt); } else { if (text) { txt=prompt("Зачеркнутый текст.",text); } else { txt=prompt("Зачеркнутый текст.","Текст"); } if (txt!=null) { AddTxt=""+txt+""; AddText(AddTxt); } } } function left() { var text = getText(); if (helpstat) { alert("Текст, заключенный между тегами
, выравнивается по левому краю. \nПример:
Текст выравнен по левому карю
"); } else if (basic) { AddTxt="
" + text + "
"; AddText(AddTxt); } else { if (text) { txt=prompt("Текст вырвнивается по левому краю",text); } else { txt=prompt("Текст вырвнивается по левому краю","Текст"); } if (txt!=null) { AddTxt="
"+txt+""; AddText(AddTxt); } } } function center() { var text = getText(); if (helpstat) { alert("Текст, заключенный между тегами
, выравнивается по центру. \nПример: Текст выравнен по центру"); } else if (basic) { AddTxt="
" + text + "
"; AddText(AddTxt); } else { if (text) { txt=prompt("Текст выравнивается по центру",text); } else { txt=prompt("Текст выравнивается по центру","Текст"); } if (txt!=null) { AddTxt="
"+txt+"
"; AddText(AddTxt); } } } function right() { var text = getText(); if (helpstat) { alert("Текст, заключенный между тегами
, выравнивается по правому краю. \nПример:
Текст выравнен по правому карю
"); } else if (basic) { AddTxt="
" + text + "
"; AddText(AddTxt); } else { if (text) { txt=prompt("Текст выравнивается по правому карю",text); } else { txt=prompt("Текст выравнивается по правому карю","Текст"); } if (txt!=null) { AddTxt="
"+txt+"
"; AddText(AddTxt); } } } function hr() { var text = getText(); if (helpstat) { alert("Тег
создает горизонтальную линию в Вашем сообщении.\nПример:
"); } else { AddTxt="
"; AddText(AddTxt); } } function hyperlink() { var text = getText(); if (text != ""){ AddTxt=""+text+""; } else { AddTxt="текст или ссылка"; } AddText(AddTxt); } function email() { var text = getText(); if (text != ""){ AddTxt=""+text+""; } else { AddTxt="адрес"; } AddText(AddTxt); } function image() { var text = getText(); if (text != "") { AddTxt==""; } else { AddTxt="";; } AddText(AddTxt); } function showcode() { var text = getText(); AddTxt="[code]" + text + "[/code]"; AddText(AddTxt); } function quote() { var text = getText(); if (helpstat){ alert("Для выделения цитаты из другого сообщения, поместите текст между тегами [quote][/quote].\n Пример: [quote]Это текст цитаты[/quote]"); } else if (basic) { AddTxt="[quote]" + text + "[/quote]"; AddText(AddTxt); } else { if (text) { txt=prompt("Цитата",text); } else { txt=prompt("Цитата","Text"); } if(txt!=null) { AddTxt="[quote] "+txt+"[/quote]"; AddText(AddTxt); } } } function spoler() { var text = getText(); if (helpstat){ alert("Для скрытия текста, поместите текст между тегами .\n Пример: Это скрытый текст"); } else if (basic) { AddTxt="[sp]" + text + "[/sp]"; AddText(AddTxt); } else { if (text) { txt=prompt("Скрытый текст",text); } else { txt=prompt("Скрытый текст","Text"); } if(txt!=null) { AddTxt="[sp] "+txt+" [/sp]"; AddText(AddTxt); } } } function quot() { var text = getText(); if (helpstat){ alert("Для выделения текста кавычками, поместите текст между тегами .\n Пример: Это текст в кавычках"); } else if (basic) { AddTxt="[quot]" + text + "[/quot]"; AddText(AddTxt); } else { if (text) { txt=prompt("Текст в кавычках",text); } else { txt=prompt("Текст в кавычках","Text"); } if(txt!=null) { AddTxt="[quot] "+txt+" [/quot]"; AddText(AddTxt); } } } function undo() { var tarea = document.PostTopic.Message; tarea.document.execCommand('Undo','false',0); } function list() { var text = getText(); AddTxt=""; AddText(AddTxt); } function showfont(font) { var text = getText(); AddTxt="" + text + ""; AddText(AddTxt); } function showsize(size) { var text = getText(); AddTxt="" + text + ""; AddText(AddTxt); } function showcolor(color) { var text = getText(); AddTxt="" + text + ""; AddText(AddTxt); } function smile() { var text = getText(); if (helpstat) { alert("Смайлик - радость.\nПример: [:)]"); } else { AddTxt="[:)]"; AddText(AddTxt); } } function smile_big() { var text = getText(); if (helpstat) { alert("Смайлик - радость!!!.\nПример: [:D]"); } else { AddTxt="[:D]"; AddText(AddTxt); } } function smile_cool() { var text = getText(); if (helpstat) { alert("Смайлик - крутизна.\nПример: [8D]"); } else { AddTxt="[8D]"; AddText(AddTxt); } } function smile_blush() { var text = getText(); if (helpstat) { alert("Смайлик - стыд.\nПример: [:I]"); } else { AddTxt="[:I]"; AddText(AddTxt); } } function smile_tongue() { var text = getText(); if (helpstat) { alert("Смайлик - язык.\nПример: [:P]"); } else { AddTxt="[:P]"; AddText(AddTxt); } } function smile_evil() { var text = getText(); if (helpstat) { alert("Смайлик - злость.\nПример: [}:)]"); } else { AddTxt="[}:)]"; AddText(AddTxt); } } function smile_wink() { var text = getText(); if (helpstat) { alert("Смайлик - подмигивание.\nПример: [;)]"); } else { AddTxt="[;)]"; AddText(AddTxt); } } function smile_clown() { var text = getText(); if (helpstat) { alert("Смайлик - шутка.\nПример: [:o)]"); } else { AddTxt="[:o)]"; AddText(AddTxt); } } function smile_blackeye() { var text = getText(); if (helpstat) { alert("Смайлик - черный глаз.\nПример: [B)]"); } else { AddTxt="[B)]"; AddText(AddTxt); } } function smile_8ball() { var text = getText(); if (helpstat) { alert("Смайлик - неудача.\nПример: [8]"); } else { AddTxt="[8]"; AddText(AddTxt); } } function smile_sad() { var text = getText(); if (helpstat) { alert("Смайлик - грусть.\nПример: [:(]"); } else { AddTxt="[:(]"; AddText(AddTxt); } } function smile_shy() { var text = getText(); if (helpstat) { alert("Смайлик - скромность.\nПример: [8)]"); } else { AddTxt="[8)]"; AddText(AddTxt); } } function smile_shock() { var text = getText(); if (helpstat) { alert("Смайлик - шок.\nПример: [:O]"); } else { AddTxt="[:O]"; AddText(AddTxt); } } function smile_angry() { var text = getText(); if (helpstat) { alert("Смайлик - гнев.\nПример: [:(!]"); } else { AddTxt="[:(!]"; AddText(AddTxt); } } function smile_dead() { var text = getText(); if (helpstat) { alert("Смайлик - смерть.\nПример: [xx(]"); } else { AddTxt="[xx(]"; AddText(AddTxt); } } function smile_sleepy() { var text = getText(); if (helpstat) { alert("Смайлик - сонливость.\nПример: [|)]"); } else { AddTxt="[|)]"; AddText(AddTxt); } } function smile_kisses() { var text = getText(); if (helpstat) { alert("Смайлик - поцелуй.\nПример: [:X]"); } else { AddTxt="[:X]"; AddText(AddTxt); } } function smile_approve() { var text = getText(); if (helpstat) { alert("Смайлик - одобрение.\nПример: [^]"); } else { AddTxt="[^]"; AddText(AddTxt); } } function smile_dissapprove() { var text = getText(); if (helpstat) { alert("Смайлик - несогласие.\nПример: [V]"); } else { AddTxt="[V]"; AddText(AddTxt); } } function smile_question() { var text = getText(); if (helpstat) { alert("Смайлик - вопрос.\nПример: [?]"); } else { AddTxt="[?]"; AddText(AddTxt); } } //function AddTextMessage(NewCode) { //document.PostTopic.Message.value+=NewCode //} function AddTextMessage(NewCode) { var text = getText(); AddTxt=NewCode + text; AddText(AddTxt); } function resizeTextarea(tmpCookieURL) { var today = new Date(); var expires = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); // plus 365 days if (document.PostTopic.SelectSize.value == 1) { document.PostTopic.Message.cols = 55; document.PostTopic.Message.rows = 15; } if (document.PostTopic.SelectSize.value == 2) { document.PostTopic.Message.cols = 70; document.PostTopic.Message.rows = 12; } if (document.PostTopic.SelectSize.value == 3) { document.PostTopic.Message.cols = 90; document.PostTopic.Message.rows = 12; } if (document.PostTopic.SelectSize.value == 4) { document.PostTopic.Message.cols = 130; document.PostTopic.Message.rows = 15; } document.cookie = tmpCookieURL + "strSelectSize=" + document.PostTopic.SelectSize.value + "; expires=" + expires.toUTCString() } function storeCaret(ftext) { if (ftext.createTextRange) { ftext.caretPos = document.selection.createRange().duplicate(); } } function getText() { var tarea = document.PostTopic.Message; if (tarea.createTextRange && tarea.caretPos) { return tarea.caretPos.text; } else if (typeof tarea.selectionStart != 'undefined'){ return tarea.value.substr(tarea.selectionStart,tarea.selectionEnd-tarea.selectionStart) } return ''; } function OpenPreview(){ if (document.PostTopic.Message) { if (trim(document.PostTopic.Message.value)=="") { alert("Нет текста для просмотра!") return false } popupWin = window.open('pop_preview.asp', 'preview_page', 'scrollbars=yes,width=750,height=450') return true } } function OpenSigPreview() { if (document.Form1.Sig) { if (trim(document.Form1.Sig.value)=="") { alert("Нет текста для просмотра!") return false } popupWin = window.open('pop_preview_sig.asp', 'preview_page', 'scrollbars=yes,width=750,height=450') return true } } function validate(){ if (document.PostTopic.Subject) { if (trim(document.PostTopic.Subject.value)=="") { alert("Введите тему сообщения") return false } } if (document.PostTopic.Message) { if (trim(document.PostTopic.Message.value)=="") { alert("Введите текст сообщения") return false } } document.PostTopic.Submit.disabled = true return true } function ResetForm(form) { var where_to= confirm("Вы, действительно, хотите очистить поля формы?"); if (where_to== true) { form.reset(); } } //code below found here: http://www.marzie.com/devtools/javascript/functions.asp function ltrim(s) { return s.replace( /^\s*/, "" ); } function rtrim(s) { return s.replace( /\s*$/, "" ); } function trim ( s ) { return rtrim(ltrim(s)); } function selectUsers() { if (document.PostTopic.AuthUsers.length == 1) { document.PostTopic.AuthUsers.options[0].value = ""; return; } if (document.PostTopic.AuthUsers.length == 2) document.PostTopic.AuthUsers.options[0].selected = true else for (x = 0;x < document.PostTopic.AuthUsers.length - 1 ;x++) document.PostTopic.AuthUsers.options[x].selected = true; } function MoveWholeList(strAction) { if (strAction == "Add") { if (document.PostTopic.AuthUsersCombo.length > 1) { for (x = 0;x < document.PostTopic.AuthUsersCombo.length - 1 ;x++) document.PostTopic.AuthUsersCombo.options[x].selected = true; InsertSelection("Add"); } } else { if (document.PostTopic.AuthUsers.length > 1) { for (x = 0;x < document.PostTopic.AuthUsers.length - 1 ;x++) document.PostTopic.AuthUsers.options[x].selected = true; InsertSelection("Del"); } } } function InsertSelection(strAction) { var pos,user,mText; var count,finished; if (strAction == "Add") { pos = document.PostTopic.AuthUsers.length; finished = false; count = 0; do //Add to destination { if (document.PostTopic.AuthUsersCombo.options[count].text == "") { finished = true; continue; } if (document.PostTopic.AuthUsersCombo.options[count].selected) { document.PostTopic.AuthUsers.length +=1; document.PostTopic.AuthUsers.options[pos].value = document.PostTopic.AuthUsers.options[pos-1].value; document.PostTopic.AuthUsers.options[pos].text = document.PostTopic.AuthUsers.options[pos-1].text; document.PostTopic.AuthUsers.options[pos-1].value = document.PostTopic.AuthUsersCombo.options[count].value; document.PostTopic.AuthUsers.options[pos-1].text = document.PostTopic.AuthUsersCombo.options[count].text; document.PostTopic.AuthUsers.options[pos-1].selected = true; } pos = document.PostTopic.AuthUsers.length; count += 1; }while (!finished); //finished adding finished = false; count = document.PostTopic.AuthUsersCombo.length - 1; do //remove from source { if (document.PostTopic.AuthUsersCombo.options[count].text == "") { --count; continue; } if (document.PostTopic.AuthUsersCombo.options[count].selected ) { for ( z = count ; z < document.PostTopic.AuthUsersCombo.length-1;z++) { document.PostTopic.AuthUsersCombo.options[z].value = document.PostTopic.AuthUsersCombo.options[z+1].value; document.PostTopic.AuthUsersCombo.options[z].text = document.PostTopic.AuthUsersCombo.options[z+1].text; } document.PostTopic.AuthUsersCombo.length -= 1; } --count; if (count < 0) finished = true; }while(!finished) //finished removing } if (strAction == "Del") { pos = document.PostTopic.AuthUsersCombo.length; finished = false; count = 0; do //Add to destination { if (document.PostTopic.AuthUsers.options[count].text == "") { finished = true; continue; } if (document.PostTopic.AuthUsers.options[count].selected) { document.PostTopic.AuthUsersCombo.length +=1; document.PostTopic.AuthUsersCombo.options[pos].value = document.PostTopic.AuthUsersCombo.options[pos-1].value; document.PostTopic.AuthUsersCombo.options[pos].text = document.PostTopic.AuthUsersCombo.options[pos-1].text; document.PostTopic.AuthUsersCombo.options[pos-1].value = document.PostTopic.AuthUsers.options[count].value; document.PostTopic.AuthUsersCombo.options[pos-1].text = document.PostTopic.AuthUsers.options[count].text; document.PostTopic.AuthUsersCombo.options[pos-1].selected = true; } count += 1; pos = document.PostTopic.AuthUsersCombo.length; }while (!finished); //finished adding finished = false; count = document.PostTopic.AuthUsers.length - 1; do //remove from source { if (document.PostTopic.AuthUsers.options[count].text == "") { --count; continue; } if (document.PostTopic.AuthUsers.options[count].selected ) { for ( z = count ; z < document.PostTopic.AuthUsers.length-1;z++) { document.PostTopic.AuthUsers.options[z].value = document.PostTopic.AuthUsers.options[z+1].value; document.PostTopic.AuthUsers.options[z].text = document.PostTopic.AuthUsers.options[z+1].text; } document.PostTopic.AuthUsers.length -= 1; } --count; if (count < 0) finished = true; }while(!finished) //finished removing } } function autoReload(objform) { var tmpCookieURL = '<%=strCookieURL%>'; if (objform.SelectSize.value == 1) { document.PostTopic.Message.cols = 55; document.PostTopic.Message.rows = 15; } if (objform.SelectSize.value == 2) { document.PostTopic.Message.cols = 80; document.PostTopic.Message.rows = 12; } if (objform.SelectSize.value == 3) { document.PostTopic.Message.cols = 90; document.PostTopic.Message.rows = 12; } if (objform.SelectSize.value == 4) { document.PostTopic.Message.cols = 130; document.PostTopic.Message.rows = 15; } document.cookie = tmpCookieURL + "strSelectSize=" + objform.SelectSize.value } function OpenPreview() { var curCookie = "strMessagePreview=" + escape(document.PostTopic.Message.value); document.cookie = curCookie; popupWin = window.open('pop_preview.asp', 'preview_page', 'scrollbars=yes,width=750,height=450') } function OpenSearchWord() { var word = document.PostTopic.word.value; window.open("http://www.gramota.ru/dic/search.php?word=" + word +"","d2003","width=700,height=500,status=yes,toolbar=no,menubar=no,scrollbars=yes"); }