//---------------------------------------------------------------------------
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    } //MM_swapImgRestore
//---------------------------------------------------------------------------
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    } //MM_preloadImages
//---------------------------------------------------------------------------
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    } //MM_findObj
//---------------------------------------------------------------------------
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    } //MM_swapImage
//---------------------------------------------------------------------------
    function fnAssociateHorse(eid) {
      var features = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=460,top=100,left=150';
      window.open('popups/horse.aspx?eid='+eid,'Associate',features);
    } //fnAssociateHorse
//---------------------------------------------------------------------------
    function fnAssociateShareholder(eid) {
      var features = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=460,top=100,left=150';
      window.open('popups/shareholder.aspx?eid='+eid,'Associate',features);
    } //fnAssociateShareholder
//---------------------------------------------------------------------------
    function fnCancel(url) {
      window.location.href=url;
    }  //fnCancel
//---------------------------------------------------------------------------
    function fnClose() {
      window.close();
    } //fnClose
//---------------------------------------------------------------------------
    function fnConfirmDeleteEntity(name) {
      return confirm('Are you sure you want to delete '+name+'?');
    } //fnConfirmDeleteEntity
//---------------------------------------------------------------------------
    function fnConfirmDeleteFocusOn() {
      return confirm('Are you sure you want to delete this focus on item?');
    } //fnConfirmDeleteFocusOn
//---------------------------------------------------------------------------
    function fnConfirmDeleteHorse(name) {
      return confirm('Are you sure you want to delete '+name+'?\n\nPlease delete any BRIS reports for this horse before proceeding.');
    } //fnConfirmDeleteHorse
//---------------------------------------------------------------------------
    function fnConfirmDeleteShareholder(name) {
      return confirm('Are you sure you want to delete '+name+'?');
    } //fnConfirmDeleteShareholder
//---------------------------------------------------------------------------
    function fnConfirmLogOut() {
      return confirm('Are you sure you want to log out?');
    } //fnConfirmLogOut
//---------------------------------------------------------------------------
    function fnEnlarge(server,img) {
      var imgSrc = new Image();
//      imgSrc.src = 'http://'+server+'/dapple/media/photos/horses/lg_'+img; //localhost only
      imgSrc.src = 'http://'+server+'/media/photos/horses/lg_'+img;
      
      var bolResizable = 'no';

      var screenWidth = window.screen.availWidth;
      var screenHeight = window.screen.availHeight;
  
      var offsetXWinXP = 5;
      var offsetYWinXP = 15;
  
      var windowWidth = imgSrc.width;
      var windowHeight = imgSrc.height;
      
      if(windowWidth < 1) {
        windowWidth = 640;
        bolResizable = 'yes';
      }

      if(windowHeight < 1) {
        windowHeight = 480;
        bolResizable = 'yes';
      }
  
      var halfScreenWidth = Number(window.screen.availWidth/2);
      var halfScreenHeight = Number(window.screen.availHeight/2);
  
      var halfWindowWidth = Number(windowWidth/2);
      var halfWindowHeight = Number(windowHeight/2);
  
      var diffWidth = Number(halfScreenWidth-halfWindowWidth);
      var diffHeight = Number(halfScreenHeight-halfWindowHeight);
  
      diffWidth -= offsetXWinXP;
      diffHeight -= offsetYWinXP;

      var features = 'directories=no,location=no,menubar=yes,resizable='+bolResizable+',scrollbars=no,status=no,toolbar=no,width='+windowWidth+',height='+windowHeight+',top='+diffHeight+',left='+diffWidth;
      window.open('enlarge.aspx?i='+imgSrc.src,'EnlargeWin',features);
    } //fnEnlarge
//---------------------------------------------------------------------------
    function fnEnlargeAerial()
    {
        var aerial = fnOpenWindow("", 1000, 665, "no", "yes");
        aerial.document.write("<html><head><title>Dapple Stud Aerial Photo</title><style type=\"text/css\">body { margin: 0px; }</style></head><body><img src=\"/images/photos/dapple_aerial.jpg\" /></body></html>");
        aerial.document.close();
    }
//---------------------------------------------------------------------------
    function fnLit(obj,bool) {
      obj.style.backgroundColor = bool ? '#f2f4ec' : '';
    } //fnLit
//---------------------------------------------------------------------------
    function fnManageBrisReports(hid) {
      var features = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=280,top=100,left=150';
      window.open('popups/bris_reports.aspx?hid='+hid,'BrisReports',features);
    } //fnManageBrisReports
//---------------------------------------------------------------------------
    function fnManagePDF(eid) {
      var features = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=480,top=100,left=150';
      window.open('popups/documents.aspx?eid='+eid,'PDF',features);
    } //fnManagePDF
//---------------------------------------------------------------------------
    function fnPdfUpload(ref) {
      var features = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=480,top=100,left=150';
      window.open('popups/pdf.aspx?ref='+ref,'PdfUpload',features);
    } //fnPdfUpload
//---------------------------------------------------------------------------
    function fnArchivedPDF(eid, user) {
      var features = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=280,top=100,left=150';
      window.open('documents.aspx?eid=' + eid + '&u=' + user,'ArchivedPDF',features);
    } //fnArchivedPDF
