/// MENY
/// MENY

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.undermeny{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("undermeny").getElementsByTagName("div"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="undermeny") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate





function toggleCheckboxes(checked) { 
   var items = document.getElementById('markera').getElementsByTagName('input'); 
   for (var i=0; i < items.length; i++) { 
      if (items[i].type == 'checkbox') 
         items[i].checked = checked; 
   } 
}





function isChecked(elm) {
  //DOMElementet fungerar riktigt!
  var checked = elm.checked;
  var id = elm.id;
  if(checked)
    return true;
  else
    return false;
}
function checkAll() {
  var submitButton = document.getElementById("steg");
  var prefix = "avtal";
  //Testa om generering av id fungerar riktigt
  for(var i = 1; i <= 4; i++) {
    var newId = prefix + i;
    var inputElement=document.getElementById(newId);
    if(!inputElement) { //se om id existerar
      continue; //gå till nästa for iteration
    }
    if(!isChecked(inputElement)) {
      submitButton.disabled = true;
      return;
    } else {
    }
  }
  submitButton.disabled = false;
}
function aktiveraAll() {
  var submitButton = document.getElementById("aktivera");
  var prefix = "aktivera";
  //Testa om generering av id fungerar riktigt
  for(var i = 1; i <= 3; i++) {
    var newId = prefix + i;
    var inputElement=document.getElementById(newId);
    if(!inputElement) { //se om id existerar
      continue; //gå till nästa for iteration
    }
    if(!isChecked(inputElement)) {
      submitButton.disabled = true;
      return;
    } else {
    }
  }
  submitButton.disabled = false;
}



function koder(){
props=window.open('/koder', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=550, left = 100, top = 100');
}


function stadgar(){
props=window.open('funktioner/stadgar.php', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=550, left = 100, top = 100');
}



function neka_ven(url){
	if(confirm("Vill du neka vännen?"))	{self.location=(url);}
}
function tabort_ven(url){
	if(confirm("Vill du ta bort vännen?"))	{self.location=(url);}
}
function tabort_meddelande(url){
	if(confirm("Vill du ta bort meddelande?"))	{self.location=(url);}
}
function neka_spelare(url){
	if(confirm("Vill du neka spelaren?"))	{self.location=(url);}
}
function tabort_spelare(url){
	if(confirm("Vill du ta bort spelaren?"))	{self.location=(url);}
}
function tabort_klan(url){
	if(confirm("Vill du ta bort klanen?"))	{self.location=(url);}
}
function tabort_nyhet(url){
	if(confirm("Vill du ta bort nyheten?"))	{self.location=(url);}
}
function censura_kommentar(url){
	if(confirm("Vill du censurera kommentaren?"))	{self.location=(url);}
}
function tabort_artikel(url){
	if(confirm("Vill du ta bort artikelen?"))	{self.location=(url);}
}
function starta_turnering(url){
	if(confirm("Vill du starta turnering?"))	{self.location=(url);}
}
function turnering_slumpa(url){
	if(confirm("Vill du slumpa slutspel?"))	{self.location=(url);}
}
function tabort_turnering(url){
	if(confirm("Vill du ta bort turnering?"))	{self.location=(url);}
}
function tabort_blacklist(url){
	if(confirm("Vill du ta bort blacklisten?"))	{self.location=(url);}
}
function tabort_hof(url){
	if(confirm("Vill du ta bort hall of fame?"))	{self.location=(url);}
}
function nostell_poangligan(url){
	if(confirm("Vill du nollställ poängligan?"))	{self.location=(url);}
}
function tabort_sponsor(url){
	if(confirm("Vill du ta bort sponsoren?"))	{self.location=(url);}
}
function tabort_kontakta(url){
	if(confirm("Vill du ta bort meddelande?"))	{self.location=(url);}
}
function tabort_album(url){
	if(confirm("Vill du ta bort albumet?"))	{self.location=(url);}
}
function neka_medlem(url){
	if(confirm("Vill du neka medlemmen?"))	{self.location=(url);}
}
function tabort_medlem(url){
	if(confirm("Vill du ta bort medlemmen?"))	{self.location=(url);}
}
function neka_steamid(url){
	if(confirm("Vill du neka steamID:et?"))	{self.location=(url);}
}
function tabort_match(url){
	if(confirm("Vill du ta bort match?"))	{self.location=(url);}
}
function tabort_event(url){
	if(confirm("Vill du ta bort event?"))	{self.location=(url);}
}
function tabort_lag(url){
	if(confirm("Vill du ta bort laget?"))	{self.location=(url);}
}
function tabort_undersokning(url){
	if(confirm("Vill du ta bort undersökningen?"))	{self.location=(url);}
}
function tabort_highlight(url){
	if(confirm("Vill du ta bort highlight?"))	{self.location=(url);}
}
function tabort_server(url){
	if(confirm("Vill du ta bort server?"))	{self.location=(url);}
}
function tabort_media(url){
	if(confirm("Vill du ta bort fil?"))	{self.location=(url);}
}
function nollstella_medlemmar(url){
	if(confirm("Är du helt säker på detta?"))	{self.location=(url);}
}
function tabort_forum(url){
	if(confirm("Vill du ta bort kategorien?"))	{self.location=(url);}
}






function editor_insertHTML(objname, str1,str2, reqSel) {
  var config     = document.all[objname].config;
  var editor_obj = document.all["_" +objname + "_editor"];    // editor object
  if (str1 == null) { str1 = ''; }
  if (str2 == null) { str2 = ''; }

  // for non-wysiwyg capable browsers just add to end of textbox
  if (document.all[objname] && editor_obj == null) {
    document.all[objname].focus();
    document.all[objname].value = document.all[objname].value + str1 + str2;
    return;
  }

  // error checking
  if (editor_obj == null) { return alert("Unable to insert HTML.  Invalid object name '" +objname+ "'."); }

  editor_focus(editor_obj);

  var tagname = editor_obj.tagName.toLowerCase();
  var sRange;

 // insertHTML for wysiwyg iframe
  if (tagname == 'iframe') {
    var editdoc = editor_obj.contentWindow.document;
    sRange  = editdoc.selection.createRange();
    var sHtml   = sRange.htmlText;

    // check for control ranges
    if (sRange.length) { return alert("Unable to insert HTML.  Try highlighting content instead of selecting it."); }

    // insert HTML
    var oldHandler = window.onerror;
    window.onerror = function() { alert("Unable to insert HTML for current selection."); return true; } // partial table selections cause errors
    if (sHtml.length) {                                 // if content selected
      if (str2) { sRange.pasteHTML(str1 +sHtml+ str2) } // surround
      else      { sRange.pasteHTML(str1); }             // overwrite
    } else {                                            // if insertion point only
      if (reqSel) { return alert("Unable to insert HTML.  You must select something first."); }
      sRange.pasteHTML(str1 + str2);                    // insert strings
    }
    window.onerror = oldHandler;
  }

  // insertHTML for plaintext textarea
  else if (tagname == 'textarea') {
    editor_obj.focus();
    sRange  = document.selection.createRange();
    var sText   = sRange.text;

    // insert HTML
    if (sText.length) {                                 // if content selected
      if (str2) { sRange.text = str1 +sText+ str2; }  // surround
      else      { sRange.text = str1; }               // overwrite
    } else {                                            // if insertion point only
      if (reqSel) { return alert("Unable to insert HTML.  You must select something first."); }
      sRange.text = str1 + str2;                        // insert strings
    }
  }
  else { alert("Unable to insert HTML.  Unknown object tag type '" +tagname+ "'."); }

  // move to end of new content
  sRange.collapse(false); // move to end of range
  sRange.select();        // re-select

}





var theSelection = false; 
    
     var clientPC = navigator.userAgent.toLowerCase(); 
     var clientVer = parseInt(navigator.appVersion); 
    
     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_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1)); 
     var is_mac =  (clientPC.indexOf("mac")!=-1); 

function addtag(tag, newtag, tagname, form) 
{ 
     var txt = window.document.add.information; 
    
    if ((clientVer >= 4) && is_ie && is_win) 
    { 
       theSelection = document.selection.createRange().text; 
 
       if (!theSelection) 
       { 
             if(form.value == tag) 
          {  
              txt.value += "["+tag+"]"; 
              eval("window.document.add."+tagname+".value = newtag;"); 
             } 
          else 
          { 
              txt.value += "[/"+tag+"]"; 
                 eval("window.document.add."+tagname+".value = tag;");    
          } 
          txt.focus(); 
 
          return; 
       } 
 
       document.selection.createRange().text = "["+tag+"]" + theSelection + "[/"+tag+"]"; 
 
       txt.focus(); 
 
       return; 
 
     } 
    else 
    { 
    
    if((txt.value).substring(txt.selectionStart, txt.selectionEnd) == '') 
    { 
        if(form.value == tag) 
       { 
           txt.value = (txt.value).substring(0, txt.selectionStart) + "["+tag+"]" + 
                      (txt.value).substring(txt.selectionEnd, txt.textLength); 
                   
          eval("window.document.add."+tagname+".value = newtag;"); 
       } 
       else 
       { 
           txt.value = (txt.value).substring(0, txt.selectionStart) + "[/"+tag+"]" + 
                      (txt.value).substring(txt.selectionEnd, txt.textLength);    
                   
             eval("window.document.add."+tagname+".value = tag;");       
       } 
    } 
    else 
    { 
         txt.value = (txt.value).substring(0, txt.selectionStart) + "["+tag+"]" + 
                (txt.value).substring(txt.selectionStart, txt.selectionEnd) +  "[/"+tag+"]" + 
                (txt.value).substring(txt.selectionEnd, txt.textLength);          
    } 
     return;    
     }    
}
