﻿   function getBrowserName() {
      var nVer = navigator.appVersion;
      var nAgt = navigator.userAgent;
      var browserName = navigator.appName;
      var fullVersion = '' + parseFloat(navigator.appVersion);
      var nameOffset, verOffset, ix;

      // In MSIE, the true version is after "MSIE" in userAgent
      if ((verOffset = nAgt.indexOf("MSIE")) != -1) {
         browserName = "MSIE";
      }
      // In Opera, the true version is after "Opera" 
      else if ((verOffset = nAgt.indexOf("Opera")) != -1) {
         browserName = "Opera";
      }
      // In Chrome, the true version is after "Chrome" 
      else if ((verOffset = nAgt.indexOf("Chrome")) != -1) {
         browserName = "Chrome";
      }
      // In Safari, the true version is after "Safari" 
      else if ((verOffset = nAgt.indexOf("Safari")) != -1) {
         browserName = "Safari";
      }
      // In Firefox, the true version is after "Firefox" 
      else if ((verOffset = nAgt.indexOf("Firefox")) != -1) {
         browserName = "Firefox";
      }
      return browserName;
   }

   function ventana(url, winW,winH){
      quizWin = window.open(url  , "quizWin", "width=" + winW + ",height=" + winH + ", top=10, left=10, pageY=10, pageX=10, toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
      quizWin.focus();
   }

   function popvideo(url, winW, winH) {
      var intWidth = winW;
      var intHeight = winH;
      var regex = new RegExp("\.swf", "i");
      // Increase popup size for player
      // All browsers seem fine with the same size.
      if (regex.test(url)) {
         intWidth += 90;
      }
      intHeight += 50;
      quizWin = window.open(url, "quizWin", "width=" + intWidth + ",height=" + intHeight + ", top=10, left=10, pageY=10, pageX=10, toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0");
      quizWin.focus();
   }

   function newWin(){
      winW = 792;
      winH = 540;
      quizWin = window.open("create_xml.asp?sections_id=<%= id %>", "quizWin", "width=" + winW + ",height=" + winH + ", top=10, left=10, pageY=10, pageX=10, toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
      quizWin.focus();
   }

   function changeImg(txttitle, txtdesc, tblimg ) {
      // document.images["theImg"].src=src;
      // alert(tblimg);
      if (tblimg == 1)
      {  
         if  (document.all) {
            document.all.texttitle.innerHTML=txttitle;
            document.all.textdesc.innerHTML=txtdesc;
            document.getElementById('displaytable').style.display = 'block';
         }else{
            document.getElementById("texttitle").innerHTML=txttitle;
            document.getElementById("textdesc").innerHTML=txtdesc;
            document.getElementById('displaytable').style.display = 'block';
         }
      } else {
            document.getElementById('displaytable').style.display = "none"
      }
      window.scrollTo(0,0);
   }

   function AskWhy() {
      return confirm("Are you sure?");
   }

   $(document).ready(function() {
      // Create a click handler for every <a></a> tag with the id=aPopup
      // Get the id that was clicked and display the associated div.
      $("[id*='aPopup']").click(function() {
         var id = "#" + $(this).attr("id")
         var result = id.match(/aPopup[0-9]+/i);
         if (result != null) {
            var strPopupDiv = "divPopup" + result[0].match(/[0-9]+/);
            $("#" + strPopupDiv).centerInClient();
            $("#" + strPopupDiv).fadeIn('slow');
         }
      });
      // Create a click handler for every <a></a> tag with the id=aGloss
      // Get the id that was clicked and display the associated div.
      $("[id*='aGloss']").click(function() {
         var id = "#" + $(this).attr("id")
         var result = id.match(/aGloss[0-9]+/i);
         if (result != null) {
            var strPopupDiv = "divGloss" + result[0].match(/[0-9]+/);
            $("#" + strPopupDiv).centerInClient();
            $("#" + strPopupDiv).fadeIn('slow');
         }
      });

      // Close any div that was displayed.    
      $("[id*='linkPopupClose']").click(function() {
         $("[id*='divPopup']").fadeOut('fast'); // close popups
         $("[id*='divGloss']").fadeOut('fast'); // close glossaries
      });

      // When hovering over the image the figure text window will be displayed below the image.
      // When leaving the image the figure text window will be hidden.
      $(".olceimage").hover(function(e) {
         var imagecaption = $(e.target).siblings("div.olceimagecaption").get(0);
         var hiddenspan = $(imagecaption).children("span.olcehidden").get(0);
         if (typeof (imagecaption) != 'undefined' && imagecaption != null &&
          typeof (hiddenspan) != 'undefined' && hiddenspan != null) {
            var image = $(e.target).get(0);
            var txtFigure = imagecaption.innerHTML;
            var spanCaptionTitle = document.getElementById('spanCaptionTitle');
            var divCaption = document.getElementById('divCaption');
            spanCaptionTitle.innerHTML = txtFigure;
            // if the image is too small leave the default width
            if (image.width > 200) {
               divCaption.style.width = image.width;
            }
            divCaption.style.left = $(imagecaption).offset().left + "px";
            divCaption.style.top = $(imagecaption).offset().top + "px";
            document.getElementById('divCaptionText').innerHTML = hiddenspan.innerHTML.toString().trim() + $(imagecaption).offset().left;
            divCaption.style.display = 'block';
         }
      },
      function() {
         document.getElementById('divCaption').style.display = 'none';
      });
      $("#divCaption").click(function() {
         document.getElementById('divCaption').style.display = 'none';
      });

   });

