$(document).ready(function() {
   
   $('ul.udm').superfish({
        delay:       1000,                            // one second delay on mouseout
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
        speed:       'normal',                          // faster animation speed
        autoArrows:  true,                           // disable generation of arrow mark-up
        dropShadows: true                            // disable drop shadows
    });

    

    $('div#container-centre div.introText p:first').addClass('firstPara').before('<div class="sandbag"><!-- block --></div>');
    var paraHeight = $('p.firstPara').height();
    $('div.sandbag').css({"height" : paraHeight + 20});

    $('.staff_intro p:nth-child(2)').addClass('staffPara'); // add a class to the 2nd paragraph so we can style and
    
    $('.staffPara').insertAfter('.job_title');
            
            
    $('.staff_intro .job_title').insertAfter('.staff_intro .title h1'); // put the job title directly after name title (h1) so we can float in css
    
    $("#container-right .staff_profile_info .image").insertAfter("p.staffPara"); // put the staff image AFTER the main paragraph

    $('ul.udm_menu_level_2').hover(function() {
        $(this).siblings('a').addClass("hoverover");
        }, function() {
        $(this).siblings('a').removeClass("hoverover");
    });
    
    $('body#profile #container-centre .text .image:first').remove();
    
    $('.vcard a img.vcardIcon').css({"width" : "25px", "height" : "20px"})
    
    var pgLoc=location.pathname;
    
    if (pgLoc == "/site/people/") {
    
    $('table.a2zreveal').prepend('<tr id="addedAtoZ"><td colspan="4" class="letterIndex"><div class="letterRow"><a id="idxA" class="indexLetter" href="#" onclick="reveal(\'A\',this)">A</a><a id="idxB" class="normalLetter" href="#" onclick="reveal(\'B\',this)">B</a><a id="idxC" class="normalLetter" href="#" onclick="reveal(\'C\',this)">C</a><a id="idxD" class="normalLetter" href="#" onclick="reveal(\'D\',this)">D</a><a id="idxE" class="normalLetter" href="#" onclick="reveal(\'E\',this)">E</a><a id="idxF" class="normalLetter" href="#" onclick="reveal(\'F\',this)">F</a><a id="idxG" class="normalLetter" href="#" onclick="reveal(\'G\',this)">G</a><a id="idxH" class="normalLetter" href="#" onclick="reveal(\'H\',this)">H</a><a id="idxI" class="normalLetter" href="#" onclick="reveal(\'I\',this)">I</a><a id="idxJ" class="normalLetter" href="#" onclick="reveal(\'J\',this)">J</a><a id="idxK" class="normalLetter" href="#" onclick="reveal(\'K\',this)">K</a><a id="idxL" class="normalLetter" href="#" onclick="reveal(\'L\',this)">L</a><a id="idxM" class="normalLetter" href="#" onclick="reveal(\'M\',this)">M</a><a id="idxN" class="normalLetter" href="#" onclick="reveal(\'N\',this)">N</a><a id="idxO" class="normalLetter" href="#" onclick="reveal(\'O\',this)">O</a><a id="idxP" class="normalLetter" href="#" onclick="reveal(\'P\',this)">P</a><div class="hiddenLetter">Q</div><a id="idxR" class="normalLetter" href="#" onclick="reveal(\'R\',this)">R</a><a id="idxS" class="normalLetter" href="#" onclick="reveal(\'S\',this)">S</a><a id="idxT" class="normalLetter" href="#" onclick="reveal(\'T\',this)">T</a><div class="hiddenLetter">U</div><div class="hiddenLetter">V</div><a id="idxW" class="normalLetter" href="#" onclick="reveal(\'W\',this)">W</a><div class="hiddenLetter">X</div><a id="idxY" class="normalLetter" href="#" onclick="reveal(\'Y\',this)">Y</a><div class="hiddenLetter">Z</div></div></td></tr>');
    
    } else if (pgLoc != "/site/people/" ) {
        
        $('table.a2zreveal').css({"margin-top" : "0px"}).before("<h1>Team profiles</h1>");
    }
    
    
    // $('.trigger').hover(function() {
        // $('.popup').animate({
            // height: 'toggle',
            // opacity : 'toggle'
        // }, 250, 'swing');
    // });
    
$(function () {
    $('.bubbleInfo').each(function (i) {
        // options
        var distance = 10;
        var time = 250;
        var hideDelay = 500;
        var popupOffset = 35;

        var hideDelayTimer = null;

        // tracker
        var beingShown = false;
        var shown = false;

        var trigger = $('.trigger', this);
        var popup = $('.popup', this).css('opacity', 0);
        // get initial position
        // position() gives left and top, css('right') gives distance with px
        var pos = trigger.position();
        var right = trigger.css('right');

        // set the mouseover and mouseout on both element
        // use i to group elements
        $([trigger.get(i), popup.get(i)]).mouseover(function () {
          // stops the hide event if we move from the trigger to the popup element
          if (hideDelayTimer) clearTimeout(hideDelayTimer);

          // don't trigger the animation again if we're being shown, or already visible
          if (beingShown || shown) {
            return;
          } else {
            beingShown = true;

            // reset position of popup box
            popup.css({
              top: pos.top + popupOffset,
              right: right,
              display: 'block' // brings the popup back in to view
            })

            // (we're using chaining on the popup) now animate it's opacity and position
            .animate({
              top: '-=' + distance + 'px',
              opacity: 1
            }, time, 'swing', function() {
              // once the animation is complete, set the tracker variables
              beingShown = false;
              shown = true;
            });
          }
        }).mouseout(function () {
          // reset the timer if we get fired again - avoids double animations
          if (hideDelayTimer) clearTimeout(hideDelayTimer);

          // store the timer so that it can be cleared in the mouseover if required
          hideDelayTimer = setTimeout(function () {
            hideDelayTimer = null;
            popup.animate({
              top: '-=' + distance + 'px',
              opacity: 0
            }, time, 'swing', function () {
              // once the animate is complete, set the tracker variables
              shown = false;
              // hide the popup entirely after the effect (opacity alone doesn't do the job)
              popup.css('display', 'none');
            });
          }, hideDelay);
        });
      });
    });
});



