// ...............................
// Detta script är programerat av och ägs exlusivt av :
// ...............................
// Jonas Colbro : jonas@colbro.se
// ...............................
// Detta script får ej kopieras på något sätt.
// ...............................

var clientPC = navigator.userAgent.toLowerCase();
var clientVer = parseInt(navigator.appVersion);
var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));


// Font taggar funktion
function taggar(bbopen, bbclose) {
var theSelection = false;
var txtarea = document.getElementById('form');

if ((clientVer >= 4) && is_ie && is_win) {
theSelection = document.selection.createRange().text;
if (!theSelection) {
txtarea.value += bbopen + bbclose;
txtarea.focus();
return;
}
document.selection.createRange().text = bbopen + theSelection + bbclose;
txtarea.focus();
return;
}
else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
{
var s1 = (txtarea.value).substring(0,txtarea.selectionStart);
var s2 = (txtarea.value).substring(txtarea.selectionStart, txtarea.selectionEnd)
var s3 = (txtarea.value).substring(txtarea.selectionEnd, txtarea.textLength);
txtarea.value = s1 + bbopen + s2 + bbclose + s3;
return;
}
else
{
txtarea.value += bbopen + bbclose;
txtarea.focus();
}
}
// Smile funktion
function smile(smile) {
var txtarea = document.getElementById('form');
txtarea.value = txtarea.value + smile
txtarea.focus()
}
// Citat funktion
function citat(tag1, tag2) {
var txtarea = document.getElementById('form');
if (window.getSelection) {
txtarea.value += tag1 + window.getSelection() + tag2;
} 
else if (document.getSelection) {
txtarea.value += tag1 + document.getSelection() + tag2;
} 
else if (document.selection) {
txtarea.value += tag1 + document.selection.createRange().text + tag2;
}
}

