// JavaScript Document


winW = screen.width;
winH = screen.height;




function win(pic,caption,w,h,t,gn,n,p)
// parms:
// pic: index of file name
// caption: caption text
// w: width of full-size image (not used anymore, can put zero)
// h: height of full-size image (not used anymore, can put zero)
// t: gallery folder name
// gn: gallery short description
// n: old--no longer used
// p: old--no longer used
{
var agt=navigator.userAgent.toLowerCase();
var isIE = agt.indexOf("msie");
var isMac = navigator.userAgent.indexOf("Mac");

if (isMac != -1 && isIE != -1) {
var ht=h+150;
var wd=w+200;
var winh = (screen.height - ht) / 2;
ieMac = 'yes';
}
else
ieMac = 'no';


if (ieMac == 'no') {
var winpg = "../gallerypicwin.php?pic=" + t + "/imgs/" + pic + "&caption=" + caption + "&gn=" + gn;
// If I implement rotation in full-size window (with Next and Prev links):
/*
var winpg = "../gallerypicwin.php?pic=" + t + "/imgs/" + pic + "&caption=" + caption + "&gn=" + gn + "&n=" + n + "&p=" + p;
*/
window.open(winpg,"", "height="  + winH + ",width=" + winW + ",scrollbars=no, resizable=1, toolbar=no, location=no, menubar=no, titlebar=no");
}
else {
var winpg = "../gallerypicwinOLD.php?pic=" + t + "/imgs/" + pic + "&caption=" + caption + "&gn=" + gn;
// If I implement rotation in full-size window (with Next and Prev links):
/*
var winpg = "../gallerypicwinOLD.php?pic=" + t + "/imgs/" + pic + "&caption=" + caption + "&gn=" + gn + "&n=" + n + "&p=" + p;
*/
window.open(winpg,"","height="  + winH + ",width=" + winW + ",scrollbars=no, resizable=1, toolbar=no, location=no, menubar=no, titlebar=no");
}

}



function gallery_footer() {

// html validation link in here:
//document.write("<div style=\"float:right;\"><a href='simpleviewer/' class=\"lesswhite10Bold\">slides</a></div><span class=\"lesswhite9pxBold\"><a href=\"../../\" class=\"lesswhite9pxBold\">Home</a>&nbsp;|&nbsp;<a href=\"http://validator.w3.org/check?uri=referer\" class=\"lesswhite9pxBold\" onclick=\"window.open('http://validator.w3.org/check?uri=referer','_blank');return false;\">W3C XHTML validation</a></span>");

// no validation link:
document.write("<div style=\"float:right;\"><a href='simpleviewer/' class=\"lesswhite10Bold\">slides</a></div><span class=\"lesswhite9pxBold\"><a href=\"../../\" class=\"lesswhite9pxBold\">Home</a></span>");

document.write("<div class=\"lesswhite9pxBold\" style=\"margin-top:15px;\">");

document.write("&copy; Madeline Salocks ");

currDate = new Date();
currYr = currDate.getFullYear();
document.write(currYr);

document.write("</div>");
}


function gallery_footer_no_slides() {

// html validation link in here:
//document.write("<span class=\"lesswhite9pxBold\"><a href=\"../../\" class=\"lesswhite9pxBold\">Home</a>&nbsp;|&nbsp;<a href=\"http://validator.w3.org/check?uri=referer\" class=\"lesswhite9pxBold\" onclick=\"window.open('http://validator.w3.org/check?uri=referer','_blank');return false;\">W3C XHTML validation</a></span>");

// no validation link:
document.write("<span class=\"lesswhite9pxBold\"><a href=\"../../\" class=\"lesswhite9pxBold\">Home</a></span>");

document.write("<div class=\"lesswhite9pxBold\" style=\"margin-top:15px;\">");

document.write("&copy; Madeline Salocks ");

currDate = new Date();
currYr = currDate.getFullYear();
document.write(currYr);

document.write("</div>");
}



// start featured pic on main photography page

// selected pictures from which to randomly display an image on main
// photography page
var pixArray = new Array();
pixArray[0] = "yellowstonemorningglory1_med.jpg";
/*
pixArray[0] = "yellowstonemorningglory1_med.jpg";
pixArray[1] = "saguaro_nat_pk_1998_med.jpg";
pixArray[2] = "geeseFamily_med.jpg";
pixArray[3] = "hollister1_med.jpg";
pixArray[4] = "StarfishAnchovies_med.jpg";
pixArray[5] = "LastDay2007_med.jpg";
pixArray[6] = "minerets_med.jpg";
pixArray[7] = "falltreeb_med.jpg";
pixArray[8] = "anacapaIs_med.jpg";
pixArray[9] = "LafayetteTreeMarch08_3_med.jpg";
pixArray[10] = "silverton1_1992med.jpg";
*/


