tags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[big]','[/big]','[red]','[/red]','[green]','[/green]','[blue]','[/blue]','[c]','[/c]','[quote]','[/quote]','[img]','[/img]','[a h=]','[/a]','[code=php]','[/code]');
tagsc = new Array();
for (var a = 0; a<50; a++) tagsc[a] = 0;
var clientPC = navigator.userAgent.toLowerCase();
var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var clientVer = parseInt(navigator.appVersion);

function smile(text) {
        if (FormTextObj.createTextRange && FormTextObj.caretPos) {
                var caretPos = FormTextObj.caretPos;
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
                FormTextObj.focus();
        } else {
	        FormTextObj.value  += text;
	        FormTextObj.focus();
        }
}

function SocialOpen(social, tpl) {
	var link, name, keywords, description, spos;
	var meta = document.getElementsByTagName('META');
	var MetaLength = meta.length;

	for(i = 0; i < MetaLength; i++){
		switch (meta[i].name) {
			case 'keywords':
				keywords = meta[i].content;
				break;
			case 'description':
				description = meta[i].content;
				break;
		}

	}
	spos = document.location.href.search('#');
	if (-1 != spos) {
		link = document.location.href.substr(0, spos);
	} else {
		link = document.location.href;
	}
	link = decodeURI(link);
	switch (social) {
		case 'digg':
		case 'furl':
			link = encodeURIComponent(link);
			break;
	}
	switch (social) { // - it is OK
		case 'furl':
			link = encodeURIComponent(link);
			break;
	}


	/*tpl = tpl.replace(/-STheme-/gi, encodeURI(document.title));
	tpl = tpl.replace(/-SUrl-/gi, encodeURI(document.location.href));
	tpl = tpl.replace(/-STags-/gi, encodeURI(keywords));
	tpl = tpl.replace(/-SDescription-/gi, encodeURI(description));*/
	tpl = tpl.replace(/-STheme-/gi, document.title);
	tpl = tpl.replace(/-SUrl-/gi, link);
	tpl = tpl.replace(/-STags-/gi, keywords);
	tpl = tpl.replace(/-SDescription-/gi, description);
	/*alert(tpl);
	alert(document.location.href);
	alert(tpl.length);*/
	//FormTextObj.value = tpl;
	window.open(tpl, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no');
}

function storeCaret(src) {
        if (src.createTextRange) src.caretPos = document.selection.createRange().duplicate();
}

function addtag(nn) {

        theSelection = false;

        if ((clientVer >= 4) && is_ie)
                theSelection = document.selection.createRange().text; // Get text selection

        if (theSelection) {
                document.selection.createRange().text = tags[nn] + theSelection + tags[nn+1];
                FormTextObj.focus();
                theSelection = '';
                return;
        }
        else {
              if (tagsc[nn] == 0) { tagsc[nn] = 1; smile(tags[nn]); }
              else { tagsc[nn] = 0; smile(tags[nn+1]); }
        }
}

function DoNothing() {

}