// Accordion //

var TINY={};function T$(i){return document.getElementById(i)}function T$$(e,p){return p.getElementsByTagName(e)}TINY.accordion=function(){function slider(n){this.n=n;this.a=[]}slider.prototype.init=function(t,e,m,o,k){var a=T$(t),i=s=0,n=a.childNodes,l=n.length;this.s=k||0;this.m=m||0;for(i;i<l;i++){var v=n[i];if(v.nodeType!=3){this.a[s]={};this.a[s].h=h=T$$(e,v)[0];this.a[s].c=c=T$$('div',v)[0];h.onclick=new Function(this.n+'.pr(0,'+s+')');if(o==s){h.className=this.s;c.style.height='auto';c.d=1}else{c.style.height=0;c.d=-1}s++}}this.l=s};slider.prototype.pr=function(f,d){for(var i=0;i<this.l;i++){var h=this.a[i].h,c=this.a[i].c,k=c.style.height;k=k=='auto'?1:parseInt(k);clearInterval(c.t);if((k!=1&&c.d==-1)&&(f==1||i==d)){c.style.height='';c.m=c.offsetHeight;c.style.height=k+'px';c.d=1;h.className=this.s;su(c,1)}else if(k>0&&(f==-1||this.m||i==d)){c.d=-1;h.className='';su(c,-1)}}};function su(c){c.t=setInterval(function(){sl(c)},20)};function sl(c){var h=c.offsetHeight,d=c.d==1?c.m-h:h;c.style.height=h+(Math.ceil(d/5)*c.d)+'px';c.style.opacity=h/c.m;c.style.filter='alpha(opacity='+h*100/c.m+')';if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'}clearInterval(c.t)}};return{slider:slider}}();

function showcaptcha(myElement) {
var myElement
document.getElementById(myElement).style.display='block';
}