//---------------------------------------------------------------------------
    function fnPdfArchive(ref) {
      var features = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=280,top=100,left=150';
      window.open('documents.aspx?ref=' + ref,'PdfArchive',features);
    } //fnPdfArchive
//---------------------------------------------------------------------------
    function fnOpenPDF(path)
    {
      var list = document.getElementById("lstDocuments");
      var pdf = list.options[list.selectedIndex].value;
      if (path != null)
      {
        window.open(path + 'media/pdf/' + pdf, 'Archive', '');      
      }
      else
      {
        window.open('../media/pdf/' + pdf, 'Archive', '');      
      }
    } //end fnOpenPDF
//---------------------------------------------------------------------------
    function fnOpenWindow(url, w, h, sb, r, mb, tb, s, loc, dir)
    {
      var screenWidth = window.screen.availWidth;
      var screenHeight = window.screen.availHeight;
    
      var offsetXWinXP = 5;
      var offsetYWinXP = 18;
    
      var halfScreenWidth = Number(window.screen.availWidth / 2);
      var halfScreenHeight = Number(window.screen.availHeight / 2);
    
      var halfWindowWidth = Number(w / 2);
      var halfWindowHeight = Number(h / 2);
    
      var diffWidth = Number(halfScreenWidth-halfWindowWidth);
      var diffHeight = Number(halfScreenHeight-halfWindowHeight);
    
      diffWidth -= offsetXWinXP;
      diffHeight -= offsetYWinXP;
      
      //The windowName is a zero-based integer corresponding to the number of milliseconds
      //since January 1, 1970, to the date specified by the instance of the Date object;
      //therefore, the windowName will almost always be unique.
      var dtm = new Date();
      var windowName = dtm.getTime();
      
      //if (url == null) { url = "" };
      if (w == null) { w = 640 };
      if (h == null) { h = 480 };
      if (sb == null) { sb = "no" };
      if (r == null) { r = "no" };
      if (mb == null) { mb = "no" };
      if (tb == null) { tb = "no" };
      if (s == null) { s = "no" };
      if (loc == null) { loc = "no" };
      if (dir == null) { dir = "no" };
    
      var features = "directories=" + dir + ",";
      features += "location=" + loc + ",";
      features += "menubar=" + mb + ",";
      features += "resizable=" + r + ",";
      features += "scrollbars=" + sb + ",";
      features += "status=" + s + ",";
      features += "toolbar=" + tb +",";
      features += "width=" + w + ",";
      features += "height=" + h + ",";
      features += "top=" + diffHeight + ",";
      features += "left=" + diffWidth;
      
      //if (url != null && url != "")
      //{
      return window.open(url, windowName, features);
      //}
      //else
      //{
      //  alert("The url parameter is missing.");
      //  return;
      //}
    } //fnOpenWindow
//---------------------------------------------------------------------------
    function fnPrint(page,hid) {
      var features = 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600';
      window.open(page+'_horse_print.aspx?hid='+hid,'_blank',features);
    } //end fnPrint
//---------------------------------------------------------------------------
    function fnToggleControls(obj,controlist) {
      var d = document.all;
      var arrControls = controlist.split(',');
      if(d[obj].value!='') {
        for(var i=0;i<arrControls.length;i++) {
          d[arrControls[i]].disabled=false;
        }
      } else {
        for(var i=0;i<arrControls.length;i++) {
          d[arrControls[i]].disabled=true;
        }
      }
    } // fnToggleControls
//---------------------------------------------------------------------------
    function fnToggleEntity(i) {
      var entity = document.getElementById('entity_'+i);
      var toggle = document.getElementById('toggle_'+i);
  
      entity.style.display=='inline' ? fnCollapse() : fnExpand();
      
      function fnCollapse() {
        toggle.src='images/btn_expand.gif';
        toggle.alt='Expand';
        entity.style.display = 'none';
      } //fnCollapse
  
      function fnExpand() {
        toggle.src='images/btn_collapse.gif';
        toggle.alt='Collapse';
        entity.style.display = 'inline';
      } //fnExpand
  
    } //fnToggleEntity
//---------------------------------------------------------------------------
    function fnToggleEntityDesc(i, name) {
      var entity = document.getElementById('entity_'+i);
      var desc = document.getElementById('desc_'+i);
  
      entity.style.display == 'inline' ? fnCollapse() : fnExpand();
      
      function fnCollapse() {
        entity.style.display = 'none';
        desc.innerHTML = '<img src="../images/btn_expand.gif" width="9" height="9" border="0" alt="Expand ' + name + '" style="margin-right: 1px;" />' + name;
      } //fnCollapse
  
      function fnExpand() {
        entity.style.display = 'inline';
        desc.innerHTML = '<img src="../images/btn_collapse.gif" width="9" height="9" border="0" alt="Collapse ' + name + '" style="margin-right: 1px;" />' + name;
      } //fnExpand
  
    } //fnToggleEntityDesc
//---------------------------------------------------------------------------
