// JavaScript Document

				//$(this).click(function() {
									   
					function makeAjax(callTitle) {
				
//					var linkVal=$(this).find('a').attr('href'); // find link within div
//					var aPosition = linkVal.indexOf("=");
//					var refloc = aPosition+1;
//					var ref = linkVal.substr(refloc,3); // get ref at the end of the string after =	
					
					var ref = callTitle;
					var rand = ((new Date()).getTime()); // generate random number (for get ajax request to prevent cache problem)	
					
					// alert("ref " + ref);			
				
				   // ------------

					// AJAX REQUEST - JSON Object
					$.getJSON("diary_detail.php", // target server script
							{ ref: ref, rnd: rand }, // data (object literal ... NB serialize for form data							
								  function(data){ // callback function
								  
									//alert("JSON Data: " + data.title);
									//alert("JSON Data: " + data.mainparag);

								  	$("#mainGalInfo h1").html(data.title); // target DIV for ourput from server  //.before
									$("#mainGalInfo p").html(data.mainparag + "<br/><br/>"+ data.mainparag2); // target DIV for ourput from server  
								
									
									// initBinding(); // call initial binding After AJAX update
									
									  return false; 
									  
								  });	

				// });
					
				} // end function makeAjax


			// ---------------------------------------------
			// controls move gal down			
			// ---------------------------------------------

//			$(function(){
//			
//				$("div.scrollDown").mouseover(function () { // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ADD THIS AS AN ARROW TO THE PAGE
//				
//				// get height of div as css attribute of "div.galleryScrollPanel" 
//				
//				$("div.galleryScrollPanel").scrollTo( '520px', 800, {duration:3000} );
//				
//				}) // end of mouseover
//				
//				
//				$("div.scrollUp").mouseover(function () { // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ADD THIS AS AN ARROW TO THE PAGE
//				
//				// get height of div as css attribute of "div.galleryScrollPanel" 
//				
//				$("div.galleryScrollPanel").scrollTo( '0px', 200, {duration:3000} );
//				
//				}) // end of mouseover
//
//			});
					

			// ---------------------------------------------
			// rollover in gal thumbnails				
			// ---------------------------------------------			

			$(document).ready(function() {
			
				$('#gallery img').each(function() {
					var imgFile = $(this).attr('src');
					var preloadImage = new Image();
					preloadImage.src = imgFile.replace('_BW.','_TH.');
						
					$(this).hover(
						function() {
							$(this).attr('src', preloadImage.src);
						},
						function () {
							$(this).attr('src', imgFile);
						}
					); // end hover
				}); // end each
				
			}); // end ready()		
				
			// ---------------------------------------------
			// load and fade in main image				
			// ---------------------------------------------
			
			$(document).ready(function() {	
				
			$('div.foo a.gallery').click(function(evt) {
				//don't follow link
				 evt.preventDefault();
				 //get path to new image
			   var imgPath = $(this).attr('href');

				 //get reference to old image
				 var oldImage = $('#mainstage_home img');
				 //check to see if they're the same image
			
					
					 //create HTML for new image
					 var newImage = $('<img src="' + imgPath +'">');
					 //make new image invisible
					 newImage.hide();
					 
					 //fade out old image and remove from DOM
					 //oldImage.fadeOut(1000,function(){
					 //$(this).remove();
					 //	});
					
					 oldImage.remove();	
									 
					 //add to the #photo div
					 $('#mainstage_home').prepend(newImage);
					 //fade in new image
					 newImage.fadeIn(1000);
					 
					 
				   // ajax call - diary info 
				   var txtTitle = $(this).attr('title'); 
				   makeAjax(txtTitle); // ajax call - diary info					 
					 
			}); // end click
		
		$('div.foo a.gallery:first').click();
				
				
				
					
		}); // end ready()	
