//
//  File: default.js
//
//	This file contains most of the javascript used in the Adobe Mountain Desert RailRoad Park web site.
//
//  Author:  Marshall Wales
//  Date: 3/20/10
//
//  Change Control:
//	Who		Date:	   Purpose
//	-----		-------	   -------
//	M. Wales	3/20/10	   Created from version used on AMRS website
//	M. Wales	3/20/10    Created makeHeaderLine1(pathModifier)
//	M. Wales	3/20/10    Created makeHeaderLine2(pathModifier)
//	M. Wales	5/20/10    Added newsletter menu option with current & back issuses
//	M. Wales	5/21/10    Added more back issues of the newsletter
//	M. Wales	5/24/10    Removed "title=" from "home".  Added Directions and Contact Us menu options
//                                 and Title= to newsletters; added Jan/Feb 2010 newsletter to menu options
//	M. Wales	7/06/10    Fix directory pointer to current newsletter and add July/2010 issue
//	M. Wales	7/11/10    changed ref. to July/10 newsletter to "updated" version
//	M. Wales	9/8/10     Added Sept/Oct. 2010 newsletter
//	M. Wales	11/8/10    Added Nov/Dec. 2010 newsletter
//	M. Wales	1/7/11     Added Jan/Feb 2011 newsletter
//	M. Wales	3/8/11	   Added Mar/Apr 2011 newsletter
//
//
//  Global data
//
//	None
//
//
//  Function: popupwin()
//
//	This function opens a pop up window
//
//  Inputs:
//	url - path(optional) and name of html file to be in the window
//	winName - name for the window...can be anything you want
//	w - width of window in pixels
//	h - height of window in pixels
//	type - "nonav" means no navigation features for the window.
//		anything else means navigation features for the window.
//

function popupWin(url,winName,w,h,type)
{
 	if(type == 'nonav')
	{
	    window.open(url, winName, 'width='+w+',height='+h+',scrollbars=yes,menubar=no,status=no,toolbar=no,resizable=yes');
	}
  	else
	{
	    this.popWindow = window.open(url, winName, 'width='+w+',height='+h+',scrollbars=yes,menubar=yes,status=no,toolbar=yes,resizable=yes');
	}
}

//
//  Function: makeHeader1(pathModifier)
//
//	This function writes the park website header on pages that call this function.  It writes the code for the date, AZ flag and Header Line
//
//	Inputs:  pathModifier - The path modifier to finding the images.  If "undefined" (i.e., not passed), pathModifier is set to "./"
//
//

function makeHeaderLine1(pathModifier)
{
	if (pathModifier==undefined)
	   pathModifier="./"

	var d = new Date()
	var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
	var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
	var today="<p class=date>"+weekday[d.getDay()] + " "+monthname[d.getMonth()] + " "+d.getDate() + ", "+d.getFullYear()+"<\/p>"
	document.write("<table width='88%' border='0' cellspacing='4' cellpadding='4'>")
	document.write("<td class='azflag'>"+today+"<br /><img src='"+pathModifier+"webimages/gifs/azflag.gif'  width='100' height='59'></td>")
	document.write("<td class='club_name'>Adobe Mountain Desert Railroad Park</td>")
	document.write("</tr>")
	document.write("</table>")
}

//
//  Function: makeHeader1(pathModifier)
//
//	This function writes the park website header on pages that call this function.  It writes the logos for AMRS, Sahuaro Central, and MLS
//
//	Inputs:  pathModifier - The path modifier to finding the images.  If "undefined" (i.e., not passed), pathModifier is set to "./"
//
//
function makeHeaderLine2(pathModifier)
{
	if (pathModifier==undefined)
	   pathModifier="./"
	document.write("<table width='100%' border='0' cellspacing='4' cellpadding='4'>")
	document.write("<tr>") 
	document.write("<td class='right'><img src='"+pathModifier+"webimages/logos/AMRS Color Logo(2).gif' width='130' height='130'></td>")
	document.write("<td class='center'><img src='"+pathModifier+"webimages/logos/sahuaro_logo.gif' width='320' height='102'></td>")
	document.write("<td class='left'><img src='"+pathModifier+"webimages/logos/mls 2.gif' width='140' height='108'></td>")
	document.write("</tr>")
	document.write("</table>")
}

 // end makeHeader function