// slide pic titles
var titlesArray = new Array();
titlesArray[0] = "Morning Glory Pool, Yellowstone National Park, 1991";
/*
titlesArray[1] = "Saguaro National Park, Arizona, 1998";
titlesArray[2] = "Family at the Don Edwards Wildlife Refuge, May 2006";
titlesArray[3] = "Near Hollister, California, 1987";
titlesArray[4] = "Starfish and Anchovies, 2007";
titlesArray[5] = "New Years Eve, 2007";
titlesArray[6] = "Storm over the Minerets, Sierra Nevada, 1997";
titlesArray[7] = "Autumn Tree, Contra Costa County, 1993";
titlesArray[8] = "Anacapa Island, March 2007";
titlesArray[9] = "Tree near the Lafayette BART Station, March 2008";
titlesArray[10] = "Silverton, Colorado, 1992";

// larger pic locations (for use with LightBox)
var largeimgArray = new Array();
largeimgArray[0] = "AmericanWest/imgs/yellowstonemorningglory1.jpg";
largeimgArray[1] = "AmericanSouthwest/imgs/saguaro_nat_pk_1998_3.jpg";
largeimgArray[2] = "DonEdwards/imgs/geeseFamily.jpg";
largeimgArray[3] = "California/imgs/hollister1.jpg";
largeimgArray[4] = "Wildlife/imgs/StarfishAnchovies.jpg";
largeimgArray[5] = "SFBayArea/imgs/LastDay2007DeerHillRd650x488.jpg";
largeimgArray[6] = "California/imgs/mineretsOutline.jpg";
largeimgArray[7] = "SFBayArea/imgs/FallTreeSpringbrookRd93b.jpg";
largeimgArray[8] = "California/imgs/anacapaIs.jpg";
largeimgArray[9] = "SFBayArea/imgs/LafayetteTreeMarch08_3_h500.jpg";
largeimgArray[10] = "AmericanWest/imgs/silverton1_1992.jpg";
*/


/* the following function uses Lightbox */
function showStartSlide(currpic)
{
// Use the following line if no LightBox popup:
//document.getElementById("picture").src="slides/" + pixArray[currpic];
// Use the following lines if enabling LightBox popup:
e2 = document.getElementById("slide");
e2.innerHTML = "<a href=\""  + largeimgArray[currpic]  +  "\" rel=\"lightbox\" title=\"" + titlesArray[currpic] + "\"><img id=\"picture\" alt=\"\" src=\"" + "slides/" + pixArray[currpic] +   "\" /></a>"; 

// Slide title:
e = document.getElementById("slidetitle");
e.innerHTML = titlesArray[currpic];
}


function showStartSlide_new(currpic)
{
e2 = document.getElementById("slide");
e2.innerHTML = "<a href=\"simpleviewer/index.html\" title=\"view selected slides\"><img id=\"picture\" alt=\"\" src=\"" + "slides/" + pixArray[currpic] +   "\" /></a>"; 

// Slide title:
e = document.getElementById("slidetitle");
e.innerHTML = titlesArray[currpic] + "<br />&copy; Madeline Salocks";
}



// start randomizer. -->
// See:  http://www.msc.cornell.edu/~houle/JavaScript/randomizer.html

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function rand(number) {
        return Math.ceil(rnd()*number);
};

// end randomizer -->

// end featured pic on main photography page



//Hide status bar message
// most browsers now prevent you from manipulating status bar
function hidestatus(){
window.status="";
return true
}



// dreamweaver stuff...
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_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;
}

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];}
}






// start jquery vertical center plugin
(function($) {

  $.fn.vCenter = function(options) {

    var pos = {

      sTop : function() {

        return window.pageYOffset

        || document.documentElement && document.documentElement.scrollTop

        ||  document.body.scrollTop;

      },

      wHeight : function() {

        return window.innerHeight

        || document.documentElement && document.documentElement.clientHeight

        || document.body.clientHeight;

      }

    };

    return this.each(function(index) {

      if (index == 0) {

        var $this = $(this);

        var elHeight = $this.height();

        var elTop = pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2);

        $this.css({

          position: 'absolute',

          marginTop: '0',

          top: elTop

        });

      }

    });

  };

})(jQuery); 
// end jquery vertical center plugin


