this.tooltip = function(){  
  /* CONFIG */
    xOffset = 10;
    yOffset = 20;
    // these 2 variable determine popup's distance from the cursor
    // you might want to adjust to get the right result
  /* END CONFIG */
  $("a.tooltip").hover(function(e){
    this.t = this.title;
    this.title = "";
    $("body").append("<p id='tooltip'>"+ this.t +"</p>");
    $("#tooltip")
      .css("top",(e.pageY - xOffset) + "px")
      .css("left",(e.pageX + yOffset) + "px")
      .fadeIn("fast");
    },
  function(){
    this.title = this.t;
    $("#tooltip").remove();
    });
  $("a.tooltip").mousemove(function(e){
    $("#tooltip")
      .css("top",(e.pageY - xOffset) + "px")
      .css("left",(e.pageX + yOffset) + "px");
  });
};

// starting the script on page load
$(document).ready(function(){
  tooltip();
});

function showCompetitionsDiv(){
  $("#quoteclubs").animate({"height": "toggle"}, { duration: 1000 });
}


// ---------- Textarea vergroten/verkleinen -------------
$(function init()
    {
        // copyright Drupal, GNU General Public License
        $('textarea.resizable:not(.textarea-processed)').each(function() {
            var textarea = $(this).addClass('textarea-processed'), staticOffset = null;

            // When wrapping the text area, work around an IE margin bug.  See:
            // http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout
            $(this).wrap('<div class="resizable-textarea"><span></span></div>')
                .parent().append($('<div class="grippie"></div>').mousedown(startDrag));

            var grippie = $('div.grippie', $(this).parent())[0];
            grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px';

            function startDrag(e) {
                staticOffset = textarea.height() - e.pageY;
                textarea.css('opacity', 0.25);
                $(document).mousemove(performDrag).mouseup(endDrag);
                return false;
            }

            function performDrag(e) {
                textarea.height(Math.max(32, staticOffset + e.pageY) + 'px');
                return false;
            }

            function endDrag(e) {
                $(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag);
                textarea.css('opacity', 1);
            }
        });
    });
// ---------- Einde textarea -------------
    
function addSmilie(code) {
  document.plaatsbericht.reactie_bericht.value += " "+code+" ";
  document.plaatsbericht.reactie_bericht.focus();
}

function sure(text) {
    if(confirm(text)) { return true; }
    else { return false; }
}

function ShowHide(div,image) {
  var thisLevel = document.getElementById(div);
  var thisImage = document.getElementById(image);

  if (thisLevel.style.display == "none"){
      thisLevel.style.display = "block";
      thisImage.src = "gfx/min.jpg";
  }
  else{
    var thisLevel = document.getElementById(div);
    thisLevel.style.display = "none";
    thisImage.src = "gfx/plus.jpg";
  }
}

function addQuote(id) {
    obj_txt = document.getElementById(id);
    obj_textbox = document.getElementById('reactie_bericht');

    RegExp.multiline = true;

    obj_quote = obj_txt.innerHTML.replace(/\[quote\](.*)\[\/quote\]/gm, '');
    obj_quote2 = obj_quote.replace(/\[quote\](.*)\[\/quote\]/gm, '');

    document.plaatsbericht.reactie_bericht.value += '[quote]' + obj_quote2 + '[/quote]';
}

function telinzet() {
  var sum = 0;
  var inputs = document.getElementsByTagName("input");
  for (i =0; i < inputs.length; i++)
  {
    if (!inputs[i].type || !inputs[i].type == "text")
    {
      continue;  //negeer alle elementen zonder type attribuut of niet text inputs.
    }
    if (!inputs[i].name || !inputs[i].name.match(/^inzet\[\d+\]$/))
    {
      continue; //negeer alle elementen zonder name attribuut, de regex snap je wel neem ik aan.
    }
    if( inputs[i].value.match( /^\d+$/))
    {
      sum += parseInt(inputs[i].value, 10);
    }
    else
    {
      alert('U kunt alleen getallen invoeren!');
      document.getElementById("totaalinzet").value = "0";
      return;
    }
  }
  document.getElementById("totaalinzet").value = sum;
}

var win=null;
function popup(mypage,myname,w,h,pos,infocus){
    if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
    else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
    settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
    win.focus();
}

function SelectUser(user) {
        window.opener.document.forms['pmnieuw'].elements['gebruiker'].value = user;
        window.top.close() ;
        window.top.opener.focus() ;
}

function quickjump(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function signupBM(g){
    if(g=='ja'){
    document.getElementById('bmform').style.display='block';
    }
    else if(g=='nee'){
    document.getElementById('bmform').style.display='none';
    }
    else {
    document.getElementById('bmform').style.display='none';
    }
}