//
//
//  Function: makeMenu()
//
//  This function makes the Option menu in the header.
//
//   Passed arguments:  MenuOption - contains a value specifying what menu option was selected
//

function makeMenu()
{
	document.write("<ul class='menulist' id='listMenuRoot'>")
	document.write("<li><a href='index.html' >Home</a></li>")
	document.write("<li><a href='directions.html' >Directions</a></li>")
	document.write("<li><a href='parkhistory.html'>Park History</a></li>")

	document.write("<li><a href='#' Title='Newsletters are published every two months'>News Letters</a>")
	document.write("<ul>")
	document.write("<li><a href='Newsletters/2011/Sahuaro Central Newsletter Mar 2011.pdf'>Current Issue</a></li>")
	document.write("<li><a href='#'>Back Issues</a>")
	document.write("<ul>")
	document.write("<li><a href='#'>2011</a>")
	document.write("<ul>")
	document.write("<li><a href='Newsletters/2011/Sahuaro Central Newsletter Jan 2011.pdf'>Jan &frasl; Feb</a></li>")
	document.write("<li><a href='Newsletters/2011/Sahuaro Central Newsletter Mar 2011.pdf'>Mar &frasl; Apr</a></li>")
	document.write("</ul></li>")
	document.write("<li><a href='#'>2010</a>")
	document.write("<ul>")
	document.write("<li><a href='Newsletters/2010/Sahuaro Central Newsletter Jan 2010.pdf'>Jan &frasl; Feb</a></li>")
	document.write("<li><a href='Newsletters/2010/Sahuaro Central Newsletter Mar 2010.pdf'>Mar &frasl; Apr</a></li>")
	document.write("<li><a href='Newsletters/2010/Sahuaro Central Newsletter May 2010.pdf'>May &frasl; Jun</a></li>")
	document.write("<li><a href='Newsletters/2010/Sahuaro Central Newsletter July 2010_updated.pdf'>Jul &frasl; Aug</a></li>")
	document.write("<li><a href='Newsletters/2010/Sahuaro Central Newsletter Sept 2010.pdf'>Sept &frasl; Oct</a></li>")
	document.write("<li><a href='Newsletters/2010/Sahuaro Central Newsletter Nov 2010.pdf'>Nov &frasl; Dec</a></li>")
	document.write("</ul></li>")
	document.write("<li><a href='#'>2009</a>")
	document.write("<ul>")
	document.write("<li><a href='Newsletters/2009/Sahuaro Central Newsletter Jan 09.pdf'>January &frasl; February</a></li>")
	document.write("<li><a href='Newsletters/2009/Sahuaro Central Newsletter Mar 09.pdf'>March &frasl; April</a></li>")
	document.write("<li><a href='Newsletters/2009/Sahuaro Central Newsletter May 09.pdf'>May &frasl; June</a></li>")
	document.write("<li><a href='Newsletters/2009/Sahuaro Central Newsletter July 09.pdf'>July &frasl; August</a></li>")
	document.write("<li><a href='Newsletters/2009/Sahuaro Central Newsletter Sept 09-2.pdf'>September &frasl; October</a></li>")
	document.write("<li><a href='Newsletters/2009/Sahuaro Central Newsletter Nov 09.pdf'>November &frasl; December</a></li>")
	document.write("</ul></li>")
	document.write("</ul></li>")
	document.write("</ul></li>")
	document.write("<li><a href='#'>Photo Gallery</a></li>")
	document.write("<li><a href='http://www.maricopalivesteamers.com/party.htm' target='_blank'>Schedule a Party</a></li>")

	document.write("<li><a href='http://www.azmodelrr.com' target='_blank'>AMRS</a></li>")

	document.write("<li><a href='http://www.maricopalivesteamers.com' target='_blank'>MLS</a></li>")
	document.write("<li><a href='#' >Contact Us</a>")
	document.write("<ul>")
	document.write("<li><a href='#' >(623) 670-1904</a></li>")
	document.write("</ul></li>")
	document.write("</ul>")

// The fsmenu-1.js script file is part of the FreeSytle Menu v1.0RC by Angus Turnbull
// This script and the fsmenu.js script invoked in the <head> of each html file are required to make dropdown menus work on older browers
// such as IE6 and earlier.
//

	document.write("<script type='text/javascript' src='scripts/fsmenu-1.js'></script>")

}  // end makeMenu function


