Cufon.replace(['h2'], {
    hover: true
});

$(document).ready(function()
{
    //slides the element with class "menu_body" when paragraph with class "menu_head" is clicked 
    $("#firstpane p.menu_head").click(function()
    {       
        var k = 0;
        var inp = $("#firstpane p.menu_head"); 
        index = inp.index(this);   
        menu_item = inp[index]; 
        
        if ($ (this).next ().hasClass ('menu_body')) {
            var onext = $ (this).next ();
            k = 1;
            $(this).addClass('selected');
            $(this).next("div.menu_body").slideToggle(400).siblings("div.menu_body").slideUp(800);    
        }
        
        if(index>0)
            var prev = inp[index-1];
        
        if(index+1<$("#firstpane p.menu_head").size())
            var next = inp[index+1];        
        
        $(this).siblings().removeClass('selected');
        
        if(k == 1)
            $ (this).next ().css('background','none');  
    });
    $("#firstpane p.menu_head").mouseover(function()
    {
        var inp = $("#firstpane p.menu_head");
        var indexover = inp.index(this);
        
        if(indexover != index)
        {    
            $(this).addClass('selected');  
        } 
    }
    );
    $("#firstpane p.menu_head").mouseout(function()
    {
        var inp = $("#firstpane p.menu_head");
        var indexover = inp.index(this);
        
        if(indexover != index)
        {
            $(this).removeClass('selected');
        }            
    }
    );
    
    contentHeight = $("#content").height();
    if(contentHeight < 550)
    {
        $("#content").css('height', "550px");
        contentHeight = 550;
        
    }
    var totalHeight = $("#adfino").height();
    $("footer").css('top', totalHeight+'px');
    var contentHeight = $("#content").height();  
    $("#firstpane").css('height', contentHeight + 32 +'px');
    $("#left_text").css('height', contentHeight + 32 +'px'); 
    $("#news_text").css('height', contentHeight + 32 +'px'); 
    $("#footer_content").css('top', contentHeight - 5 +'px');
    $("#news_footer").css('top', contentHeight - 45 +'px');  
});

function getNews(slug, type, e)
{
     var contentElement = $ ('#left_text'),
     contentText    = '',
     animationDone  = false;
     var contentHeight = $("#content").height();
     var allElement = $ ('.referenties-background');   
     $('#news_text ul li a').removeClass('selected'); 
     $(e).addClass('selected');
     allElement.fadeOut(1000, function ()
     {
        allElement.fadeIn(1000);  
     });
  
     contentElement.slideUp (1000, function ()
     {
         
         contentElement.html (contentText);
         Cufon.replace(['h2'], {
            hover: true
         });             
         contentElement.slideDown (1000);   
         animationDone = true;   
         var contentHeight = $("#content").height();  
         if(type == 'nieuws')
            $("#footer_content").css('top', contentHeight - 5 +'px'); 
         else
            $("#footer_content").css('top', contentHeight - 5 +'px');  
     });
     
     
     
     jQuery.ajax ({
         type: 'GET',
         url:  '/referenties.php',
         data: 'slug='+ slug +'&type='+ type,
         success: function (msg) 
         {
             contentText = msg;
             if (animationDone)
             {             
                 contentElement.html (msg);
                 contentElement.slideDown (1000);
                 Cufon.replace(['h2'], {
                    hover: true
                 }); 
                 animationDone = true;
             }
         }
     });
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
 var anchor = anchors[i];
 if (anchor.getAttribute("href") &&
 anchor.getAttribute("rel") == "external")
 anchor.target = "_blank";
 }
} 


