// BrutalCS Javascript


function showSubmenu(element)
{	
	document.getElementById("submenu_" + element).style.display = "block";
	document.getElementById("menu_" + element).className = "selected";
	for(i = 1; i < 10; i++)
	{
		if(i != element)
		{
			document.getElementById("submenu_" + i).style.display = "none";
			document.getElementById("menu_" + i).className = "deselected";
		}
	}
}

function clearloginfields(standard, field)
{
	element = document.getElementById(field);
	if(element.value == standard || element.value == "")
	{
		element.value = "";	
	}
}

function aroundSelected(tag1, tag2, field)
{	
	var clientPC = navigator.userAgent.toLowerCase(); // Get client info
	var clientVer = parseInt(navigator.appVersion); // Get browser version	
	var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
	var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
					&& (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
					&& (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
	var is_moz = 0;	
	var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
	var is_mac = (clientPC.indexOf("mac")!=-1);

	element = document.getElementById(field);
	
	if ((clientVer >= 4) && is_ie && is_win)

	{
		theSelection = document.selection.createRange().text;

		if (theSelection) {

			document.selection.createRange().text = tag1 + theSelection + tag2;

			element.focus();

			theSelection = '';

			return;

		}

	}
	else
	{
		length = element.textLength;
		start = element.selectionStart;
		end = element.selectionEnd;
		
		before = (element.value).substring(0, start);
		marked = (element.value).substring(start, end);
		after = (element.value).substring(end, length);
		
		element.value = before + tag1 + marked + tag2 + after;
		element.focus();
	}
}

function sure(msg)
{
	return confirm(msg);
}

function report_comment(id)
{
	window.open('?p=15447&id=' + id + '','Rapportera kommentar','left=300,top=300,width=383,height=270,toolbar=0,resizable=0,location=0,status=0');
} 

function report_answer(id)
{
	window.open('?p=15450&id=' + id + '','Rapportera svar','left=300,top=300,width=383,height=270,toolbar=0,resizable=0,location=0,status=0');
} 

function report_thread(id)
{
	window.open('?p=15451&id=' + id + '','Rapportera tråd','left=300,top=300,width=383,height=270,toolbar=0,resizable=0,location=0,status=0');
}

function show_adminmenu_items(id)
{
	if(document.getElementById(id).className == "adminmenu_item")
	{
		document.getElementById(id).className = "adminmenu_item2";
		document.cookie = 'amenu' + id + '=1; expires=Thu, 2 Aug 2100 00:00:01 GMT; path=/'
	}
	else
	{
		document.getElementById(id).className = "adminmenu_item";
		document.cookie = 'amenu' + id + '=0; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/'
	}
}

function change_cat(id)
{
	document.location='?p=9&category=' + id;	
}

function change_guide_cat(id)
{
	document.location='?p=4&category=' + id;	
}

function change_forum_sort(srt, id)
{
	document.location='?p=200&id=' + id + '&sort=' + srt;	
}

function mark_all(check, box) { 
  var mark_fields = document.getElementsByName(box + '[]'); 
  for (i=0; i<mark_fields.length; i++) 
  { 
     mark_fields[i].checked = check; 
  } 
} 

function change_sort(sortt, ordr, page, url)
{
	document.location='?p=' + url + '&sort=' + sortt + '&ordr=' + ordr + '&page=' + page;
}

function searchthis(value)
{
	if(value == "Sök på sidan")
	{
		document.searchform.word.value = "";	
	}
}

function show_searchbox()
{
	document.getElementById("searchbox").style.display = "block";
}

function hide_searchbox()
{
	searchbox = document.getElementById("searchbox");
	searchbox.style.display = "none";
}

function switch_searchcat(value)
{
	document.searchform.cat.value = value;	
	searchbox = document.getElementById("searchbox");
	searchbox.style.display = "none";
	document.cookie = 'search_cat=' + value + '; expires=Thu, 2 Aug 2100 00:00:01 GMT; path=/'
	document.searchform.word.focus();
}

function change_forum_list(int)
{
	document.cookie = 'forum_list=' + int + '; expires=Thu, 01-Jan-2100 00:00:01 GMT; path=/'	
	document.location='?p=2';
}

function change_news(int)
{	
	document.location='?p=' + int;
}

function change_rss(int)
{	
	document.location='?p=43524&rss=' + int;
}

function change_forum_list_dynamic(int, qs)
{
	document.cookie = 'forum_list=' + int + '; expires=Thu, 01-Jan-2100 00:00:01 GMT; path=/'	
	document.location='?' + qs;
}

function change_file_list_dynamic(int, qs)
{
	document.cookie = 'file_list=' + int + '; expires=Thu, 01-Jan-2100 00:00:01 GMT; path=/'	
	document.location='?' + qs;
}

function select_vote(voteid)
{
	document.getElementById("vote_" + voteid).checked = 1;	
}

function hide_show_addpoll(check)
{
	if(check == 0)
	{
		document.getElementById("add_poll").style.display = "none";	
	}
	else
	{
		document.getElementById("add_poll").style.display = "block";
	}
}

function change_styrelse_info(id)
{
	document.getElementById("styrelse1").className = "styrelse_hide_info";
	document.getElementById("styrelse17").className = "styrelse_hide_info";
	document.getElementById("styrelse19").className = "styrelse_hide_info";
	
	if(id == 17)
	{
		document.getElementById("styrelsen").style.display = "block";	
		document.getElementById("styrelsen_topic").style.display = "block";
	}
	else
	{
		document.getElementById("styrelsen").style.display = "none";	
		document.getElementById("styrelsen_topic").style.display = "none";
	}
	
	document.getElementById("styrelse" + id).className = "styrelse_show_info";
}
function add_smiley(smiley, field)
{
	element = document.getElementById(field);
	element.value = element.value + smiley;
	element.focus();
}