//
//  Function: displayPhotos(photoArray)
//
//	This function creates a table of rows with varying number of photos per row
//	based on the screen resolution.
//
//
//   Passed arguments:  Directory where photos are located
//			An array by reference of photos to display
//

function displayGalleryPhotos(photoDir,photoArray) {

	var k=0;
	var photosPerRow = 6;  // for screen resolution gt. 1400
	if(screen.width > 1024 && screen.width < 1400)
	     photosPerRow = 5;
	if(screen.width > 800 && screen.width <= 1024)
	     photosPerRow = 4;
	if(screen.width <= 800)
	     photosPerRow = 3;

	numberPhotos=photoArray.length;

	document.write("<table id='GalleryPhotos'>");
	for (j=0; j<numberPhotos; )
	{
	   document.write("<tr>");
	   for (i=0; i<photosPerRow; i++)
	   {
		photo = "webimages/"+photoDir+"/"+photoArray[j];
		photoName=photoArray[j];
		photoTitle = "tn_"+photoArray[j];
		tn_photo = "webimages/"+photoDir+"/ThumbNails/tn_"+photoArray[j];
            document.write("<td><a href='"+photo+"'> <img src='"+tn_photo+"' title='"+photoName+"' alt='"+photoTitle+"' ></a></td>");
	      j++;
	   }
	   document.write("</tr>");
	   k=numberPhotos-j;
	   if(k<photosPerRow)
		photosPerRow=k;
		
	}
	document.write("</table>");

}  // end displayPhotos function

//
//  Function: galleryCaption(caption)
//
//	This function creates a caption for a table whose "ID" is GalleryPhotos.
//	The caption is passed to this function.  The rest of the caption is internal
//	to this function.
//
//

function galleryCaption(caption){
    var caption2 = '<p>The pictures below are thumbnail pictures. Click on them to get a larger image. If you see a magnifying glass with a "+" as the cursor, the picture can be expanded. Use the browser "back" feature to return to the thumbnails.</p>'
    var x=document.getElementById('GalleryPhotos').createCaption()
    x.innerHTML=caption+caption2
}

//
//  Function: buildvideoGallery(videoArray,width,height)
//
//	This function creates a table of rows with varying number of videos per row
//	based on the screen resolution.
//
//
//   Passed arguments:  An array by reference of youtube video keys
//

function buildvideoGallery(videokeyArray,width,height) {

	var k=0;
	var videosPerRow = 3;  // for screen resolution gt. 1400
	if(screen.width <= 800)
	     videosPerRow = 2;

	numbervideos=videokeyArray.length;

	document.write("<table id='Galleryvideos' align='center'>");
	for (j=0; j<numbervideos; )
	{
	   document.write("<tr>");
	   for (i=0; i<videosPerRow; i++)
	   {
	     videokey = videokeyArray[j];
             document.write("<td>");
	     document.write('<object width="'+width+'" height="'+height+'">')
	     document.write('<param name="movie" value="http://www.youtube-nocookie.com/v/'+videokeyArray[j]+'&hl=en_US&fs=1&rel=0&color1=0x006699&color2=0x54abd6&border=1"></param>')
	     document.write('<param name="allowFullScreen" value="true"></param>')
	     document.write('<param name="allowscriptaccess" value="always"></param>')
	     document.write('<param name="wmode" value="transparent"/>')
	     document.write('<embed src="http://www.youtube-nocookie.com/v/'+videokeyArray[j]+'&hl=en_US&fs=1&rel=0&color1=0x006699&color2=0x54abd6&border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="'+width+'" height="'+height+'"></embed>')
	     document.write('</object>')
             document.write("</td>");
	     j++;
	   }
	   document.write("</tr>");
	   k=numbervideos-j;
	   if(k<videosPerRow)
		videosPerRow=k;
		
	}
	document.write("</table>");

}  // end buildvideoGallery function

