﻿//google analytics
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-16589914-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
var plstart = new Date();
function logLoad() {
    // set the end date stamp
    var plend = new Date();
    // calculate the elapsed time between the start and the end. 
    // This is in milliseconds
    var plload = plend.getTime() - plstart.getTime();
    // determine the load thresholds
    if (plload < 2000) // less than 2 seconds is very fast
        lc = "Very Fast";
    else if (plload < 5000) // 5 seconds = fast
        lc = "Fast";
    else if (plload < 10000) // 10 seconds medium
        lc = "Medium";
    else if (plload < 30000) // 30 seconds - sluggish
        lc = "Sluggish";
    else if (plload < 45000) // 45 seconds slow 
        lc = "Slow";
    else
        lc = "Very Slow"; // wow more than a minute
    // capture the URL that we are going to record
    var fn = document.location.pathname;
    if (document.location.search)
        fn += document.location.search;
    pageTracker._trackPageview("/load times/" + lc + " Loading Pages" + fn);
    window.status = lc;
        try
        {
            pageTracker._trackEvent("Page Load",lc + 
            " Loading Pages", fn, Math.round(plload/1000));
        }
        catch(err)
        {
            alert(err);
        }    
}
var pageTracker;
function mygat() {
    if (typeof (_gat) == 'undefined') {
        window.setTimeout(mygat, 1000);
    }
    else {
        pageTracker = _gat._getTracker("'UA-16589914-1");
        pageTracker._trackPageview();
        logLoad();
    }
}
window.attachEvent("onload", mygat);  
//Get request object
function RObj(ea) { var LS = ""; var QS = new Object(); var un = "undefined"; var f = "function"; var n = "number"; var r = "string"; var e1 = "ERROR:Index out of range in\r\nRequest.QueryString"; var e2 = "ERROR:Wrong number of arguments or invalid property assignment\r\nRequest.QueryString"; var e3 = "ERROR:Object doesn't support this property or method\r\nRequest.QueryString.Key"; function Err(arg) { if (ea) alert("Request Object:\r\n" + arg) }; function URID(t) { var d = ""; if (t) { for (var i = 0; i < t.length; ++i) { var c = t.charAt(i); d += (c == "+" ? " " : c); }; }; return unescape(d); }; function OL(o) { var l = 0; for (var i in o) { if (typeof (o[i]) != f) l++; }; return l; }; function AK(key) { var auk = true; for (var u in QS) { if (typeof (QS[u]) != f && u.toString().toLowerCase() == key.toLowerCase()) { auk = false; return u; } }; if (auk) { QS[key] = new Object(); QS[key].toString = function() { return TS(QS[key]) }; QS[key].Count = function() { return OL(QS[key]) }; QS[key].Count.toString = function() { return OL(QS[key]).toString() }; QS[key].Item = function(e) { if (typeof (e) == un) return QS[key]; else { if (typeof (e) == n) { var a = QS[key][Math.ceil(e)]; if (typeof (a) == un) Err(e1 + "(\"" + key + "\").Item(" + e + ")"); return a; } else Err("ERROR:Expecting numeric input in\r\nRequest.QueryString(\"" + key + "\").Item(\"" + e + "\")"); } }; QS[key].Item.toString = function(e) { if (typeof (e) == un) return QS[key].toString(); else { var a = QS[key][e]; if (typeof (a) == un) Err(e1 + "(\"" + key + "\").Item(" + e + ")"); return a.toString(); }; }; QS[key].Key = function(e) { var t = typeof (e); if (t == r) { var a = QS[key][e]; return (typeof (a) != un && a && a.toString() ? e : ""); } else Err(e3 + "(" + (e ? e : "") + ")"); }; QS[key].Key.toString = function() { return un }; }; return key }; function AVTK(key, val) { if (key != "") { var key = AK(key); var l = OL(QS[key]); QS[key][l + 1] = val; } }; function TS(o) { var s = ""; for (var i in o) { var ty = typeof (o[i]); if (ty == "object") s += TS(o[i]); else if (ty != f) s += o[i] + ", "; }; var l = s.length; if (l > 1) return (s.substring(0, l - 2)); return (s == "" ? un : s); }; function KM(k, o) { var k = k.toLowerCase(); for (var u in o) { if (typeof (o[u]) != f && u.toString().toLowerCase() == k) return u; }; } if (window.location && window.location.search) { LS = window.location.search; var l = LS.length; if (l > 0) { LS = LS.substring(1, l); var preAmpAt = 0; var ampAt = -1; var eqAt = -1; var k = 0; var skip = false; for (var i = 0; i < l; ++i) { var c = LS.charAt(i); if (LS.charAt(preAmpAt) == "=" || (preAmpAt == 0 && i == 0 && c == "=")) skip = true; if (c == "=" && eqAt == -1 && !skip) eqAt = i; if (c == "&" && ampAt == -1) { if (eqAt != -1) ampAt = i; if (skip) preAmpAt = i + 1; skip = false; }; if (ampAt > eqAt) { AVTK(URID(LS.substring(preAmpAt, eqAt)), URID(LS.substring(eqAt + 1, ampAt))); preAmpAt = ampAt + 1; eqAt = ampAt = -1; ++k; }; }; if (LS.charAt(preAmpAt) != "=" && (preAmpAt != 0 || i != 0 || c != "=")) { if (preAmpAt != l) { if (eqAt != -1) AVTK(URID(LS.substring(preAmpAt, eqAt)), URID(LS.substring(eqAt + 1, l))); else if (preAmpAt != l - 1) AVTK(URID(LS.substring(preAmpAt, l)), ""); }; if (l == 1) AVTK(LS.substring(0, 1), ""); }; }; }; var TC = OL(QS); if (!TC) TC = 0; QS.toString = function() { return LS.toString() }; QS.Count = function() { return (TC ? TC : 0) }; QS.Count.toString = function() { return (TC ? TC.toString() : "0") }; QS.Item = function(e) { if (typeof (e) == un) return LS; else { if (typeof (e) == n) { var e = Math.ceil(e); var c = 0; for (var i in QS) { if (typeof (QS[i]) != f && ++c == e) return QS[i]; }; Err(e1 + "().Item(" + e + ")"); } else return QS[KM(e, QS)]; }; return un; }; QS.Item.toString = function() { return LS.toString() }; QS.Key = function(e) { var t = typeof (e); if (t == n) { var e = Math.ceil(e); var c = 0; for (var i in QS) { if (typeof (QS[i]) != f && ++c == e) return i; } } else if (t == r) { var e = KM(e, QS); var a = QS[e]; return (typeof (a) != un && a && a.toString() ? e : ""); } else Err(e2 + "().Key(" + (e ? e : "") + ")"); Err(e1 + "().Item(" + e + ")"); }; QS.Key.toString = function() { Err(e2 + "().Key"); }; this.QueryString = function(k) { if (typeof (k) == un) return QS; else { var k = KM(k, QS); if (typeof (QS[k]) == un) { t = new Object(); t.Count = function() { return 0 }; t.Count.toString = function() { return "0" }; t.toString = function() { return un }; t.Item = function(e) { return un }; t.Item.toString = function() { return un }; t.Key = function(e) { Err(e3 + "(" + (e ? e : "") + ")"); }; t.Key.toString = function() { return un }; return t; } if (typeof (k) == n) return QS.Item(k); else return QS[k]; } }; this.QueryString.toString = function() { return LS.toString(); }; this.QueryString.Count = function() { return (TC ? TC : 0) }; this.QueryString.Count.toString = function() { return (TC ? TC.toString() : "0") }; this.QueryString.Item = function(e) { if (typeof (e) == un) return LS.toString(); else { if (typeof (e) == n) { var e = Math.ceil(e); var c = 0; for (var i in QS) { if (typeof (QS[i]) != f && ++c == e) return QS[i]; }; Err(e1 + ".Item(" + e + ")"); } else return QS[KM(e, QS)]; } if (typeof (e) == (n)) Err(e1 + ".Item(" + e + ")"); return un; }; this.QueryString.Item.toString = function() { return LS.toString() }; this.QueryString.Key = function(e) { var t = typeof (e); if (t == n) { var e = Math.ceil(e); var c = 0; for (var i in QS) { if (typeof (QS[i]) == "object" && (++c == e)) { return i; } } } else if (t == r) { var e = KM(e, QS); var a = QS[e]; return (typeof (a) != un && a && a.toString() ? e : ""); } else Err(e2 + ".Key(" + (e ? e : "") + ")"); Err(e1 + ".Item(" + e + ")"); }; this.QueryString.Key.toString = function() { Err(e2 + ".Key"); }; this.Version = 1.2; this.Author = "Andrew Urquhart (www.andrewu.co.uk)"; }; var Request = new RObj(false);  
//Redirect page from a dropdown menu
function menu_goto(menuform) {
    var theurl = menuform.options[menuform.selectedIndex].value;
    results = theurl.search(/pdf/gi);
    if (results != -1) {
        theurl = theurl + roletype;
        window.open(theurl, 'viewPDF', 'location=no,menubar=no,status=no,directories=no,scrollbars=yes,status=no,toolbar=no,dependent=yes,innerHeight=400,innerWidth=600');
    }
    else {
        window.location = theurl;
    }
}
  function LogIn() {
      loggedin = false;
      username = "";
      password = "";
      username = prompt("Username:", "");
      username = username.toLowerCase();
      password = prompt("Password:", "");
      password = password.toLowerCase();
      if (username == "guest" && password == "login") {
          loggedin = true;
          window.location = "home-page.html";
      }
      if (username == "guest2" && password == "login2") {
          loggedin = true;
          window.location = "home-page2.html";
      }
      if (loggedin == false) {
          alert("Invalid login!");
      }
  }
  function OnChange(dropdown, id) {
      var selectedIndex = dropdown.selectedIndex;
      var moduleTypeName = dropdown.options[selectedIndex].text;
      document.getElementById(id + "fundDiv").style.display = "none";
      document.getElementById(id + "documentDiv").style.display = "none";
      document.getElementById(id + "fundClassDiv").style.display = "none";
      document.getElementById(id + "disclosureDiv").style.display = "none";
      if (moduleTypeName.indexOf("Fund") == 0 && moduleTypeName != "Fund Performance Statistics" && moduleTypeName != "Fund Performance and Prices") {
          document.getElementById(id + "fundDiv").style.display = "block";
      }
      if (moduleTypeName.indexOf("Document") == 0) {
          document.getElementById(id + "documentDiv").style.display = "block";
      }
      if (moduleTypeName.indexOf("Fund Performance and Prices") == 0) {
          document.getElementById(id + "fundClassDiv").style.display = "block";
      }
      if (moduleTypeName.indexOf("Disclosure Block") == 0) {
          document.getElementById(id + "disclosureDiv").style.display = "block";
      }
  }
  function changeElementDisplay(idT, displayStyle, tagOnId) {
      if (tagOnId.length > 0) {
          idT = idT + document.getElementById(tagOnId).value;
      }
      document.getElementById(idT).style.display = displayStyle;
  }
  function BringToFront(ToFrontId) {
      var m = document.getElementsByTagName("table");
      for (var i = 0; i < m.length; i++) {
          if (m[i].id != ToFrontId) {
              m[i].style.display = "block";
          }
          else {
              m[i].style.style.Zindex = 15;
          }
      }
  }
  function showhideToggle(index) {
      var panelName = "";
      for (i = 1; i <= 5; i++) {
          var linkName = '#link' + i;
          panelName = '#panel' + i;
          if (i != index) {
              $(linkName).removeClass('here');
              $(panelName).fadeOut('slow')
          }
      }
      linkName = '#link' + index;
      $(linkName).addClass('here');
      panelName = '#panel' + index;
      setTimeout(" fade('" + panelName + "')", 800);
      if (index == 5) {
          $("#disclosurePanel1").fadeOut('slow');
          setTimeout(" fade('#disclosurePanel2')", 800);
      }
      else {
          $("#disclosurePanel2").fadeOut('slow');
          setTimeout(" fade('#disclosurePanel1')", 800);
      }
  }
  function fade(panelName)
  { $(panelName).fadeIn(); }
  function submitenterSearch(myfield, e, role) {
      var keycode;
      if (window.event) keycode = window.event.keyCode;
      else if (e) keycode = e.which;
      else return true;

      if (keycode == 13) {
          processSearch(document.getElementById("zoom_query").value, role);
          return false;
      }
      else
          return true;
  }
  function openWindowWithContent(id, panelId) {
      var url = document.location.href;
      if (url.indexOf("?") > 0) {
          url += "&Print=true&DisplayZone=" + id + "&Panel=" + panelId + "#" + panelId;
      }
      else {
          url += "?DisplayZone=" + id + "&Print=true&Panel=" + panelId + "#" + panelId;
      }
      var PUtest = window.open(url, "newwin", "width=1000,height=500, resizable, scrollbars");
      if (!PUtest) {
          alert("You should disable your popup blocker for this site to work properly");
          window.location = url;
      }
  }
  function appendRemoveNames(checkBox) {
      if (checkBox.checked == true) {
          document.getElementById("FormNames").innerHTML += checkBox.value + "|";
      }
      else {
          document.getElementById("FormNames").innerHTML = document.getElementById("FormNames").innerHTML.replace(checkBox.value + "|", "");
      }
  }
  function submitenter(myfield, e) {
      var keycode;
      if (window.event) keycode = window.event.keyCode;
      else if (e) keycode = e.which;
      else return true;

      if (keycode == 13) {
          document.forms['HomeLogin'].submit();
          return false;
      }
      else
          return true;
  }
  // cookie functions http://www.quirksmode.org/js/cookies.html
  function createCookie(name, value, days) {
      if (days) {
          var date = new Date();
          date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
          var expires = "; expires=" + date.toGMTString();
      }
      else var expires = "";
      document.cookie = name + "=" + value + expires + "; path=/";
  }
  function readCookie(name) {
      var nameEQ = name + "=";
      var ca = document.cookie.split(';');
      for (var i = 0; i < ca.length; i++) {
          var c = ca[i];
          while (c.charAt(0) == ' ') c = c.substring(1, c.length);
          if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
      }
      return null;
  }
  function eraseCookie(name) {
      createCookie(name, "", -1);
  }
  // /cookie functions
