
//
//  ###############  Javascript Functions for Creating Photo Pages #######################
//
//               Written by Jim Roberts / Programmer for RRobertsPhoto.com
//
//  ######################################################################################
 

//  ######################################################################################
//   CurrentYear() function:  simpy returns the current year and is used to place the
//                            current year in the copyright notice at the bottom of each
//                            page.
//  ######################################################################################
//   
 	function CurrentYear(){
    var d = new Date();
    var s = d.getUTCFullYear();
    return(s);
  }  

//  ######################################################################################
//   OpenNewWindow() function:  Opens a new browser window to the size specified and
//                            sets each window to close simply by clicking on the 
//                            displayed photo.  
//       Parameters:
//           PhotoTitle - Name of the Photo that will be displayed on the page
//           PhotoURL - the location of the photo to be displayed
//           PicWidth - the actual Width of the photo in pixels
//           PicHeight - the actual Height of the photo in pixels
//           PicWinWidth - The width of the Window to be opened
//           PicWinHeight - the Height of the Window to be opened
//           
//  ######################################################################################
//   
  function OpenNewWindow(PhotoTitle, PhotoURL, PicWidth, PicHeight, PicWinWidth, PicWinHeight) 
  {
    var ThisYear = CurrentYear();
    var PicWindow = window.open('', 'PhotoViewer', 'location=0, directories=0, fullscreen=0, menubar=0, status=0, toolbar=0, width='  + PicWinWidth + ', height=' + PicWinHeight + ', scrollbars=0');
    PicWindow.document.writeln('<html>');
    PicWindow.document.writeln('<head>');
    PicWindow.document.writeln('  <link rel="stylesheet" type="text/css" href="css_main.css" title="main_style">');
    PicWindow.document.writeln('  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
    PicWindow.document.writeln('  <meta name="author" content="RRobertsPhoto.com © 2005 / R. Roberts Photographer">');
    PicWindow.document.writeln('  <meta name="description" content="The Photography of R. Roberts/RRobertsPhoto.com:  Fine art, Birds, Flowers, Nature, Scenic, New Mexico, France, Far East. ">');
    PicWindow.document.writeln('  <meta name="keywords" content="Photography, fine, art, Birds, Flowers, Nature, Scenic, New Mexico, France, Far East, Sepia, BW, B&W, Black and White">');
    PicWindow.document.writeln('  <meta name="rating" content="General">');
    PicWindow.document.writeln('  <meta name="robots" content="ALL">');
    PicWindow.document.writeln('  <title>The Photography of R. Roberts / RRobertsPhoto.com © 2005</title>');
    PicWindow.document.writeln('  <script language="javascript">');
    PicWindow.document.writeln('  	self.focus();');
    PicWindow.document.writeln(' 	</script>');
    PicWindow.document.writeln('</head>');
    PicWindow.document.writeln('<body style="margin: 10 10 10 10;">');
    PicWindow.document.writeln('<table border="0" cellspacing="0" cellpadding="0" cols="3">');
    PicWindow.document.writeln('');
    PicWindow.document.writeln('  <!--##############################>');
    PicWindow.document.writeln('  <---##########  HEADER  ##########>');
    PicWindow.document.writeln('  <---##############################-->');
    PicWindow.document.writeln('');
    PicWindow.document.writeln('  <tr>'); 
    PicWindow.document.writeln('  	<td>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp</td>');
    PicWindow.document.writeln('    <td align="center"><font class="subheading">' + PhotoTitle + '</font><br></td>');
    PicWindow.document.writeln('    <td align="right"><a href="javascript:window.close();">Close</td>');
    PicWindow.document.writeln('  </tr>');    
    PicWindow.document.writeln('');
    PicWindow.document.writeln('  <!--##############################>');
    PicWindow.document.writeln('  <---##########  PHOTO  ###########>');
    PicWindow.document.writeln('  <---##############################-->');
    PicWindow.document.writeln('');
    PicWindow.document.writeln('  <tr>');
    PicWindow.document.writeln('    <td align="center" colspan="3">');
    PicWindow.document.writeln('    <a href="javascript:window.close();"><img src="' + PhotoURL + '" width="' + PicWidth + '" height="' + PicHeight + '" border="0" alt="Click to close" id="bigImage"></a>');
    PicWindow.document.writeln('    </td>');
    PicWindow.document.writeln('  </tr>');
    PicWindow.document.writeln('');
    PicWindow.document.writeln('  <!--##############################>');
    PicWindow.document.writeln('  <---##########  FOOTER  ##########>');   
    PicWindow.document.writeln('  <---##############################-->');
    PicWindow.document.writeln('');
    PicWindow.document.writeln('  <tr>');
    PicWindow.document.writeln('    <td align="center" colspan="3">');
    PicWindow.document.writeln('      <font class=Copyright>');
    PicWindow.document.writeln('        <br>');
    PicWindow.document.writeln('        All Images in this site are Copyrighted by RRobertsPhoto.com © 2005-' + ThisYear + '<br>');
    PicWindow.document.writeln('        and may not be copied without prior written permission.<br><br>');
    PicWindow.document.writeln('        R. Roberts Photographer/Artist<br>');
    PicWindow.document.writeln('      </font>');
    PicWindow.document.writeln('    </td>');
    PicWindow.document.writeln('  </tr>');
    PicWindow.document.writeln('</table>');
    PicWindow.document.writeln('');
    PicWindow.document.writeln('</body>');
    PicWindow.document.writeln('</html>');
    PicWindow.document.writeln('');
    PicWindow.document.close();
  }  
       
//  ######################################################################################
//   AddPicture() function:   Used in the main HTML page to write the code for displaying
//                            the thumbnails of each gallery.  Note:  This is setup to be
//                            Used with tables on the main page.  the function creates a
//                            single <td> entry within the table.  
//          Parameters:
//               sTitle     - String: containing Display name of the image
//               nWidth     - Number: width of print
//               nHeight    - Number: Height of print
//               nPrice     - Number: Price of the print
//               nPhotoNum  - Number: Product # of the print
//  ######################################################################################
//            
  function AddPicture(sTitle, nWidth, nHeight, nPrice, nPhotoNum)
  {
	  document.write('<tr>');
	  document.write('<td align="right" valign="top"><font class="default_font">' + nWidth + '" x ' + nHeight + '" - $' + nPrice + ' ----&nbsp </font></td>');
    document.write('<td align="left">');
    document.write('<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">');
	  document.write('<input type="image" src="graphics/x-click-but22.jpg" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!"> ');
	  document.write('<input type="hidden" name="add" value="1">');
	  document.write('<input type="hidden" name="cmd" value="_cart">');
	  document.write('<input type="hidden" name="business" value="rmroberts@mywdo.com">');
	  document.write('<input type="hidden" name="item_name" value="Photo - ' + sTitle + ' / Matte Finish / Size-' + nWidth + 'x' + nHeight + '">');
	  document.write('<input type="hidden" name="item_number" value="Photo_' + nPhotoNum + '">');
	  document.write('<input type="hidden" name="amount" value="' + nPrice + '">');
	  document.write('<input type="hidden" name="page_style" value="RRobertsPhotoStyle">');
	  document.write('<input type="hidden" name="no_shipping" value="2">');
	  document.write('<input type="hidden" name="currency_code" value="USD">');
	  document.write('</form>');
	  document.write('</td>');
	  document.write('</tr>');
  }      

//  ######################################################################################
//   CreatePicture() function:  Used in the main HTML page to write the code for displaying
//                            the thumbnails of each gallery.  Note:  This is setup to be
//                            Used with tables on the main page.  the function creates a
//                            single <tr> entry within the table.  Note 2:  Inside the <tr>
//                            are two <td> entries. One for display of the thumbnail and 
//                            the second displays the sizing and pricing for print sales.
//          Parameters:
//               sPhotoName - String: Filename of the full size photo
//               sGallery   - String: Name of the folder the photos are stored in
//               nTWidth    - Number: width of Thumbnail in pixels
//               nTHeight   - Number: Height of the thumbnail in pixels
//               sTitle     - String: Displayed Title of the Image
//               nPicWidth  - Number: width of the photo in pixels
//               arWidth    - Array:  Array containing the Widths of available Prints for sale
//               arHeight   - Array:  Array containing the Heights of available Prints for sale
//               arPrice    - Array:  Array containing the Prices of available prints for sale
//               arPhotoNum - Array:  Array containing the Product Numbers of the prints for sale
//               nPicHeight - Number: height of the photo in pixels                              
//               nPicWidth  - Number: Width of the photo in pixels
//               nPicWinWidth  - Number: Width to create the large display window for photo
//               nPicWinHeight - Number: height to create the large display window for photo 
//  ######################################################################################
//     
  function CreatePicture(sPhotoName, sGallery, nTWidth, nTHeight, sTitle, arWidth, arHeight, arPrice, arPhotoNum, nPicWidth, nPicHeight, nPicWinWidth, nPicWinHeight)
  {
	  document.write('<tr><td align="center" valign="middle">');
    document.write('<img src="graphics/spacer_20x20.jpg"><br>');
    document.write('<a href="#" onClick="OpenNewWindow(\'' + sTitle + '\',\'photos/' + sGallery + '/' + sPhotoName + '.jpg\', ' + nPicWidth + ', ' + nPicHeight + ', ' + nPicWinWidth + ', ' + nPicWinHeight + ');return false">');
    document.write('<img src="Photos/' + sGallery + '/thumbs/' + sPhotoName + '-t.jpg" width="' + nTWidth + '" height="' + nTHeight + '" border="0"></a><br><br>');
	  document.write('</td>');
	  document.write('<td align="center"><font class="Sale_Info">' + sTitle + '</font></td>');
	  document.write('<td align="center">');
    document.write('<img src="graphics/spacer_12x12.jpg"><br>');
    document.write('<table border="0" cellspacing="0" cellpadding="0" cols="2" width="250">');
    
    for (var i=0; i < arWidth.length; i++)
    {
		AddPicture(sTitle, arWidth[i], arHeight[i], arPrice[i], arPhotoNum[i]);
    }
    
    document.write('</table>');

	  document.write('</td></tr>');
	  document.write('<tr><td colspan="3"><img src="graphics/horz_line_650x2.jpg"></td></tr>');
	  
  }
       
//  ######################################################################################
//   MULTIPLE functionS:      Stole these from somewhere on the web.  It is used to
//                            Preload the images used in the Main Menu on the left of the 
//                            Page.  The preloaded images will allow the Menu items to change
//                            color (go lighter/darker) when the mouse rolls over them.
//          Parameters:
//               sPhotoName - String: Filename of the full size photo
//               sGallery   - String: Name of the folder the photos are stored in
//               nTWidth    - Number: width of Thumbnail in pixels
//               nTHeight   - Number: Height of the thumbnail in pixels
//               sTitle     - String: Displayed Title of the Image
//               nPicWidth  - Number: width of the photo in pixels
//               arWidth    - Array:  Array containing the Widths of available Prints for sale
//               arHeight   - Array:  Array containing the Heights of available Prints for sale
//               arPrice    - Array:  Array containing the Prices of available prints for sale
//               arPhotoNum - Array:  Array containing the Product Numbers of the prints for sale
//               nPicHeight - Number: height of the photo in pixels                              
//               nPicWidth  - Number: Width of the photo in pixels
//               nPicWinWidth  - Number: Width to create the large display window for photo
//               nPicWinHeight - Number: height to create the large display window for photo 
//  ######################################################################################
//            
  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;
  }
    
  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];}}
  }

  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];}
  }  
  
  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;
  }