$(document).ready(function() {
  $("div[id~=xSK]").mouseover(function() {
    var a = $(this).attr('id').split('SK ');
    $("div[id~="+a[1]+" sprow]").css('background', '#123');
  });
  $("div[id~=xSK]").mouseout(function() {
    var a = $(this).attr('id').split('SK ');
    $("div[id~="+a[1]+" sprow]").css('background', 'transparent');
  });
});

function scrollMe(anchor) {
  if (!anchor)
    return;

  var a = "#level"+anchor;
  if (anchor == "top")
    a = "#top";

  var control=document.guildform.elements;
  for (var i=0;i<control.length;i++) {
    if (control[i].selectedIndex)
      control[i].selectedIndex = 0;
  }

  if (window.location.href.match(/&s=1/i)) {
    if (a == "#top")
      return;
    if (anchor < 10)
      anchor = "0"+anchor;
    else
      anchor = ""+anchor;

    $("[id~=spdiv]").each(function(x) {
      this.style.background = 'transparent';
      this.style.fontWeight = 'normal';
    });

    var i = $("[id~='"+anchor+"']");
    i.each(function(x) {
      this.style.background = '#123';
      this.style.fontWeight = 'bold';
    });
    return;
  }

  var pos = $(a).position();
  $(this).scrollTop(pos.top - 15);


  control=document.getElementsByTagName('div');
  for (var i=0;i<control.length;i++) {
    if (control[i].id.match(/block/i))
      if (control[i].id == "block"+anchor) {
        control[i].style.borderColor = '#9AC';
        control[i].style.background = '#001';
        control[i].style.color = '#DDD';
      } else {
        control[i].style.borderColor = '#456';
        control[i].style.background = '#011223';
        control[i].style.color = '#999';
      }

    if (control[i].id.match(/head/i))
      if (control[i].id == "head"+anchor) {
        control[i].style.background = '#9AC';
        control[i].style.color = '#000';
      } else {
        control[i].style.background = '#123';
        control[i].style.color = '#CEE';
      }
  }
}

function switchStyle() {
  if (window.location.href.match(/&s=1/i))
    window.location.href = window.location.href.replace("&s=1", "&s=0");
  else if (window.location.href.match(/&s=0/i))
    window.location.href = window.location.href.replace("&s=0", "&s=1");
  else if (!window.location.href.match(/&s=1/i))
    window.location.href = window.location.href+"&s=1";
}

