<!--

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
///
/// (m) Ajos1 2009/03/30 - MSIE8 (+30) added...  [and MSIE9 (+30)]...
/// (m) Ajos1 2008/05/22 - Minor fix...
/// (m) Ajos1 2008/01/23 - Test for SubPhoto being undefined to stop crash!!
/// (m) Ajos1 2007/03/27 - Move where-we-are/direction to bottom of photo...
/// (m) Ajos1 2007/03/02 - MSIE7 (+30) added for the annoying address-bar
/// (m) Ajos1 2006/08/19 - </script> causing hassles & defer="true" needed!!
/// (m) Ajos1 2006/08/18 - Some attempts to get the freezing to stop!
/// (m) Ajos1 2006/02/11 - Major Overhaul...
/// (m) Ajos1 2005/04/11 - Change of layout for easier editing.......
/// (m) Ajos1 2005/02/15 - Re-Written to one procedure for 365mag.com
/// (m) Ajos1 2004/07/03 - Added in variable Slide Show
/// (m) Ajos1 2003/08/26 - Auto-forward of slide show added - 5 seconds
/// (c) Ajos1 2003/01/01 - Bits and pieces borrowed from elsewhere
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Navigator items... Order of appearance is important...          ///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
var nav=navigator.userAgent.toLowerCase();;
var isMac=(nav.indexOf("macintosh")!=-1);
var isN6=(nav.indexOf("gecko")!=-1);
var isN4=(document.layers)?true:false;
var isOpera=(nav.indexOf("opera")!=-1)?true:false;
var isOpera5=(nav.indexOf("opera 5")!=-1 || nav.indexOf("opera/5")!=-1)?true:false;
var isOpera6=(isOpera && parseInt(navigator.appVersion)>=6)?true:false;
var isSafari=(nav.indexOf("safari")!=-1)?true:false;
var isIE=(document.all && !isOpera && (!isMac || navigator.appVersion.indexOf("MSIE 4")==-1))?true:false;

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Based Upon: http://obvcode.blogspot.com/2007/11/easiest-way-to-check-ie-version-with.html ///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
var Browser = {
   Version: function() {
      //
      // We assume a sane browser
      //
      var version = 999;
      if (navigator.appVersion.indexOf("MSIE") != -1) {
         //
         // bah, IE again, lets downgrade version number
         //
         version = parseFloat(navigator.appVersion.split("MSIE")[1]);
      }
      return version;
   }
}
var IEVersion = Browser.Version();
var isIE7=(nav.indexOf("msie 7")!=-1);
var isIE8=(nav.indexOf("msie 8")!=-1);
var isIE9=(nav.indexOf("msie 9")!=-1);

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
///                                                                 ///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
var SubPhoto;

/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
///
/// How do we want the sub-window want to appear???
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
var PhotoWinElements = new Array(
   "alwaysLowered=0",
   "alwaysRaised=0",
   "channelmode=0",
   "dependent=0",
   "directories=0",
   "fullscreen=0",
   "hotkeys=0",
   "location=0",
   "menubar=0",
   "resizable=0",
   "scrollbars=0",
   "status=0",
   "titlebar=1",
   "toolbar=0",
   "z-lock=0",
   ""
);


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
///
/// Function - Join Up Array elements into one string.. (Separator Inc)
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function arryjoin(procarray, newseparator)
{
   var tempstrg = '';
   var numsofar = 0;

   if (newseparator.length <= 0) {
      newseparator = ',';
   }

   if (procarray.length > 0) {
      for (var i = 0; i < procarray.length; i++) {
         if (procarray[i].length > 0) {
            if (numsofar > 0) {
               tempstrg = tempstrg + newseparator;
            }
            tempstrg = tempstrg + procarray[i]
            numsofar = numsofar + 1;
         }
      }
   }
   return(tempstrg);
}


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
///
/// Function
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function photostart(tmpflag)
{
   var alertxt;

   //
   // Make sure that any previous windows are not there!
   //
   photowinclose();

   //
   // This is the message!
   //
   alertxt = '';
   alertxt = alertxt + 'THESE PHOTOGRAPHS ARE CUT DOWN VERSIONS OF THE ORIGINAL HIGH-RESOLUTION PICTURES.\n\n';
   alertxt = alertxt + 'To allow for reasonable download speeds, the photos shown on these webpages are set to low quality.\n\n';
   alertxt = alertxt + '(The ** ORIGINAL HIGH-RESOLUTION ** copies are available on \'reasonable\' request).\n';

   if (parseInt(tmpflag) > 0) {
      alert(alertxt);
   }

   //return false;
}


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/01/23
///
/// Function
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function photowinclose()
{
   ///
   /// Open window or not... Lets decide...
   ///
   if (SubPhoto!=undefined) {
      if (window.SubPhoto && window.SubPhoto.open && !window.SubPhoto.closed) {
         ///
         /// Order is very very very important...
         ///
         SubPhoto.document.clear();
         window.SubPhoto.opener = null;
         window.SubPhoto.close();
      }
   }

   //return true;
}


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
///
/// Function - Limit copying of images...
///
/// http://www.javascripter.net/faq/leftvsri.htm
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
//function stoprightclick()
//{
//   if (event.button==2) {
//      alert("** Browser Error **");
//   }
//}
//


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
///
/// Function
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function imgwalk(PosnOnScrn, strAlbumTitle, strImageFile, ImageXSize, ImageYSize, strPhotoDescrp)
{
   var PhotoList = new Array(strImageFile, ImageXSize, ImageYSize, strPhotoDescrp, "END_MARKER");
   imgslide(1, 0, 0, PosnOnScrn, strAlbumTitle, PhotoList);
}