// start accordion of gallery links popup copied from include.js

// start jquery pop

(function($) {
  
  $.pop = function(options){
    
    // settings
    var settings = {
     pop_class : '.pop',
     pop_toggle_text : ''
    }
    
    // inject html wrapper
    function initpops (){
      $(settings.pop_class).each(function() {
        var pop_classes = $(this).attr("class");
        $(this).addClass("pop_menu");
        $(this).wrap("<div class='"+pop_classes+"'></div>");
        $(".pop_menu").attr("class", "pop_menu");
        $(this).before(" \
          <div class='pop_toggle'>"+settings.pop_toggle_text+"</div> \
          ");
      });
    }
    initpops();
    
    // assign reverse z-indexes to each pop
    var totalpops = $(settings.pop_class).size() + 1000;
    $(settings.pop_class).each(function(i) {
     var popzindex = totalpops - i;
     $(this).css({ zIndex: popzindex });
    });
    // close pops if user clicks outside of pop
    activePop = null;
    function closeInactivePop() {
      $(settings.pop_class).each(function (i) {
        if ($(this).hasClass('active') && i!=activePop) {
          $(this).removeClass('active');
          }
      });
      return false;
    }
    $(settings.pop_class).mouseover(function() { activePop = $(settings.pop_class).index(this); });
    $(settings.pop_class).mouseout(function() { activePop = null; });

    $(document.body).click(function(){ 
     closeInactivePop();
    });
    // toggle that pop
    $(".pop_toggle").click(function(){
      $(this).parent(settings.pop_class).toggleClass("active");
    });
  }

})(jQuery);

// end jquery pop

// end accordion of gallery links popup copied from include.js





// start not using 
/*
function doPrevious() {

    if (document.images && currpic > 0) {
        currpic--;
        document.getElementById("picture").src= "slides/" + pixArray[currpic];
    }
	else
	{
	currpic = pixArray.length-1;
	document.getElementById("picture").src= "slides/" + pixArray[currpic];
	}
	e = document.getElementById("slidetitle");
	e.innerHTML = titlesArray[currpic];
}

function doNext() {

    if (document.images && (currpic < (pixArray.length-1))) {
        currpic++;
        document.getElementById("picture").src= "slides/" + pixArray[currpic];
    }
	else
	{
	currpic = 0;
	document.getElementById("picture").src= "slides/" + pixArray[currpic];
	}
	e = document.getElementById("slidetitle");
	e.innerHTML = titlesArray[currpic];
	 
}

function doSlideWin() {
current ="slides/fullsize/" + pixArrayFull[currpic];
currentTitle = titlesArray[currpic];
win(current, currentTitle , 'Slides');
}


// old version of func win
function win(pic,caption,h,w,t) 
{
// following 3 lines are if using a smaller popup window:
var ht=h+150;
var wd=w+200;
var winh = (screen.height - ht) / 2;
//var winpg = "../gallerypicwin.html?pic=" + t + "/imgs/" + pic + "&caption=" + caption;
var winpg = "../gallerypicwin.php?pic=" + t + "/imgs/" + pic + "&caption=" + caption;
// smaller popup:
//window.open(winpg,"","height="  + ht + ",width=" + wd + ",left=" + 50 + ",top=" + winh + ",scrollbars=no, resizable=1");
// full screen:
window.open(winpg,"","height="  + winH + ",width=" + winW + ",scrollbars=no, resizable=1");
}


function winslides() 
{

var winpg = "imgs/phpslideshow.php";
	try
	{
		// open window

		var win = window.open(winpg, "largeimg", "width="+screen.availWidth+",height="+screen.availHeight+",top=0,left=0,resizable=yes,status=yes,scrollbars=yes");
	
		if (document.all) 
		{
			win.resizeTo(screen.availWidth,screen.availHeight);
		}
		else if (document.layers||document.getElementById) 
		{
			if (win.outerHeight<screen.availHeight||win.outerWidth<screen.availWidth)
			{
				win.outerHeight = screen.availHeight;
				win.outerWidth = screen.availWidth;
			}	
		}
	}
	catch(e)
	{
	    // if cannot open window, just do a new page redirect
		window.location = winpg;
	}              
    
}

/* end: not using anymore */

