function storeCaret(text) {
	if (text.createTextRange) {
		text.caretPos = document.selection.createRange().duplicate();
	}
}

function setsmiley_s(text,id) {
	text = text.split('^');
	if (document.getElementsByName('faqdesk_answer_short['+id+'][]')[0]) {
		var textAreaValue = document.getElementsByName('faqdesk_answer_short['+id+'][]')[0].value;
		var startIndex = document.getElementsByName('faqdesk_answer_short['+id+'][]')[0].selectionStart;
		var endIndex = document.getElementsByName('faqdesk_answer_short['+id+'][]')[0].selectionEnd;
		if(text[0] == '<ul>'){
			var list = '';
			var selText = textAreaValue.substring(startIndex,endIndex);
			if(selText.indexOf('\n')>0){
				selText = selText.split('\n');
				for(i=0;i<selText.length;i++)if(selText[i]!='')list += '<li>' + selText[i] + '</li>';
			}else{
				list = '<li>' + selText + '</li>';
			}
			if(document.selection && document.selection.createRange)
				document.getElementsByName('faqdesk_answer_short['+id+'][]')[0].value = textAreaValue+text[0]+"<li></li>"+text[1];
			else
				document.getElementsByName('faqdesk_answer_short['+id+'][]')[0].value = textAreaValue.substring(0,startIndex)+text[0]+list+text[1]+textAreaValue.substring(endIndex,textAreaValue.length);
		}else{
			if(document.selection && document.selection.createRange)
				document.getElementsByName('faqdesk_answer_short['+id+'][]')[0].value = textAreaValue+text[0]+text[1];
			else
				document.getElementsByName('faqdesk_answer_short['+id+'][]')[0].value = textAreaValue.substring(0,startIndex)+text[0]+textAreaValue.substring(startIndex,endIndex)+text[1]+textAreaValue.substring(endIndex,textAreaValue.length);
		}
		document.getElementsByName('faqdesk_answer_short['+id+'][]')[0].focus();
	}
}
function setsmiley_c(text,id) {
	text = text.split('^');
	if (document.getElementsByName('faqdesk_answer_long['+id+'][]')[0]) {
		var textAreaValue = document.getElementsByName('faqdesk_answer_long['+id+'][]')[0].value;
		var startIndex = document.getElementsByName('faqdesk_answer_long['+id+'][]')[0].selectionStart;
		var endIndex = document.getElementsByName('faqdesk_answer_long['+id+'][]')[0].selectionEnd;
		if(text[0] == '<ul>'){
			var list = '';
			var selText = textAreaValue.substring(startIndex,endIndex);
			if(selText.indexOf('\n')>0){
				selText = selText.split('\n');
				for(i=0;i<selText.length;i++)if(selText[i]!='')list += '<li>' + selText[i] + '</li>';
			}else{
				list = '<li>' + selText + '</li>';
			}
			if(document.selection && document.selection.createRange)
				document.getElementsByName('faqdesk_answer_long['+id+'][]')[0].value = textAreaValue+text[0]+"<li></li>"+text[1];
			else
				document.getElementsByName('faqdesk_answer_long['+id+'][]')[0].value = textAreaValue.substring(0,startIndex)+text[0]+list+text[1]+textAreaValue.substring(endIndex,textAreaValue.length);
		}else{
			if(document.selection && document.selection.createRange)
				document.getElementsByName('faqdesk_answer_long['+id+'][]')[0].value = textAreaValue+text[0]+text[1];
			else
				document.getElementsByName('faqdesk_answer_long['+id+'][]')[0].value = textAreaValue.substring(0,startIndex)+text[0]+textAreaValue.substring(startIndex,endIndex)+text[1]+textAreaValue.substring(endIndex,textAreaValue.length);
		}
		document.getElementsByName('faqdesk_answer_long['+id+'][]')[0].focus();
	}
}
function orignal_code_copyright(text) {
//orginally code and images are from  htttp://www.fusionphp.com
}
