// JavaScript Document

var buffer="#1";

function pageInit(pageName){
	
	//newImg=pageName+'O.gif';
	//document.getElementById(pageName).src='images/nav/'+newImg;
	document.getElementById(pageName).style.color='#bf4838';
	
}

// rollovers for main navigation.
$(".rollover").hover(
	function(){
		if($(this).attr("src").indexOf("O") == -1) {
			var newSrc = $(this).attr("src").replace(".gif","O.gif#hover");
			$(this).attr("src",newSrc);
		}
	},
	function(){
		if($(this).attr("src").indexOf("O.gif#hover") != -1) {
			var oldSrc = $(this).attr("src").replace("O.gif#hover",".gif");
			$(this).attr("src",oldSrc);
		}
	}
);
// end rollovers for main navigation 


// rollover for gallery navigation
$(".galNav").hover(
	function(){
		if($(this).attr("src").indexOf("O") == -1) {
			var newSrc = $(this).attr("src").replace(".gif","O.gif#hover");
			$(this).attr("src",newSrc);
		}
	},
	function(){
		if($(this).attr("src").indexOf("O.gif#hover") != -1) {
			var oldSrc = $(this).attr("src").replace("O.gif#hover",".gif");
			$(this).attr("src",oldSrc);
		}
	}
);
// end rollovers for gallery navigation 


$(".galNav").click(
	function(){// gets the new image name from the id of the button clicked and changes the image
	var newImg="portfolio/"+$(this).attr("id")+".jpg";

	$("#portImg").attr("src",newImg);

	//var newSrc = $(this).attr("src").replace(".gif","O.gif#active");
	var newSrc = $(this).attr("src").replace(".gif","O.gif");
	$(this).attr("src",newSrc);
			
	$(this).trigger('changeBuffer');
	buffer="#"+$(this).attr("id");
	}
);

$(".galNav").bind('changeBuffer', function(e) {
   var oldSrc = $(buffer).attr("src","images/portIcon.gif")	
    return;
});

/// MODAL STUFF


$(function() {
		$.nyroModalSettings({
			debug: false,
			width: 384,
			height: 490,
			padding: 0,
			minWidth: 384,
			minHeight: 490,
			
		});
		
		
		
		function preloadImg(image) {
			var img = new Image();
			img.src = image;
		}
		
		preloadImg('../images/ajaxLoader.gif');
		preloadImg('../images/prev.gif');
		preloadImg('../images/next.gif');
		
	});
	


