//Variables for controlling opening and closing tags (function tag)

var b = 2;
var i = 2;
var u = 2;
var url = 2;
var img = 2;
var youtube = 2;
var izlesene = 2;
var timsah = 2;


//Function for creating non-font tags

function tag(v, tagadd, newbut, tagclose, oldbut, name) {
    if (eval(v)%2 == 0) {
        eval("window.document.editform."+name+".value = newbut;");
        var post = window.document.editform.post.value;
        window.document.editform.post.value = post + tagadd;
        window.document.editform.post.focus();
    } else {
        eval("window.document.editform."+name+".value = oldbut;");
        var post = window.document.editform.post.value;
        window.document.editform.post.value = post + tagclose;
        window.document.editform.post.focus();
    }
    eval(v+"++;");
}
//Function for adding font color and size tags

function font(bbopen, bbclose) {
        var post = document.editform.post;
        post.value += bbopen + bbclose;
        post.focus();
        return;
}

//Function for adding smilies

function smilie (smilie) {
        var post = document.editform.post;
        post.value += smilie;
        post.focus();
        return;
}
//Helpbox messages
bold_help = "Kalın: [b]yazı[/b]";
italic_help = "İtalik: [i]yazı[/i]";
underline_help = "Altı çizgili: [u]yazı[/u]";
img_help = "Resim ekle: [img]http://siteadi.com/resim.jpg[/img]";
url_help = "Link ekle: [url]http://siteadi.com[/url] ya da [url=http://siteadi.com]Link ismi[/url]";
youtube_help = "Youtube ekle: [youtube]Zev04UJ_pqI[/youtube] ...watch?v=Zev04UJ_pqI ";
izlesene_help = "İzlesene ekle: [izlesene]715488[/izlesene] ...video/sinema-alacakaranlik/715488";
timsah_help = "Timsah ekle: [timsah]n000MHITtKT[/timsah] ...4-yuz-Canli-yayinda-yere-yapisti/n000MHITtKT";


//Function for displaying help information

// Shows the help messages in the helpline window
function helpline(help) {
        var helpbox = document.editform.helpbox;
        helpbox.value = eval(help + "_help");
}

//Function to confirm reset

function confirm_reset () {
        if(confirm("Yazıyı temizlemek istediğinize emin misiniz?\n \n" +
                "Tüm yazılanlar silinecek.")) {
                        return true;
                                }
                else {
                        return false;
                                }
}
//Check the form submission for errors

function checkForm() {
        var subject = document.editform.subject;
        var post = document.editform.post;

        //Check to make sure post lengths are sensible

        if (subject.value.length < 2 && post.value.length < 2) {
                alert("This is a short post!" + " \n \n " +
                                "We require that each post (and subject) \n" +
                                "be at least 2 characters long. \n \n" +
                                "Go back and try again.");
                return false;
        }
        else { if (subject.value.length < 2) {
                        alert("We require that the subject  \n" +
                                "be at least 2 characters long. \n \n" +
                                "Go back and try again.");
                                return false;
                                }
                        else { if (post.value.length < 2) {
                        alert("We require that each post  \n" +
                                "be at least 2 characters long. \n \n" +
                                "Go back and try again.");
                                return false;
                                }
                                else {
                                        return true;
                                }
                        }
        }
}
