var clickPos = 0;

$(function(evt) {
		

    $("ul#project-previews li").click(function() {
		
		
		var clickPos = $(this).parent().find('li').index(this);

//ie doubles the amount of nodes found when finding clicPos...
//solution: divide by two....
if ( true === $.browser.msie ) {
	clickPos = clickPos / 2;
}


		//console.log('clickPos: ' + clickPos);
		//alert('clickPos: ' + clickPos);
		
		// close button
		$('#projects a#close-full-project').fadeIn(2000);


	if (  $('ul#full-projects li.project').is(":visible")){
			
			$.scrollTo('#projects', 1000);

			// keep open
			//var containerHeight = $('#container-full-project').height();
			//alert(containerHeight);
			
		$('ul#full-projects li.project').fadeOut(1000).delay(1000);

		$('ul#full-projects li.project:eq(' + clickPos + ')').fadeIn(1000);
		
		//$('#container-full-project').css('height', containerHeight);
		
		
		
		

		} else {
		$.scrollTo('#projects', 1000);
						
		$('#container-full-project').slideDown(1000);

		$('ul#full-projects li.project:eq(' + clickPos + ')').fadeIn(2000);
		
		//console.log($('ul#full-projects li.project:eq(' + clickPos + ')').fadeIn(2000));
		
		
		
		
		}
	
	});


});


// on close case study
$(function() {
    $('#projects a#close-full-project').click(function(evt) {
		// on close hide all list items in container-02
		$('ul#full-projects li.project').fadeOut(1000);
		
		
    	
		//slide up and hide the case study
    	$('#container-full-project').slideUp(1000);
    	//fade out 
    	$(this).fadeOut(2000);
    	
    	// remove active states
    	$('ul.pagination li a').removeClass('active');
    	
    	// stop jumping
		event.preventDefault();
				    
    });

});


/*
$(document).ready(function() {

//$('#pagination #pagination-links ul').css('border', 'solid 10px blue');

$('#pagination #pagination-links ul').each(function(){
// this is inner scope, in reference to the .phrase element

$(this).find('li').each(function(){
    // cache jquery var
    var current = $(this);
    // check if our current li has children (sub elements)
    // if it does, skip it
    
    alert(current);
    
    
    if(current.children().size() > 1) { 
    
    	$(this).remove(); 
    
    }
    // add current text to our current phrase
    
    	
    
    phrase += current.text();
});

});

});  

*/		

