
//Link Rewrites, we should always load this first!
/*$(document).ready(function() {
	//GALLERY - Lightbox
	$(".largeImg").each(function () {
		//Set the lightbox image dir  - We initially laoded the dom with tiny images, where images are invisible.  We use the source of those files with the image dir changed to populate our lightbox, this also allows the larger images to load in the back ground after the page has been displayed.
		var largedir = "800wm";
		var myvar = $(this).attr("src").split("10ws").join(largedir).split("300ws").join(largedir).split("400ws").join(largedir).split("500ws").join(largedir).split("600ws").join(largedir);
		$(this).parent().attr("href" , myvar); 
		$(this).attr("href", myvar);  
	});
	$("#currlargeImg").each(function () {
		var largedir = "800wm";
		var myvar = $(this).attr("src").split("10ws").join(largedir).split("300ws").join(largedir).split("400ws").join(largedir).split("500ws").join(largedir).split("600ws").join(largedir);  
		$("p a.nyroModal").attr("href", myvar);
	});
});
*/
/*Display Defaults:*/
$(document).ready(function() {

	$('#exifdata').hide();//hides exifdata
	$('a#detail-show').show();//shows the detail buton
	
	//Closes EXIF DATA BOX
	$('a#detail-hide,#exifdata').click(function() {
		var ecHeight = $("#exifdata").height();
		var iHeight = $("#currlargeImg").height();
		var iBorder = ($("#currlargeImg").outerWidth() - $("#currlargeImg").width()) / 2;
		
		//hide the box
		if (ecHeight > iHeight+iBorder) {//slideout insted of fadeout
			$("#exifdata").slideUp("slow");
		}else{
			$('#exifdata').fadeOut("slow");
		}
		
		$('a#detail-hide').hide();//hides the detail buton
		$('a#detail-show').show();//shows the detail buton
	return false;
	});

	//Shows EXIF DATA BOX
	$('a#detail-show').click(function() {
		var iWidth = $("#currlargeImg").width();
		var iHeight = $("#currlargeImg").height();
		var iBorder = ($("#currlargeImg").outerWidth() - $("#currlargeImg").width()) / 2;
		var ocPos = $("#largeCornerContainer").offset();//top position of outer container
		var ocWidth = $("#largeCornerContainer").width();//outer container width
		var ecHeight = $("#exifdata").height();//exif container height
		var iPos = $("#currlargeImg").offset();//image position
		
		//set up box position and dimensions
		if (ecHeight > iHeight+iBorder) {//exif data to large for overlay
			$('#exifdata').css({position:"relative",height:"auto"});
			var leftpos = 0;
			var toppos = 0;
			var eHeight = "auto";
		}else{//exif data will fit as overlay
			$('#exifdata').css({position:"absolute",marginTop:"0px"});
			var leftpos = (((ocWidth-iWidth)/2));
			var toppos = ((iPos.top-ocPos.top));
			var eHeight = (iHeight);
		}
		if (iHeight>iWidth) {
			var leftpos = (((ocWidth-iWidth)/2)-1);
		}
		//assign values to the box
		$('#exifdata').css({width:(iWidth),height:(eHeight),top:(toppos),left:(leftpos)});
		
		//display the box
		if (ecHeight > iHeight+iBorder) {//slideout insted of fadeout
			$("#exifdata").css({opacity:"1"}).slideDown("slow");
		}else{
			$('#exifdata').css({opacity:"0.8"}).fadeIn("slow");
		}
		
		$('a#detail-show').hide();//hides the detail buton
		$('a#detail-hide').show();//shows the detail buton

	return false;
	});
});