﻿ //15-7-2008 Wilbert Corts
 //Zorgt voor de popup.
 //De code wordt dynamisch toegevoegd aan de pagina, zonder js staat er een anchor naar de popuptekst.
 
 // Wait until the Dom is fully loaded.
 $(document).ready(function(){
  $(".ref_lit_container").hide();
                //The popup in the left botttom corner.
                //Get all the links that should have popup behaviour. These have a class 'popup'.
                var popups =  $(".nw_uo_popup");

                //Prevent the default action, which would direct the page to the anchor.
                popups.click(function(event)
                {
                    event.preventDefault();
                });

                for(var i=0 ; i<popups.length; i++ ) 
                {
                       //Add an eventlistener to all those links with the class popup.
                        $(popups[i]).click(function()
                        {
                        
                        if ($(getIdFromHref(this.href)).get(0).nodeName.toLowerCase()=='dt') // afkortingen, defities
                        {
                            showHelp("<strong>" + $(getIdFromHref(this.href)).html()+ "</strong>" + $(getIdFromHref(this.href)).next().html() ,'/vtvredactieguipublic/pictures/allsites/definition_1.gif',200,200,10);
                        }
                        else  // literatuur
                        {
                            showHelp($(getIdFromHref(this.href)).html(),'/vtvredactieguipublic/pictures/allsites/definition_1.gif',200,200,10);
                        }
                         
                        //Shows a popup 
                        
                        
                        //alert(getTextFromElement(getIdFromHref(this.href)));
                        });
                }
                
       
                
                //The reference and literature and bronnen popup:
                //Get all the links that open a reference or definition popup. These have a class '.indexLiterature'.
                
                var openRefLitLink =  $(".indexLiterature");
                   $(".indexLiterature").click(function(event) {
                    event.preventDefault();
                        $("#bronnenliteratuur").toggle();
                    });
                var openDefLitLink =  $(".indexDefinition");
                   $(".indexDefinition").click(function(event) {
                    event.preventDefault();
                        $("#afkortingendefinities").toggle();
                    });
                    
              
                //Get all the buttons that close a reference or definition popup. These have a class '.close_ref_lit'.
                var closebutton =  $(".close_ref_lit");
                 for(var i=0 ; i<closebutton.length; i++ ) 
                {
                        $(closebutton[i]).click(function(event)
                        {
                           
                            //Close the popup.
                            this.parentNode.parentNode.style.display='none';
                        });
                }
                
 });
//                function getTextFromElement(sId)
//                {
//                    //Returns the text of an element with the given id.
//                    var elm = $(elm);
//                    var text= elm.text();
//                    return text;
//                    
//                }
                function getIdFromHref(sHref)
                {
                    //Returns the Id of the given anchors href attribute.
                    return sHref.substring(sHref.indexOf("#"),sHref.length)
                }



