// Advanced Clan System
// Copyright Zelnen, 2006

//Adding NaviBar Links
//By Webworldx


var aLink=new Array()
aLink[0]='<a href="http://s10.invisionfree.com/CAOP/index.php?act=clans">Alignment</a>'

var uCell = document.getElementsByTagName('TD')
for (i=0;i<uCell.length;i++){
if (uCell[i].align=="right" && uCell[i].innerHTML.match("act=calendar") && uCell[i].innerHTML.match("act=Help")){
var addLink=""
for (j=0;j<aLink.length;j++){
addLink+=aLink[j]+"&nbsp;&nbsp;&nbsp;&nbsp;"
}

uCell[i].innerHTML=addLink+uCell[i].innerHTML
}}


function get(){

  if(location.href.match("act=clans")){

    i = document.getElementById("c")
   
    clan = i.value
   
   
    forms = window.frames['zelnen'].document.forms["REPLIER"]
   
    forms.Post.value += '[A]' + clan + '[B]'
   
    window.frames['zelnen'].document.REPLIER.submit()
     
     
  }
}

function moo(){
 
  forms = window.frames['zelnen'].document.forms["REPLIER"]
 
  if(forms.Post.value.match("[A]")){
   
    var content = "<div style='text-align:center'><table width='65%' align='center' border='0'><tr><td><div class='tableborder'><div class='maintitle' align='left' style='text-align:left'><img src='http://209.85.48.8/style_images/1/nav_m.gif' border='0' alt='>' width='8' height='8' />Alignment</div><table width='100%' border='0' cellspacing='1' cellpadding='4'><tr><td class='row1'>Welcome to the <I><B>Alignment</B></I> system. You are currently with a specific alignment in the fight between good and evil. To leave the <B>alignment</B> you are in simply click the button below. <br><br><input type='button' id='leave' value='Leave Alignment' onclick='leave()'><br><br></td></tr></table></div></td></tr></table></div><br />"
    document.getElementById('clans').innerHTML=content
  }
   
    else{
     
      var content = "<div style='text-align:center'><table width='65%' align='center' border='0'><tr><td><div class='tableborder'><div class='maintitle' align='left' style='text-align:left'><img src='http://209.85.48.8/style_images/1/nav_m.gif' border='0' alt='>' width='8' height='8' />Alignment</div><table width='100%' border='0' cellspacing='1' cellpadding='4'><tr><td class='row1'>Welcome to the <I><B>Alignment</B></I> section. Here you can join alignments for the forces of <b>darkness</b> or forces of <b>light</b>. To join an alignment simply select the side your character is aligned with from the drop down box and hit submit.  Once you've joined the correct alignment the name will show up in your profile and your post details. <br><br><SELECT id='c' NAME='clans'><OPTION VALUE='Choose an alignment to join'>Choose an alignment to join<OPTION VALUE='Of Darkness'>Of Darkness<OPTION VALUE='Of Light'>Of Light</SELECT><input type='submit' id='join' value='Join' onclick='get()'><br><br>Select the alignment you would like to join from the drop down the hit the 'Join' button.</td></tr></table></div></td></tr></table></div><br />"
      document.getElementById('clans').innerHTML=content
    }
}

function leave(){

  forms = window.frames['zelnen'].document.forms["REPLIER"]
 
  forms.Post.value = forms.Post.value.replace(/\[A\](.*)\[B\]/," ")
 
  window.frames['zelnen'].document.REPLIER.submit();
 
} 
   

if(location.href.match("act=UserCP&CODE=22")){

  tds = document.getElementsByTagName("td")
 
  for(x=0; x < tds.length; x++){
 
    if(tds[x].innerHTML.match("Open Tags:") && tds[x].className == 'pformright'){
     
      tds[x].innerHTML = tds[x].innerHTML.replace("Open Tags:","If you see the [A] [B] tags inside your signature please DO NOT remove them.<br> Open Tags:")
     
    }
  }
}

if(location.href.match("showtopic=")){

  divs = document.getElementsByTagName("div");
 
  var myReg = new RegExp("\\[A\\](.*?)\\[B\\]" , "i");
 
  for(x=0; x < divs.length; x++){
 
    if(divs[x].className == 'signature' && divs[x].innerHTML.match(myReg)){
   
        var clan = RegExp.$1
       
        var r = divs[x].parentNode.parentNode
       
        spans = r.getElementsByTagName("span")
       
        for(y=0; y < spans.length; y++){
     
          spans[y].innerHTML = spans[y].innerHTML.replace("Posts:","Force: " + clan + "<br>Posts:")
       
        } 
    }
     
  }
 
}


if(location.href.match("showuser=")){

  tds = document.getElementsByTagName("td")
 
  var myReg = new RegExp("\\[A\\](.*?)\\[B\\]" , "i")
 
  for(x=0; x < tds.length; x++){
 
 
    if(tds[x].className == 'row3' && tds[x].innerHTML.match("Signature") && tds[x+1].innerHTML.match(myReg)){
   
      var clan = RegExp.$1
     
      tables = document.getElementsByTagName("table")
     
      for(y=0; y < tables.length; y++){
     
        if(tables[y].innerHTML.match("Information") && tables[y].innerHTML.match("Home Page")){
         
          tables[y].innerHTML = tables[y].innerHTML.replace("<!--{CUSTOM.FIELDS}-->","<tr><td class='row3' valign='top'><b>Force</b></td><td align='left' class='row1'><i>" + clan + "</i></td></tr>")
         
        }
      }
    }
  }
}

if(location.href.match("showtopic=")){

  divs = document.getElementsByTagName("div")
 
  for(x=0; x < divs.length; x++){
 
    if(divs[x].className == 'signature' && divs[x].innerHTML.match("[A]")){
 
      divs[x].innerHTML = divs[x].innerHTML.replace(/\[A\](.*)\[B\]/," ")
     
    }
  }
}     

if(location.href.match("showuser=")){

  tds = document.getElementsByTagName("td")
 
    for(x=0; x < tds.length; x++){
   
      if(tds[x].className == 'row1' && tds[x].innerHTML.match("[A]")){
     
        tds[x].innerHTML = tds[x].innerHTML.replace(/\[A\](.*)\[B\]/," ")
       
      }
    }
}

if(location.href.match("act=UserCP&CODE=22")){

  divs = document.getElementsByTagName("div")
 
    for(x=0; x < divs.length; x++){
   
      if(divs[x].className == 'signature' && divs[x].innerHTML.match("[A]")){
     
        divs[x].innerHTML = divs[x].innerHTML.replace(/\[A\](.*)\[B\]/," ")
       
      }
    }
}         
         
 
if(location.href.match("act=clans")){
document.write("<iframe name='zelnen' src='http://s10.invisionfree.com/CAOP/index.php?act=UserCP&CODE=22' height='0%' width='0%' border='0' onload='moo()'></iframe>")
}