function addcat(){

	if (document.getElementById('categories').value != '' && document.getElementById('catmenu').value != '') {
		document.getElementById('categories').value = document.getElementById('categories').value + ", " + document.getElementById('catmenu').value;
	}
	else if (document.getElementById('catmenu').value != '') {
		document.getElementById('categories').value = document.getElementById('catmenu').value;
	}
	document.getElementById('catmenu').options[document.getElementById('catmenu').selectedIndex] = null;

	if (document.getElementById('catmenu').options.length == 0) {
		document.getElementById('catmenu').disabled = true;
		document.getElementById('catbutton').disabled = true;
	}
}

function ShowOrHide(d1, d2) {
if (d1 != '') DoDiv(d1);
if (d2 != '') DoDiv(d2);
}

function DoDiv(id) {
var item = null;
if (document.getElementById) {
item = document.getElementById(id);
} else if (document.all){
item = document.all[id];
} else if (document.layers){
item = document.layers[id];
}
if (!item) {
}
else if (item.style) {
if (item.style.display == "none"){ item.style.display = ""; }
else {item.style.display = "none"; }
}else{ item.visibility = "show"; }
}

function check_uncheck_all(area) {
var frm = area;
for (var i=0;i<frm.elements.length;i++) {
var elmnt = frm.elements[i];
if (elmnt.type=="checkbox") {
if(frm.master_box.checked == true){ elmnt.checked=true; }
else{ elmnt.checked=false; }
}
}
if(frm.master_box.checked == true){ frm.master_box.checked = true; }
else{ frm.master_box.checked = false; }
}

function showpreview(image,name){
if (image != ""){
document.images[name].src = image;
} else {
document.images[name].src = "skins/images/blank.gif";
}
}

function insertext(open, close, area){
if (area == "short"){
	msgfield = document.form.contentshort
}
else if (area == "full") {
	msgfield = document.form.contentfull
}
else if (area == "" || !area) {
	msgfield = document.form.content
}
// IE support
if (document.selection && document.selection.createRange){
msgfield.focus();
sel = document.selection.createRange();
sel.text = open + sel.text + close;
msgfield.focus();
}

// Moz support
else if (msgfield.selectionStart || msgfield.selectionStart == "0"){
var startPos = msgfield.selectionStart;
var endPos = msgfield.selectionEnd;

msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length);
msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length;
msgfield.focus();
}

// Fallback support for other browsers
else {
msgfield.value += open + close;
msgfield.focus();
}

return;
}

function setCookie(name, value){
document.cookie = name + "=" + value + "; path=/;" + " expires=Wed, 1 Jan 2020 00:00:00 GMT;";
}

function deleteCookie(name){
document.cookie = name + "=" + "; path=/;" + " expires=Sut, 1 Jan 2000 00:00:01 GMT;";
}

function insertimage(text, area){
if (area == "short"){
opener.document.forms['form'].contentshort.focus();
opener.document.forms['form'].contentshort.value += text;
opener.document.forms['form'].contentshort.focus();
}
else if (area == "full"){
opener.document.forms['form'].contentfull.focus();
opener.document.forms['form'].contentfull.value += text;
opener.document.forms['form'].contentfull.focus();
}
else if (area == "" || !area){
opener.document.forms['form'].content.focus();
opener.document.forms['form'].content.value += text;
opener.document.forms['form'].content.focus();
}
}
function SymbolCounter(id, end){
	ln = end - id.value.length;
	begin1 = (end * 50)/100;
	begin2 = (end * 80)/100; 

	if (ln < 0) {
		ln = 0;
		id.value = id.value.slice(0, end);
	}
	linepx = Math.round(id.value.length / end * 200);

	if (linepx == 0) {
		linepx = 1;
	}
	if (linepx == 200) {
		linepx = 2;
	}
	if (ln > (end - begin1)) {
		color = '#9f0';
	}
	else if (ln > (end - begin2)) {
		color = '#ff0';
	}
	else {
		color = '#f90';
	}

	document.getElementById(id.name+'_c').innerHTML='<img src="/images/dot.gif" align="middle" width="'+linepx+'" height="10" style="background:'+color+'"/><img src="/images/dot.gif" align="middle" width="'+(200-linepx)+'" height="10" style="border: 1px solid #eeeeef;"/> ('+ln+'/'+end+')';
}

function quote(q_name) {

	txt = ''

	if (document.getSelection) {
		txt = document.getSelection()
	}
	else if (document.selection) {
		txt = document.selection.createRange().text;
	}
	
	if (txt == "") {
		insertext('[b',']'+q_name+'[/b], ', '')
	}
	if (txt.replace(" ","") != "") {
		insertext('[quote='+q_name,']'+txt+'[/quote]', '')
	}
}

function confirmit(url, text){
	var agree = confirm(text);

	if (agree) {
		document.location=url;
	}
}
