// GALLERY PAGE - first page for projects and artists 

//set vars
currentPage = 1;	// current page
currentRow = 1;		// Current row
pages	= 0;				// number of pages of thumbs


// THUMBS PRESSED 

//	project thumb - navigates to single project page
function thumbsPressed(obj)
{
		var t = $(obj).find('img').attr('title');	
		//$(document).find('#gallery-thumb-holder').fadeOut(600, function(){ window.location.assign("http://morgandaviesart.com/projects/"+t);});
		window.location.assign("/projects/"+t);	
}

// artist thumbs - navigates to single artist page
function aThumbsPressed(obj)
{
		var t = $(obj).find('img').attr('title');
		//$(document).find('#gallery-thumb-holder').fadeOut(600, function(){ window.location.assign("http://morgandaviesart.com/artists/"+t);});
		window.location.assign("/artists/"+t);
}

// NAVIGATION OF THUMBS

// Nav Pressed
function nextPressed()
{
		if(currentPage != pages){ 
			topPos = $(document).find('#gallery-thumb-holder').css("top");
			newPos = parseFloat(topPos) - 420;
			fadeToNew(newPos);
			currentPage++;
		}
		sortButtons();	
}

function prevPressed()
{
		if(currentPage != 1){ 
			topPos = $(document).find('#gallery-thumb-holder').css("top");
			newPos = 420 + parseFloat(topPos);				
			fadeToNew(newPos);
			currentPage--;
		}
		sortButtons();	
}

// Fade to new page of thumbs
function fadeToNew(pos)
{			
			newPos = pos;
			// FADE OUT
			$(document).find('#gallery-thumb-holder').stop(false,true).animate({'opacity':0}, {duration:300}, "jswing");
			// SWAP
			setTimeout('$(document).find("#gallery-thumb-holder").stop(false,true).css("top",newPos);',300);
			// FADE IN
			setTimeout('$(document).find("#gallery-thumb-holder").stop(false,true).animate({"opacity":1}, {duration:200}, "jswing");',320);
}

// Hide or Show nav buttons  
function sortButtons()
{
		if(currentPage == pages){   
			$(document).find('.next').fadeOut(500);	
		}else{                      
			$(document).find('.next').fadeIn(500);	
		}                           
		if (currentPage == 1) {     
			$(document).find('.prev').fadeOut(500);	
		}else{                      
			$(document).find('.prev').fadeIn(500);	
		}		                        
		                            
}

// HIDE ALL BUTTONS
function	hideAllButtons(){
		$(document).find('.next').hide();
		$(document).find('.prev').hide();
		$(document).find('.sold').hide();
		$(document).find('.tiny-thumb img').hide();
}


