(function($) {
  $.fn.pageOpening = function(path) {
  		$(".rightColInner").hide().fadeIn(1500);
		$("#loadingGal").show();
		var imageObj = new Image(); 
		$(imageObj).attr("src",path).load(function(){
			$("#loadingGal").hide();
			$("#leftCol").hide().css("background-image","url("+path+")").fadeIn(1000);
		});
		$(imageObj).attr("src",path).error(function(){
		});
  }
})(jQuery);

function aboutImage(path,alt){
	$("#loadingGal").show();
	var imageObj = new Image(); 
	$(imageObj).attr("src",path).load(function(){
		$("#leftCol").hide().css("background-image","url("+path+")").fadeIn(1000);
		$("#loadingGal").hide();
	});
	$(imageObj).attr("src",path).error(function(){  // fixes IE. somehow.
	});
}


(function($) {
  $.fn.galimg = function() {
	  
	 function loadImage(path,alt){
		$("#loadingGal").show();
		var imageObj = new Image(); 
		$(imageObj).attr("src",path).load(function(){
			$("#leftCol").hide().css("background-image","url("+path+")").fadeIn(1000);
			$("#loadingGal").hide();
		});
		$(imageObj).attr("src",path).error(function(){  // fixes IE. somehow.
			
		});
		$("#caption").text(alt);
		$(".galleryNav ul li").removeClass();
	}
	
 	/*  when page loads  */
  	
	$("#loadingGal").hide();
	$(".galleryNav ul, #caption").hide().fadeIn(2000);   
	$(".galimg a img").css("opacity", 0.3);
	var galleryCaption = $(".galleryNav li a:first").attr("title");
	var imagePath = $(".galleryNav .galimg a:first").attr("href");
	loadImage(imagePath,galleryCaption);
	$(".galleryNav img:first").addClass("thumbHighlight");
	$(".galleryNav img:first").css("opacity", 1.0);
	$(".galleryNav li:first").addClass("highlight");
	return this.each(function() {  	// work with each galimg div element
	
	$("a:first",".galleryNav ul li").click(function(){
		var imagePath = $(this).siblings("div").children("a:first").attr("href");
		var galleryCaption = $(this).attr("title");
		loadImage(imagePath,galleryCaption);
		$(this).parent().addClass("highlight");											
		$(this).siblings("div a").find("img:first").addClass("thumbHighlight");
		$(this).siblings("div a").find("img:first").css("opacity", 1.0);
		return false;
		});
	
	$(".galimg a").click(function() {
		var imagePath = $(this).attr("href");
		var galleryCaption = $(this).parent().siblings("a").attr("title");
		loadImage(imagePath,galleryCaption);
		$(this).parent().parent().addClass("highlight");
		$("img", this).addClass("thumbHighlight");
		return false;
		});
	
	/*$(".galimg a").hover(
		function(){
			$(this).stop().animate({opacity: 1.0}, 100);
		},
		function(){
			$(this).stop().animate({opacity: .3}, 400); 
		}
	); return false; */
	
	$(".galimg a").mouseover(function() {
		if ($("img",this).hasClass("thumbHighlight")){
								 
		} else {
			$("img",this).stop().animate({opacity: 1.0}, 100);	
		}
										
	});
	
	$(".galimg a").mouseout(function() {
		if ($("img",this).hasClass("thumbHighlight")){
		} else {
			$("img",this).stop().css("opacity", 1.0).animate({opacity: .3}, 500); 		
		}
										
	});
	
		
	
	/*$(".galimg a img").not(".thumbHighlight").hover(
		function(){
			$(this).stop().animate({opacity: 1.0}, 100);
		},
		function(){
			$(this).stop().animate({opacity: .3}, 400);
		}
	);  return false//hover  */
});
};

})(jQuery);