function emo_poper()
{
  window.open('index.php?act=sbextras&CODE=emoticons','SBExtras','width=250,height=500,resizable=yes,scrollbars=yes'); 
}
function bbc_poper()
{
  window.open('index.php?act=sbextras&CODE=bbcode','SBExtras','width=700,height=500,resizable=yes,scrollbars=yes'); 
}
function mod_edit_shout(id)
{
  window.open('index.php?act=Shoutbox&sbmod=04&sid='+id,'Shoutbox','width=375,height=275,resizable=no,scrollbars=yes'); 
}	
function add_emoticon(code)
{
	document.SHOUTBOX.Post.value += ' ' + code + ' ';
	//return true;
}
function SelectAll()
{
	for (var i=0;i<document.DShoutbox.elements.length;i++)
	{
		var e = document.DShoutbox.elements[i];
		var b = document.all ? document.all.shoutsall : document.getElementById ? document.getElementById('shoutsall') : "";
		if(e.type == 'checkbox')
		{
			if (b.value == 1)
			{
				e.checked = "checked";
				bv = 0;
			}
			else if (b.value == 0)
			{
				e.checked = "";
				bv = 1;
			}
		}
	}
	var obj = document.all ? document.all.shoutsall : document.getElementById ? document.getElementById('shoutsall') : "";
	obj.value = bv;
}

function multi_page_jump( url_bit, total_posts, per_page )
{
	pages = 1;
	cur_st = dsb_start;
	cur_page = 1;
	
	if ( total_posts % per_page == 0 )
	{
		pages = total_posts / per_page;
	}
	else
	{
		pages = Math.ceil( total_posts / per_page );
	}
	
	msg = dsb_tplq1 + " " + pages;
	if ( cur_st > 0 )
	{
		cur_page = cur_st / per_page;
		cur_page = cur_page -1;
	}
	show_page = 1;
	if ( cur_page < pages )
	{
		show_page = cur_page + 1;
	}
	
	if ( cur_page >= pages )
	{
		show_page = cur_page - 1;
	}
	else
	{
		show_page = cur_page + 1;
	}
	
	userPage = prompt( msg, show_page );
	if ( userPage > 0  )
	{
		if ( userPage < 1 )
		{
			userPage = 1; 
		}
		if ( userPage > pages )
		{
			userPage = pages;
		}
		if ( userPage == 1 )
		{
			start = 0;
		}
		else
		{
			start = (userPage - 1) * per_page;
		}
		
		window.location = url_bit + "&start=" + start;
	}
}

function my_getcookie( name )
{
	cname = dsb_cookie + name + '=';
	cpos  = document.cookie.indexOf( cname );
	
	if (cpos != -1)
	{
		cstart = cpos + cname.length;
		cend   = document.cookie.indexOf(";", cstart);
		
		if (cend == -1)
		{
			cend = document.cookie.length;
		}
		
		return unescape( document.cookie.substring(cstart, cend) );
	}
	
	return null;
}

function my_setcookie( name, value, sticky )
{
	expire = "";
	
	if (sticky)
	{
		expire = " expires=Wed, 1 Jan 2020 00:00:00 GMT;";
	}
	
	document.cookie = dsb_cookie + name + "=" + value + "; path=/;" + expire;
}

function my_getbyid(id)
{
	itm = null;
	
	if (document.getElementById)
	{
		itm = document.getElementById(id);
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}
	
	return itm;
}

function my_hide_div(itm, img)
{
	if (!itm) return;
	
	itm.style.display = "none";
}

function my_show_div(itm)
{
	if (!itm) return;

	itm.style.display = "";
}

function togglecategory( fid, add )
{
	saved = new Array();
	clean = new Array();

	if ( tmp = my_getcookie('dsbsets') )
	{
		saved = tmp.split(",");
	}
	
	for( i = 0 ; i < saved.length; i++ )
	{
		if ( saved[i] != fid && saved[i] != "" )
		{
			clean[clean.length] = saved[i];
		}
	}

	if ( add )
	{
		clean[ clean.length ] = fid;
		my_show_div( my_getbyid( 'fc_'+fid  ) );
		my_hide_div( my_getbyid( 'fo_'+fid  ) );
	}
	else
	{
		my_show_div( my_getbyid( 'fo_'+fid  ) );
		my_hide_div( my_getbyid( 'fc_'+fid  ) );
	}

	my_setcookie( 'dsbsets', clean.join(','), 1 );
}