function input_value_io(action, value, id)
{
	var oper_input = document.getElementById(id);
	if(action == 'in')
	{
		if(oper_input.value == '') oper_input.value = value;
	}
	if(action == 'out')
	{
		if(oper_input.value == value) oper_input.value = '';
	}
}

function ai(text, url) { if (confirm(text)) parent.location.href=url; }

function enable_ssl_login(id)
{
	var form_login = document.getElementById("login_form");
	var form_input = document.getElementById(id);
	if(form_input.checked == true) form_login.action = window.location.href.replace("http", "https");
	else if(form_input.checked == false) form_login.action = window.location.href.replace("https", "http");
}

function storeCaret(textEl, which)
{
	document.getElementById("which").value = which;
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function wrapSelection(h, strFore, strAft)
{
	h.focus();
	if (h.setSelectionRange)
	{
		var selStart = h.selectionStart, selEnd = h.selectionEnd;
		h.value = h.value.substring(0, selStart) + strFore + h.value.substring(selStart, selEnd) + strAft + h.value.substring(selEnd);
		setSelectionRange(h, selStart + strFore.length, selEnd + strFore.length);
	}
	else if (document.selection)
	{
		var oRange = document.selection.createRange();
		var numLen = oRange.text.length;
		oRange.text = strFore + oRange.text + strAft;
	}
	else
	{
		h.value += strFore + strAft;
	}
}

function bbcode(strFore, strAft)
{
	wrapSelection(document.getElementById(document.getElementById("which").value), strFore, strAft);
}