/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
/// Last Updated: 2008/01/23
///
/// Function
///
///  array(photofile  x_size  y_size  title_for_photo)
///
/// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
function imgslide(CurrntNumb, whichway, TimeFlag, PosnOnScrn, strAlbumTitle, PhotoArray)
{
   //
   //
   //
   var MaxWinX  = 800;
   var MaxWinY  = 600;

   var MinWinX  = 360;
   var MinWinY  = 270;

   var NumPhoto = 0;

   var TimeMin  = 3;
   var TimeMax  = 20;


   //
   // How many photos?
   //
   NumPhoto = parseInt(PhotoArray.length / 4);


   //
   // Keep Time between slides within limits
   //
   if (TimeFlag < TimeMin) {
      TimeFlag = TimeMin;
   }
   if (TimeFlag > TimeMax) {
      TimeFlag = TimeMax;
   }


   //
   // Scrolling/Wrapping the picture slide show
   //
   if (whichway < 0) {
      CurrntNumb = CurrntNumb - 1;
   }
   if (whichway > 0) {
      CurrntNumb = CurrntNumb + 1;
   }
   if (CurrntNumb <= 0) {
      CurrntNumb = NumPhoto;
   }
   if (CurrntNumb > NumPhoto) {
      CurrntNumb = 1;
   }


   //
   // Now deal with a photo-graph...
   //
   if ((CurrntNumb <= 0) || (CurrntNumb > NumPhoto)) {
      //
      // Error message if something has gone wrong...
      //
      alert("Panic Current phot counter Out Of Sync [" + CurrntNumb + " vs " + NumPhoto + "]");
   } else {
      //
      // We start of with a minimum size, which will hopefully grow a little bit more...
      // This has been changed to look at the biggest image of the array to stop silly flickering
      //
      ArryMaxX = 0;
      ArryMaxY = 0;
      for (i = 1; i <= NumPhoto; i++) {
         elementcnt = ((i - 1) * 4);
         TmpX = PhotoArray[(elementcnt + 1)];
         TmpY = PhotoArray[(elementcnt + 2)];
         if (TmpX > ArryMaxX) {
            ArryMaxX = TmpX;
         }
         if (TmpY > ArryMaxY) {
            ArryMaxY = TmpY;
         }
         //
         // To save time... Store Details... if we pass the photo we need to display...
         //
         if (CurrntNumb == i) {
            strImageFile   = PhotoArray[(elementcnt + 0)];
            ImageXSize     = PhotoArray[(elementcnt + 1)];
            ImageYSize     = PhotoArray[(elementcnt + 2)];
            strPhotoDescrp = PhotoArray[(elementcnt + 3)];
         }
      }

      //
      // Some very clever ajos1 code that resizes big pictures to fit onto the current
      // screen!  [But then... what do you expect from the best!]
      //
      NewX = ImageXSize
      NewY = ImageYSize

      //
      // WidthFactors...
      //
      WidthFactor = 9;
      //if (NumPhoto > 1) {
      //   WidthFactor = 15;
      //}

      //
      // These are the MAXIMUM dimensions the IMAGE will take up on the screen...
      // The BIGGER photographs are re-scaled proportionally to be BELOW these MAXs
      //
      MaxImgX = parseInt(screen.width * WidthFactor / 16);
      MaxImgY = parseInt(screen.height - 235);

      //
      // Order is very very important!
      //    (1) X-Factor image down
      //    (2) Y-Factor image down
      //    (3) Then convert to whole numbers
      //
      // Applied to:
      //    (a) Biggest photo re-scaled to set the maximum width/height for all photos
      //    (b) Current photo based on biggest photo (this deals with a photo being wider than the max!?)
      //
      DivX = MaxImgX / ArryMaxX;
      if (ArryMaxX > MaxImgX) {
         ArryMaxX = DivX * ArryMaxX;
         ArryMaxY = DivX * ArryMaxY;
      }
      DivY = MaxImgY / ArryMaxY;
      if (ArryMaxY > MaxImgY) {
         ArryMaxX = DivY * ArryMaxX;
         ArryMaxY = DivY * ArryMaxY;
      }
      ArryMaxX = parseInt(ArryMaxX);
      ArryMaxY = parseInt(ArryMaxY);

      DivX = ArryMaxX / NewX;
      if (NewX > ArryMaxX) {
         NewX = DivX * NewX;
         NewY = DivX * NewY;
      }
      DivY = ArryMaxY / NewY;
      if (NewY > ArryMaxY) {
         NewX = DivY * NewX;
         NewY = DivY * NewY;
      }
      NewX = parseInt(NewX);
      NewY = parseInt(NewY);

      //
      // Probs with IE - So Resize the RE-USED window... in case it is still
      // the old size!!
      //
      // With some strange "added" factors to deal with browsers problems.
      //
      addon_x =  10;
      addon_y = 120;

      //
      // DEBUG
      //
      // alert(navigator.appVersion);

      if (isMac) {
         if (isSafari) {
            addon_y = addon_y + 20;
         }
      } else {
         addon_x = addon_x + 10;
         addon_y = addon_y + 20;
         //if ((IEVersion >= 7) && (IEVersion <= 9)) {
            addon_y = addon_y + 30;
         //}
      }

      //
      // Additional factors to add... beyond that of the size of the picture
      //
      //NO!!// wheight = ArryMaxY + parseInt(screen.height / 25 * 5);
      wwidth  = ArryMaxX + addon_x;
      wheight = ArryMaxY + addon_y;

      //
      // We re-check the final window is set to mininum values, so it looks okay
      //
      if (wwidth <= MinWinX) {
         wwidth = MinWinX;
      }
      if (wheight <= MinWinY) {
         wheight = MinWinY;
      }


      //
      // Override if slide-show
      //
      //if (NumPhoto > 1) {
      //   wwidth  = (screen.width  - 40);
      //   wheight = (screen.height - 75);
      //}


      //
      // Where about to position the window...
      //
      toppos  = 5;
      leftpos = 5;
      if (screen) {
         //
         // Centering code ...
         //
         if (NumPhoto == 1) {
            leftpos = screen.width;
            leftpos = (leftpos / 2);
            leftpos = leftpos - (wwidth / 2);
            toppos  = screen.height;
            toppos  = (toppos / 2);
            toppos  = toppos - (wheight / 2);
         } else {
            leftpos = parseInt((screen.width - wwidth - 10) / 2);
            toppos  = parseInt((screen.height - wheight - 10) / 2);
         }
      }


      //
      // Override for most
      //
      if (NumPhoto == 1) {
         leftpos = 22;
         toppos = 70;

         // Push to the right - if required
         if (PosnOnScrn == 1) {
            leftpos = screen.width - 30 - wwidth;
         }
      }

      //alert("a "+toppos+"-"+leftpos+"-"+screen.height+"-"+screen.width+"");

      //
      //
      //
      WW = wwidth  + 12;
      WH = wheight + 10;
      LP = leftpos;
      TP = toppos;

      ///
      /// Open window or not... Lets decide...
      ///
      WindyOpen = 0;
      if (SubPhoto != undefined) {
         if (window.SubPhoto && window.SubPhoto.open && !window.SubPhoto.closed) {
            WindyOpen = 1;
         }
      }

      ///
      /// Open window or not... Lets create...
      ///
      if (WindyOpen == 1) {
         ///
         /// Problems with windows already being there, but free windows being used up.
         /// So we do not want to close... we want to clear and reuse the window!!
         ///
         SubPhoto.document.clear();
      } else {
         ///
         /// None open... lets open one now... and party on down...
         ///
         WinString = arryjoin(PhotoWinElements, ",");
         //alert("w"+WW+"-h"+WH);
         BigString = "width="+WW+",height="+WH+",left="+LP+",top="+TP+","+WinString;
         // Must be Single quotes for Opera to work!!
         SubPhoto = window.open('', 'winphoto', "'"+BigString+"'", false);
      }

      ///
      /// Start write to the document...
      ///
      var PhotDoc = SubPhoto.document;
      PhotDoc.clear();
      PhotDoc.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
      PhotDoc.write("<!-- Ajos1 - Win Pos L"+LP+" x T"+TP+" - Win Use "+WW+"x"+WH+" - Img Act "+ImageXSize+"*"+ImageYSize+" - Img Use "+NewX+"*"+NewY+" - ArrMax "+ArryMaxX+"*"+ArryMaxY+" -->\n");
      PhotDoc.write('<html lang="en">\n');
      PhotDoc.write("<head>\n");
      PhotDoc.write("<title>" + strAlbumTitle + "</title>\n");
      PhotDoc.write('<link rel="stylesheet" type="text/css" href="/ajosweb/style/discoimg.css">\n');

      if (NumPhoto > 1) {
         PhotDoc.write('<script type="text/javascript" src="/ajosweb/javascript/discoimg.js" defer="true">');
         PhotDoc.write("</"+"script>\n"); // AJOS HACK  AJOS HACK
      }

      PhotDoc.write('<script type="text/javascript">\n');
      if (NumPhoto > 1) {
         PhotDoc.write("var PhotoList = new Array(");
         for (i = 0; i < PhotoArray.length; i++) {
            j = i - (parseInt((i / 4)) * 4);
            if ((j == 0) || (j == 3)) {
               //
               // Put quotes on items 0 and 3 (strings);
               //
               PhotDoc.write("\"");
            }
            PhotDoc.write(PhotoArray[i]);
            if ((j == 0) || (j == 3)) {
               //
               // Put quotes on items 0 and 3 (strings);
               //
               PhotDoc.write("\"");
            }
            if (i < (PhotoArray.length - 1)) {
               PhotDoc.write(",");
            }
         }
         PhotDoc.write(");\n");

         //
         // clearTimeout is well important... otherwise Opera goes wild!
         //
         PhotDoc.write("function pic_stop()\n");
         PhotDoc.write("{\n");
         PhotDoc.write("   clearTimeout(MooTime);\n");
         PhotDoc.write("}\n");

         PhotDoc.write("function pic_prev()\n");
         PhotDoc.write("{\n");
         PhotDoc.write("   pic_stop();\n");
         PhotDoc.write("   imgslide(" + CurrntNumb + ", -1, " + TimeFlag + ", " + PosnOnScrn + ", \"" + strAlbumTitle + "\", PhotoList);\n");
         PhotDoc.write("}\n");

         PhotDoc.write("function pic_next()\n");
         PhotDoc.write("{\n");
         PhotDoc.write("   pic_stop();\n");
         PhotDoc.write("   imgslide(" + CurrntNumb + ",  1, " + TimeFlag + ", " + PosnOnScrn + ", \"" + strAlbumTitle + "\", PhotoList);\n");
         PhotDoc.write("}\n");
      }

      PhotDoc.write("function stoprightclick()\n");
      PhotDoc.write("{\n");
      //////moooooPhotDoc.write("   if (event.button==2) { alert(\"** Browser Error **\");}\n");
      PhotDoc.write("}\n");

      // // // // // // // // // // // // // // // // // // // // // // // //
      // No Right-Click...
      // // // // // // // // // // // // // // // // // // // // // // // //
      PhotDoc.write("document.onmousedown=stoprightclick\n"); // no ;

      // // // // // // // // // // // // // // // // // // // // // // // //
      // Crazy IE6 (1) - moveTo, resizeTo, focus (Must be run twice to work!!
      // // // // // // // // // // // // // // // // // // // // // // // //
      PhotDoc.write("this.moveTo("+LP+", "+TP+");\n");
      PhotDoc.write("this.resizeTo("+WW+", "+WH+");\n");
      PhotDoc.write("this.focus();\n");

      // // // // // // // // // // // // // // // // // // // // // // // //
      // Crazy IE6 (2) - moveTo, resizeTo, focus (Must be run twice to work!!
      // // // // // // // // // // // // // // // // // // // // // // // //
      PhotDoc.write("this.moveTo("+LP+", "+TP+");\n");
      PhotDoc.write("this.resizeTo("+WW+", "+WH+");\n");
      PhotDoc.write("this.focus();\n");

      if (NumPhoto > 1) {
         if (whichway >= 0) {
            funcuse = "pic_next()";
         } else {
            funcuse = "pic_prev()";
         }

         PhotDoc.write("var MooTime = setTimeout(\'" + funcuse + "\', " + ((TimeFlag * 1000) + 501) + ");\n");
      }

      //
      // Order is important!
      //
      // AJOS Hack below - The /script was being intepretted and not printed!
      // Apparently a well known bug...
      //
      //PhotDoc.write("alert(this.screenLeft);\n");
      //PhotDoc.write("alert(this.screenTop);\n");
      PhotDoc.write("</"+"script>\n"); // AJOS HACK  AJOS HACK

      PhotDoc.write("</head>\n");

      PhotDoc.write("<body>\n");
      PhotDoc.write("<div id=\"iwdivouter\" style=\"width:"+(ArryMaxX + 4)+"px;\">\n");
         /// ### /// ### /// ### /// ### /// ### /// ### /// ### ///
         /// ### /// ### /// ### /// ### /// ### /// ### /// ### ///
         PhotDoc.write("<div id=\"iwbackheader\">");
         PhotDoc.write('<p>&nbsp;&nbsp;');
         if (NumPhoto > 1) {
            PhotDoc.write('<a href=\"javascript:pic_prev();\">');
            PhotDoc.write('<img src="/ajosweb/images/website/discoimg_reverse.gif">');
            PhotDoc.write('</a>');
            PhotDoc.write('&nbsp;&nbsp;');
            PhotDoc.write('<a href=\"javascript:pic_stop();\">');
            PhotDoc.write('<img src="/ajosweb/images/website/discoimg_stop.gif">');
            PhotDoc.write('</a>');
            PhotDoc.write('&nbsp;&nbsp;');
            PhotDoc.write('<a href=\"javascript:pic_next();\">');
            PhotDoc.write('<img src="/ajosweb/images/website/discoimg_forward.gif">');
            PhotDoc.write('</a>');
            PhotDoc.write('&nbsp;&nbsp;');
         }

         if (NumPhoto <= 1) {
            PhotDoc.write("<span class=\"iwtitlealbumnorm\">");
         } else {
            PhotDoc.write("<span class=\"iwtitlealbumsmall\">");
         }
         PhotDoc.write(strAlbumTitle);
         PhotDoc.write("</span>");
         PhotDoc.write('&nbsp;&nbsp;</p>');
         PhotDoc.write("</div>\n");

         PhotDoc.write("<div id=\"iwbackimage\" style=\"height:"+ArryMaxY+"px;\">\n");
            ///
            /// We need to define a padding from the top... as
            /// DIVs do not have vertical-align:middle statement!
            ///
            Pad_Y = parseInt((ArryMaxY - NewY) / 2);
            PhotDoc.write("<div style=\"padding-top:"+Pad_Y+"px;\">");
               PhotDoc.write("<img src=\"");
               PhotDoc.write(strImageFile);
               PhotDoc.write("\"");
               PhotDoc.write(" Width="+NewX+" ");
               PhotDoc.write(" height="+NewY+"");
               PhotDoc.write(" alt=\"");
               PhotDoc.write(strAlbumTitle+" - "+strPhotoDescrp);
               PhotDoc.write("\"");
               PhotDoc.write(">");
            PhotDoc.write("</div>\n");
         PhotDoc.write("</div>\n");
         /// ### /// ### /// ### /// ### /// ### /// ### /// ### ///
         /// ### /// ### /// ### /// ### /// ### /// ### /// ### ///
         PhotDoc.write("<div id=\"iwbackfoot\"><span class=iwtitlephoto>");
         PhotDoc.write(strPhotoDescrp);
         ///
         /// Print where we are now... and the direction...
         ///
         if (NumPhoto > 1) {
            LeadZero = "";
            if (NumPhoto >= 10) {
               if (CurrntNumb < 10) {
                  LeadZero = "0";
               }
            }
            if (NumPhoto >= 100) {
               if (CurrntNumb < 100) {
                  LeadZero = "0";
               }
               if (CurrntNumb < 10) {
                  LeadZero = "00";
               }
            }
            if (whichway >= 0) {
               funcuse = "&gt;";
            } else {
               funcuse = "&lt;";
            }
            PhotDoc.write(" (" + LeadZero + CurrntNumb + " of " + NumPhoto + " " + funcuse + " " + TimeFlag + "s)");
         }
         PhotDoc.write("</span></div>\n");
         /// ### /// ### /// ### /// ### /// ### /// ### /// ### ///
         /// ### /// ### /// ### /// ### /// ### /// ### /// ### ///

      //x//
      //x//PhotDoc.write("<div class=iwbackfoot valign=bottom><span class=iwtitleother>Ideas from <a href=\"http://www.ImageWalker.com/\" target=\"_top\">ImageWalker</a></span></div>\n");
      //x//

      PhotDoc.write("</div>\n");

      PhotDoc.write("</body>\n");
      PhotDoc.write("</html>\n");

      SubPhoto.focus();
      PhotDoc.close();
   }

   //
   // Must be false to stop a submission!
   //
   //return false;
}
//-->
